forked from ddrilling/AsbCloudServer
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using AsbCloudApp.Data.Progress;
|
|
using AsbCloudApp.Requests;
|
|
using AsbCloudApp.Services;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AsbCloudInfrastructure.Background
|
|
{
|
|
/// <summary>
|
|
/// Класс для создания отчета
|
|
/// </summary>
|
|
internal class WorkToCreateReport : Work
|
|
{
|
|
private int idWell;
|
|
private int idUser;
|
|
private ReportParametersRequest request;
|
|
private Action<object, string> progressHandler;
|
|
|
|
public WorkToCreateReport(int idWell, int idUser, ReportParametersRequest request, Action<object, string> progressHandler) : base("")
|
|
{
|
|
this.idWell = idWell;
|
|
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<string, double?> onProgress, CancellationToken token)
|
|
{
|
|
var reportService = services.GetRequiredService<IReportService>();
|
|
Action<ProgressDto, string> handler = (state, workId) =>
|
|
{
|
|
onProgress?.Invoke(state.Operation ?? string.Empty, state.Progress);
|
|
progressHandler?.Invoke(state, workId);
|
|
};
|
|
await reportService.CreateReportAsync(Id, idWell, idUser, request, handler, token);
|
|
}
|
|
}
|
|
}
|