Complete
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@ -49,6 +51,7 @@ public class ProcessData : IProcessData
|
||||
public string UniqueId { get; set; }
|
||||
public string Zone { get; set; }
|
||||
|
||||
private readonly ILog _Log;
|
||||
List<object> Shared.Properties.IProcessData.Details => _Details;
|
||||
|
||||
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
|
||||
@ -57,6 +60,7 @@ public class ProcessData : IProcessData
|
||||
fileInfoCollection.Clear();
|
||||
_Details = new List<object>();
|
||||
MesEntity = logistics.MesEntity;
|
||||
_Log = LogManager.GetLogger(typeof(ProcessData));
|
||||
Parse(fileRead, logistics, fileInfoCollection);
|
||||
}
|
||||
|
||||
@ -317,6 +321,24 @@ public class ProcessData : IProcessData
|
||||
return result;
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
|
||||
private Complete? GetComplete(Logistics logistics)
|
||||
{
|
||||
Complete? result;
|
||||
int take = 14;
|
||||
string[] lines = File.ReadAllLines(logistics.ReportFullPath);
|
||||
ReadOnlyCollection<string> collection = new(lines);
|
||||
if (collection.Count > take)
|
||||
result = Complete.Get(take, collection);
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
_Log.Warn($"File {logistics.ReportFullPath} has less than {take} lines");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060
|
||||
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
|
||||
#pragma warning restore IDE0060
|
||||
@ -380,10 +402,25 @@ public class ProcessData : IProcessData
|
||||
}
|
||||
_ = stringBuilder.AppendLine($"Avg = {Avg} {StandardDeviationPercentage} SEMI Radial= {"#.##%"}");
|
||||
LogBody = stringBuilder.ToString();
|
||||
try
|
||||
{
|
||||
Complete? complete = GetComplete(logistics);
|
||||
if (complete is null)
|
||||
_Log.Warn($"Could not get Complete from {logistics}");
|
||||
else
|
||||
{
|
||||
FileInfo fileInfo = new($"{logistics}.json");
|
||||
string json = JsonSerializer.Serialize(complete, CompleteSourceGenerationContext.Default.Complete);
|
||||
File.WriteAllText(fileInfo.FullName, json);
|
||||
fileInfoCollection.Add(fileInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_Log.Error($"Error in {nameof(GetComplete)}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
|
||||
internal static List<Description> GetDescriptions(JsonElement[] jsonElements)
|
||||
{
|
||||
List<Description> results = new();
|
||||
|
Reference in New Issue
Block a user