diff --git a/.gitignore b/.gitignore index 7ddc337..1629816 100644 --- a/.gitignore +++ b/.gitignore @@ -335,9 +335,11 @@ ASALocalRun/ !**/.vscode/extensions.json !**/.vscode/format-report.json !**/.vscode/launch.json +!**/.vscode/mklink.md !**/.vscode/settings.json !**/.vscode/tasks.json +!**/.vscode/mklink.md *.lnk -Adaptation/.kanbn +.kanbn/**/* \ No newline at end of file diff --git a/.vscode/mklink.md b/.vscode/mklink.md new file mode 100644 index 0000000..7a8fc3a --- /dev/null +++ b/.vscode/mklink.md @@ -0,0 +1,11 @@ +--- +type: "note" +created: "2023-10-20T03:52:57.401Z" +updated: "2023-10-20T03:53:49.161Z" +--- + +# mklink + +```bash +mklink /J "L:\Workspaces\33_CS29_79_72\MIT_EAF_Adaptations\Trunk\MESAFIBACKLOG\06_SourceCode\MESAFIBACKLOG\.kanbn" "D:\Documents\Kanban\MESAFIBACKLOG" +``` diff --git a/Adaptation/.vscode/mklink.md b/Adaptation/.vscode/mklink.md new file mode 100644 index 0000000..931ca61 --- /dev/null +++ b/Adaptation/.vscode/mklink.md @@ -0,0 +1,15 @@ +--- +type: "note" +created: "2023-10-20T03:56:21.490Z" +updated: "2023-10-20T03:57:15.006Z" +--- + +# mklink + +```bash +mklink /J "T:\MESAFIBACKLOG\06_SourceCode\MESAFIBACKLOG\Adaptation\.kanbn" "D:\Documents\Kanban\MESAFIBACKLOG" +``` + +```bash +mklink /J "T:\MESAFIBACKLOG\06_SourceCode\MESAFIBACKLOG\Adaptation\.kanbn" "D:\5-Other-Small\Kanban\MESAFIBACKLOG" +``` diff --git a/Adaptation/FileHandlers/CellInstanceConnectionName.cs b/Adaptation/FileHandlers/CellInstanceConnectionName.cs index cee542a..d239a30 100644 --- a/Adaptation/FileHandlers/CellInstanceConnectionName.cs +++ b/Adaptation/FileHandlers/CellInstanceConnectionName.cs @@ -16,15 +16,17 @@ public class CellInstanceConnectionName nameof(APC) => new APC.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(Archive) => new Archive.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(ConvertExcelToJson) => new ConvertExcelToJson.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(CopyToPaths) => new CopyToPaths.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(DownloadExcelFile) => new DownloadExcelFile.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(Dummy) => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(IQSSi) => new IQSSi.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(json) => new json.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(Kanban) => new Kanban.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(MoveMatchingFiles) => new MoveMatchingFiles.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(OpenInsight) => new OpenInsight.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(OpenInsightMetrologyViewer) => new OpenInsightMetrologyViewer.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(OpenInsightMetrologyViewerAttachments) => new OpenInsightMetrologyViewerAttachments.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(Processed) => new Processed.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), - nameof(json) => new json.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), nameof(SPaCe) => new SPaCe.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), _ => throw new Exception($"\"{cellInstanceConnectionName}\" not mapped") }; diff --git a/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs b/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs index 7cc133b..05f4bb2 100644 --- a/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs +++ b/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs @@ -94,17 +94,17 @@ public class ProcessData : IProcessData if (@object is null) value = string.Empty; else - value = string.Concat(@object); - if (value.Contains("\"")) - value = value.Replace("\"", "\\\""); - if (value.Contains("\n")) - value = value.Replace("\n", "
"); - name = table.Columns[j].ColumnName.ToString().Trim(); - if (name.Contains("\"")) - name = name.Replace("\"", "\\\""); - if (name.Contains("\n")) - name = name.Replace("\n", "
"); - _ = jsonString.Append('"').Append(name).Append("\":").Append('"').Append(value).Append('"'); + value = JsonSerializer.Serialize(@object.ToString()); + if (value.Contains("\\n")) + value = value.Replace("\\n", "
"); + if (value.Contains("\\t")) + value = value.Replace("\\t", " "); + name = JsonSerializer.Serialize(table.Columns[j].ColumnName.ToString().Trim()); + if (name.Contains("\\n")) + name = name.Replace("\\n", "
"); + if (name.Contains("\\t")) + name = name.Replace("\\t", " "); + _ = jsonString.Append(name).Append(':').Append(value); if (j < table.Columns.Count - 1) _ = jsonString.Append(','); } @@ -118,6 +118,34 @@ public class ProcessData : IProcessData return jsonString.ToString(); } + private static List Parse(IFileRead fileRead, JsonElement[] jsonElements) + { + string key; + string json; + FIBacklogMesa? fiBacklogMesa; + JsonProperty[] jsonProperties; + List fiBacklogMesaCollection = new(); + foreach (JsonElement jsonElement in jsonElements) + { + if (jsonElement.ValueKind != JsonValueKind.Object) + continue; + jsonProperties = jsonElement.EnumerateObject().ToArray(); + if (jsonProperties.Length < 2) + continue; + key = jsonProperties[0].Value.ToString(); + if (string.IsNullOrEmpty(key)) + continue; + json = jsonElement.ToString(); + if (!fileRead.IsEAFHosted) + File.WriteAllText(".json", json); + fiBacklogMesa = JsonSerializer.Deserialize(json); + if (fiBacklogMesa is null) + throw new NullReferenceException(); + fiBacklogMesaCollection.Add(fiBacklogMesa); + } + return fiBacklogMesaCollection; + } + private void Parse(IFileRead fileRead, Logistics logistics, List fileInfoCollection, string sheet) { if (fileRead is null) @@ -129,10 +157,20 @@ public class ProcessData : IProcessData if (dataTable.Rows.Count == 0) throw new Exception("No rows"); string json = DataTableToJSON(dataTable); - FIBacklogMesa[]? fIBacklogMesaCollection = JsonSerializer.Deserialize(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); - if (fIBacklogMesaCollection is null || !fIBacklogMesaCollection.Any()) + if (!fileRead.IsEAFHosted) + File.WriteAllText(".json", json); + JsonElement[]? jsonElements = JsonSerializer.Deserialize(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); + if (jsonElements is null || !jsonElements.Any()) throw new NullReferenceException(); - json = JsonSerializer.Serialize(from l in fIBacklogMesaCollection orderby l.Req.Length, l.Req select l, new JsonSerializerOptions() { WriteIndented = true }); + if (!fileRead.ReportFullPath.Contains("Backlog")) + json = JsonSerializer.Serialize(jsonElements, new JsonSerializerOptions() { WriteIndented = true }); + else + { + List fiBacklogMesaCollection = Parse(fileRead, jsonElements); + json = JsonSerializer.Serialize(from l in fiBacklogMesaCollection orderby l.Req.Length, l.Req select l, new JsonSerializerOptions() { WriteIndented = true }); + } + if (!fileRead.IsEAFHosted) + File.WriteAllText(".json", json); _Details.Add(json); } diff --git a/Adaptation/FileHandlers/CopyToPaths/FileRead.cs b/Adaptation/FileHandlers/CopyToPaths/FileRead.cs new file mode 100644 index 0000000..7f7051c --- /dev/null +++ b/Adaptation/FileHandlers/CopyToPaths/FileRead.cs @@ -0,0 +1,135 @@ +using Adaptation.Eaf.Management.ConfigurationData.CellAutomation; +using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration; +using Adaptation.Shared; +using Adaptation.Shared.Duplicator; +using Adaptation.Shared.Methods; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Text.Json; +using System.Threading; + +namespace Adaptation.FileHandlers.CopyToPaths; + +public class FileRead : Shared.FileRead, IFileRead +{ + + private readonly ReadOnlyDictionary _CopyToPaths; + + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) + { + _MinFileLength = 10; + _NullData = string.Empty; + _Logistics = new(this); + if (_FileParameter is null) + throw new Exception(cellInstanceConnectionName); + if (_ModelObjectParameterDefinitions is null) + throw new Exception(cellInstanceConnectionName); + if (!_IsDuplicator) + throw new Exception(cellInstanceConnectionName); + Dictionary copyToPaths = new(); + string cellInstancecellInstanceConnectionNamed = string.Concat("CellInstance.", cellInstanceName, '.', cellInstanceConnectionName, '.'); + ModelObjectParameterDefinition[] modelObjectParameterDefinitions = GetProperties(cellInstanceConnectionName, modelObjectParameters, cellInstancecellInstanceConnectionNamed); + foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in modelObjectParameterDefinitions) + copyToPaths.Add(modelObjectParameterDefinition.Name.Split('.')[3], modelObjectParameterDefinition.Value); + _CopyToPaths = new(copyToPaths); + } + + void IFileRead.Move(Tuple> extractResults, Exception exception) => Move(extractResults); + + void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null); + + string IFileRead.GetEventDescription() + { + string result = _Description.GetEventDescription(); + return result; + } + + List IFileRead.GetHeaderNames() + { + List results = _Description.GetHeaderNames(); + return results; + } + + string[] IFileRead.Move(Tuple> extractResults, string to, string from, string resolvedFileLocation, Exception exception) + { + string[] results = Move(extractResults, to, from, resolvedFileLocation, exception); + return results; + } + + JsonProperty[] IFileRead.GetDefault() + { + JsonProperty[] results = _Description.GetDefault(this, _Logistics); + return results; + } + + Dictionary IFileRead.GetDisplayNamesJsonElement() + { + Dictionary results = _Description.GetDisplayNamesJsonElement(this); + return results; + } + + List IFileRead.GetDescriptions(IFileRead fileRead, List tests, IProcessData processData) + { + List results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData); + return results; + } + + Tuple> IFileRead.GetExtractResult(string reportFullPath, string eventName) + { + Tuple> results; + if (string.IsNullOrEmpty(eventName)) + throw new Exception(); + _ReportFullPath = reportFullPath; + DateTime dateTime = DateTime.Now; + results = GetExtractResult(reportFullPath, dateTime); + if (results.Item3 is null) + results = new Tuple>(results.Item1, Array.Empty(), JsonSerializer.Deserialize("[]"), results.Item4); + if (results.Item3.Length > 0 && _IsEAFHosted) + WritePDSF(this, results.Item3); + UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks); + return results; + } + + Tuple> IFileRead.ReExtract() + { + Tuple> results; + List headerNames = _Description.GetHeaderNames(); + Dictionary keyValuePairs = _Description.GetDisplayNamesJsonElement(this); + results = ReExtract(this, headerNames, keyValuePairs); + return results; + } + + private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) + { + Tuple> results; + string path; + string checkDirectory; + string ticks = dateTime.Ticks.ToString(); + string fileExtension = Path.GetExtension(reportFullPath); + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(reportFullPath); + _Logistics = new Logistics(reportFullPath, $"LOGISTICS_1{'\t'}A_JOBID={"BACKLOG"};A_MES_ENTITY={"BACKLOG"};"); + foreach (KeyValuePair keyValuePair in _CopyToPaths) + { + path = keyValuePair.Value.Replace("%OriginalFileName%", fileNameWithoutExtension).Replace("%OriginalFileExtension%", fileExtension).Replace($".{fileExtension}", fileExtension); + checkDirectory = Path.GetDirectoryName(path); + if (string.IsNullOrEmpty(checkDirectory)) + continue; + if (!Directory.Exists(checkDirectory)) + _ = Directory.CreateDirectory(Path.Combine(checkDirectory, ticks)); + if (File.Exists(path)) + { + if (_IsEAFHosted) + File.Delete(path); + Thread.Sleep(500); + } + if (_IsEAFHosted) + File.Copy(reportFullPath, path); + } + results = new(_Logistics.Logistics1[0], Array.Empty(), Array.Empty(), new List()); + return results; + } + +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/Kanban/FileRead.cs b/Adaptation/FileHandlers/Kanban/FileRead.cs new file mode 100644 index 0000000..b3ab4de --- /dev/null +++ b/Adaptation/FileHandlers/Kanban/FileRead.cs @@ -0,0 +1,194 @@ +using Adaptation.Eaf.Management.ConfigurationData.CellAutomation; +using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration; +using Adaptation.Shared; +using Adaptation.Shared.Duplicator; +using Adaptation.Shared.Methods; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text.Json; +using System.Text.RegularExpressions; + +namespace Adaptation.FileHandlers.Kanban; + +public class FileRead : Shared.FileRead, IFileRead +{ + + private readonly ReadOnlyCollection _CSSLines; + private readonly ReadOnlyCollection _FrontMatterLines; + + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) + { + _MinFileLength = 10; + _NullData = string.Empty; + _Logistics = new(this); + if (_FileParameter is null) + throw new Exception(cellInstanceConnectionName); + if (_ModelObjectParameterDefinitions is null) + throw new Exception(cellInstanceConnectionName); + if (!_IsDuplicator) + throw new Exception(cellInstanceConnectionName); + List cssLines = new(); + string cssLinesName = string.Concat("CellInstance.", cellInstanceName, '.', cellInstanceConnectionName, ".CSS.Lines"); + ModelObjectParameterDefinition[] cssLinesDefinitions = GetProperties(cellInstanceConnectionName, modelObjectParameters, cssLinesName); + foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cssLinesDefinitions) + cssLines.Add(modelObjectParameterDefinition.Value); + _CSSLines = new(cssLines); + List FrontMatterLines = new(); + string FrontMatterLinesName = string.Concat("CellInstance.", cellInstanceName, '.', cellInstanceConnectionName, ".Front.Matter.Lines"); + ModelObjectParameterDefinition[] FrontMatterLinesDefinitions = GetProperties(cellInstanceConnectionName, modelObjectParameters, FrontMatterLinesName); + foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in FrontMatterLinesDefinitions) + FrontMatterLines.Add(modelObjectParameterDefinition.Value); + _FrontMatterLines = new(FrontMatterLines); + } + + void IFileRead.Move(Tuple> extractResults, Exception exception) => Move(extractResults); + + void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null); + + string IFileRead.GetEventDescription() + { + string result = _Description.GetEventDescription(); + return result; + } + + List IFileRead.GetHeaderNames() + { + List results = _Description.GetHeaderNames(); + return results; + } + + string[] IFileRead.Move(Tuple> extractResults, string to, string from, string resolvedFileLocation, Exception exception) + { + string[] results = Move(extractResults, to, from, resolvedFileLocation, exception); + return results; + } + + JsonProperty[] IFileRead.GetDefault() + { + JsonProperty[] results = _Description.GetDefault(this, _Logistics); + return results; + } + + Dictionary IFileRead.GetDisplayNamesJsonElement() + { + Dictionary results = _Description.GetDisplayNamesJsonElement(this); + return results; + } + + List IFileRead.GetDescriptions(IFileRead fileRead, List tests, IProcessData processData) + { + List results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData); + return results; + } + + Tuple> IFileRead.GetExtractResult(string reportFullPath, string eventName) + { + Tuple> results; + if (string.IsNullOrEmpty(eventName)) + throw new Exception(); + _ReportFullPath = reportFullPath; + DateTime dateTime = DateTime.Now; + results = GetExtractResult(reportFullPath, dateTime); + if (results.Item3 is null) + results = new Tuple>(results.Item1, Array.Empty(), JsonSerializer.Deserialize("[]"), results.Item4); + if (results.Item3.Length > 0 && _IsEAFHosted) + WritePDSF(this, results.Item3); + UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks); + return results; + } + + Tuple> IFileRead.ReExtract() + { + Tuple> results; + List headerNames = _Description.GetHeaderNames(); + Dictionary keyValuePairs = _Description.GetDisplayNamesJsonElement(this); + results = ReExtract(this, headerNames, keyValuePairs); + return results; + } + + private void Save(string key, string fileNameWithoutExtension, string rootDirectory, JsonElement jsonElement) + { + string checkFile; + List indexLines = new(); + indexLines.AddRange(_FrontMatterLines); + indexLines.Add(string.Empty); + indexLines.Add($"# {key}"); + indexLines.Add(string.Empty); + indexLines.Add("## Backlog"); + indexLines.Add(string.Empty); + indexLines.Add("## Todo"); + indexLines.Add(string.Empty); + indexLines.Add("## In Progress"); + indexLines.Add(string.Empty); + indexLines.Add("## Done"); + string singletonDirectory = Path.Combine(rootDirectory, $"{key}-{fileNameWithoutExtension}"); + string vscodeDirectory = Path.Combine(singletonDirectory, ".vscode"); + if (!Directory.Exists(vscodeDirectory)) + _ = Directory.CreateDirectory(vscodeDirectory); + checkFile = Path.Combine(vscodeDirectory, "settings.json"); + if (!File.Exists(checkFile)) + File.WriteAllText(checkFile, "{ \"[markdown]\": { \"editor.wordWrap\": \"off\" }, \"cSpell.words\": [ \"kanbn\" ] }"); + string kanbanDirectory = Path.Combine(singletonDirectory, ".kanbn"); + if (!Directory.Exists(kanbanDirectory)) + _ = Directory.CreateDirectory(kanbanDirectory); + checkFile = Path.Combine(kanbanDirectory, ".json"); + if (!File.Exists(checkFile)) + File.WriteAllText(checkFile, jsonElement.ToString()); + else + { + string singletonJson = jsonElement.ToString(); + string checkJson = Regex.Replace(File.ReadAllText(checkFile), @"\s+", " ", RegexOptions.Multiline); + if (Regex.Replace(singletonJson, @"\s+", " ", RegexOptions.Multiline) != checkJson) + File.WriteAllText(checkFile, singletonJson); + } + string tasksDirectory = Path.Combine(kanbanDirectory, "tasks"); + if (!Directory.Exists(tasksDirectory)) + _ = Directory.CreateDirectory(tasksDirectory); + checkFile = Path.Combine(kanbanDirectory, "board.css"); + if (!File.Exists(checkFile)) + File.WriteAllLines(checkFile, _CSSLines); + checkFile = Path.Combine(kanbanDirectory, "index.md"); + if (!File.Exists(checkFile)) + File.WriteAllLines(checkFile, indexLines); + } + + private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) + { + Tuple> results; + string key; + JsonProperty[] jsonProperties; + string ticks = dateTime.Ticks.ToString(); + _Logistics = new Logistics(reportFullPath, $"LOGISTICS_1{'\t'}A_JOBID={"BACKLOG"};A_MES_ENTITY={"BACKLOG"};"); + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(reportFullPath).Replace(" ", "-").Replace("---", "-"); + string rootDirectory = Path.Combine(_FileConnectorConfiguration.SourceFileLocation, fileNameWithoutExtension); + if (string.IsNullOrEmpty(rootDirectory)) + throw new NullReferenceException(nameof(rootDirectory)); + if (!Directory.Exists(rootDirectory)) + _ = Directory.CreateDirectory(Path.Combine(rootDirectory, ticks)); + string json = File.ReadAllText(reportFullPath); + JsonElement[] jsonElements = JsonSerializer.Deserialize(json); + foreach (JsonElement jsonElement in jsonElements) + { + if (jsonElement.ValueKind != JsonValueKind.Object) + continue; + jsonProperties = jsonElement.EnumerateObject().ToArray(); + if (jsonProperties.Length < 2) + continue; + key = jsonProperties[0].Value.ToString(); + if (string.IsNullOrEmpty(key)) + continue; + if (string.IsNullOrEmpty(jsonProperties[1].Value.ToString())) + continue; + Save(key, fileNameWithoutExtension, rootDirectory, jsonElement); + if (!_IsEAFHosted) + break; + } + results = new(_Logistics.Logistics1[0], Array.Empty(), Array.Empty(), new List()); + return results; + } + +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/FileRead.cs b/Adaptation/FileHandlers/json/FileRead.cs index b1e41ea..dc345c0 100644 --- a/Adaptation/FileHandlers/json/FileRead.cs +++ b/Adaptation/FileHandlers/json/FileRead.cs @@ -61,17 +61,17 @@ public class FileRead : Shared.FileRead, IFileRead _Project = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.HttpClient.Project"); string basePage = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.HttpClient.BasePage"); string baseAddress = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.HttpClient.BaseAddress"); - ModelObjectParameterDefinition[] assignedTo = GetProperties(cellInstanceConnectionName, modelObjectParameters, "Assinged.To."); + ModelObjectParameterDefinition[] assignedTo = GetProperties(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.Assinged.To."); foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in assignedTo) - assignedToNameToUser.Add(modelObjectParameterDefinition.Name.Split('.')[2], modelObjectParameterDefinition.Value); + assignedToNameToUser.Add(modelObjectParameterDefinition.Name.Split('.')[4], modelObjectParameterDefinition.Value); _AssignedToNameToUser = new(assignedToNameToUser); - ModelObjectParameterDefinition[] requestor = GetProperties(cellInstanceConnectionName, modelObjectParameters, "Requestor."); + ModelObjectParameterDefinition[] requestor = GetProperties(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.Requestor."); foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in requestor) - requestorNameToUser.Add(modelObjectParameterDefinition.Name.Split('.')[1], modelObjectParameterDefinition.Value); + requestorNameToUser.Add(modelObjectParameterDefinition.Name.Split('.')[3], modelObjectParameterDefinition.Value); _RequestorNameToUser = new(requestorNameToUser); - ModelObjectParameterDefinition[] encodedPAT = GetProperties(cellInstanceConnectionName, modelObjectParameters, "Encoded.PAT."); + ModelObjectParameterDefinition[] encodedPAT = GetProperties(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.Encoded.PAT."); foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in encodedPAT) - assignedToNameToEncodedPAT.Add(modelObjectParameterDefinition.Name.Split('.')[2], modelObjectParameterDefinition.Value); + assignedToNameToEncodedPAT.Add(modelObjectParameterDefinition.Name.Split('.')[4], modelObjectParameterDefinition.Value); _AssignedToNameToEncodedPAT = new(assignedToNameToEncodedPAT); byte[] bytes = Encoding.ASCII.GetBytes($":{pat}"); string base64 = Convert.ToBase64String(bytes); diff --git a/Adaptation/_Tests/CreateSelfDescription/Development/v2.52.0/ALIGNMENT.cs b/Adaptation/_Tests/CreateSelfDescription/Development/v2.52.0/ALIGNMENT.cs new file mode 100644 index 0000000..e6e0265 --- /dev/null +++ b/Adaptation/_Tests/CreateSelfDescription/Development/v2.52.0/ALIGNMENT.cs @@ -0,0 +1,61 @@ +using Adaptation._Tests.Shared; +using Microsoft.Extensions.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; + +namespace Adaptation._Tests.CreateSelfDescription.Development.v2_52_0; + +[TestClass] +public class ALIGNMENT : EAFLoggingUnitTesting +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + internal static string DummyRoot { get; private set; } + internal static ALIGNMENT EAFLoggingUnitTesting { get; private set; } + + static ALIGNMENT() => DummyRoot = @"\\messdv002.na.infineon.com\Candela\EC_Characterization_Si\Dummy"; + + public ALIGNMENT() : base(DummyRoot, testContext: null, declaringType: null, skipEquipmentDictionary: false) + { + if (EAFLoggingUnitTesting is null) + throw new Exception(); + } + + public ALIGNMENT(TestContext testContext) : base(DummyRoot, testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) + { + } + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + EAFLoggingUnitTesting ??= new ALIGNMENT(testContext); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); + string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); + File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); + File.WriteAllText(fileNameAndText[2], fileNameAndText[3]); + } + + [ClassCleanup()] + public static void ClassCleanup() + { + EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Dispose(); + } + + [Ignore] + [TestMethod] + public void Development__v2_52_0__ALIGNMENT__ConvertExcelToJson() + { + string check = "*.xlsx"; + MethodBase methodBase = new StackFrame().GetMethod(); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); + _ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + } + +} \ No newline at end of file diff --git a/Adaptation/_Tests/CreateSelfDescription/Development/v2.52.0/MESAFIBACKLOG.cs b/Adaptation/_Tests/CreateSelfDescription/Development/v2.52.0/MESAFIBACKLOG.cs index 7bd145d..09d9f5f 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Development/v2.52.0/MESAFIBACKLOG.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Development/v2.52.0/MESAFIBACKLOG.cs @@ -47,6 +47,17 @@ public class MESAFIBACKLOG : EAFLoggingUnitTesting EAFLoggingUnitTesting?.Dispose(); } + [Ignore] + [TestMethod] + public void Development__v2_52_0__MESAFIBACKLOG__CopyToPaths() + { + string check = "*.json"; + MethodBase methodBase = new StackFrame().GetMethod(); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); + _ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + } + [Ignore] [TestMethod] public void Development__v2_52_0__MESAFIBACKLOG__json() @@ -58,4 +69,15 @@ public class MESAFIBACKLOG : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } + [Ignore] + [TestMethod] + public void Development__v2_52_0__MESAFIBACKLOG__Kanban() + { + string check = "*.json"; + MethodBase methodBase = new StackFrame().GetMethod(); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); + _ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + } + } \ No newline at end of file diff --git a/Adaptation/_Tests/Extract/Development/v2.52.0/ALIGNMENT.cs b/Adaptation/_Tests/Extract/Development/v2.52.0/ALIGNMENT.cs new file mode 100644 index 0000000..b91978d --- /dev/null +++ b/Adaptation/_Tests/Extract/Development/v2.52.0/ALIGNMENT.cs @@ -0,0 +1,58 @@ +using Adaptation.Shared; +using Adaptation.Shared.Methods; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Text.Json; + +namespace Adaptation._Tests.Extract.Development.v2_52_0; + +[TestClass] +public class ALIGNMENT +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + private static CreateSelfDescription.Development.v2_52_0.ALIGNMENT _ALIGNMENT; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + CreateSelfDescription.Development.v2_52_0.ALIGNMENT.ClassInitialize(testContext); + _ALIGNMENT = CreateSelfDescription.Development.v2_52_0.ALIGNMENT.EAFLoggingUnitTesting; + } + + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + + [Ignore] + [TestMethod] + public void Development__v2_52_0__ALIGNMENT__ConvertExcelToJson() => _ALIGNMENT.Development__v2_52_0__ALIGNMENT__ConvertExcelToJson(); + + [Ignore] + [TestMethod] + public void Development__v2_52_0__ALIGNMENT__ConvertExcelToJson638353030755467303__Normal() + { + string check = "*.xlsx"; + bool validatePDSF = false; + MethodBase methodBase = new StackFrame().GetMethod(); + _ALIGNMENT.Development__v2_52_0__ALIGNMENT__ConvertExcelToJson(); + Assert.IsFalse(string.IsNullOrEmpty(_ALIGNMENT.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); + string[] variables = _ALIGNMENT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); + IFileRead fileRead = _ALIGNMENT.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); + Tuple> extractResult = fileRead.ReExtract(); + Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); + Assert.IsNotNull(extractResult.Item3); + Assert.IsNotNull(extractResult.Item4); + NonThrowTryCatch(); + } + +} \ No newline at end of file diff --git a/Adaptation/_Tests/Extract/Development/v2.52.0/MESAFIBACKLOG.cs b/Adaptation/_Tests/Extract/Development/v2.52.0/MESAFIBACKLOG.cs index 690cf64..c26d700 100644 --- a/Adaptation/_Tests/Extract/Development/v2.52.0/MESAFIBACKLOG.cs +++ b/Adaptation/_Tests/Extract/Development/v2.52.0/MESAFIBACKLOG.cs @@ -93,7 +93,25 @@ public class MESAFIBACKLOG [Ignore] [TestMethod] - public void Development__v2_52_0__MESAFIBACKLOG__json638323658386612550__Normal() + public void Development__v2_52_0__MESAFIBACKLOG__CopyToPaths638323658386612550__Normal() + { + string check = "*.json"; + bool validatePDSF = false; + _MESAFIBACKLOG.Development__v2_52_0__MESAFIBACKLOG__CopyToPaths(); + MethodBase methodBase = new StackFrame().GetMethod(); + Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); + string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); + IFileRead fileRead = _MESAFIBACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); + Tuple> extractResult = fileRead.ReExtract(); + Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); + Assert.IsNotNull(extractResult.Item3); + Assert.IsNotNull(extractResult.Item4); + NonThrowTryCatch(); + } + + [Ignore] + [TestMethod] + public void Development__v2_52_0__MESAFIBACKLOG__json638323658386612551__Normal() { string check = "*.json"; bool validatePDSF = false; @@ -109,4 +127,22 @@ public class MESAFIBACKLOG NonThrowTryCatch(); } + [Ignore] + [TestMethod] + public void Development__v2_52_0__MESAFIBACKLOG__Kanban638323658386612552__Normal() + { + string check = "*.json"; + bool validatePDSF = false; + _MESAFIBACKLOG.Development__v2_52_0__MESAFIBACKLOG__Kanban(); + MethodBase methodBase = new StackFrame().GetMethod(); + Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); + string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); + IFileRead fileRead = _MESAFIBACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); + Tuple> extractResult = fileRead.ReExtract(); + Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); + Assert.IsNotNull(extractResult.Item3); + Assert.IsNotNull(extractResult.Item4); + NonThrowTryCatch(); + } + } \ No newline at end of file diff --git a/Adaptation/_Tests/Static/BACKLOG.cs b/Adaptation/_Tests/Static/BACKLOG.cs index 8ad0532..b38f973 100644 --- a/Adaptation/_Tests/Static/BACKLOG.cs +++ b/Adaptation/_Tests/Static/BACKLOG.cs @@ -62,8 +62,8 @@ public class BACKLOG : LoggingUnitTesting, IDisposable StringBuilder results = new(); (string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[] { - new("BACKLOG", "v2.49.2"), - new("BACKLOG-EQPT", "v2.49.2"), + new("BACKLOG", "v2.52.0"), + new("BACKLOG-EQPT", "v2.52.0"), }; string development = "http://eaf-dev.mes.infineon.com:9003/CellInstanceServiceV2"; Shared.PasteSpecialXml.EAF.XML.API.CellInstance.CellInstanceVersion cellInstanceVersion; diff --git a/Adaptation/_Tests/Static/MESAFIBACKLOG.cs b/Adaptation/_Tests/Static/MESAFIBACKLOG.cs index 5edd2b4..13ae5f2 100644 --- a/Adaptation/_Tests/Static/MESAFIBACKLOG.cs +++ b/Adaptation/_Tests/Static/MESAFIBACKLOG.cs @@ -77,7 +77,7 @@ public class MESAFIBACKLOG : LoggingUnitTesting, IDisposable StringBuilder results = new(); (string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[] { - new("MESAFIBACKLOG", "v2.49.2"), + new("MESAFIBACKLOG", "v2.52.0"), }; string staging = "http://mestsa07ec.infineon.com:9003/CellInstanceServiceV2"; Shared.PasteSpecialXml.EAF.XML.API.CellInstance.CellInstanceVersion cellInstanceVersion; diff --git a/Adaptation/appsettings.Development.json b/Adaptation/appsettings.Development.json index f7e0b36..8630239 100644 --- a/Adaptation/appsettings.Development.json +++ b/Adaptation/appsettings.Development.json @@ -45,7 +45,7 @@ "Password": "tVyC7uPHtScZR8NLInSaxQ==" }, { - "Use": true, + "Use": false, "Letter": "i", "Share": "\\\\messdv002.na.infineon.com\\Candela", "User": "INFINEON\\MESGaNEAF", @@ -115,14 +115,14 @@ "Password": "rzXkXdHKetDfsukhZKW0yA==" }, { - "Use": true, + "Use": false, "Letter": "s", "Share": "\\\\messv02ecc1.ec.local\\EC_EAFRepository", "User": "EC\\ECMESEAF", "Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00=" }, { - "Use": true, + "Use": false, "Letter": "t", "Share": "\\\\messv02ecc1.ec.local\\EC_EDA", "User": "EC\\ECEDASvc", diff --git a/Adaptation/appsettings.json b/Adaptation/appsettings.json index d15d437..842b156 100644 --- a/Adaptation/appsettings.json +++ b/Adaptation/appsettings.json @@ -45,7 +45,7 @@ "Password": "tVyC7uPHtScZR8NLInSaxQ==" }, { - "Use": true, + "Use": false, "Letter": "i", "Share": "\\\\messdv002.na.infineon.com\\Candela", "User": "INFINEON\\MESGaNEAF", @@ -115,14 +115,14 @@ "Password": "rzXkXdHKetDfsukhZKW0yA==" }, { - "Use": true, + "Use": false, "Letter": "s", "Share": "\\\\messv02ecc1.ec.local\\EC_EAFRepository", "User": "EC\\ECMESEAF", "Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00=" }, { - "Use": true, + "Use": false, "Letter": "t", "Share": "\\\\messv02ecc1.ec.local\\EC_EDA", "User": "EC\\ECEDASvc", diff --git a/MESAFIBACKLOG.csproj b/MESAFIBACKLOG.csproj index c002098..7225201 100644 --- a/MESAFIBACKLOG.csproj +++ b/MESAFIBACKLOG.csproj @@ -104,6 +104,7 @@ + @@ -124,10 +125,11 @@ + - - + + @@ -135,9 +137,7 @@ - - Component - + @@ -174,6 +174,12 @@ + + + + + + @@ -189,14 +195,5 @@ 6.0.3 - - - - - - - - - \ No newline at end of file