From 063096e236ef69f0e8f3291da1ceeedc87a0713b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Mon, 27 May 2024 15:37:33 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BE=D0=B1=20?= =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B5,=20=D0=B5=D1=81=D0=BB?= =?UTF-8?q?=D0=B8=20=D1=84=D0=B0=D0=B9=D0=BB=20=D0=BF=D0=BE=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=D0=B9-=D1=82=D0=BE=20=D0=BF=D1=80=D0=B8=D1=87?= =?UTF-8?q?=D0=B8=D0=BD=D0=B5=20=D0=BD=D0=B5=20=D1=81=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/Progress/ProgressExceptionDto.cs | 12 +---------- .../Data/Progress/ReportProgressDto.cs | 2 +- .../Services/ReportService.cs | 20 +++++++++++++++++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/AsbCloudApp/Data/Progress/ProgressExceptionDto.cs b/AsbCloudApp/Data/Progress/ProgressExceptionDto.cs index cb264178..a8eb4fdd 100644 --- a/AsbCloudApp/Data/Progress/ProgressExceptionDto.cs +++ b/AsbCloudApp/Data/Progress/ProgressExceptionDto.cs @@ -5,18 +5,8 @@ namespace AsbCloudApp.Data.Progress; /// /// DTO прогресса с ошибкой /// -public class ProgressExceptionDto +public class ProgressExceptionDto : 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 index 400b6c9f..8bfb07d2 100644 --- a/AsbCloudApp/Data/Progress/ReportProgressDto.cs +++ b/AsbCloudApp/Data/Progress/ReportProgressDto.cs @@ -8,5 +8,5 @@ public class ReportProgressFinalDto : ReportProgressDto /// /// файл /// - public FileInfoDto? file { get; set; } + public FileInfoDto file { get; set; } = null!; } diff --git a/AsbCloudInfrastructure/Services/ReportService.cs b/AsbCloudInfrastructure/Services/ReportService.cs index 4d321525..c5df7c7c 100644 --- a/AsbCloudInfrastructure/Services/ReportService.cs +++ b/AsbCloudInfrastructure/Services/ReportService.cs @@ -54,13 +54,15 @@ public class ReportService : IReportService progressHandler.Invoke(state, work.Id); }, token); - backgroundWorkerService.Enqueue(work); - progressHandler.Invoke(new ReportProgressDto { Operation = "Ожидает начала в очереди.", Progress = 0f, }, work.Id); + + backgroundWorkerService.Enqueue(work); + + return work.Id; } @@ -153,6 +155,20 @@ public class ReportService : IReportService var fileInfo = (await fileService.MoveAsync(idWell, idUser, ReportCategoryId, reportFileName, reportFileName, token))!; + if (fileInfo == null) + { + var state = new ProgressExceptionDto + { + Operation = "error", + Progress = 0f, + Message = "Не удалось сгенерировать файл отчёта", + Exception = new FileNotFoundException(), + }; + progressHandler(state, workId); + + return; + } + progressHandler(new ReportProgressFinalDto() { Operation = "done",