public Uploader(ScrapeInfo scrapeInfo, DimensionInfo dimensionInfo, InspectionInfo inspectionInfo, AeiInfo aei) { this.scrapeInfo = scrapeInfo ?? throw new ArgumentNullException(nameof(scrapeInfo)); this.dimensionInfo = dimensionInfo ?? throw new ArgumentNullException(nameof(dimensionInfo)); this.inspectionInfo = inspectionInfo ?? throw new ArgumentNullException(nameof(inspectionInfo)); this.aei = aei ?? throw new ArgumentNullException(nameof(aei)); }
public static void Load() { int axleCount; DateTime time; //找出该列车的探测时间和轴数 //采用数据的优先级为 AEI -> 探伤 -> 几何尺寸 -> 擦伤 if (AeiFile != null) { var a = AeiInfo.Create(AeiFile); axleCount = a.AxleCount; time = a.Time; } else if (InspectionFile != null) { var ins = InspectionInfo.Create(InspectionFile); axleCount = ins.Formations.Count * 32; time = DateTime.ParseExact(ins.Time, "yyyyMMddHHmmss", null); } else if (DimensionFile != null) { var dim = DimensionInfo.Create(DimensionFile); axleCount = dim.BaseInfo.AxleCount; time = DateTime.ParseExact(dim.BaseInfo.DetectionTime, "yyyyMMddHHmmss", null); } else if (ScrapeFile != null) { var scr = ScrapeInfo.Create(ScrapeFile); axleCount = scr.AxleCnt; time = DateTime.ParseExact(scr.Time, "yyyyMMddHHmmss", null); } else { throw new Exception("AEI,探伤,几何尺寸,擦伤报文均不存在,无法入库"); } if (axleCount >= 22 && axleCount <= 42) { axleCount = 32; } else if (axleCount > 42 && axleCount <= 74) { axleCount = 64; } ScrapeInfo scrape; DimensionInfo dimension; AeiInfo aei; InspectionInfo inspection; if (ScrapeFile is null) { scrape = ScrapeInfo.CreateDefault(axleCount, time); } else { scrape = ScrapeInfo.Create(ScrapeFile); } if (AeiFile is null) { aei = AeiInfo.CreateDefault(axleCount, time); } else { aei = AeiInfo.Create(AeiFile); } if (DimensionFile is null) { dimension = DimensionInfo.CreateDefault(axleCount, time); } else { dimension = DimensionInfo.Create(DimensionFile); } if (InspectionFile is null) { inspection = InspectionInfo.CreateDefault(axleCount, time); } else { inspection = InspectionInfo.Create(InspectionFile); } var loader = new Uploader(scrape, dimension, inspection, aei); loader.Insert(); Clear(); }