From 1d3294e799210c619e686d07c3af4a082beb620f Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 26 Dec 2023 14:31:20 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80:=20=D0=BE=D0=B4=D0=B8=D0=BD=20=D1=8D=D0=BA=D1=88=D0=BD,?= =?UTF-8?q?=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D0=B9=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=B5=20=D0=BF=D0=B0?= =?UTF-8?q?=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=B0=20=D0=B2=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=B4=20CreateReportAsync.=20=D0=92=D0=BD?= =?UTF-8?q?=D1=83=D1=82=D1=80=D0=B8=20=D1=8D=D0=BA=D1=88=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B7=D1=8B=D0=B2=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20?= =?UTF-8?q?2=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0:=20onProgress=20=D0=B8?= =?UTF-8?q?=20progressHandler.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/ReportProgressDto.cs | 5 +++++ AsbCloudApp/Services/IReportService.cs | 3 ++- .../Background/WorkToCreateReport.cs | 12 ++++++++++-- AsbCloudInfrastructure/Services/ReportService.cs | 6 +++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/AsbCloudApp/Data/ReportProgressDto.cs b/AsbCloudApp/Data/ReportProgressDto.cs index c7bf4cbb..5a271180 100644 --- a/AsbCloudApp/Data/ReportProgressDto.cs +++ b/AsbCloudApp/Data/ReportProgressDto.cs @@ -5,6 +5,11 @@ /// public class ReportProgressDto { + /// + /// файл + /// + public FileInfoDto file { get; set; } + /// /// прогресс 0 - 100% /// diff --git a/AsbCloudApp/Services/IReportService.cs b/AsbCloudApp/Services/IReportService.cs index 994db83a..283e27ee 100644 --- a/AsbCloudApp/Services/IReportService.cs +++ b/AsbCloudApp/Services/IReportService.cs @@ -27,13 +27,14 @@ namespace AsbCloudApp.Services /// /// Создание отчета /// + /// /// /// /// /// /// /// - Task CreateReportAsync(int idWell, int idUser, ReportParametersRequest request, Action progressHandler, CancellationToken token); + Task CreateReportAsync(string workId, int idWell, int idUser, ReportParametersRequest request, Action progressHandler, CancellationToken token); /// /// Получить предполагаемый список страниц рапорта diff --git a/AsbCloudInfrastructure/Background/WorkToCreateReport.cs b/AsbCloudInfrastructure/Background/WorkToCreateReport.cs index 4100634d..671dff65 100644 --- a/AsbCloudInfrastructure/Background/WorkToCreateReport.cs +++ b/AsbCloudInfrastructure/Background/WorkToCreateReport.cs @@ -1,4 +1,5 @@ -using AsbCloudApp.Requests; +using AsbCloudApp.Data; +using AsbCloudApp.Requests; using AsbCloudApp.Services; using Microsoft.Extensions.DependencyInjection; using System; @@ -23,13 +24,20 @@ namespace AsbCloudInfrastructure.Background this.idUser = idUser; this.request = request; this.progressHandler = progressHandler; + + Id = $"create report by wellid:{idWell} for userid:{idUser} requested at {DateTime.Now}"; } protected override async Task Action(string id, IServiceProvider services, Action onProgress, CancellationToken token) { var reportService = services.GetRequiredService(); - await reportService.CreateReportAsync(idWell, idUser, request, progressHandler, token); + Action handler = (state, workId) => + { + onProgress?.Invoke(state.Operation ?? string.Empty, state.Progress); + progressHandler?.Invoke(state, workId); + }; + await reportService.CreateReportAsync(Id, idWell, idUser, request, handler, token); } } } diff --git a/AsbCloudInfrastructure/Services/ReportService.cs b/AsbCloudInfrastructure/Services/ReportService.cs index 795be62a..99ee490b 100644 --- a/AsbCloudInfrastructure/Services/ReportService.cs +++ b/AsbCloudInfrastructure/Services/ReportService.cs @@ -117,13 +117,13 @@ public class ReportService : IReportService public async Task CreateReportAsync( + string workId, int idWell, int idUser, ReportParametersRequest request, - Action progressHandler, + Action progressHandler, CancellationToken token) { - var workId = $"create report by wellid:{idWell} for userid:{idUser} requested at {DateTime.Now}"; var timezoneOffset = wellService.GetTimezone(idWell).Hours; var beginRemote = request.Begin.ToTimeZoneOffsetHours(timezoneOffset); var endRemote = request.End.ToTimeZoneOffsetHours(timezoneOffset); @@ -150,7 +150,7 @@ public class ReportService : IReportService var fileInfo = (await fileService.MoveAsync(idWell, idUser, ReportCategoryId, reportFileName, reportFileName, token))!; - progressHandler(new + progressHandler(new ReportProgressDto() { Operation = "done", Progress = 100f,