DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/ProcessMapPlan/Export/ProcessMapPlanDrillingExportService.cs

52 lines
1.6 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Requests.ExportOptions;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
public class ProcessMapPlanDrillingExportService : ProcessMapPlanExportService<ProcessMapPlanDrillingDto>
{
public ProcessMapPlanDrillingExportService(
IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepository,
IWellService wellService)
: base(processMapPlanRepository, wellService)
{
}
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanDrillingTemplate();
protected override async Task<string> BuildFileNameAsync(WellRelatedExportRequest options, CancellationToken token)
{
var caption = await wellService.GetWellCaptionByIdAsync(options.IdWell, token);
return $"{caption}_РТК_План_бурение.xlsx";
}
protected override async Task<IEnumerable<ProcessMapPlanDrillingDto>> GetDtosAsync(WellRelatedExportRequest options,
CancellationToken token)
{
var dtos = await base.GetDtosAsync(options, token);
var dtosWithMode = dtos.Select(dto =>
{
dto.Mode = dto.IdMode switch
{
1 => "Ротор",
2 => "Слайд",
_ => throw new ArgumentOutOfRangeException()
};
return dto;
});
return dtosWithMode;
}
}