SECS Description for get IQS

This commit is contained in:
2023-03-22 14:56:01 -07:00
parent 56a6af4fb8
commit 5139c15b67
8 changed files with 180 additions and 18 deletions

View File

@ -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<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics) =>
throw new NotImplementedException();
List<string> IDescription.GetDetailNames() =>
throw new NotImplementedException();
List<string> IDescription.GetHeaderNames() =>
throw new NotImplementedException();
IDescription IDescription.GetDisplayNames() =>
throw new NotImplementedException();
List<string> IDescription.GetParameterNames() =>
throw new NotImplementedException();
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics) =>
throw new NotImplementedException();
List<string> IDescription.GetPairedParameterNames() =>
throw new NotImplementedException();
List<string> IDescription.GetIgnoreParameterNames(Test test) =>
throw new NotImplementedException();
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics) =>
throw new NotImplementedException();
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead) =>
throw new NotImplementedException();
List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData) =>
throw new NotImplementedException();
internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt";
}

View File

@ -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<object> _Details;
public string JobID { get; set; }
public string MesEntity { get; set; }
public DateTime Date { get; set; }
public string PSN { get; set; }
List<object> Shared.Properties.IProcessData.Details => _Details;
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string ghostPCLFileName, string pdfTextStripperFileName)
{
fileInfoCollection.Clear();
_Details = new List<object>();
JobID = logistics.JobID;
MesEntity = logistics.MesEntity;
_Log = LogManager.GetLogger(typeof(ProcessData));
Date = DateTime.Now;
}
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
List<Test> tests = new();
foreach (object item in _Details)
tests.Add(Test.HgCV);
List<IDescription> 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<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList();
string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection);
return results;
}
private object Parse() => throw new NotImplementedException();
#nullable enable
internal static List<Description> GetDescriptions(JsonElement[] jsonElements)
{
List<Description> 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<Description>(jsonElement.ToString(), jsonSerializerOptions);
if (description is null)
continue;
results.Add(description);
}
return results;
}
}