Require Complete

IDE0060
This commit is contained in:
Mike Phares 2024-11-20 12:35:54 -07:00
parent a95f783733
commit 334929a025
10 changed files with 49 additions and 103 deletions

View File

@ -115,10 +115,10 @@ public class FileRead : Shared.FileRead, IFileRead
} }
} }
#pragma warning disable IDE0060
private void MoveArchive(string reportFullPath, DateTime dateTime) private void MoveArchive(string reportFullPath, DateTime dateTime)
#pragma warning restore IDE0060
{ {
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
string logisticsSequence = _Logistics.Sequence.ToString(); string logisticsSequence = _Logistics.Sequence.ToString();
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}"; string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}";

View File

@ -165,10 +165,10 @@ public class FileRead : Shared.FileRead, IFileRead
OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, _OriginalDataBioRad, descriptions, matchDirectories[0], subGroupId, headerId, headerIdDirectory); OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, _OriginalDataBioRad, descriptions, matchDirectories[0], subGroupId, headerId, headerIdDirectory);
} }
#pragma warning disable IDE0060
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
#pragma warning restore IDE0060
{ {
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
Tuple<string, Test[], JsonElement[], List<FileInfo>> results; Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
_Logistics = new Logistics(reportFullPath, pdsf.Item1); _Logistics = new Logistics(reportFullPath, pdsf.Item1);

View File

@ -108,10 +108,10 @@ public class FileRead : Shared.FileRead, IFileRead
return results; return results;
} }
#pragma warning disable IDE0060
private void DirectoryMove(string reportFullPath, DateTime dateTime, List<Stratus.Description> descriptions) private void DirectoryMove(string reportFullPath, DateTime dateTime, List<Stratus.Description> descriptions)
#pragma warning restore IDE0060
{ {
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
FileInfo fileInfo = new(reportFullPath); FileInfo fileInfo = new(reportFullPath);
string logisticsSequence = _Logistics.Sequence.ToString(); string logisticsSequence = _Logistics.Sequence.ToString();
string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID); string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID);

View File

@ -1,5 +1,9 @@
using Adaptation.Shared;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.Stratus; namespace Adaptation.FileHandlers.Stratus;
@ -20,10 +24,12 @@ internal class Complete
public Wafer[] Wafers { get; } public Wafer[] Wafers { get; }
public Footer Footer { get; } public Footer Footer { get; }
internal static Complete? Get(string text, Constant constant) internal static Complete? Get(Logistics logistics, List<FileInfo> fileInfoCollection)
{ {
Complete? result; Complete? result;
Constant constant = new();
int[] i = new int[] { 0 }; int[] i = new int[] { 0 };
string text = File.ReadAllText(logistics.ReportFullPath);
Header? header = Header.Get(text, constant, i); Header? header = Header.Get(text, constant, i);
if (header is null) if (header is null)
result = null; result = null;
@ -43,7 +49,14 @@ internal class Complete
if (footer is null) if (footer is null)
result = null; result = null;
else else
{
result = new(header, wafers.ToArray(), footer); result = new(header, wafers.ToArray(), footer);
FileInfo fileInfo = new($"{logistics.ReportFullPath}.json");
string json = JsonSerializer.Serialize(result, CompleteSourceGenerationContext.Default.Complete);
File.WriteAllText(fileInfo.FullName, json);
File.SetLastWriteTime(fileInfo.FullName, logistics.DateTimeFromSequence);
fileInfoCollection.Add(fileInfo);
}
} }
} }
} }

View File

@ -98,9 +98,11 @@ public class FileRead : Shared.FileRead, IFileRead
return results; return results;
} }
#nullable enable
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{ {
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>()); Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, Array.Empty<Test>(), Array.Empty<JsonElement>(), new List<FileInfo>());
_TickOffset ??= 0; // new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks; _TickOffset ??= 0; // new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
_Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true); _Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID(); SetFileParameterLotIDToLogisticsMID();
@ -108,9 +110,12 @@ public class FileRead : Shared.FileRead, IFileRead
results.Item4.Add(_Logistics.FileInfo); results.Item4.Add(_Logistics.FileInfo);
else else
{ {
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _OriginalDataBioRad, dataText: string.Empty); Complete? complete = Complete.Get(_Logistics, results.Item4);
if (iProcessData is not ProcessData processData) if (complete is null)
throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks)); throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks));
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _OriginalDataBioRad, complete, dataText: string.Empty);
if (iProcessData is not ProcessData processData)
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
string mid; string mid;
if (!string.IsNullOrEmpty(processData.Cassette) && string.IsNullOrEmpty(processData.Reactor) && string.IsNullOrEmpty(processData.RDS) && string.IsNullOrEmpty(processData.PSN)) if (!string.IsNullOrEmpty(processData.Cassette) && string.IsNullOrEmpty(processData.Reactor) && string.IsNullOrEmpty(processData.RDS) && string.IsNullOrEmpty(processData.PSN))
mid = processData.Cassette; mid = processData.Cassette;
@ -124,7 +129,7 @@ public class FileRead : Shared.FileRead, IFileRead
SetFileParameterLotID(mid); SetFileParameterLotID(mid);
_Logistics.Update(mid, processData.Reactor); _Logistics.Update(mid, processData.Reactor);
if (iProcessData.Details.Count == 0) if (iProcessData.Details.Count == 0)
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks)); throw new Exception(string.Concat("C) No Data - ", dateTime.Ticks));
if (iProcessData.Details[0] is Detail detail && string.IsNullOrEmpty(detail.PassFail)) if (iProcessData.Details[0] is Detail detail && string.IsNullOrEmpty(detail.PassFail))
results.Item4.Add(_Logistics.FileInfo); results.Item4.Add(_Logistics.FileInfo);
else else

View File

@ -1,5 +1,3 @@
using log4net;
using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
namespace Adaptation.FileHandlers.Stratus; namespace Adaptation.FileHandlers.Stratus;
@ -18,47 +16,6 @@ public class Footer
public string MeanThickness { get; } public string MeanThickness { get; }
public string StdDev { get; } public string StdDev { get; }
private static string GetBefore(string text, int[] i, string search, bool trim)
{
string str;
string before;
if (trim)
before = Header.GetBefore(text, i, search);
else
{
int num = text.IndexOf(search, i[0]);
if (num <= -1)
{
str = text.Substring(i[0]);
i[0] = text.Length;
before = str;
}
else
{
str = text.Substring(i[0], num - i[0]);
i[0] = num + search.Length;
before = str;
}
}
return before;
}
private static string GetToEOL(string text, int[] i, bool trim)
{
string str;
if (text.IndexOf("\n", i[0]) > -1)
str = !trim ? GetBefore(text, i, "\n", false) : Header.GetToEOL(text, i);
else
str = !trim ? GetBefore(text, i, Environment.NewLine, false) : Header.GetToEOL(text, i);
return str;
}
private static bool IsBlankLine(string text, int[] i)
{
int num = text.IndexOf("\n", i[0]);
return Wafer.IsNullOrWhiteSpace(num > -1 ? text.Substring(i[0], num - i[0]) : text.Substring(i[0]));
}
internal static Footer? Get(Constant constant, ReadOnlyCollection<string> groups) internal static Footer? Get(Constant constant, ReadOnlyCollection<string> groups)
{ {
Footer? result; Footer? result;
@ -80,12 +37,6 @@ public class Footer
if (stdDev.EndsWith(",")) if (stdDev.EndsWith(","))
stdDev = stdDev.Remove(stdDev.Length - 1, 1); stdDev = stdDev.Remove(stdDev.Length - 1, 1);
} }
// if (PeekNextLine(groupText, j).Contains(constant.Cassette))
// _ = Header.GetToEOL(groupText, j);
// if (PeekNextLine(groupText, j).Contains(constant.Cassette))
// _ = Header.GetToEOL(groupText, j);
// if (PeekNextLine(groupText, j).Contains("Process failed"))
// _ = Header.GetToEOL(groupText, j);
result = new(meanThickness: meanThickness, result = new(meanThickness: meanThickness,
stdDev: stdDev); stdDev: stdDev);
return result; return result;

View File

@ -42,14 +42,16 @@ public partial class ProcessData : IProcessData
private string _Data; private string _Data;
private readonly ILog _Log; private readonly ILog _Log;
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, string dataText) #nullable enable
internal ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, Complete? complete, string dataText)
{ {
JobID = logistics.JobID; JobID = logistics.JobID;
fileInfoCollection.Clear(); fileInfoCollection.Clear();
_Details = new List<object>(); _Details = new List<object>();
MesEntity = logistics.MesEntity; MesEntity = logistics.MesEntity;
_Log = LogManager.GetLogger(typeof(ProcessData)); _Log = LogManager.GetLogger(typeof(ProcessData));
Parse(fileRead, logistics, fileInfoCollection, originalDataBioRad, dataText); Parse(fileRead, logistics, fileInfoCollection, originalDataBioRad, complete, dataText);
} }
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse))); string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
@ -72,7 +74,7 @@ public partial class ProcessData : IProcessData
} }
List<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList(); List<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList();
string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType()); string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json); JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json) ?? throw new Exception();
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection); results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection);
return results; return results;
} }
@ -383,7 +385,7 @@ public partial class ProcessData : IProcessData
return result; return result;
} }
private void Set(Logistics logistics) private void Set(Logistics logistics, Complete? complete)
{ {
string psn; string psn;
string rds; string rds;
@ -413,6 +415,8 @@ public partial class ProcessData : IProcessData
batch = GetToText(startedKey); batch = GetToText(startedKey);
ScanPast(startedAtKey); ScanPast(startedAtKey);
} }
if (complete is not null)
{ }
ScanPast(cassetteKey); ScanPast(cassetteKey);
if (!_Data.Substring(_I).Contains(startedKey)) if (!_Data.Substring(_I).Contains(startedKey))
text = string.Empty; text = string.Empty;
@ -445,48 +449,17 @@ public partial class ProcessData : IProcessData
UniqueId = string.Concat("StratusBioRad_", reactor, "_", rds, "_", psn, "_", logistics.DateTimeFromSequence.ToString("yyyyMMddHHmmssffff")); UniqueId = string.Concat("StratusBioRad_", reactor, "_", rds, "_", psn, "_", logistics.DateTimeFromSequence.ToString("yyyyMMddHHmmssffff"));
} }
#nullable enable private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, Complete? complete, string receivedData)
private static Complete? GetComplete(string text)
{
Complete? result;
Constant constant = new();
result = Complete.Get(text, constant);
return result;
}
#pragma warning disable IDE0060
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, string receivedData)
#pragma warning restore IDE0060
{ {
if (fileRead is null)
throw new ArgumentNullException(nameof(fileRead));
_I = 0; _I = 0;
_Data = string.Empty; _Data = string.Empty;
List<Detail> details = new(); List<Detail> details = new();
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(logistics.ReportFullPath);
if (string.IsNullOrEmpty(receivedData))
{
receivedData = File.ReadAllText(logistics.ReportFullPath);
try
{
Complete? complete = GetComplete(receivedData);
if (complete is null)
_Log.Warn($"Could not get Complete from {fileNameWithoutExtension}");
else
{
FileInfo fileInfo = new($"{fileNameWithoutExtension}.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);
}
}
_Log.Debug($"****ParseData - Source file contents:"); _Log.Debug($"****ParseData - Source file contents:");
_Log.Debug(receivedData); _Log.Debug(receivedData);
List<string> moveFiles = new(); List<string> moveFiles = new();
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(logistics.ReportFullPath);
string directoryName = Path.GetDirectoryName(logistics.ReportFullPath) ?? throw new Exception(); string directoryName = Path.GetDirectoryName(logistics.ReportFullPath) ?? throw new Exception();
moveFiles.AddRange(Directory.GetFiles(directoryName, string.Concat(originalDataBioRad, "*", logistics.Sequence, "*"), SearchOption.TopDirectoryOnly)); moveFiles.AddRange(Directory.GetFiles(directoryName, string.Concat(originalDataBioRad, "*", logistics.Sequence, "*"), SearchOption.TopDirectoryOnly));
moveFiles.AddRange(Directory.GetFiles(directoryName, string.Concat(originalDataBioRad, "*", fileNameWithoutExtension.Split('_').Last(), "*"), SearchOption.TopDirectoryOnly)); moveFiles.AddRange(Directory.GetFiles(directoryName, string.Concat(originalDataBioRad, "*", fileNameWithoutExtension.Split('_').Last(), "*"), SearchOption.TopDirectoryOnly));
@ -504,7 +477,7 @@ public partial class ProcessData : IProcessData
string nextLine; string nextLine;
_I = 0; _I = 0;
_Data = receivedData; _Data = receivedData;
Set(logistics); Set(logistics, complete);
nextLine = PeekNextLine(); nextLine = PeekNextLine();
string cassette = "Cassette"; string cassette = "Cassette";
if (nextLine.Contains("Wafer")) if (nextLine.Contains("Wafer"))

View File

@ -1,4 +1,3 @@
using log4net;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -100,8 +100,10 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{ {
if (dateTime == DateTime.MinValue)
throw new ArgumentNullException(nameof(dateTime));
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>()); Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_TickOffset ??= new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks; _TickOffset ??= 0; // new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
_Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true); _Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true);
SetFileParameterLotID(_Logistics.MID); SetFileParameterLotID(_Logistics.MID);
FileInfo fileInfo = new(reportFullPath); FileInfo fileInfo = new(reportFullPath);

View File

@ -59,6 +59,8 @@ public partial class ProcessData : IProcessData
return results; return results;
} }
#nullable enable
private List<Tuple<string, bool, DateTime, string>> Parse(IFileRead fileRead, Logistics logistics, long tickOffset, List<FileInfo> fileInfoCollection, string originalDataBioRad) private List<Tuple<string, bool, DateTime, string>> Parse(IFileRead fileRead, Logistics logistics, long tickOffset, List<FileInfo> fileInfoCollection, string originalDataBioRad)
{ {
List<Tuple<string, bool, DateTime, string>> results = new(); List<Tuple<string, bool, DateTime, string>> results = new();
@ -224,7 +226,8 @@ public partial class ProcessData : IProcessData
} }
else else
{ {
processData = new Stratus.ProcessData(fileRead, logistics, fileInfoCollection, originalDataBioRad, dataText: dataText); Stratus.Complete? complete = null;
processData = new Stratus.ProcessData(fileRead, logistics, fileInfoCollection, originalDataBioRad, complete, dataText: dataText);
iProcessData = processData; iProcessData = processData;
if (iProcessData.Details.Count == 0) if (iProcessData.Details.Count == 0)
_Log.Warn("No Details!"); _Log.Warn("No Details!");