using AsbCloudApp.Data; using AsbCloudApp.Repositories; using AsbCloudApp.Services; using AsbCloudDb.Model; using ClosedXML.Excel; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services.Trajectory { public class PlannedTrajectoryImportService : TrajectoryImportService //IPlannedTrajectoryImportService { /* * password for PlannedTrajectoryTemplate.xlsx is Drill2022 */ private readonly IWellService wellService; private readonly ITrajectoryEditableRepository plannedTrajectoryService; //private const string templateFileName = "PlannedTrajectoryTemplate.xlsx"; //private const string usingTemplateFile = "AsbCloudInfrastructure.Services.Trajectory"; //private const string sheetNamePlannedTrajectory = "Плановая траектория"; //private const int headerRowsCount = 2; //private const int ColumnWellboreDepth = 1; //private const int ColumnZenithAngle = 2; //private const int ColumnAzimuthGeo = 3; //private const int ColumnAzimuthMagnetic = 4; //private const int ColumnVerticalDepth = 5; //private const int ColumnRadius = 6; //private const int ColumnComment = 7; public override string templateFileName { get; set; } = "PlannedTrajectoryTemplate.xlsx"; public override string usingTemplateFile { get; set; } = "AsbCloudInfrastructure.Services.Trajectory"; public override string sheetNamePlannedTrajectory { get; set; } = "Плановая траектория"; public override int headerRowsCount { get; set; } = 2; public override int ColumnWellboreDepth { get; set; } = 1; public override int ColumnZenithAngle { get; set; } = 2; public override int ColumnAzimuthGeo { get; set; } = 3; public override int ColumnAzimuthMagnetic { get; set; } = 4; public override int ColumnVerticalDepth { get; set; } = 5; public override int ColumnRadius { get; set; } = 6; public override int ColumnComment { get; set; } = 7; public PlannedTrajectoryImportService( IWellService wellService, ITrajectoryEditableRepository plannedTrajectoryService) : base(plannedTrajectoryService, wellService) { this.wellService = wellService; } protected override TrajectoryGeoPlanDto ParseRow(IXLRow row) { var trajectoryRow = new TrajectoryGeoPlanDto { WellboreDepth = row.Cell(ColumnWellboreDepth).GetCellValue(), ZenithAngle = row.Cell(ColumnZenithAngle).GetCellValue(), AzimuthGeo = row.Cell(ColumnAzimuthGeo).GetCellValue(), AzimuthMagnetic = row.Cell(ColumnAzimuthMagnetic).GetCellValue(), VerticalDepth = row.Cell(ColumnVerticalDepth).GetCellValue(), Radius = row.Cell(ColumnRadius).GetCellValue(), Comment = row.Cell(ColumnComment).GetCellValue() }; return trajectoryRow; } protected override void AddCoordinatesToRow(IXLRow row, TrajectoryGeoPlanDto trajectory) { row.Cell(ColumnWellboreDepth).Value = trajectory.WellboreDepth; row.Cell(ColumnZenithAngle).Value = trajectory.ZenithAngle; row.Cell(ColumnAzimuthGeo).Value = trajectory.AzimuthGeo; row.Cell(ColumnAzimuthMagnetic).Value = trajectory.AzimuthMagnetic; row.Cell(ColumnVerticalDepth).Value = trajectory.VerticalDepth; row.Cell(ColumnRadius).Value = trajectory.Radius; row.Cell(ColumnComment).Value = trajectory.Comment; } } }