From 9c33e31214cf23cae783cf51ca75eaccb4289a7b Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Tue, 27 Jun 2023 08:29:15 -0700 Subject: [PATCH] Save ProcessDataStandardFormat to EC_Metrology_Si IDescription.GetDescriptions with body --- .../OpenInsightMetrologyViewer/FileRead.cs | 17 ++++++--- .../OpenInsightMetrologyViewer/WSRequest.cs | 6 ++-- Adaptation/MET08DDUPSFS6420.Tests.csproj | 12 +++---- Adaptation/Shared/Duplicator/Description.cs | 36 +++++++++++++++++++ 4 files changed, 58 insertions(+), 13 deletions(-) diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs index 49affd8..f7823ed 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/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.Json; @@ -16,6 +17,7 @@ public class FileRead : Shared.FileRead, IFileRead { private readonly string _OpenInsightMetrologyViewerAPI; + private readonly string _OpenInsightMetrologyViewerFileShare; 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) @@ -29,6 +31,7 @@ public class FileRead : Shared.FileRead, IFileRead throw new Exception(cellInstanceConnectionName); if (!_IsDuplicator) throw new Exception(cellInstanceConnectionName); + _OpenInsightMetrologyViewerFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\MetrologyAttachments\TencorRunHeader_"; _OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI"); } @@ -107,11 +110,15 @@ public class FileRead : Shared.FileRead, IFileRead return results; } -#pragma warning disable IDE0060 - private void SendData(DateTime dateTime, List descriptions) -#pragma warning restore IDE0060 + private void SendData(string reportFullPath, DateTime dateTime, List descriptions) { - WSRequest wsRequest = new(this, _Logistics, descriptions); + int weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday); + string directory = Path.Combine(_OpenInsightMetrologyViewerFileShare, dateTime.Year.ToString(), $"WW{weekOfYear:00}", _Logistics.Sequence.ToString()); + if (!Directory.Exists(directory)) + _ = Directory.CreateDirectory(directory); + string fullPath = Path.Combine(directory, Path.GetFileName(reportFullPath)); + File.Copy(reportFullPath, fullPath); + WSRequest wsRequest = new(this, _Logistics, descriptions, fullPath); (string json, WS.Results wsResults) = WS.SendData(_OpenInsightMetrologyViewerAPI, wsRequest); if (!wsResults.Success) throw new Exception(wsResults.ToString()); @@ -134,7 +141,7 @@ public class FileRead : Shared.FileRead, IFileRead List descriptions = pcl.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) - SendData(dateTime, descriptions); + SendData(reportFullPath, dateTime, descriptions); results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs index 78b484e..db72484 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs @@ -68,13 +68,15 @@ public class WSRequest #pragma warning disable IDE1006 public int i { get; set; } public List Details { get; protected set; } + public string ProcessDataStandardFormat { get; set; } [Obsolete("For json")] public WSRequest() { } #pragma warning disable IDE0060 - internal WSRequest(IFileRead fileRead, Logistics logistics, List descriptions) + internal WSRequest(IFileRead fileRead, Logistics logistics, List descriptions, string processDataStandardFormat = null) #pragma warning restore IDE0060 { + ProcessDataStandardFormat = processDataStandardFormat; i = -1; Id = 0; Zone = null; @@ -293,7 +295,7 @@ public class WSRequest string checkFileName; if (string.IsNullOrEmpty(json)) { - WSRequest wsRequest = new(fileRead, logistics, descriptions); + WSRequest wsRequest = new(fileRead, logistics, descriptions, string.Empty); (json, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, wsRequest); if (!wsResults.Success) throw new Exception(wsResults.ToString()); diff --git a/Adaptation/MET08DDUPSFS6420.Tests.csproj b/Adaptation/MET08DDUPSFS6420.Tests.csproj index caf2346..b2dfc32 100644 --- a/Adaptation/MET08DDUPSFS6420.Tests.csproj +++ b/Adaptation/MET08DDUPSFS6420.Tests.csproj @@ -33,7 +33,7 @@ Linux - + NU1701 NU1701 @@ -53,10 +53,10 @@ - + - - + + NU1701 @@ -67,8 +67,8 @@ - - + + NU1701 diff --git a/Adaptation/Shared/Duplicator/Description.cs b/Adaptation/Shared/Duplicator/Description.cs index ee456bf..ee6eb49 100644 --- a/Adaptation/Shared/Duplicator/Description.cs +++ b/Adaptation/Shared/Duplicator/Description.cs @@ -110,6 +110,42 @@ public class Description : IDescription, Properties.IDescription List IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List tests, IProcessData iProcessData) { List results = new(); + if (iProcessData is null || !iProcessData.Details.Any()) + results.Add(GetDefault(fileRead, logistics)); + else + { + string nullData; + Description description; + object configDataNullData = fileRead.NullData; + if (configDataNullData is null) + nullData = string.Empty; + else + nullData = configDataNullData.ToString(); + for (int i = 0; i < iProcessData.Details.Count; i++) + { + if (iProcessData.Details[i] is null) + continue; + description = new Description + { + Test = (int)tests[i], + Count = tests.Count, + Index = i, + // + EventName = fileRead.EventName, + NullData = nullData, + JobID = fileRead.CellInstanceName, + Sequence = logistics.Sequence.ToString(), + MesEntity = logistics.MesEntity, + ReportFullPath = logistics.ReportFullPath, + ProcessJobID = logistics.ProcessJobID, + MID = logistics.MID, + // + Date = DateTime.Now.ToString(GetDateFormat()), + RDS = string.Empty, + }; + results.Add(description); + } + } return results; }