forked from ddrilling/AsbCloudServer
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
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 dtos = await GetProcessMapPlanAsync(idWell, token);
|
|
|
|
var fileName = await BuildFileNameAsync(idWell, token);
|
|
var file = Export(dtos);
|
|
return (fileName, file);
|
|
}
|
|
|
|
protected abstract Task<string> BuildFileNameAsync(int idWell, CancellationToken token);
|
|
|
|
protected virtual async Task<IEnumerable<TDto>> GetProcessMapPlanAsync(int idWell, CancellationToken token)
|
|
{
|
|
var request = new ProcessMapPlanBaseRequestWithWell(idWell);
|
|
var dtos = await processMapPlanRepository.Get(request, token);
|
|
return dtos;
|
|
}
|
|
} |