From 617a529780e2ec9d1f8e0493a4e3e0fe6a3f40f3 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Wed, 27 Dec 2023 09:38:00 +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=D0=B8=D0=BD=D0=B3=20=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D0=B0=D0=BC=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/Progress/ProgressDto.cs | 19 +++++++++++ .../Data/Progress/ReportProgressDto.cs | 13 ++++++++ .../Data/Progress/ReportProgressFinalDto.cs | 18 ++++++++++ AsbCloudApp/Data/ReportProgressDto.cs | 33 ------------------- AsbCloudApp/Services/IReportService.cs | 3 +- .../Background/WorkToCreateReport.cs | 4 +-- .../Services/ReportService.cs | 5 +-- 7 files changed, 57 insertions(+), 38 deletions(-) create mode 100644 AsbCloudApp/Data/Progress/ProgressDto.cs create mode 100644 AsbCloudApp/Data/Progress/ReportProgressDto.cs create mode 100644 AsbCloudApp/Data/Progress/ReportProgressFinalDto.cs delete mode 100644 AsbCloudApp/Data/ReportProgressDto.cs diff --git a/AsbCloudApp/Data/Progress/ProgressDto.cs b/AsbCloudApp/Data/Progress/ProgressDto.cs new file mode 100644 index 00000000..601268ca --- /dev/null +++ b/AsbCloudApp/Data/Progress/ProgressDto.cs @@ -0,0 +1,19 @@ +namespace AsbCloudApp.Data.Progress +{ + /// + /// DTO прогресса + /// + public class ProgressDto + { + /// + /// прогресс 0 - 100% + /// + public float Progress { get; set; } + + /// + /// название текущей операции генерации + /// + public string? Operation { get; set; } + + } +} diff --git a/AsbCloudApp/Data/Progress/ReportProgressDto.cs b/AsbCloudApp/Data/Progress/ReportProgressDto.cs new file mode 100644 index 00000000..00db12a8 --- /dev/null +++ b/AsbCloudApp/Data/Progress/ReportProgressDto.cs @@ -0,0 +1,13 @@ +namespace AsbCloudApp.Data.Progress +{ + /// + /// DTO завершенного прогресса генерации рапорта-диаграммы + /// + public class ReportProgressFinalDto : ReportProgressDto + { + /// + /// файл + /// + public FileInfoDto file { get; set; } + } +} diff --git a/AsbCloudApp/Data/Progress/ReportProgressFinalDto.cs b/AsbCloudApp/Data/Progress/ReportProgressFinalDto.cs new file mode 100644 index 00000000..29956546 --- /dev/null +++ b/AsbCloudApp/Data/Progress/ReportProgressFinalDto.cs @@ -0,0 +1,18 @@ +namespace AsbCloudApp.Data.Progress +{ + /// + /// DTO прогресса генерации рапорта-диаграммы + /// + public class ReportProgressDto : ProgressDto + { + /// + /// номер текущей страницы + /// + public int CurrentPage { get; set; } + + /// + /// предполагаемое суммарное количество страниц + /// + public int TotalPages { get; set; } + } +} diff --git a/AsbCloudApp/Data/ReportProgressDto.cs b/AsbCloudApp/Data/ReportProgressDto.cs deleted file mode 100644 index 5a271180..00000000 --- a/AsbCloudApp/Data/ReportProgressDto.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace AsbCloudApp.Data -{ - /// - /// DTO прогресса генерации рапорта-диаграммы - /// - public class ReportProgressDto - { - /// - /// файл - /// - public FileInfoDto file { get; set; } - - /// - /// прогресс 0 - 100% - /// - public float Progress { get; set; } - - /// - /// название текущей операции генерации - /// - public string? Operation { get; set; } - - /// - /// номер текущей страницы - /// - public int CurrentPage { get; set; } - - /// - /// предполагаемое суммарное количество страниц - /// - public int TotalPages { get; set; } - } -} diff --git a/AsbCloudApp/Services/IReportService.cs b/AsbCloudApp/Services/IReportService.cs index 283e27ee..5f992a20 100644 --- a/AsbCloudApp/Services/IReportService.cs +++ b/AsbCloudApp/Services/IReportService.cs @@ -1,4 +1,5 @@ using AsbCloudApp.Data; +using AsbCloudApp.Data.Progress; using AsbCloudApp.Requests; using System; using System.Collections.Generic; @@ -34,7 +35,7 @@ namespace AsbCloudApp.Services /// /// /// - Task CreateReportAsync(string workId, 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 671dff65..3381f033 100644 --- a/AsbCloudInfrastructure/Background/WorkToCreateReport.cs +++ b/AsbCloudInfrastructure/Background/WorkToCreateReport.cs @@ -1,4 +1,4 @@ -using AsbCloudApp.Data; +using AsbCloudApp.Data.Progress; using AsbCloudApp.Requests; using AsbCloudApp.Services; using Microsoft.Extensions.DependencyInjection; @@ -32,7 +32,7 @@ namespace AsbCloudInfrastructure.Background protected override async Task Action(string id, IServiceProvider services, Action onProgress, CancellationToken token) { var reportService = services.GetRequiredService(); - Action handler = (state, workId) => + Action handler = (state, workId) => { onProgress?.Invoke(state.Operation ?? string.Empty, state.Progress); progressHandler?.Invoke(state, workId); diff --git a/AsbCloudInfrastructure/Services/ReportService.cs b/AsbCloudInfrastructure/Services/ReportService.cs index 99ee490b..59fd97ea 100644 --- a/AsbCloudInfrastructure/Services/ReportService.cs +++ b/AsbCloudInfrastructure/Services/ReportService.cs @@ -1,4 +1,5 @@ using AsbCloudApp.Data; +using AsbCloudApp.Data.Progress; using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudDb.Model; @@ -121,7 +122,7 @@ public class ReportService : IReportService int idWell, int idUser, ReportParametersRequest request, - Action progressHandler, + Action progressHandler, CancellationToken token) { var timezoneOffset = wellService.GetTimezone(idWell).Hours; @@ -150,7 +151,7 @@ public class ReportService : IReportService var fileInfo = (await fileService.MoveAsync(idWell, idUser, ReportCategoryId, reportFileName, reportFileName, token))!; - progressHandler(new ReportProgressDto() + progressHandler(new ReportProgressFinalDto() { Operation = "done", Progress = 100f,