DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanExportService.cs
2024-03-14 08:30:25 +03:00

38 lines
1.3 KiB
C#

using System.IO;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ExcelServices;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
public abstract class ProcessMapPlanExportService<TDto> : ExportExcelService<TDto>,
IProcessMapPlanExportService
where TDto : ChangeLogAbstract
{
protected readonly IWellService wellService;
private readonly IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepository;
protected ProcessMapPlanExportService(IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepository,
IWellService wellService)
{
this.processMapPlanRepository = processMapPlanRepository;
this.wellService = wellService;
}
public async Task<(string FileName, Stream File)> ExportAsync(int idWell, CancellationToken token)
{
var request = new ProcessMapPlanBaseRequestWithWell(idWell);
var dtos = await processMapPlanRepository.Get(request, token);
var fileName = await BuildFileNameAsync(idWell, token);
var file = Export(dtos);
return (fileName, file);
}
protected abstract Task<string> BuildFileNameAsync(int idWell, CancellationToken token);
}