Added Hypen

Dual write PDSF for Metrology Viewer
Version Error Message
Tests Passed
gitignore
cellInstanceVersion.EdaConnection.PortNumber
NETFRAMEWORK
Added Climatec to Test.cs
GetJobIdDirectory
Remove and
This commit is contained in:
2024-05-16 12:12:13 -07:00
parent ee7be147e0
commit 457a27a357
95 changed files with 1612 additions and 269 deletions

View File

@ -29,8 +29,8 @@ public class FileRead : Shared.FileRead, IFileRead
{
_LastIndex = -1;
_MinFileLength = 10;
_NullData = string.Empty;
_Logistics = new(this);
_NullData = string.Empty;
if (_FileParameter is null)
throw new Exception(cellInstanceConnectionName);
if (_ModelObjectParameterDefinitions is null)
@ -261,8 +261,8 @@ public class FileRead : Shared.FileRead, IFileRead
string lines = GetLines(_Logistics, descriptions);
if (!string.IsNullOrEmpty(lines))
{
long? subGroupId;
_LastIndex += 1;
long? subGroupId;
if (_LastIndex >= _IQSCopyCollection.Count)
_LastIndex = 0;
long breakAfter = dateTime.AddSeconds(_BreakAfterSeconds).Ticks;
@ -276,6 +276,12 @@ public class FileRead : Shared.FileRead, IFileRead
collection.Add(new(new ScopeInfo(tests[0], _OpenInsightFilePattern), lines));
else
collection.Add(new(new ScopeInfo(tests[0], $"{subGroupId.Value} {_OpenInsightFilePattern}"), lines));
if (_StaticRuns.TryGetValue(_Logistics.Sequence, out List<string> values))
{
if (values.Count != 1)
throw new Exception($"{nameof(_StaticRuns)} {values.Count} != 1 {_Logistics.Sequence}!");
values[0] = $"{values[0]}|{subGroupId}";
}
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
FromIQS.Save(_OpenInsightApiECDirectory, _Logistics, reportFullPath, logistics, descriptions.First(), lines, subGroupId, weekOfYear);
try

View File

@ -31,8 +31,8 @@ public class FileRead : Shared.FileRead, IFileRead
throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
_OpenInsightMetrologyViewerFileShare = @"\\mesfs.infineon.com\EC_Metrology_Si\MetrologyAttachments\TencorRunHeader_";
_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,16 +112,15 @@ public class FileRead : Shared.FileRead, IFileRead
private void SendData(string reportFullPath, DateTime dateTime, List<pcl.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));
if (File.Exists(fullPath))
File.Delete(fullPath);
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);
@ -129,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

@ -67,7 +67,6 @@ public class WSRequest
#pragma warning disable IDE1006
public int i { get; set; }
public List<pcl.Detail> Details { get; protected set; }
public string ProcessDataStandardFormat { get; set; }
[Obsolete("For json")] public WSRequest() { }
@ -75,7 +74,6 @@ public class WSRequest
internal WSRequest(IFileRead fileRead, Logistics logistics, List<pcl.Description> descriptions, string processDataStandardFormat = null)
#pragma warning restore IDE0060
{
ProcessDataStandardFormat = processDataStandardFormat;
i = -1;
Id = -1;
Zone = null;
@ -287,23 +285,30 @@ public class WSRequest
pdDocument.close();
}
#pragma warning disable IDE0060
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, DateTime dateTime, string json, List<pcl.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<pcl.Description> descriptions)
{
string checkFileName;
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<pcl.Description> descriptions, string matchDirectory, string subGroupId, long headerId, string headerIdDirectory)
#pragma warning restore IDE0060
{
string checkFileName;
string[] pclFiles = Directory.GetFiles(matchDirectory, "*.pcl", SearchOption.TopDirectoryOnly);
if (pclFiles.Length != 1)
throw new Exception($"Invalid source file count for <{wsResultsHeaderID}>!{Environment.NewLine}{json}");
throw new Exception($"Invalid source file count for <{headerId}>!");
string sourceFileNameNoExt = Path.GetFileNameWithoutExtension(pclFiles[0]);
List<WS.Attachment> dataAttachments = new();
List<WS.Attachment> headerAttachments = new();
@ -313,23 +318,23 @@ public class WSRequest
else
{
UpdateDataPDF(descriptions, checkFileName);
headerAttachments.Add(new WS.Attachment(descriptions[0].HeaderUniqueId, "Data.pdf", checkFileName));
headerAttachments.Add(new WS.Attachment(subGroupId, headerId, headerIdDirectory, descriptions[0].HeaderUniqueId, "Data.pdf", checkFileName));
}
foreach (pcl.Description description in descriptions)
{
checkFileName = Path.Combine(matchDirectory, $"{sourceFileNameNoExt}_{description.Slot.Replace('*', 's')}_image.pdf");
if (File.Exists(checkFileName))
dataAttachments.Add(new WS.Attachment(description.UniqueId, "Image.pdf", checkFileName));
dataAttachments.Add(new WS.Attachment(subGroupId, headerId, headerIdDirectory, description.UniqueId, "Image.pdf", checkFileName));
else
{
checkFileName = Path.Combine(matchDirectory, $"{sourceFileNameNoExt}_{description.Slot.Replace('*', 's')}_data.pdf");
if (File.Exists(checkFileName))
dataAttachments.Add(new WS.Attachment(description.UniqueId, "Image.pdf", checkFileName));
dataAttachments.Add(new WS.Attachment(subGroupId, headerId, headerIdDirectory, description.UniqueId, "Image.pdf", checkFileName));
}
}
if (dataAttachments.Count == 0 || dataAttachments.Count != descriptions.Count)
throw new Exception($"Invalid attachment count! {dataAttachments.Count} != {descriptions.Count}");
WS.AttachFiles(openInsightMetrologyViewerAPI, wsResultsHeaderID, headerAttachments, dataAttachments);
WS.AttachFiles(openInsightMetrologyViewerAPI, headerAttachments, dataAttachments);
}
}

View File

@ -5,6 +5,7 @@ using Adaptation.Shared.Duplicator;
using Adaptation.Shared.Methods;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.Json;
@ -14,8 +15,8 @@ namespace Adaptation.FileHandlers.OpenInsightMetrologyViewerAttachments;
public class FileRead : Shared.FileRead, IFileRead
{
private readonly string _JobIdParentDirectory;
private readonly string _OpenInsightMetrologyViewerAPI;
private readonly string _OpenInsightMetrologyViewerFileShare;
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> 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,8 +30,8 @@ public class FileRead : Shared.FileRead, IFileRead
throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
_JobIdParentDirectory = GetJobIdParentDirectory(_FileConnectorConfiguration.SourceFileLocation);
_OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI");
_OpenInsightMetrologyViewerFileShare = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerFileShare");
}
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
@ -108,26 +109,58 @@ public class FileRead : Shared.FileRead, IFileRead
return results;
}
#pragma warning disable IDE0060
private void PostOpenInsightMetrologyViewerAttachments(string reportFullPath, DateTime dateTime, List<pcl.Description> descriptions)
#pragma warning restore IDE0060
#nullable enable
private string? GetHeaderIdDirectory(DateTime[] dateTimes, long headerId)
{
string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID);
string? result = null;
int weekNum;
string year;
string weekDirectory;
string checkDirectory;
foreach (DateTime dateTime in dateTimes)
{
year = dateTime.Year.ToString();
weekNum = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
weekDirectory = Path.Combine(_OpenInsightMetrologyViewerFileShare, dateTime.Year.ToString(), $"WW{weekNum:00}");
if (!Directory.Exists(weekDirectory))
_ = Directory.CreateDirectory(weekDirectory);
checkDirectory = Path.Combine(weekDirectory, $"-{headerId}");
if (!Directory.Exists(checkDirectory))
continue;
result = checkDirectory;
break;
}
return result;
}
private void PostOpenInsightMetrologyViewerAttachments(DateTime dateTime, List<pcl.Description> descriptions)
{
string? json;
string? subGroupId;
string jobIdDirectory = Path.Combine(Path.GetDirectoryName(_FileConnectorConfiguration.AlternateTargetFolder) ?? throw new Exception(), _Logistics.JobID);
if (!Directory.Exists(jobIdDirectory))
_ = Directory.CreateDirectory(jobIdDirectory);
string json;
string[] matchDirectories = GetInProcessDirectory(jobIdDirectory);
if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List<string> collection))
json = string.Empty;
if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List<string>? values))
(json, subGroupId) = (null, null);
else
{
if (collection.Count != 1)
throw new Exception($"{nameof(_StaticRuns)} has too many values for {_Logistics.Sequence}!");
json = collection[0];
if (values.Count != 1)
throw new Exception($"{nameof(_StaticRuns)} {values.Count} != 1 {_Logistics.Sequence}!");
string[] segments = values[0].Split(new string[] { "|" }, StringSplitOptions.None);
json = segments[0];
subGroupId = segments.Length > 1 ? segments[1] : null;
lock (_StaticRuns)
_ = _StaticRuns.Remove(_Logistics.Sequence);
}
OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, dateTime, json, descriptions, matchDirectories[0]);
DateTime[] dateTimes = new DateTime[] { dateTime, dateTime.AddDays(-6.66) };
int weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
long headerId = OpenInsightMetrologyViewer.WSRequest.GetHeaderId(this, _Logistics, _OpenInsightMetrologyViewerAPI, dateTime, weekOfYear, json, descriptions);
string? headerIdDirectory = GetHeaderIdDirectory(dateTimes, headerId);
if (string.IsNullOrEmpty(headerIdDirectory))
throw new Exception($"Didn't find header id directory <{headerId}>");
OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, descriptions, matchDirectories[0], subGroupId, headerId, headerIdDirectory);
}
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
@ -140,7 +173,7 @@ public class FileRead : Shared.FileRead, IFileRead
List<pcl.Description> descriptions = pcl.ProcessData.GetDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
PostOpenInsightMetrologyViewerAttachments(reportFullPath, dateTime, descriptions);
PostOpenInsightMetrologyViewerAttachments(dateTime, descriptions);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
return results;
}

View File

@ -418,10 +418,10 @@ public class ProcessData : IProcessData
{
_I = 0;
ParseErrorText = string.Empty;
if (!pages.ContainsKey(headerFileName))
if (!pages.TryGetValue(headerFileName, out string value))
throw new Exception();
_I = 0;
_Data = pages[headerFileName];
_Data = value;
ScanPast("Date:");
_ = GetToEOL();
Set(logistics);
@ -508,10 +508,10 @@ public class ProcessData : IProcessData
result.HeaderUniqueId = UniqueId;
result.Id = 0;
result.Title = null;
if (!pages.ContainsKey(waferFileName))
if (!pages.TryGetValue(waferFileName, out string value))
throw new Exception();
_I = 0;
_Data = pages[waferFileName];
_Data = value;
ScanPast("Date:");
result.Date = GetToEOL();
ScanPast("ID#");