Refactor file handling classes: rename MoveAllFiles to MoveMapFiles, add MoveTextFiles, and update logistics sequence handling across various FileRead implementations.
Bug fix for recipe to session Add one to run count
This commit is contained in:
@ -17,8 +17,9 @@ public class CellInstanceConnectionName
|
||||
nameof(Archive) => new Archive.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
nameof(Dummy) => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
nameof(IQSSi) => new IQSSi.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
nameof(MoveAllFiles) => new MoveAllFiles.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
nameof(MoveMapFiles) => new MoveMapFiles.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
nameof(MoveMatchingFiles) => new MoveMatchingFiles.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
nameof(MoveTextFiles) => new MoveTextFiles.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
nameof(OpenInsight) => new OpenInsight.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
nameof(OpenInsightMetrologyViewer) => new OpenInsightMetrologyViewer.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
nameof(OpenInsightMetrologyViewerAttachments) => new OpenInsightMetrologyViewerAttachments.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||
|
||||
@ -115,50 +115,50 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
StringBuilder result = new();
|
||||
char del = '\t';
|
||||
txt.Description x = descriptions[0];
|
||||
_ = result.Append(x.DcnLpdMin).Append(del). // 001 -
|
||||
Append(x.DcnLpdMax).Append(del). // 002 -
|
||||
Append(x.DcnLpdMean).Append(del). // 003 - DCN LPD
|
||||
Append(x.DcnAreaCountMin).Append(del). // 004 -
|
||||
Append(x.DcnAreaCountMax).Append(del). // 005 -
|
||||
Append(x.DcnAreaCountMean).Append(del).// 006 - DCN Area
|
||||
Append(x.DcnAreaMin).Append(del). // 007 -
|
||||
Append(x.DcnAreaMax).Append(del). // 008 -
|
||||
Append(x.Date).Append(del). // 009 -
|
||||
Append(x.DcnHazeAvgMean).Append(del). // 010 - Haze Average
|
||||
Append(string.Empty).Append(del). // 011 -
|
||||
Append(string.Empty).Append(del). // 012 -
|
||||
Append(string.Empty).Append(del). // 013 -
|
||||
Append(string.Empty).Append(del). // 014 -
|
||||
Append(string.Empty).Append(del). // 015 -
|
||||
Append(string.Empty).Append(del). // 016 -
|
||||
Append(string.Empty).Append(del). // 017 -
|
||||
Append(string.Empty).Append(del). // 018 -
|
||||
Append(string.Empty).Append(del). // 019 -
|
||||
Append(string.Empty).Append(del). // 020 -
|
||||
Append(string.Empty).Append(del). // 021 -
|
||||
Append(string.Empty).Append(del). // 022 -
|
||||
Append(string.Empty).Append(del). // 023 -
|
||||
Append(string.Empty).Append(del). // 024 -
|
||||
Append(string.Empty).Append(del). // 025 -
|
||||
Append(string.Empty).Append(del). // 026 -
|
||||
Append(string.Empty).Append(del). // 027 -
|
||||
Append(x.RDS).Append(del). // 028 - Lot
|
||||
Append(x.Reactor).Append(del). // 029 - Process
|
||||
Append(x.Recipe).Append(del). // 030 - Part
|
||||
Append(x.DcnScrMean).Append(del). // 031 - Scratch Count
|
||||
Append(string.Empty).Append(del). // 032 -
|
||||
Append(string.Empty).Append(del). // 033 -
|
||||
Append(string.Empty).Append(del). // 034 -
|
||||
Append(x.DcnMicroScrMean).Append(del). // 035 - Scratch Length
|
||||
Append(string.Empty).Append(del). // 036 -
|
||||
Append(string.Empty).Append(del). // 037 -
|
||||
Append(string.Empty).Append(del). // 038 -
|
||||
Append(x.DcnAllMean).Append(del). // 039 - Average Sum of Defects
|
||||
Append(x.DcnAllMax).Append(del). // 040 - Max Sum of defects
|
||||
Append(x.DcnAllMin).Append(del). // 041 - Min Sum of Defects
|
||||
Append(string.Empty).Append(del). // 042 -
|
||||
Append(logistics.MesEntity).Append(del). // 043 -
|
||||
Append(x.DcnAreaMean).Append(del). // 044 - DCN MM2
|
||||
_ = result.Append(x.DcnLpdMin).Append(del). // 001 -
|
||||
Append(x.DcnLpdMax).Append(del). // 002 -
|
||||
Append(x.DcnLpdMean).Append(del). // 003 - DCN LPD
|
||||
Append(x.DcnAreaCountMin).Append(del). // 004 -
|
||||
Append(x.DcnAreaCountMax).Append(del). // 005 -
|
||||
Append(x.DcnAreaCountMean).Append(del). // 006 - DCN Area
|
||||
Append(x.DcnAreaMin).Append(del). // 007 -
|
||||
Append(x.DcnAreaMax).Append(del). // 008 -
|
||||
Append(x.Date).Append(del). // 009 -
|
||||
Append(x.DcnHazeAvgMean).Append(del). // 010 - Haze Average
|
||||
Append(string.Empty).Append(del). // 011 -
|
||||
Append(string.Empty).Append(del). // 012 -
|
||||
Append(string.Empty).Append(del). // 013 -
|
||||
Append(string.Empty).Append(del). // 014 -
|
||||
Append(string.Empty).Append(del). // 015 -
|
||||
Append(string.Empty).Append(del). // 016 -
|
||||
Append(string.Empty).Append(del). // 017 -
|
||||
Append(string.Empty).Append(del). // 018 -
|
||||
Append(string.Empty).Append(del). // 019 -
|
||||
Append(string.Empty).Append(del). // 020 -
|
||||
Append(string.Empty).Append(del). // 021 -
|
||||
Append(string.Empty).Append(del). // 022 -
|
||||
Append(string.Empty).Append(del). // 023 -
|
||||
Append(string.Empty).Append(del). // 024 -
|
||||
Append(string.Empty).Append(del). // 025 -
|
||||
Append(string.Empty).Append(del). // 026 -
|
||||
Append(string.Empty).Append(del). // 027 -
|
||||
Append(x.RDS).Append(del). // 028 - Lot
|
||||
Append(x.Reactor).Append(del). // 029 - Process
|
||||
Append(x.Session).Append(del). // 030 - Part
|
||||
Append(x.DcnScrMean).Append(del). // 031 - Scratch Count
|
||||
Append(string.Empty).Append(del). // 032 -
|
||||
Append(string.Empty).Append(del). // 033 -
|
||||
Append(string.Empty).Append(del). // 034 -
|
||||
Append(x.DcnMicroScrMean).Append(del). // 035 - Scratch Length
|
||||
Append(string.Empty).Append(del). // 036 -
|
||||
Append(string.Empty).Append(del). // 037 -
|
||||
Append(string.Empty).Append(del). // 038 -
|
||||
Append(x.DcnAllMean).Append(del). // 039 - Average Sum of Defects
|
||||
Append(x.DcnAllMax).Append(del). // 040 - Max Sum of defects
|
||||
Append(x.DcnAllMin).Append(del). // 041 - Min Sum of Defects
|
||||
Append(string.Empty).Append(del). // 042 -
|
||||
Append(logistics.MesEntity).Append(del). // 043 -
|
||||
Append(x.DcnAreaMean).Append(del). // 044 - DCN MM2
|
||||
AppendLine();
|
||||
return new Tuple<string, string>(result.ToString(), x.Date);
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Adaptation.FileHandlers.MoveAllFiles;
|
||||
namespace Adaptation.FileHandlers.MoveMapFiles;
|
||||
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
@ -267,11 +267,12 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
List<Post> 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<Shared.Metrology.WS.Results>? wsResults))
|
||||
if (!_StaticRuns.TryGetValue(uniqueSequence, out List<Shared.Metrology.WS.Results>? wsResults))
|
||||
wsResults = null;
|
||||
if (processDataStandardFormat.InputPDSF is null)
|
||||
File.Move(preWith.MatchingFile, preWith.CheckFile);
|
||||
|
||||
112
Adaptation/FileHandlers/MoveTextFiles/FileRead.cs
Normal file
112
Adaptation/FileHandlers/MoveTextFiles/FileRead.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Duplicator;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Adaptation.FileHandlers.MoveTextFiles;
|
||||
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
|
||||
#nullable enable
|
||||
|
||||
private long? _TickOffset;
|
||||
|
||||
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<Shared.Metrology.WS.Results>> 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)
|
||||
{
|
||||
_MinFileLength = 10;
|
||||
_NullData = string.Empty;
|
||||
_Logistics = new(this);
|
||||
if (_FileParameter is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_ModelObjectParameterDefinitions is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_IsDuplicator)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
}
|
||||
|
||||
#nullable disable
|
||||
|
||||
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults);
|
||||
|
||||
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
|
||||
|
||||
string IFileRead.GetEventDescription()
|
||||
{
|
||||
string result = _Description.GetEventDescription();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IFileRead.GetHeaderNames()
|
||||
{
|
||||
List<string> results = _Description.GetHeaderNames();
|
||||
return results;
|
||||
}
|
||||
|
||||
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||
{
|
||||
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IFileRead.GetDefault()
|
||||
{
|
||||
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||
return results;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||
{
|
||||
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||
{
|
||||
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
throw new Exception();
|
||||
_ReportFullPath = reportFullPath;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
results = GetExtractResult(reportFullPath, dateTime);
|
||||
if (results.Item3 is null)
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
|
||||
if (results.Item3.Length > 0 && _IsEAFHosted)
|
||||
WritePDSF(this, results.Item3);
|
||||
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
List<string> headerNames = _Description.GetHeaderNames();
|
||||
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
|
||||
results = ReExtract(this, headerNames, keyValuePairs);
|
||||
return results;
|
||||
}
|
||||
|
||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||
{
|
||||
if (dateTime == DateTime.MinValue)
|
||||
throw new ArgumentNullException(nameof(dateTime));
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
|
||||
_TickOffset ??= 0; // new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
|
||||
_Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
@ -125,13 +125,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<WS.Results> wsResults))
|
||||
if (_StaticRuns.TryGetValue(uniqueSequence, out List<WS.Results> wsResults))
|
||||
{
|
||||
if (wsResults is null || wsResults.Count != 1)
|
||||
throw new NullReferenceException($"{nameof(wsResults)} {wsResults?.Count} != 1 {_Logistics.Sequence}!");
|
||||
|
||||
@ -113,6 +113,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
private void SendData(string reportFullPath, DateTime dateTime, JsonElement[] jsonElements, List<txt.Description> 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))
|
||||
|
||||
@ -611,11 +611,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}";
|
||||
}
|
||||
}
|
||||
|
||||
@ -624,7 +625,7 @@ public class WSRequest
|
||||
/// </summary>
|
||||
/// <param name="sourceFile">source file to be converted to PDF</param>
|
||||
/// <returns></returns>
|
||||
private static string ConvertSourceFileToPdf(string ghostPCLFileName, string sourceFile)
|
||||
public static string ConvertSourceFileToPdf(string ghostPCLFileName, string sourceFile)
|
||||
{
|
||||
string result = Path.ChangeExtension(sourceFile, ".pdf");
|
||||
if (!File.Exists(result))
|
||||
@ -661,29 +662,48 @@ public class WSRequest
|
||||
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string ghostPCLFileName, List<txt.Description> descriptions, string matchDirectory, WS.Results results, string headerIdDirectory)
|
||||
#pragma warning restore IDE0060
|
||||
{
|
||||
string extension;
|
||||
List<string> 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[] prnFiles = Directory.GetFiles(matchDirectory, "WaferMap*.prn", SearchOption.TopDirectoryOnly);
|
||||
List<string> pdfFiles = new();
|
||||
foreach (string prnFile in prnFiles.OrderBy(l => l))
|
||||
pdfFiles.Add(ConvertSourceFileToPdf(ghostPCLFileName, prnFile));
|
||||
if (pdfFiles.Count == 0 || pdfFiles.Count != descriptions.Count)
|
||||
throw new Exception("Invalid *.pdf file count!");
|
||||
string[] xpsFiles = Directory.GetFiles(matchDirectory, "*.xps", SearchOption.TopDirectoryOnly);
|
||||
if (xpsFiles.Length > 0)
|
||||
{
|
||||
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!");
|
||||
}
|
||||
List<WS.Attachment> dataAttachments = new();
|
||||
List<WS.Attachment> headerAttachments = new()
|
||||
{
|
||||
new WS.Attachment(results, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}", "Data.txt", summaryFiles[0])
|
||||
new WS.Attachment(results, headerIdDirectory, uniqueId, "Data.txt", summaryFiles[0])
|
||||
};
|
||||
int count;
|
||||
if (pdfFiles.Count < descriptions.Count)
|
||||
count = pdfFiles.Count;
|
||||
if (attachmentFiles.Count < descriptions.Count)
|
||||
count = attachmentFiles.Count;
|
||||
else
|
||||
count = descriptions.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(pdfFiles[i]))
|
||||
dataAttachments.Add(new WS.Attachment(results, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}_Item-{i + 1}", "Image.pdf", pdfFiles[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}");
|
||||
|
||||
@ -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<Shared.Metrology.WS.Results>? wsResults))
|
||||
if (!_StaticRuns.TryGetValue(uniqueSequence, out List<Shared.Metrology.WS.Results>? wsResults))
|
||||
results = null;
|
||||
else
|
||||
{
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -116,7 +116,7 @@ public partial class Job
|
||||
{ runCount = GetScalar(iqsSQLConnectionString, commandText); }
|
||||
catch (Exception)
|
||||
{ runCount = null; }
|
||||
basicType = runCount is null ? hyphen : runCount.ToString();
|
||||
basicType = runCount is null ? hyphen : (runCount + 1).ToString();
|
||||
}
|
||||
Qty = "1";
|
||||
Status = hyphen; // INFO
|
||||
|
||||
@ -93,7 +93,11 @@ internal class Run
|
||||
private static void AddPrintFiles(Logistics logistics, List<FileInfo> fileInfoCollection)
|
||||
{
|
||||
string sourceDirectory = Path.GetDirectoryName(logistics.ReportFullPath) ?? throw new Exception();
|
||||
string[] files = Directory.GetFiles(sourceDirectory, "WaferMap*.prn", SearchOption.TopDirectoryOnly);
|
||||
string[] files;
|
||||
files = Directory.GetFiles(sourceDirectory, "*.xps", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
fileInfoCollection.Add(new FileInfo(file));
|
||||
files = Directory.GetFiles(sourceDirectory, "WaferMap*.prn", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
fileInfoCollection.Add(new FileInfo(file));
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -108,8 +108,9 @@
|
||||
<Compile Include="Adaptation\FileHandlers\CellInstanceConnectionName.cs" />
|
||||
<Compile Include="Adaptation\FileHandlers\Dummy\FileRead.cs" />
|
||||
<Compile Include="Adaptation\FileHandlers\IQSSi\FileRead.cs" />
|
||||
<Compile Include="Adaptation\FileHandlers\MoveAllFiles\FileRead.cs" />
|
||||
<Compile Include="Adaptation\FileHandlers\MoveMapFiles\FileRead.cs" />
|
||||
<Compile Include="Adaptation\FileHandlers\MoveMatchingFiles\FileRead.cs" />
|
||||
<Compile Include="Adaptation\FileHandlers\MoveTextFiles\FileRead.cs" />
|
||||
<Compile Include="Adaptation\FileHandlers\OpenInsight\FileRead.cs" />
|
||||
<Compile Include="Adaptation\FileHandlers\OpenInsight\FromIQS.cs" />
|
||||
<Compile Include="Adaptation\FileHandlers\OpenInsight\Root.cs" />
|
||||
|
||||
Reference in New Issue
Block a user