forked from ddrilling/AsbCloudServer
16645d053a
1. Изменено апи 2. Добавлен парсер для ГГД 3. Добавлен ссервис экспорта ГГД
43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using AsbCloudApp.Repositories;
|
||
using AsbCloudApp.Requests.ExportOptions;
|
||
using AsbCloudApp.Services;
|
||
using AsbCloudApp.Services.Export;
|
||
using AsbCloudDb.Model;
|
||
using AsbCloudInfrastructure.Services.ExcelServices.Templates.WellOperations;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
|
||
namespace AsbCloudInfrastructure.Services.WellOperations.Factories;
|
||
|
||
public class WellOperationExportServiceFactory : IExportServiceFactory<int>
|
||
{
|
||
private readonly IDictionary<int, Func<IExportService>> exportServices;
|
||
|
||
public WellOperationExportServiceFactory(IServiceProvider serviceProvider)
|
||
{
|
||
var wellOperationRepository = serviceProvider.GetRequiredService<IWellOperationRepository>();
|
||
var wellService = serviceProvider.GetRequiredService<IWellService>();
|
||
|
||
exportServices = new Dictionary<int, Func<IExportService>>
|
||
{
|
||
{
|
||
WellOperation.IdOperationTypeFact,
|
||
() => new WellOperationExport<WellOperationFactTemplate>(wellOperationRepository, wellService)
|
||
},
|
||
{
|
||
WellOperation.IdOperationTypePlan,
|
||
() => new WellOperationExport<WellOperationPlanTemplate>(wellOperationRepository, wellService)
|
||
}
|
||
};
|
||
}
|
||
|
||
public IExportService<TOptions> CreateExportService<TOptions>(int id)
|
||
where TOptions : IExportOptionsRequest
|
||
{
|
||
var parser = exportServices[id].Invoke();
|
||
|
||
return parser as IExportService<TOptions>
|
||
?? throw new ArgumentNullException(nameof(id), "Не удалось экспортировать файл");
|
||
}
|
||
} |