From 03aabf9bac1fbbf70f44b20dd18bdcedb6565727 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Tue, 7 Mar 2023 11:41:44 -0700 Subject: [PATCH] Assembly Version WS Result bug fix and Nuget bump PSN, Reactor and Extra RDS rule OpenInsightApi and testRunTitle serializerValue --- Adaptation/.editorconfig | 4 +- Adaptation/.vscode/Reactor.js | 6 +- Adaptation/.vscode/psn.js | 6 +- .../FileHandlers/OpenInsight/FileRead.cs | 11 ++- .../FileHandlers/OpenInsight/FromIQS.cs | 81 +++++++++++++++++++ Adaptation/FileHandlers/QS408M/ProcessData.cs | 13 +-- Adaptation/MET08THFTIRQS408M-Development.yml | 1 + Adaptation/MET08THFTIRQS408M.Tests.csproj | 2 +- Adaptation/MET08THFTIRQS408M.yml | 1 + Adaptation/Shared/Metrology/WS.cs | 3 +- Adaptation/_Tests/Static/QS408M.cs | 8 ++ Properties/AssemblyInfo.cs | 4 +- 12 files changed, 121 insertions(+), 19 deletions(-) diff --git a/Adaptation/.editorconfig b/Adaptation/.editorconfig index b84fca4..1e59ffa 100644 --- a/Adaptation/.editorconfig +++ b/Adaptation/.editorconfig @@ -79,9 +79,11 @@ dotnet_code_quality.CAXXXX.api_surface = private, internal dotnet_diagnostic.CA1825.severity = warning # CA1823: Avoid zero-length array allocations dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable +dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer AsSpan over Substring +dotnet_diagnostic.CA1847.severity = none # CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name -dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2"); +dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049) diff --git a/Adaptation/.vscode/Reactor.js b/Adaptation/.vscode/Reactor.js index 684d803..5c6aaef 100644 --- a/Adaptation/.vscode/Reactor.js +++ b/Adaptation/.vscode/Reactor.js @@ -19,8 +19,8 @@ function getValue(value, length, mesEntity, recipe, processJobId) { return mesEntity; else if (recipe.toUpperCase() === 'T_HIGH') return mesEntity; - else if (length !== 0 || processJobId === '-') - return value; - else + else if (length === 0) return processJobId; + else + return value; } \ No newline at end of file diff --git a/Adaptation/.vscode/psn.js b/Adaptation/.vscode/psn.js index ce21086..54fac6b 100644 --- a/Adaptation/.vscode/psn.js +++ b/Adaptation/.vscode/psn.js @@ -19,8 +19,8 @@ function getValue(value, length, product, recipe) { return 'T-Mid'; else if (recipe.toUpperCase() === 'T_HIGH') return 'T-High'; - else if (length !== 0 || product === '-') - return value; - else + else if (length === 0) return product; + else + return value; } \ No newline at end of file diff --git a/Adaptation/FileHandlers/OpenInsight/FileRead.cs b/Adaptation/FileHandlers/OpenInsight/FileRead.cs index 01ddac6..e658a72 100644 --- a/Adaptation/FileHandlers/OpenInsight/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsight/FileRead.cs @@ -6,6 +6,7 @@ using Adaptation.Shared.Methods; using Adaptation.Shared.Metrology; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -18,6 +19,8 @@ public class FileRead : Shared.FileRead, IFileRead private readonly string _IqsConnectionString; private readonly string _OpenInsightFilePattern; + private readonly string _OpenInsightApiECDirectory; + private readonly string _OpenInsightApiIFXDirectory; public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, 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, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) @@ -31,6 +34,8 @@ public class FileRead : Shared.FileRead, IFileRead throw new Exception(cellInstanceConnectionName); if (!_IsDuplicator) throw new Exception(cellInstanceConnectionName); + _OpenInsightApiIFXDirectory = @"\\messdv002.na.infineon.com\Candela\Archive\API"; + _OpenInsightApiECDirectory = @"\\messv02ecc1.ec.local\EC_Metrology_Si\Archive\API"; _IqsConnectionString = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.ConnectionString"); _OpenInsightFilePattern = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.FilePattern"); } @@ -130,7 +135,7 @@ public class FileRead : Shared.FileRead, IFileRead return results.ToString(); } - private void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, 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(); @@ -161,6 +166,8 @@ public class FileRead : Shared.FileRead, IFileRead collection.Add(new(new ScopeInfo(tests[0], $"{subGroupId.Value} {_OpenInsightFilePattern}"), lines)); else collection.Add(new(new ScopeInfo(tests[0], $"{subGroupId.Value} E{count.Value} {_OpenInsightFilePattern}"), lines)); + string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); + FromIQS.Save(_OpenInsightApiECDirectory, _OpenInsightApiIFXDirectory, _Logistics, reportFullPath, logistics, descriptions.First(), lines, subGroupId, weekOfYear); } } if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) @@ -178,7 +185,7 @@ public class FileRead : Shared.FileRead, IFileRead List descriptions = QS408M.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) - SaveOpenInsightFile(reportFullPath, dateTime, descriptions, tests); + SaveOpenInsightFile(reportFullPath, dateTime, pdsf.Item1, descriptions, tests); results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/OpenInsight/FromIQS.cs b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs index c3c64e7..3d279b9 100644 --- a/Adaptation/FileHandlers/OpenInsight/FromIQS.cs +++ b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs @@ -3,6 +3,7 @@ using System; using System.Data; using System.Data.SqlClient; using System.Globalization; +using System.IO; using System.Linq; using System.Text; using System.Text.Json; @@ -127,6 +128,86 @@ public class FromIQS return new(result, count, commandText); } + private static string GetJson(Logistics logistics, string logisticLines, QS408M.Description description) + { + string result; + StringBuilder stringBuilder = new(); + var @object = new + { + description.MesEntity, + description.Employee, + description.Layer, + description.PSN, + description.RDS, + description.Reactor, + description.Recipe, + description.Zone, + logistics.DateTimeFromSequence.Ticks + }; + string[] pair; + string safeValue; + string[] segments; + string serializerValue; + foreach (string line in logisticLines.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) + { + segments = line.Split('\t'); + if (segments.Length < 2) + continue; + segments = segments[1].Split(';'); + _ = stringBuilder.Append('{'); + foreach (string segment in segments) + { + pair = segment.Split('='); + if (pair.Length != 2 || pair[0].Length < 3) + continue; + serializerValue = JsonSerializer.Serialize(pair[1]); + safeValue = serializerValue.Substring(1, serializerValue.Length - 2); + _ = stringBuilder.Append('"').Append(pair[0].Substring(2)).Append('"').Append(':').Append('"').Append(safeValue).Append('"').Append(','); + } + if (stringBuilder.Length > 0) + _ = stringBuilder.Remove(stringBuilder.Length - 1, 1); + _ = stringBuilder.Append('}').Append(','); + } + if (stringBuilder.Length > 0) + _ = stringBuilder.Remove(stringBuilder.Length - 1, 1); + _ = stringBuilder.Append(']').Append('}'); + _ = stringBuilder.Insert(0, ",\"Logistics\":["); + string json = JsonSerializer.Serialize(@object); + _ = stringBuilder.Insert(0, json.Substring(0, json.Length - 1)); + JsonElement? jsonElement = JsonSerializer.Deserialize(stringBuilder.ToString()); + result = jsonElement is null ? "{}" : JsonSerializer.Serialize(jsonElement, new JsonSerializerOptions { WriteIndented = true }); + return result; + } + + internal static void Save(string openInsightApiECDirectory, string openInsightApiIFXDirectory, Logistics logistics, string reportFullPath, string logisticLines, QS408M.Description description, string lines, long? subGroupId, string weekOfYear) + { + string fileName = Path.GetFileName(reportFullPath); + string json = GetJson(logistics, logisticLines, description); + string? ecPathRoot = Path.GetPathRoot(openInsightApiECDirectory); + string? ifxPathRoot = Path.GetPathRoot(openInsightApiIFXDirectory); + bool ecExists = ecPathRoot is not null && Directory.Exists(ecPathRoot); + bool ifxExists = ifxPathRoot is not null && Directory.Exists(ifxPathRoot); + string weekYear = $"{logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}"; + string ecDirectory = Path.Combine(openInsightApiECDirectory, weekYear, $"-{description.PSN}", $"-{description.Reactor}", $"-{description.RDS}", $"-{subGroupId}"); + string ifxDirectory = Path.Combine(openInsightApiIFXDirectory, weekYear, $"-{description.PSN}", $"-{description.Reactor}", $"-{description.RDS}", $"-{subGroupId}"); + if (ecExists && !Directory.Exists(ecDirectory)) + _ = Directory.CreateDirectory(ecDirectory); + if (ifxExists && !Directory.Exists(ifxDirectory)) + _ = Directory.CreateDirectory(ifxDirectory); + if (ecExists) + File.Copy(reportFullPath, Path.Combine(ecDirectory, fileName)); + if (ifxExists) + File.Copy(reportFullPath, Path.Combine(ifxDirectory, fileName)); + if (ecExists) + File.WriteAllText(Path.Combine(ecDirectory, $"{logistics.DateTimeFromSequence.Ticks}.txt"), lines); + if (ifxExists) + File.WriteAllText(Path.Combine(ifxDirectory, $"{logistics.DateTimeFromSequence.Ticks}.txt"), lines); + if (ecExists) + File.WriteAllText(Path.Combine(ecDirectory, $"{logistics.DateTimeFromSequence.Ticks}.json"), json); + if (ifxExists) + File.WriteAllText(Path.Combine(ifxDirectory, $"{logistics.DateTimeFromSequence.Ticks}.json"), json); + } + #nullable disable } \ No newline at end of file diff --git a/Adaptation/FileHandlers/QS408M/ProcessData.cs b/Adaptation/FileHandlers/QS408M/ProcessData.cs index f04837c..561efd7 100644 --- a/Adaptation/FileHandlers/QS408M/ProcessData.cs +++ b/Adaptation/FileHandlers/QS408M/ProcessData.cs @@ -253,11 +253,11 @@ public partial class ProcessData : IProcessData return result; } - private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments) + private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments, bool hasRDS) { string rds; string reactor; - if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText)) + if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText) || (segments.Length > 1 && !hasRDS)) reactor = defaultReactor; else reactor = segments[0]; @@ -273,11 +273,11 @@ public partial class ProcessData : IProcessData return new(reactor, rds); } - private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments) + private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments, bool hasRDS) { string psn; string layer; - if (segments.Length <= 2) + if (segments.Length <= 2 || (segments.Length > 1 && !hasRDS)) { psn = defaultPSN; layer = defaultLayer; @@ -359,8 +359,9 @@ public partial class ProcessData : IProcessData if (wafer.Length > 2 && wafer[0] == '1' && (wafer[1] == 'T' || wafer[1] == 't')) wafer = wafer.Substring(2); string[] segments = wafer.Split('-'); - (reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, text, wafer, segments); - (layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments); + bool hasRDS = Regex.IsMatch(wafer, "[-]?[0-9]{5,}[-]?"); + (reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, text, wafer, segments, hasRDS); + (layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments, hasRDS); zone = GetZone(segments); if (segments.Length <= 4) employee = defaultEmployee; diff --git a/Adaptation/MET08THFTIRQS408M-Development.yml b/Adaptation/MET08THFTIRQS408M-Development.yml index b564c0f..e7bd433 100644 --- a/Adaptation/MET08THFTIRQS408M-Development.yml +++ b/Adaptation/MET08THFTIRQS408M-Development.yml @@ -119,6 +119,7 @@ steps: inputs: testResultsFormat: VSTest testResultsFiles: "**/*.trx" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" searchFolder: "$(System.DefaultWorkingDirectory)" - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 diff --git a/Adaptation/MET08THFTIRQS408M.Tests.csproj b/Adaptation/MET08THFTIRQS408M.Tests.csproj index be843c6..4a05c63 100644 --- a/Adaptation/MET08THFTIRQS408M.Tests.csproj +++ b/Adaptation/MET08THFTIRQS408M.Tests.csproj @@ -34,7 +34,7 @@ - + NU1701 NU1701 NU1701 diff --git a/Adaptation/MET08THFTIRQS408M.yml b/Adaptation/MET08THFTIRQS408M.yml index 8c67cef..2de0070 100644 --- a/Adaptation/MET08THFTIRQS408M.yml +++ b/Adaptation/MET08THFTIRQS408M.yml @@ -116,6 +116,7 @@ steps: inputs: testResultsFormat: VSTest testResultsFiles: "**/*.trx" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" searchFolder: "$(System.DefaultWorkingDirectory)" - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 diff --git a/Adaptation/Shared/Metrology/WS.cs b/Adaptation/Shared/Metrology/WS.cs index 12f261b..844efea 100644 --- a/Adaptation/Shared/Metrology/WS.cs +++ b/Adaptation/Shared/Metrology/WS.cs @@ -30,7 +30,7 @@ public partial class WS }; HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead).Result; resultsJson = httpResponseMessage.Content.ReadAsStringAsync().Result; - results = JsonSerializer.Deserialize(resultsJson); + results = JsonSerializer.Deserialize(resultsJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); } if (!results.Success) results.Errors.Add(results.ToString()); @@ -45,6 +45,7 @@ public partial class WS exception = exception.InnerException; } results.Errors ??= new List(); + results.Errors.Add(resultsJson); results.Errors.Add(stringBuilder.ToString()); } return new(resultsJson, results); diff --git a/Adaptation/_Tests/Static/QS408M.cs b/Adaptation/_Tests/Static/QS408M.cs index 6c51036..7d176ec 100644 --- a/Adaptation/_Tests/Static/QS408M.cs +++ b/Adaptation/_Tests/Static/QS408M.cs @@ -125,6 +125,14 @@ public class QS408M : LoggingUnitTesting, IDisposable Assert.IsTrue(descriptor.Reactor is "20"); Assert.IsTrue(descriptor.Zone is "1"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); + descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("P2-LOW-RR"); + Assert.IsTrue(!string.IsNullOrEmpty(descriptor.Wafer)); + Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); + Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); + Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); + Assert.IsTrue(string.IsNullOrEmpty(descriptor.Reactor)); + Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); + Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 79efefb..7c8c300 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.47.1.0")] -[assembly: AssemblyFileVersion("2.47.1.0")] +[assembly: AssemblyVersion("2.47.5.0")] +[assembly: AssemblyFileVersion("2.47.5.0")]