forked from ddrilling/AsbCloudServer
4fe570f3e9
Fix other services to use new model.
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ClosedXML.Excel;
|
|
using AsbCloudApp.Data;
|
|
|
|
namespace AsbCloudInfrastructure.Services
|
|
{
|
|
public class WellOperationImportService
|
|
{
|
|
private const string sheetNamePlan = "План";
|
|
private const string sheetNameFact = "Факт";
|
|
|
|
public IEnumerable<WellOperationDto> ParseFile(string excelFilePath)
|
|
{
|
|
if (!File.Exists(excelFilePath))
|
|
throw new FileNotFoundException($"Файл {excelFilePath} не найден.");
|
|
|
|
using var sourceExcelWorkbook = new XLWorkbook(excelFilePath, XLEventTracking.Disabled);
|
|
|
|
var sheetPlan = sourceExcelWorkbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNamePlan);
|
|
if (sheetPlan is null)
|
|
throw new FileFormatException($"Файл {excelFilePath} не не содержит листа {sheetNamePlan}.");
|
|
|
|
var sheetFact = sourceExcelWorkbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNameFact);
|
|
if (sheetFact is null)
|
|
throw new FileFormatException($"Файл {excelFilePath} не не содержит листа {sheetNameFact}.");
|
|
|
|
var wellOperations = new List<WellOperationDto>();
|
|
|
|
return wellOperations;
|
|
}
|
|
}
|
|
}
|