From 5139c15b678945b255ab275d6ec5aed75f53745d Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Wed, 22 Mar 2023 14:56:01 -0700 Subject: [PATCH] SECS Description for get IQS --- .../FileHandlers/OpenInsight/FileRead.cs | 19 +++-- .../FileHandlers/OpenInsight/FromIQS.cs | 10 +-- .../OpenInsightMetrologyViewer/FileRead.cs | 4 +- .../FileRead.cs | 4 +- Adaptation/FileHandlers/SECS/Description.cs | 72 ++++++++++++++++ Adaptation/FileHandlers/SECS/ProcessData.cs | 83 +++++++++++++++++++ Adaptation/MET08ANLYSDIFAAST230.Tests.csproj | 4 +- MET08ANLYSDIFAAST230.csproj | 2 + 8 files changed, 180 insertions(+), 18 deletions(-) create mode 100644 Adaptation/FileHandlers/SECS/Description.cs create mode 100644 Adaptation/FileHandlers/SECS/ProcessData.cs diff --git a/Adaptation/FileHandlers/OpenInsight/FileRead.cs b/Adaptation/FileHandlers/OpenInsight/FileRead.cs index 81a9293..e7cf131 100644 --- a/Adaptation/FileHandlers/OpenInsight/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsight/FileRead.cs @@ -116,17 +116,22 @@ public class FileRead : Shared.FileRead, IFileRead return results; } - internal static string GetLines(Logistics logistics, List descriptions) + internal static string GetLines(Logistics logistics, List descriptions) { StringBuilder results = new(); - Shared.Properties.IDescription x = descriptions[0]; - char del = x.MesEntity == x.Reactor ? '\t' : '~'; - _ = results.Append(logistics.MesEntity).Append(del) - .Append(x.MesEntity).Append(del); + char del = '\t'; + SECS.Description x = descriptions[0]; + _ = results.Append(x.MesEntity).Append(del) + .Append(x.Reactor).Append(del) + .Append(x.RDS).Append(del) + .Append(x.Recipe).Append(del) + .Append(x.PSN).Append(del) + .Append(x.Employee).Append(del) + .Append(logistics.MesEntity).Append(del); return results.ToString(); } - private void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, string logistics, List descriptions, Test[] tests) + private void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, string logistics, List descriptions, Test[] tests) { bool isDummyRun = false; List<(Shared.Properties.IScopeInfo, string)> collection = new(); @@ -172,7 +177,7 @@ public class FileRead : Shared.FileRead, IFileRead _Logistics = new Logistics(reportFullPath, pdsf.Item1); SetFileParameterLotIDToLogisticsMID(); JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); - List descriptions = GetDuplicatorDescriptions(jsonElements); + List descriptions = SECS.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) SaveOpenInsightFile(reportFullPath, dateTime, pdsf.Item1, descriptions, tests); diff --git a/Adaptation/FileHandlers/OpenInsight/FromIQS.cs b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs index 754680a..d1026f1 100644 --- a/Adaptation/FileHandlers/OpenInsight/FromIQS.cs +++ b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs @@ -16,7 +16,7 @@ public class FromIQS #nullable enable - private static string GetCommandText(Logistics logistics, Shared.Properties.IDescription description, string dateTime, long? subGroupId) + private static string GetCommandText(Logistics logistics, SECS.Description description, string dateTime, long? subGroupId) { StringBuilder result = new(); _ = result @@ -74,13 +74,13 @@ public class FromIQS return stringBuilder; } - internal static (long?, int?, string) GetCommandText(string connectionString, Logistics logistics, Shared.Properties.IDescription description, long breakAfter, long preWait) + internal static (long?, int?, string) GetCommandText(string connectionString, Logistics logistics, SECS.Description description, long breakAfter, long preWait) { string dateTime; int? count = null; string commandText; long? result = null; - string dateFormat = Shared.Duplicator.Description.GetDateFormat(); + string dateFormat = SECS.Description.GetDateFormat(); if (DateTime.TryParseExact(description.Date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTimeParsed)) dateTime = dateTimeParsed.ToString("yyyy-MM-dd HH:mm:ss"); else if (DateTime.TryParse(description.Date, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeParsed)) @@ -129,7 +129,7 @@ public class FromIQS return new(result, count, commandText); } - private static string GetJson(Logistics logistics, string logisticLines, Shared.Properties.IDescription description) + private static string GetJson(Logistics logistics, string logisticLines, SECS.Description description) { string result; StringBuilder stringBuilder = new(); @@ -180,7 +180,7 @@ public class FromIQS return result; } - internal static void Save(string openInsightApiECDirectory, string openInsightApiIFXDirectory, Logistics logistics, string reportFullPath, string logisticLines, Shared.Properties.IDescription description, string lines, long? subGroupId, string weekOfYear) + internal static void Save(string openInsightApiECDirectory, string openInsightApiIFXDirectory, Logistics logistics, string reportFullPath, string logisticLines, SECS.Description description, string lines, long? subGroupId, string weekOfYear) { string checkFile; string fileName = Path.GetFileName(reportFullPath); diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs index f1021d7..81c03e6 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs @@ -103,7 +103,7 @@ public class FileRead : Shared.FileRead, IFileRead return results; } - private static void SendData(DateTime dateTime, List descriptions) + private static void SendData(DateTime dateTime, List descriptions) { if (dateTime == DateTime.MinValue) { } @@ -118,7 +118,7 @@ public class FileRead : Shared.FileRead, IFileRead _Logistics = new Logistics(reportFullPath, pdsf.Item1); SetFileParameterLotIDToLogisticsMID(); JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); - List descriptions = GetDuplicatorDescriptions(jsonElements); + List descriptions = SECS.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) SendData(dateTime, descriptions); diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs index fdd81e3..15c0369 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs @@ -103,7 +103,7 @@ public class FileRead : Shared.FileRead, IFileRead return results; } - private static void PostOpenInsightMetrologyViewerAttachments(string reportFullPath, DateTime dateTime, List descriptions) + private static void PostOpenInsightMetrologyViewerAttachments(string reportFullPath, DateTime dateTime, List descriptions) { if (reportFullPath is null) { } @@ -120,7 +120,7 @@ public class FileRead : Shared.FileRead, IFileRead _Logistics = new Logistics(reportFullPath, pdsf.Item1); SetFileParameterLotIDToLogisticsMID(); JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); - List descriptions = GetDuplicatorDescriptions(jsonElements); + List descriptions = SECS.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) PostOpenInsightMetrologyViewerAttachments(reportFullPath, dateTime, descriptions); diff --git a/Adaptation/FileHandlers/SECS/Description.cs b/Adaptation/FileHandlers/SECS/Description.cs new file mode 100644 index 0000000..2828465 --- /dev/null +++ b/Adaptation/FileHandlers/SECS/Description.cs @@ -0,0 +1,72 @@ +using Adaptation.Shared; +using Adaptation.Shared.Methods; +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.SECS; + +public class Description : IDescription, Shared.Properties.IDescription +{ + + public int Test { get; set; } + public int Count { get; set; } + public int Index { get; set; } + + public string MesEntity { get; set; } + public string Date { get; set; } + + [JsonPropertyName("PATTERNTYPE")] + public string Employee { get; set; } // Item descriptor + + [JsonPropertyName("SAMPLETYPE")] + public string PSN { get; set; } // Item descriptor + + [JsonPropertyName("ID")] + public string RDS { get; set; } // Lot + + [JsonPropertyName("LotID")] + public string Reactor { get; set; } // Process + + [JsonPropertyName("CURRENT_RECIPE_NAME")] + public string Recipe { get; set; } // Part + + string IDescription.GetEventDescription() => "File Has been read and parsed"; + + List IDescription.GetNames(IFileRead fileRead, Logistics logistics) => + throw new NotImplementedException(); + + List IDescription.GetDetailNames() => + throw new NotImplementedException(); + + List IDescription.GetHeaderNames() => + throw new NotImplementedException(); + + IDescription IDescription.GetDisplayNames() => + throw new NotImplementedException(); + + List IDescription.GetParameterNames() => + throw new NotImplementedException(); + + JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics) => + throw new NotImplementedException(); + + List IDescription.GetPairedParameterNames() => + throw new NotImplementedException(); + + List IDescription.GetIgnoreParameterNames(Test test) => + throw new NotImplementedException(); + + IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics) => + throw new NotImplementedException(); + + Dictionary IDescription.GetDisplayNamesJsonElement(IFileRead fileRead) => + throw new NotImplementedException(); + + List IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List tests, IProcessData iProcessData) => + throw new NotImplementedException(); + + internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt"; + +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/SECS/ProcessData.cs b/Adaptation/FileHandlers/SECS/ProcessData.cs new file mode 100644 index 0000000..e0fc96e --- /dev/null +++ b/Adaptation/FileHandlers/SECS/ProcessData.cs @@ -0,0 +1,83 @@ +using Adaptation.Shared; +using Adaptation.Shared.Methods; +using log4net; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.SECS; + +public class ProcessData : IProcessData +{ + + private readonly ILog _Log; + private readonly List _Details; + + public string JobID { get; set; } + public string MesEntity { get; set; } + public DateTime Date { get; set; } + public string PSN { get; set; } + + List Shared.Properties.IProcessData.Details => _Details; + + public ProcessData(IFileRead fileRead, Logistics logistics, List fileInfoCollection, string ghostPCLFileName, string pdfTextStripperFileName) + { + fileInfoCollection.Clear(); + _Details = new List(); + JobID = logistics.JobID; + MesEntity = logistics.MesEntity; + _Log = LogManager.GetLogger(typeof(ProcessData)); + Date = DateTime.Now; + } + + string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary reactors) => throw new Exception(string.Concat("See ", nameof(Parse))); + + Tuple> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List fileInfoCollection) + { + Tuple> results; + List tests = new(); + foreach (object item in _Details) + tests.Add(Test.HgCV); + List descriptions = fileRead.GetDescriptions(fileRead, tests, this); + if (tests.Count != descriptions.Count) + throw new Exception(); + for (int i = 0; i < tests.Count; i++) + { + if (descriptions[i] is not Description description) + throw new Exception(); + if (description.Test != (int)tests[i]) + throw new Exception(); + } + List fileReadDescriptions = (from l in descriptions select (Description)l).ToList(); + string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType()); + JsonElement[] jsonElements = JsonSerializer.Deserialize(json); + results = new Tuple>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection); + return results; + } + + private object Parse() => throw new NotImplementedException(); + +#nullable enable + + internal static List GetDescriptions(JsonElement[] jsonElements) + { + List results = new(); + Description? description; + JsonSerializerOptions jsonSerializerOptions = new() { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString }; + foreach (JsonElement jsonElement in jsonElements) + { + if (jsonElement.ValueKind != JsonValueKind.Object) + throw new Exception(); + description = JsonSerializer.Deserialize(jsonElement.ToString(), jsonSerializerOptions); + if (description is null) + continue; + results.Add(description); + } + return results; + } + +} \ No newline at end of file diff --git a/Adaptation/MET08ANLYSDIFAAST230.Tests.csproj b/Adaptation/MET08ANLYSDIFAAST230.Tests.csproj index 4aa0995..ff1cc52 100644 --- a/Adaptation/MET08ANLYSDIFAAST230.Tests.csproj +++ b/Adaptation/MET08ANLYSDIFAAST230.Tests.csproj @@ -34,7 +34,7 @@ - + NU1701 NU1701 NU1701 @@ -43,7 +43,7 @@ NU1701 NU1701 - + diff --git a/MET08ANLYSDIFAAST230.csproj b/MET08ANLYSDIFAAST230.csproj index 4ef0bd8..be064ed 100644 --- a/MET08ANLYSDIFAAST230.csproj +++ b/MET08ANLYSDIFAAST230.csproj @@ -108,6 +108,8 @@ + +