Added Hypen

Removed IQS.Copy
Dual write PDSF for Metrology Viewer
Version Error Message
MetrologyViewerFileShare
Tests passed
net8.0
v2_52_0-Tests
editorconfig
yml ec fix
yml explict contents
Delete File if Exists
dotnet_diagnostic
Removed Open Insight API IFX Directory from Save
CA1862 and GetWeekOfYear for WritePDSF
gitignore
cellInstanceVersion.EdaConnection.PortNumber
Added Climatec to Test.cs
GetJobIdDirectory
Remove and
5-Other-Small
NETFRAMEWORK
This commit is contained in:
2024-05-16 11:56:15 -07:00
parent df24c40850
commit 67b2ddae41
158 changed files with 4162 additions and 612 deletions

View File

@ -31,8 +31,8 @@ public class FileRead : Shared.FileRead, IFileRead
throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
_OpenInsightMetrologyViewerFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\MetrologyAttachments\CDERunHeader_";
_OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI");
_OpenInsightMetrologyViewerFileShare = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerFileShare");
}
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
@ -112,14 +112,15 @@ public class FileRead : Shared.FileRead, IFileRead
private void SendData(string reportFullPath, DateTime dateTime, List<txt.Description> descriptions)
{
string checkDirectory;
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);
string directory = Path.Combine(_OpenInsightMetrologyViewerFileShare, dateTime.Year.ToString(), $"WW{weekOfYear:00}");
checkDirectory = Path.Combine(directory, _Logistics.Sequence.ToString());
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
File.Copy(reportFullPath, Path.Combine(checkDirectory, Path.GetFileName(reportFullPath)), overwrite: true);
(string jsonResults, WS.Results wsResults) = WS.SendData(_OpenInsightMetrologyViewerAPI, _Logistics.Sequence, directory, wsRequest);
if (!wsResults.Success)
throw new Exception(wsResults.ToString());
_Log.Debug(wsResults.HeaderID);
@ -127,8 +128,12 @@ public class FileRead : Shared.FileRead, IFileRead
{
if (!_StaticRuns.ContainsKey(_Logistics.Sequence))
_StaticRuns.Add(_Logistics.Sequence, new());
_StaticRuns[_Logistics.Sequence].Add(json);
_StaticRuns[_Logistics.Sequence].Add(jsonResults);
}
checkDirectory = Path.Combine(directory, $"-{wsResults.HeaderID}");
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
File.Copy(reportFullPath, Path.Combine(checkDirectory, Path.GetFileName(reportFullPath)), overwrite: true);
}
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)

View File

@ -4,7 +4,6 @@ using Adaptation.Shared.Properties;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
@ -43,7 +42,6 @@ public class WSRequest
public string UniqueId { get; set; }
public string Zone { get; set; }
public List<txt.Detail> Details { get; protected set; }
public string ProcessDataStandardFormat { get; set; }
[Obsolete("For json")] public WSRequest() { }
@ -51,7 +49,6 @@ public class WSRequest
internal WSRequest(IFileRead fileRead, Logistics logistics, List<txt.Description> descriptions, string processDataStandardFormat = null)
#pragma warning restore IDE0060
{
ProcessDataStandardFormat = processDataStandardFormat;
Id = -1;
CellName = logistics.MesEntity;
Details = new List<txt.Detail>();
@ -99,28 +96,35 @@ public class WSRequest
Details.Add(detail);
}
Date ??= logistics.DateTimeFromSequence.ToString();
if (UniqueId is null && Details.Any())
if (UniqueId is null && Details.Count != 0)
UniqueId = Details[0].HeaderUniqueId;
string onlyWSRequest = string.Empty;
FilePath = onlyWSRequest;
}
#pragma warning disable IDE0060
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, DateTime dateTime, string json, List<txt.Description> descriptions, string matchDirectory)
#pragma warning restore IDE0060
internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, DateTime dateTime, int weekOfYear, string json, List<txt.Description> descriptions)
{
long result;
if (string.IsNullOrEmpty(json))
{
WSRequest wsRequest = new(fileRead, logistics, descriptions, string.Empty);
(json, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, wsRequest);
WSRequest wsRequest = new(fileRead, logistics, descriptions);
string directory = Path.Combine(openInsightMetrologyViewerAPI, dateTime.Year.ToString(), $"WW{weekOfYear:00}");
(json, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, logistics.Sequence, directory, wsRequest);
if (!wsResults.Success)
throw new Exception(wsResults.ToString());
}
WS.Results metrologyWSRequest = JsonSerializer.Deserialize<WS.Results>(json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
long wsResultsHeaderID = metrologyWSRequest.HeaderID;
result = metrologyWSRequest.HeaderID;
return result;
}
#pragma warning disable IDE0060
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, List<txt.Description> descriptions, string matchDirectory, string subGroupId, long headerId, string headerIdDirectory)
#pragma warning restore IDE0060
{
string[] txtFiles = Directory.GetFiles(matchDirectory, "*.txt", SearchOption.TopDirectoryOnly);
if (txtFiles.Length != 1)
throw new Exception($"Invalid source file count for <{wsResultsHeaderID}>!{Environment.NewLine}{json}");
throw new Exception($"Invalid source file count for <{headerId}>!");
List<string> pdfFiles = new();
pdfFiles.AddRange(Directory.GetFiles(matchDirectory, "*.pdf_old", SearchOption.TopDirectoryOnly));
foreach (string pdfFile in pdfFiles)
@ -130,12 +134,13 @@ public class WSRequest
foreach (string pdfFile in pdfFiles)
File.Move(pdfFile, Path.ChangeExtension(pdfFile, ".pdf_old"));
pdfFiles.Clear();
if (pdfFiles.Count == 0)
throw new Exception("Invalid *.pdf file count!");
List<WS.Attachment> headerAttachments = new()
{ new WS.Attachment(descriptions[0].HeaderUniqueId, "Data.pdf", pdfFiles[0]) };
WS.AttachFiles(openInsightMetrologyViewerAPI, wsResultsHeaderID, headerAttachments, dataAttachments: null);
{
new WS.Attachment(subGroupId, headerId, headerIdDirectory, descriptions[0].HeaderUniqueId, "Data.pdf", pdfFiles[0])
};
WS.AttachFiles(openInsightMetrologyViewerAPI, headerAttachments, dataAttachments: null);
}
}