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,