diff --git a/Adaptation/FileHandlers/Dummy/FileRead.cs b/Adaptation/FileHandlers/Dummy/FileRead.cs index 3b777eb..e87c842 100644 --- a/Adaptation/FileHandlers/Dummy/FileRead.cs +++ b/Adaptation/FileHandlers/Dummy/FileRead.cs @@ -97,9 +97,9 @@ public class FileRead : Shared.FileRead, IFileRead private void CallbackInProcessCleared(string sourceArchiveFile, string traceDummyFile, string targetFileLocation, string monARessource, string inProcessDirectory, long sequence, bool warning) { - const string site = "sjc"; + const string site = "els"; string stateName = string.Concat("Dummy_", _EventName); - const string monInURL = "http://moninhttp.sjc.infineon.com/input/text"; + const string monInURL = $"http://moninhttp.{site}.infineon.com/input/text"; MonIn monIn = MonIn.GetInstance(monInURL); try { diff --git a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs index 73c6d12..5e73ef1 100644 --- a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs +++ b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs @@ -267,11 +267,12 @@ public class FileRead : Shared.FileRead, IFileRead List results = new(); Post post; long preWait; + long uniqueSequence = Logistics.GetUniqueSequence(_Logistics); foreach (PreWith preWith in preWithCollection) { if (!_IsEAFHosted) continue; - if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List? wsResults)) + if (!_StaticRuns.TryGetValue(uniqueSequence, out List? wsResults)) wsResults = null; if (processDataStandardFormat.InputPDSF is null) File.Move(preWith.MatchingFile, preWith.CheckFile); diff --git a/Adaptation/FileHandlers/OpenInsight/FileRead.cs b/Adaptation/FileHandlers/OpenInsight/FileRead.cs index a95e81c..3b39008 100644 --- a/Adaptation/FileHandlers/OpenInsight/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsight/FileRead.cs @@ -141,13 +141,14 @@ public class FileRead : Shared.FileRead, IFileRead { long? subgroupId; string fileName = Path.GetFileName(reportFullPath); + long uniqueSequence = Logistics.GetUniqueSequence(_Logistics); long breakAfter = dateTime.AddSeconds(_BreakAfterSeconds).Ticks; long preWait = _FileConnectorConfiguration?.FileHandleWaitTime is null ? dateTime.AddMilliseconds(1234).Ticks : dateTime.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks; if (string.IsNullOrEmpty(descriptions[0].Reactor) || string.IsNullOrEmpty(descriptions[0].PSN)) subgroupId = null; else (subgroupId, int? _, string _) = FromIQS.GetCommandText(_IqsConnectionString, _Logistics, descriptions[0], breakAfter, preWait); - if (_StaticRuns.TryGetValue(_Logistics.Sequence, out List wsResults)) + if (_StaticRuns.TryGetValue(uniqueSequence, out List wsResults)) { if (wsResults is null || wsResults.Count != 1) throw new NullReferenceException($"{nameof(wsResults)} {wsResults?.Count} != 1 {_Logistics.Sequence}!"); diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs index a3f798c..0da4344 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs @@ -113,6 +113,7 @@ public class FileRead : Shared.FileRead, IFileRead private void SendData(string reportFullPath, DateTime dateTime, JsonElement[] jsonElements, List descriptions) { string checkDirectory; + long uniqueSequence = Logistics.GetUniqueSequence(_Logistics); WSRequest wsRequest = new(this, _Logistics, jsonElements, descriptions); int weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday); string directory = Path.Combine(_OpenInsightMetrologyViewerFileShare, dateTime.Year.ToString(), $"WW{weekOfYear:00}"); @@ -126,9 +127,9 @@ public class FileRead : Shared.FileRead, IFileRead _Log.Debug(wsResults.HeaderId); lock (_StaticRuns) { - if (!_StaticRuns.ContainsKey(_Logistics.Sequence)) - _StaticRuns.Add(_Logistics.Sequence, new()); - _StaticRuns[_Logistics.Sequence].Add(wsResults); + if (!_StaticRuns.ContainsKey(uniqueSequence)) + _StaticRuns.Add(uniqueSequence, new()); + _StaticRuns[uniqueSequence].Add(wsResults); } checkDirectory = Path.Combine(directory, $"-{wsResults.HeaderId}"); if (!Directory.Exists(checkDirectory)) diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs index 526986d..bc01d89 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs @@ -158,11 +158,12 @@ public class WSRequest Details.Add(detail); } Date ??= logistics.DateTimeFromSequence.ToString(); - UniqueId = $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}"; + string uniqueId = Logistics.GetUniqueId(logistics); + UniqueId = uniqueId; for (int i = 0; i < Details.Count; i++) { Details[i].HeaderUniqueId = UniqueId; - Details[i].UniqueId = $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}_Item-{i + 1}"; + Details[i].UniqueId = $"{uniqueId}_Item-{i + 1}"; } } @@ -208,6 +209,7 @@ public class WSRequest internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string lincPDFCFileName, List descriptions, string matchDirectory, WS.Results results, string headerIdDirectory) #pragma warning restore IDE0060 { + string uniqueId = Logistics.GetUniqueId(logistics); string[] pclFiles = Directory.GetFiles(matchDirectory, "*.pcl", SearchOption.TopDirectoryOnly); if (pclFiles.Length != 1) throw new Exception($"Invalid source file count for <{results.HeaderId}>!"); @@ -226,7 +228,7 @@ public class WSRequest throw new Exception("Invalid *.pdf file count!"); List headerAttachments = new() { - new WS.Attachment(results, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}", "Data.pdf", pdfFiles[0]) + new WS.Attachment(results, headerIdDirectory, uniqueId, "Data.pdf", pdfFiles[0]) }; WS.AttachFiles(openInsightMetrologyViewerAPI, headerAttachments, dataAttachments: null); } diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs index 67deef7..70f9854 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs @@ -145,8 +145,9 @@ public class FileRead : Shared.FileRead, IFileRead string jobIdDirectory = Path.Combine(Path.GetDirectoryName(_FileConnectorConfiguration.AlternateTargetFolder) ?? throw new Exception(), _Logistics.JobID); if (!Directory.Exists(jobIdDirectory)) _ = Directory.CreateDirectory(jobIdDirectory); + long uniqueSequence = Logistics.GetUniqueSequence(_Logistics); string[] matchDirectories = GetInProcessDirectory(jobIdDirectory); - if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List? wsResults)) + if (!_StaticRuns.TryGetValue(uniqueSequence, out List? wsResults)) results = null; else { diff --git a/Adaptation/FileHandlers/Processed/FileRead.cs b/Adaptation/FileHandlers/Processed/FileRead.cs index 5110055..26bc54e 100644 --- a/Adaptation/FileHandlers/Processed/FileRead.cs +++ b/Adaptation/FileHandlers/Processed/FileRead.cs @@ -114,6 +114,7 @@ public class FileRead : Shared.FileRead, IFileRead throw new ArgumentNullException(nameof(dateTime)); FileInfo fileInfo = new(reportFullPath); string logisticsSequence = _Logistics.Sequence.ToString(); + long uniqueSequence = Logistics.GetUniqueSequence(_Logistics); string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID); if (!Directory.Exists(jobIdDirectory)) _ = Directory.CreateDirectory(jobIdDirectory); @@ -136,7 +137,7 @@ public class FileRead : Shared.FileRead, IFileRead File.Copy(reportFullPath, Path.Combine(sequenceDirectory, Path.GetFileName(reportFullPath)), overwrite: true); File.WriteAllText(jsonFileName, json); lock (_StaticRuns) - _ = _StaticRuns.Remove(_Logistics.Sequence); + _ = _StaticRuns.Remove(uniqueSequence); } private static void MoveMatchingFile(string jobIdDirectory, string matchDirectory) diff --git a/Adaptation/FileHandlers/pcl/Constant.cs b/Adaptation/FileHandlers/pcl/Constant.cs index 129bd11..5f599c8 100644 --- a/Adaptation/FileHandlers/pcl/Constant.cs +++ b/Adaptation/FileHandlers/pcl/Constant.cs @@ -5,6 +5,7 @@ internal class Constant public int Take { get; } = 11; public string Site { get; } = "Site: "; + public string Page1 { get; } = "Page 1"; public string Multiple { get; } = "MULTIPLE"; public string SummaryLine { get; } = "SUMMARY A A"; public string LastUnits { get; } = "Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %"; diff --git a/Adaptation/FileHandlers/pcl/Run.cs b/Adaptation/FileHandlers/pcl/Run.cs index 70e264d..a3e219d 100644 --- a/Adaptation/FileHandlers/pcl/Run.cs +++ b/Adaptation/FileHandlers/pcl/Run.cs @@ -25,11 +25,17 @@ internal class Run public Summary Summary { get; } public ReadOnlyCollection Points { get; } - private static ReadOnlyCollection FilterLines(ReadOnlyCollection collection) + private static ReadOnlyCollection FilterLines(ReadOnlyCollection collection, Constant constant) { List results = new(); foreach (string line in collection) { + if (line.EndsWith(constant.Page1)) + { + results.Clear(); + results.Add(line); + continue; + } if (string.IsNullOrEmpty(line) || line is "*" or "@") continue; if (line.Length < 3 || line[0] is not '*' and not '@' || line[1] != ' ') @@ -109,7 +115,7 @@ internal class Run { Run? result; Constant constant = new(); - ReadOnlyCollection lines = FilterLines(collection); + ReadOnlyCollection lines = FilterLines(collection, constant); if (collection.Count <= constant.Take) result = null; else diff --git a/Adaptation/Shared/Logistics.cs b/Adaptation/Shared/Logistics.cs index 7eb81b3..dd8ffcc 100644 --- a/Adaptation/Shared/Logistics.cs +++ b/Adaptation/Shared/Logistics.cs @@ -199,4 +199,31 @@ public class Logistics : ILogistics _ProcessJobID = processJobID; } + private static int GetCountFromFileName(Logistics logistics) + { + int result; + string[] segments = logistics.FileInfo.Name.Split('.'); + string[] segmentsB = segments[0].Split('_'); + string countFromFileName = segmentsB.Length < 3 ? "0" : segmentsB[2]; + if (!int.TryParse(countFromFileName, out result)) + result = 0; + return result; + } + + internal static long GetUniqueSequence(Logistics logistics) + { + long result; + int countFromFileName = GetCountFromFileName(logistics); + result = (logistics.Sequence * 10) + countFromFileName; + return result; + } + + internal static string GetUniqueId(Logistics logistics) + { + string result; + int countFromFileName = GetCountFromFileName(logistics); + result = $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}_{countFromFileName}"; + return result; + } + } \ No newline at end of file diff --git a/Adaptation/Shared/ProcessDataStandardFormat.cs b/Adaptation/Shared/ProcessDataStandardFormat.cs index bc3c424..5d2e053 100644 --- a/Adaptation/Shared/ProcessDataStandardFormat.cs +++ b/Adaptation/Shared/ProcessDataStandardFormat.cs @@ -665,7 +665,7 @@ internal class ProcessDataStandardFormat return results; } - internal static string GetPDSFText(IFileRead fileRead, Logistics logistics, JsonElement[] jsonElements, string logisticsText) + internal static string GetPDSFText(IFileRead fileRead, Logistics logistics, JsonElement[] jsonElements, string? logisticsText) { string result; if (jsonElements.Length == 0) @@ -850,33 +850,6 @@ internal class ProcessDataStandardFormat return string.Concat(((int)searchFor).ToString().PadLeft(2, '0'), separator, searchFor.ToString().Replace("In", string.Concat(separator, "In")).Replace("Ex", string.Concat(separator, "Ex"))); } - private static int? TryGetPropertyIndex(JsonProperty[] jsonProperties, string propertyName) - { - int? result = null; - for (int i = 0; i < jsonProperties.Length; i++) - { - if (jsonProperties[i].Name != propertyName) - continue; - result = i; - break; - } - if (result is null) - { - for (int i = 0; i < jsonProperties.Length; i++) - { - if (jsonProperties[i].Name[0] != propertyName[0]) - continue; - if (jsonProperties[i].Name.Length != propertyName.Length) - continue; - if (jsonProperties[i].Name != propertyName) - continue; - result = i; - break; - } - } - return result; - } - internal static string GetXml(ProcessDataStandardFormat processDataStandardFormat) { string result;