forked from ddrilling/AsbCloudServer
Olga Nemt
b7d1d26722
2. Часть методов перенесены из WellOperationRepository в WellOperationService. 3. Перенастройка ссылок на новый сервис 4. Выделение WellOperationBaseDto
50 lines
1.8 KiB
C#
50 lines
1.8 KiB
C#
using AsbCloudApp.Data.WellOperation;
|
||
using AsbCloudApp.Requests;
|
||
using AsbCloudApp.Requests.ExportOptions;
|
||
using AsbCloudApp.Services;
|
||
using AsbCloudDb.Model;
|
||
using AsbCloudInfrastructure.Services.ExcelServices;
|
||
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace AsbCloudInfrastructure.Services.WellOperations;
|
||
|
||
public class WellOperationExport<TTemplate> : ExcelExportService<WellOperationDto, WellOperationExportRequest, TTemplate>
|
||
where TTemplate : class, ITemplateParameters, new()
|
||
{
|
||
private readonly IWellService wellService;
|
||
private readonly IWellOperationService wellOperationService;
|
||
|
||
public WellOperationExport(
|
||
IWellOperationService wellOperationService,
|
||
IWellService wellService)
|
||
{
|
||
this.wellService = wellService;
|
||
this.wellOperationService = wellOperationService;
|
||
}
|
||
|
||
protected override async Task<string> BuildFileNameAsync(WellOperationExportRequest options, CancellationToken token)
|
||
{
|
||
var caption = await wellService.GetWellCaptionByIdAsync(options.IdWell, token);
|
||
|
||
return options.IdType switch
|
||
{
|
||
WellOperation.IdOperationTypeFact => $"{caption}_Фактические_операции.xlsx",
|
||
WellOperation.IdOperationTypePlan => $"{caption}_Плановые_операции.xlsx",
|
||
_ => throw new ArgumentOutOfRangeException(nameof(options.IdType))
|
||
};
|
||
}
|
||
|
||
protected override Task<IEnumerable<WellOperationDto>> GetDtosAsync(WellOperationExportRequest options, CancellationToken token)
|
||
{
|
||
var request = new WellOperationRequest(new[] { options.IdWell })
|
||
{
|
||
OperationType = options.IdType,
|
||
};
|
||
|
||
return wellOperationService.GetAsync(request, token);
|
||
}
|
||
} |