diff --git a/Adaptation/.vscode/Reactor.js b/Adaptation/.vscode/Reactor.js index 9e63d78..2de5008 100644 --- a/Adaptation/.vscode/Reactor.js +++ b/Adaptation/.vscode/Reactor.js @@ -4,20 +4,16 @@ // self : // getContextData('2', 'cds.PROCESS_JOBID', '') -getValue(self, self.length, $('dcp.CDE5/RsM/MesEntity', ''), getContextData('2', 'cds.PROCESS_JOBID', ''), $('dcp.CDE5/RsM/Recipe', '')); +getValue(self, self.length, $('dcp.CDE5/RsM/MesEntity', ''), $('dcp.CDE5/RsM/Recipe', ''), getContextData('2', 'cds.PROCESS_JOBID', '')); function getValue(value, length, mesEntity, recipe, processJobId) { - if (recipe.toUpperCase() === 'SHEET RHO LOW') + if (recipe.toUpperCase() === 'STANDARD \\ RLOW_STD') return mesEntity; - else if (recipe.toUpperCase() === 'SHEET RHO MID') + else if (recipe.toUpperCase() === 'STANDARD \\ RMID_STD') return mesEntity; - else if (recipe.toUpperCase() === 'SHEET RHO HIGH') + else if (recipe.toUpperCase() === 'STANDARD \\ RHI_STD') return mesEntity; - else if (recipe.toUpperCase() === 'SHEET RHO THIN') - return mesEntity; - else if (recipe.toUpperCase() === 'EPRO LOW') - return mesEntity; - else if (recipe.toUpperCase() === 'EPRO HIGH') + else if (recipe.toUpperCase() === 'STANDARD \\ THINSPC') return mesEntity; else if (length !== 0 || processJobId === '-') return value; diff --git a/Adaptation/.vscode/psn.js b/Adaptation/.vscode/psn.js index 98ec086..631fec8 100644 --- a/Adaptation/.vscode/psn.js +++ b/Adaptation/.vscode/psn.js @@ -7,18 +7,14 @@ getValue(self, self.length, getContextData('2', 'cds.PRODUCT', ''), $('dcp.CDE5/RsM/Recipe', '')); function getValue(value, length, product, recipe) { - if (recipe.toUpperCase() === 'SHEET RHO LOW') - return 'Sheet Rho Low'; - else if (recipe.toUpperCase() === 'SHEET RHO MID') - return 'Sheet Rho Mid'; - else if (recipe.toUpperCase() === 'SHEET RHO HIGH') - return 'Sheet Rho High'; - else if (recipe.toUpperCase() === 'SHEET RHO THIN') - return 'Sheet Rho Thin'; - else if (recipe.toUpperCase() === 'EPRO LOW') - return 'EPro Low'; - else if (recipe.toUpperCase() === 'EPRO HIGH') - return 'EPro High'; + if (recipe.toUpperCase() === 'STANDARD \\ RLOW_STD') + return 'RLOW_STD'; + else if (recipe.toUpperCase() === 'STANDARD \\ RMID_STD') + return 'RMID_STD'; + else if (recipe.toUpperCase() === 'STANDARD \\ RHI_STD') + return 'RHI_STD'; + else if (recipe.toUpperCase() === 'STANDARD \\ THINSPC') + return 'THINSPC'; else if (length !== 0 || product === '-') return value; else diff --git a/Adaptation/FileHandlers/OpenInsight/FileRead.cs b/Adaptation/FileHandlers/OpenInsight/FileRead.cs index 148d2f7..9fa6681 100644 --- a/Adaptation/FileHandlers/OpenInsight/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsight/FileRead.cs @@ -112,7 +112,7 @@ public class FileRead : Shared.FileRead, IFileRead internal static string GetLines(Logistics logistics, List descriptions) { - StringBuilder result = new(); + StringBuilder result = new("-"); if (logistics is null) { } if (descriptions is null) @@ -136,11 +136,15 @@ public class FileRead : Shared.FileRead, IFileRead { string lines = GetLines(_Logistics, descriptions); if (!string.IsNullOrEmpty(lines)) - collection.Add(new(new ScopeInfo(tests[0], _OpenInsightFilePattern), lines)); - _ = FromIQS.GetCommandText(_IqsConnectionString, _Logistics, descriptions[0]); - // string commandText = FromIQS.GetCommandText(_IqsConnectionString, _Logistics, descriptions[0]); - // if (!string.IsNullOrEmpty(commandText)) - // collection.Add(new(new ScopeInfo(tests[0], _OpenInsightFilePattern), commandText)); + { + long breakAfter = dateTime.AddSeconds(_BreakAfterSeconds).Ticks; + long preWait = _FileConnectorConfiguration?.FileHandleWaitTime is null ? dateTime.AddMilliseconds(1234).Ticks : dateTime.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks; + (long? subGroupId, string _) = FromIQS.GetCommandText(_BreakAfterSeconds, _IqsConnectionString, _Logistics, descriptions[0], breakAfter, preWait); + if (subGroupId is null) + collection.Add(new(new ScopeInfo(tests[0], _OpenInsightFilePattern), lines)); + else + collection.Add(new(new ScopeInfo(tests[0], $"{subGroupId.Value}_{_OpenInsightFilePattern}"), lines)); + } } if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) WaitForFileConsumption(dateTime, descriptions, isDummyRun, successDirectory, duplicateDirectory, collection, duplicateFile); diff --git a/Adaptation/FileHandlers/OpenInsight/FromIQS.cs b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs index fab469a..8c6f0a8 100644 --- a/Adaptation/FileHandlers/OpenInsight/FromIQS.cs +++ b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs @@ -1,10 +1,12 @@ using Adaptation.Shared; using System; +using System.Data; using System.Data.SqlClient; using System.Globalization; using System.Linq; using System.Text; using System.Text.Json; +using System.Threading; namespace Adaptation.FileHandlers.OpenInsight; @@ -13,7 +15,7 @@ public class FromIQS #nullable enable - private static string GetCommandText(Logistics logistics, txt.Description description, string dateTime, string? sid) + private static string GetCommandText(Logistics logistics, txt.Description description, string dateTime, long? subGroupId) { StringBuilder result = new(); _ = result @@ -40,8 +42,8 @@ public class FromIQS .AppendLine(" join [spcepiworld].[dbo].[test_dat] td ") .AppendLine(" on se.f_test = td.f_test ") .AppendLine(" where se.f_flag = 0 "); - if (!string.IsNullOrEmpty(sid)) - _ = result.Append(" and se.f_sgrp = ").Append(sid).AppendLine(" "); + if (subGroupId is not null) + _ = result.Append(" and se.f_sgrp = ").Append(subGroupId).AppendLine(" "); _ = result .Append(" and rd.f_name = '").Append(description.Reactor).AppendLine("' ") .Append(" and pd.f_name = '").Append(description.PSN).AppendLine("' ") @@ -56,21 +58,20 @@ public class FromIQS private static StringBuilder GetForJsonPath(string connectionString, string commandText) { StringBuilder stringBuilder = new(); - using (SqlConnection sqlConnection = new(connectionString)) - { - sqlConnection.Open(); - using SqlCommand sqlCommand = new(commandText, sqlConnection); - SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.SequentialAccess); - while (sqlDataReader.Read()) - _ = stringBuilder.Append(sqlDataReader.GetString(0)); - } + using SqlConnection sqlConnection = new(connectionString); + sqlConnection.Open(); + using SqlCommand sqlCommand = new(commandText, sqlConnection); + SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess); + while (sqlDataReader.Read()) + _ = stringBuilder.Append(sqlDataReader.GetString(0)); return stringBuilder; } - internal static string GetCommandText(string connectionString, Logistics logistics, txt.Description description) + internal static (long?, string) GetCommandText(long breakAfterSeconds, string connectionString, Logistics logistics, txt.Description description, long breakAfter, long preWait) { - string result; string dateTime; + string commandText; + long? result = null; string dateFormat = txt.Description.GetDateFormat(); if (DateTime.TryParseExact(description.Date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTimeParsed)) dateTime = dateTimeParsed.ToString("yyyy-MM-dd HH:mm:ss"); @@ -78,25 +79,43 @@ public class FromIQS dateTime = dateTimeParsed.ToString("yyyy-MM-dd HH:mm:ss"); else dateTime = logistics.DateTimeFromSequence.ToString("yyyy-MM-dd HH:mm:ss"); - string commandText = GetCommandText(logistics, description, dateTime, sid: null); - StringBuilder stringBuilder = GetForJsonPath(connectionString, commandText); + commandText = GetCommandText(logistics, description, dateTime, subGroupId: null); + for (short i = 0; i < short.MaxValue; i++) + { + if (DateTime.Now.Ticks > preWait) + break; + Thread.Sleep(100); + } + StringBuilder stringBuilder = new(); + for (short z = 0; z < short.MaxValue; z++) + { + stringBuilder = GetForJsonPath(connectionString, commandText); + if (stringBuilder.Length > 0) + break; + if (DateTime.Now.Ticks > breakAfter) + throw new Exception($"After {breakAfterSeconds} seconds, didn't find sub group id!"); + Thread.Sleep(250); + } if (stringBuilder.Length == 0) - result = commandText; + commandText = stringBuilder.ToString(); else { JsonElement[]? jsonElements = JsonSerializer.Deserialize(stringBuilder.ToString()); if (jsonElements is null || !jsonElements.Any() || jsonElements[0].ValueKind != JsonValueKind.Object) - result = commandText; + commandText = stringBuilder.ToString(); else { JsonProperty[] jsonProperties = jsonElements[0].EnumerateObject().ToArray(); - if (!jsonProperties.Any() || jsonProperties[0].Name != "se_sgrp") - result = commandText; + if (!jsonProperties.Any() || jsonProperties[0].Name != "se_sgrp" || !long.TryParse(jsonProperties[0].Value.ToString(), out long subGroupId)) + commandText = stringBuilder.ToString(); else - result = GetCommandText(logistics, description, dateTime, sid: jsonProperties[0].Value.ToString()); + { + result = subGroupId; + commandText = GetCommandText(logistics, description, dateTime, subGroupId); + } } } - return result; + return new(result, commandText); } #nullable disable diff --git a/Adaptation/Shared/FileRead.cs b/Adaptation/Shared/FileRead.cs index dd0c860..48122f8 100644 --- a/Adaptation/Shared/FileRead.cs +++ b/Adaptation/Shared/FileRead.cs @@ -327,7 +327,7 @@ public class FileRead : Properties.IFileRead { if (DateTime.Now.Ticks > preWait) break; - Thread.Sleep(500); + Thread.Sleep(100); } if (!moreThanAnHour) { @@ -373,7 +373,7 @@ public class FileRead : Properties.IFileRead } throw new Exception(string.Concat("After {", _BreakAfterSeconds, "} seconds, right side of {", sourceDirectoryCloaking, "} didn't consume file(s) ", stringBuilder)); } - Thread.Sleep(500); + Thread.Sleep(250); } } } diff --git a/Adaptation/_Tests/Static/RsM.cs b/Adaptation/_Tests/Static/RsM.cs index e77ebe3..a44ff67 100644 --- a/Adaptation/_Tests/Static/RsM.cs +++ b/Adaptation/_Tests/Static/RsM.cs @@ -36,6 +36,13 @@ public class RsM : LoggingUnitTesting, IDisposable LoggingUnitTesting?.Dispose(); } + [TestMethod] + public void TestDateTime() + { + DateTime dateTime = DateTime.Now; + Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString()); + } + [TestMethod] public void TestDescriptor() { diff --git a/Adaptation/_Tests/Static/txt.cs b/Adaptation/_Tests/Static/txt.cs index debd2f9..550f50c 100644 --- a/Adaptation/_Tests/Static/txt.cs +++ b/Adaptation/_Tests/Static/txt.cs @@ -36,6 +36,13 @@ public class TXT : LoggingUnitTesting, IDisposable LoggingUnitTesting?.Dispose(); } + [TestMethod] + public void TestDateTime() + { + DateTime dateTime = DateTime.Now; + Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString()); + } + [TestMethod] public void TestDescriptor() {