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;
|
|
|
|
|
|
|
|
public class ProcessMapPlanDrillingParser : ProcessMapPlanParser<ProcessMapPlanDrillingDto>
|
|
|
|
{
|
2024-02-16 13:53:10 +05:00
|
|
|
public ProcessMapPlanDrillingParser(IWellOperationRepository wellOperationRepository)
|
2024-03-14 10:03:57 +05:00
|
|
|
: base(wellOperationRepository)
|
2024-02-09 11:32:31 +05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-03-14 10:03:57 +05:00
|
|
|
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanDrillingTemplate();
|
2024-02-12 17:25:18 +05:00
|
|
|
|
2024-02-14 14:13:43 +05:00
|
|
|
protected override ProcessMapPlanDrillingDto 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,
|
|
|
|
TemplateParameters.Cells[nameof(ProcessMapPlanDrillingDto.Section)],
|
2024-02-09 11:32:31 +05:00
|
|
|
"Указана некорректная секция");
|
|
|
|
throw new FileFormatException(message);
|
|
|
|
}
|
|
|
|
|
2024-02-13 16:05:16 +05:00
|
|
|
var idMode = GetIdMode(dto.Mode);
|
2024-02-09 11:32:31 +05:00
|
|
|
|
|
|
|
if (idMode is null)
|
|
|
|
{
|
2024-03-14 10:03:57 +05:00
|
|
|
var message = string.Format(XLExtentions.ProblemDetailsTemplate,
|
|
|
|
TemplateParameters.SheetName,
|
|
|
|
rowNumber,
|
|
|
|
TemplateParameters.Cells[nameof(ProcessMapPlanDrillingDto.Mode)],
|
2024-02-09 11:32:31 +05:00
|
|
|
"Указан некорректный режим бурения");
|
|
|
|
throw new FileFormatException(message);
|
|
|
|
}
|
|
|
|
|
2024-02-13 16:05:16 +05:00
|
|
|
dto.IdWellSectionType = section.Id;
|
|
|
|
dto.IdMode = idMode.Value;
|
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
|
|
|
}
|
|
|
|
}
|