diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs index d7efcb8..25fbf67 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs @@ -662,52 +662,34 @@ public class WSRequest internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string ghostPCLFileName, List descriptions, string matchDirectory, WS.Results results, string headerIdDirectory) #pragma warning restore IDE0060 { - string extension; + string pdfFile; + string extension = ".pdf"; List attachmentFiles = new(); string uniqueId = Logistics.GetUniqueId(logistics); string[] summaryFiles = Directory.GetFiles(matchDirectory, "*.txt", SearchOption.TopDirectoryOnly); if (summaryFiles.Length != 1) throw new Exception($"Invalid source file count for <{results.HeaderId}>!"); - string[] xpsFiles = Directory.GetFiles(matchDirectory, "*.xps", SearchOption.TopDirectoryOnly); - if (xpsFiles.Length > 0) + string[] prnFiles = Directory.GetFiles(matchDirectory, "WaferMap*.prn", SearchOption.TopDirectoryOnly); + foreach (string prnFile in prnFiles.OrderBy(l => l)) { - extension = ".xps"; - foreach (string xpsFile in xpsFiles.OrderBy(l => l)) - attachmentFiles.Add(xpsFile); - if (attachmentFiles.Count == 0 || attachmentFiles.Count != descriptions.Count) - throw new Exception("Invalid *.pdf file count!"); - } - else - { - string pdfFile; - extension = ".pdf"; - string[] prnFiles = Directory.GetFiles(matchDirectory, "WaferMap*.prn", SearchOption.TopDirectoryOnly); - foreach (string prnFile in prnFiles.OrderBy(l => l)) - { - pdfFile = ConvertSourceFileToPdf(ghostPCLFileName, prnFile); - attachmentFiles.Add(pdfFile); - } - if (attachmentFiles.Count == 0 || attachmentFiles.Count != descriptions.Count) - throw new Exception("Invalid *.pdf file count!"); + pdfFile = ConvertSourceFileToPdf(ghostPCLFileName, prnFile); + attachmentFiles.Add(pdfFile); } + if (attachmentFiles.Count == 0) + throw new Exception("Invalid *.pdf file count!"); List dataAttachments = new(); List headerAttachments = new() { new WS.Attachment(results, headerIdDirectory, uniqueId, "Data.txt", summaryFiles[0]) }; - int count; - if (attachmentFiles.Count < descriptions.Count) - count = attachmentFiles.Count; - else - count = descriptions.Count; - for (int i = 0; i < count; i++) + for (int i = 0; i < attachmentFiles.Count; i++) { if (!string.IsNullOrEmpty(attachmentFiles[i])) dataAttachments.Add(new WS.Attachment(results, headerIdDirectory, $"{uniqueId}_Item-{i + 1}", $"Image{extension}", attachmentFiles[i])); } - if (dataAttachments.Count == 0 || dataAttachments.Count != descriptions.Count) - throw new Exception($"Invalid attachment count! {dataAttachments.Count} != {descriptions.Count}"); WS.AttachFiles(openInsightMetrologyViewerAPI, headerAttachments, dataAttachments); + if (attachmentFiles.Count == 0 || attachmentFiles.Count != descriptions.Count) + throw new Exception("Invalid *.pdf file count!"); } } \ No newline at end of file