using Adaptation.Shared.Methods; using System; using System.Collections.Generic; using System.Linq; using System.Text.Json; namespace Adaptation.Shared.Duplicator { public class Description : IDescription, Properties.IDescription { public int Test { get; set; } public int Count { get; set; } public int Index { get; set; } // public string EventName { get; set; } public string NullData { get; set; } public string JobID { get; set; } public string Sequence { get; set; } public string MesEntity { get; set; } public string ReportFullPath { get; set; } public string ProcessJobID { get; set; } public string MID { get; set; } public string Date { get; set; } //2021-10-23 string IDescription.GetEventDescription() { return "File Has been read and parsed"; } List IDescription.GetNames(IFileRead fileRead, Logistics logistics) { List results = new(); IDescription description = GetDefault(fileRead, logistics); string json = JsonSerializer.Serialize(description, description.GetType()); object @object = JsonSerializer.Deserialize(json); if (@object is not JsonElement jsonElement) throw new Exception(); foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject()) results.Add(jsonProperty.Name); return results; } List IDescription.GetDetailNames() { List results = new(); return results; } List IDescription.GetHeaderNames() { List results = new(); return results; } IDescription IDescription.GetDisplayNames() { Description result = GetDisplayNames(); return result; } List IDescription.GetParameterNames() { List results = new(); return results; } JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics) { JsonProperty[] results; IDescription description = GetDefault(fileRead, logistics); string json = JsonSerializer.Serialize(description, description.GetType()); object @object = JsonSerializer.Deserialize(json); results = ((JsonElement)@object).EnumerateObject().ToArray(); return results; } List IDescription.GetPairedParameterNames() { List results = new(); return results; } List IDescription.GetIgnoreParameterNames(Test test) { List results = new(); return results; } IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics) { Description result = GetDefault(fileRead, logistics); return result; } Dictionary IDescription.GetDisplayNamesJsonElement(IFileRead fileRead) { Dictionary results = new(); IDescription description = GetDisplayNames(); string json = JsonSerializer.Serialize(description, description.GetType()); JsonElement jsonElement = JsonSerializer.Deserialize(json); foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject()) { if (!results.ContainsKey(jsonProperty.Name)) results.Add(jsonProperty.Name, string.Empty); if (jsonProperty.Value is JsonElement jsonPropertyValue) results[jsonProperty.Name] = jsonPropertyValue.ToString(); } return results; } List IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List tests, IProcessData iProcessData) { List results = new(); return results; } private Description GetDisplayNames() { Description result = new(); return result; } private Description GetDefault(IFileRead fileRead, Logistics logistics) { Description result = new() { Test = -1, Count = 0, Index = -1, // EventName = fileRead.EventName, NullData = fileRead.NullData, JobID = fileRead.CellInstanceName, Sequence = logistics.Sequence.ToString(), MesEntity = fileRead.MesEntity, ReportFullPath = logistics.ReportFullPath, ProcessJobID = logistics.ProcessJobID, MID = logistics.MID, Date = logistics.DateTimeFromSequence.ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss") }; return result; } } }