2024-02-09 11:32:31 +05:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
2024-02-21 15:08:51 +05:00
|
|
|
using AsbCloudApp.Data.ProcessMaps;
|
2024-02-09 11:32:31 +05:00
|
|
|
using AsbCloudApp.Repositories;
|
2024-03-14 10:03:57 +05:00
|
|
|
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
|
|
|
|
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
|
2024-02-09 11:32:31 +05:00
|
|
|
|
|
|
|
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
|
|
|
|
|
2024-06-21 09:53:45 +05:00
|
|
|
public class ProcessMapPlanSlideParser : ProcessMapPlanParser<ProcessMapPlanSlideDto>
|
2024-02-09 11:32:31 +05:00
|
|
|
{
|
2024-06-21 09:53:45 +05:00
|
|
|
public ProcessMapPlanSlideParser(IWellOperationRepository wellOperationRepository)
|
2024-03-14 10:03:57 +05:00
|
|
|
: base(wellOperationRepository)
|
2024-02-09 11:32:31 +05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-06-21 09:53:45 +05:00
|
|
|
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanSlideTemplate();
|
2024-02-12 17:25:18 +05:00
|
|
|
|
2024-06-21 09:53:45 +05:00
|
|
|
protected override ProcessMapPlanSlideDto BuildDto(IDictionary<string, object?> row, int rowNumber)
|
2024-02-09 11:32:31 +05:00
|
|
|
{
|
2024-02-14 14:13:43 +05:00
|
|
|
var dto = base.BuildDto(row, rowNumber);
|
2024-02-09 11:32:31 +05:00
|
|
|
|
|
|
|
var section = sections.FirstOrDefault(s =>
|
2024-02-13 16:05:16 +05:00
|
|
|
string.Equals(s.Caption.Trim(), dto.Section?.Trim(), StringComparison.CurrentCultureIgnoreCase));
|
2024-02-09 11:32:31 +05:00
|
|
|
|
|
|
|
if (section is null)
|
|
|
|
{
|
2024-03-14 10:03:57 +05:00
|
|
|
var message = string.Format(XLExtentions.ProblemDetailsTemplate,
|
|
|
|
TemplateParameters.SheetName,
|
|
|
|
rowNumber,
|
2024-06-11 10:31:03 +05:00
|
|
|
TemplateParameters.Cells[nameof(ProcessMapPlanBaseDto.Section)],
|
2024-02-09 11:32:31 +05:00
|
|
|
"Указана некорректная секция");
|
|
|
|
throw new FileFormatException(message);
|
|
|
|
}
|
|
|
|
|
2024-02-13 16:05:16 +05:00
|
|
|
dto.IdWellSectionType = section.Id;
|
2024-02-09 11:32:31 +05:00
|
|
|
|
2024-02-12 17:25:18 +05:00
|
|
|
return dto;
|
2024-02-09 11:32:31 +05:00
|
|
|
}
|
|
|
|
}
|