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

42 lines
1.3 KiB
C#
Raw Normal View History

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;
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 ProcessMapPlanSlideParser : ProcessMapPlanParser<ProcessMapPlanSlideDto>
2024-02-09 11:32:31 +05:00
{
public ProcessMapPlanSlideParser(IWellOperationRepository wellOperationRepository)
: base(wellOperationRepository)
2024-02-09 11:32:31 +05:00
{
}
protected override ITemplateParameters TemplateParameters => new ProcessMapPlanSlideTemplate();
protected override ProcessMapPlanSlideDto BuildDto(IDictionary<string, object?> row, int rowNumber)
2024-02-09 11:32:31 +05:00
{
var dto = base.BuildDto(row, rowNumber);
2024-02-09 11:32:31 +05:00
var section = sections.FirstOrDefault(s =>
string.Equals(s.Caption.Trim(), dto.Section?.Trim(), StringComparison.CurrentCultureIgnoreCase));
2024-02-09 11:32:31 +05:00
if (section is null)
{
var message = string.Format(XLExtentions.ProblemDetailsTemplate,
TemplateParameters.SheetName,
rowNumber,
TemplateParameters.Cells[nameof(ProcessMapPlanBaseDto.Section)],
2024-02-09 11:32:31 +05:00
"Указана некорректная секция");
throw new FileFormatException(message);
}
dto.IdWellSectionType = section.Id;
2024-02-09 11:32:31 +05:00
return dto;
2024-02-09 11:32:31 +05:00
}
}