Require Complete
IDE0060
This commit is contained in:
@ -3,7 +3,6 @@ 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;
|
||||
@ -54,14 +53,13 @@ public class ProcessData : IProcessData
|
||||
private readonly ILog _Log;
|
||||
List<object> Shared.Properties.IProcessData.Details => _Details;
|
||||
|
||||
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
|
||||
internal ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, Complete complete)
|
||||
{
|
||||
JobID = logistics.JobID;
|
||||
fileInfoCollection.Clear();
|
||||
_Details = new List<object>();
|
||||
MesEntity = logistics.MesEntity;
|
||||
_Log = LogManager.GetLogger(typeof(ProcessData));
|
||||
Parse(fileRead, logistics, fileInfoCollection);
|
||||
Parse(fileRead, logistics, fileInfoCollection, complete);
|
||||
}
|
||||
|
||||
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
|
||||
@ -217,10 +215,10 @@ public class ProcessData : IProcessData
|
||||
return result;
|
||||
}
|
||||
|
||||
private void SetTitleData(Logistics logistics, string text)
|
||||
private void SetTitleData(Logistics logistics, Complete complete)
|
||||
{
|
||||
string timeFormat = "yyyyMMddHHmmss";
|
||||
Descriptor descriptor = GetDescriptor(text);
|
||||
Descriptor descriptor = GetDescriptor(complete.Line1.Title);
|
||||
PSN = descriptor.PSN;
|
||||
RDS = descriptor.RDS;
|
||||
Run = descriptor.Run;
|
||||
@ -323,23 +321,7 @@ public class ProcessData : IProcessData
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
|
||||
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, Complete complete)
|
||||
{
|
||||
if (fileRead is null)
|
||||
throw new ArgumentNullException(nameof(fileRead));
|
||||
@ -352,7 +334,7 @@ public class ProcessData : IProcessData
|
||||
{
|
||||
segments = lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (lines[i].Contains("<Title>") && segments.Length > 0)
|
||||
SetTitleData(logistics, segments[0]);
|
||||
SetTitleData(logistics, complete);
|
||||
else if (lines[i].Contains("<FileName, Proj,Rcpe, LotID,WfrID"))
|
||||
SetFileNameData(segments);
|
||||
else if (lines[i].Contains("<DateTime,Temp,TCR%,N|P>"))
|
||||
@ -402,23 +384,7 @@ 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 {reportFileName}");
|
||||
else
|
||||
{
|
||||
FileInfo fileInfo = new($"{logistics.ReportFullPath}.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);
|
||||
}
|
||||
fileInfoCollection.Add(logistics.FileInfo);
|
||||
}
|
||||
|
||||
internal static List<Description> GetDescriptions(JsonElement[] jsonElements)
|
||||
|
Reference in New Issue
Block a user