DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/ProcessMapPlan/Parser/ProcessMapPlanReamParser.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2024-02-21 15:08:51 +05:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudInfrastructure.Services.ExcelServices.Templates;
using AsbCloudInfrastructure.Services.ExcelServices.Templates.ProcessMapPlanTemplates;
2024-02-21 15:08:51 +05:00
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
public class ProcessMapPlanReamParser : ProcessMapPlanParser<ProcessMapPlanReamDto>
{
public ProcessMapPlanReamParser(IWellOperationRepository wellOperationRepository)
: base(wellOperationRepository)
2024-02-21 15:08:51 +05:00
{
}
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanReamTemplate();
2024-02-21 15:08:51 +05:00
protected override ProcessMapPlanReamDto BuildDto(IDictionary<string, object?> row, int rowNumber)
{
var dto = base.BuildDto(row, rowNumber);
var section = sections.FirstOrDefault(s =>
string.Equals(s.Caption.Trim(), dto.Section?.Trim(), StringComparison.CurrentCultureIgnoreCase));
if (section is null)
{
var message = string.Format(XLExtentions.ProblemDetailsTemplate,
TemplateParameters.SheetName, rowNumber,
TemplateParameters.Cells[nameof(ProcessMapPlanReamDto.Section)],
2024-02-21 15:08:51 +05:00
"Указана некорректная секция");
throw new FileFormatException(message);
}
dto.IdWellSectionType = section.Id;
return dto;
}
}