forked from ddrilling/AsbCloudServer
Рефакторинг по результатам ревью
This commit is contained in:
parent
1d3294e799
commit
617a529780
19
AsbCloudApp/Data/Progress/ProgressDto.cs
Normal file
19
AsbCloudApp/Data/Progress/ProgressDto.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace AsbCloudApp.Data.Progress
|
||||
{
|
||||
/// <summary>
|
||||
/// DTO прогресса
|
||||
/// </summary>
|
||||
public class ProgressDto
|
||||
{
|
||||
/// <summary>
|
||||
/// прогресс 0 - 100%
|
||||
/// </summary>
|
||||
public float Progress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// название текущей операции генерации
|
||||
/// </summary>
|
||||
public string? Operation { get; set; }
|
||||
|
||||
}
|
||||
}
|
13
AsbCloudApp/Data/Progress/ReportProgressDto.cs
Normal file
13
AsbCloudApp/Data/Progress/ReportProgressDto.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace AsbCloudApp.Data.Progress
|
||||
{
|
||||
/// <summary>
|
||||
/// DTO завершенного прогресса генерации рапорта-диаграммы
|
||||
/// </summary>
|
||||
public class ReportProgressFinalDto : ReportProgressDto
|
||||
{
|
||||
/// <summary>
|
||||
/// файл
|
||||
/// </summary>
|
||||
public FileInfoDto file { get; set; }
|
||||
}
|
||||
}
|
18
AsbCloudApp/Data/Progress/ReportProgressFinalDto.cs
Normal file
18
AsbCloudApp/Data/Progress/ReportProgressFinalDto.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace AsbCloudApp.Data.Progress
|
||||
{
|
||||
/// <summary>
|
||||
/// DTO прогресса генерации рапорта-диаграммы
|
||||
/// </summary>
|
||||
public class ReportProgressDto : ProgressDto
|
||||
{
|
||||
/// <summary>
|
||||
/// номер текущей страницы
|
||||
/// </summary>
|
||||
public int CurrentPage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// предполагаемое суммарное количество страниц
|
||||
/// </summary>
|
||||
public int TotalPages { get; set; }
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// DTO прогресса генерации рапорта-диаграммы
|
||||
/// </summary>
|
||||
public class ReportProgressDto
|
||||
{
|
||||
/// <summary>
|
||||
/// файл
|
||||
/// </summary>
|
||||
public FileInfoDto file { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// прогресс 0 - 100%
|
||||
/// </summary>
|
||||
public float Progress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// название текущей операции генерации
|
||||
/// </summary>
|
||||
public string? Operation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// номер текущей страницы
|
||||
/// </summary>
|
||||
public int CurrentPage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// предполагаемое суммарное количество страниц
|
||||
/// </summary>
|
||||
public int TotalPages { get; set; }
|
||||
}
|
||||
}
|
@ -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
|
||||
/// <param name="progressHandler"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task CreateReportAsync(string workId, int idWell, int idUser, ReportParametersRequest request, Action<ReportProgressDto, string> progressHandler, CancellationToken token);
|
||||
Task CreateReportAsync(string workId, int idWell, int idUser, ReportParametersRequest request, Action<ProgressDto, string> progressHandler, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получить предполагаемый список страниц рапорта
|
||||
|
@ -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<string, double?> onProgress, CancellationToken token)
|
||||
{
|
||||
var reportService = services.GetRequiredService<IReportService>();
|
||||
Action<ReportProgressDto, string> handler = (state, workId) =>
|
||||
Action<ProgressDto, string> handler = (state, workId) =>
|
||||
{
|
||||
onProgress?.Invoke(state.Operation ?? string.Empty, state.Progress);
|
||||
progressHandler?.Invoke(state, workId);
|
||||
|
@ -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<ReportProgressDto, string> progressHandler,
|
||||
Action<ProgressDto, string> 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,
|
||||
|
Loading…
Reference in New Issue
Block a user