process-data-standard-format with HeaderId and SubgroupId
This commit is contained in:
parent
61fea7c581
commit
f0ec303ddb
@ -14,7 +14,7 @@ namespace Adaptation.FileHandlers.APC;
|
|||||||
public class FileRead : Shared.FileRead, IFileRead
|
public class FileRead : Shared.FileRead, IFileRead
|
||||||
{
|
{
|
||||||
|
|
||||||
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
|
@ -18,7 +18,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _JobIdParentDirectory;
|
private readonly string _JobIdParentDirectory;
|
||||||
private readonly string _JobIdArchiveParentDirectory;
|
private readonly string _JobIdArchiveParentDirectory;
|
||||||
|
|
||||||
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
|
@ -9,7 +9,7 @@ namespace Adaptation.FileHandlers;
|
|||||||
public class CellInstanceConnectionName
|
public class CellInstanceConnectionName
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static IFileRead Get(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, 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, int? connectionCount)
|
internal static IFileRead Get(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, 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, int? connectionCount)
|
||||||
{
|
{
|
||||||
IFileRead result = cellInstanceConnectionName switch
|
IFileRead result = cellInstanceConnectionName switch
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly HttpClient _HttpClient;
|
private readonly HttpClient _HttpClient;
|
||||||
private readonly string _StaticFileServer;
|
private readonly string _StaticFileServer;
|
||||||
|
|
||||||
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
|
@ -23,7 +23,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private int _LastDummyRunIndex;
|
private int _LastDummyRunIndex;
|
||||||
private readonly string[] _CellNames;
|
private readonly string[] _CellNames;
|
||||||
|
|
||||||
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
|
@ -14,7 +14,7 @@ namespace Adaptation.FileHandlers.IQSSi;
|
|||||||
public class FileRead : Shared.FileRead, IFileRead
|
public class FileRead : Shared.FileRead, IFileRead
|
||||||
{
|
{
|
||||||
|
|
||||||
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
|
@ -69,7 +69,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
|
|
||||||
private readonly ProcessDataStandardFormatMapping _ProcessDataStandardFormatMapping;
|
private readonly ProcessDataStandardFormatMapping _ProcessDataStandardFormatMapping;
|
||||||
|
|
||||||
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
@ -307,7 +307,9 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
File.Move(preWith.MatchingFile, preWith.CheckFile);
|
File.Move(preWith.MatchingFile, preWith.CheckFile);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ProcessDataStandardFormat.Write(preWith.CheckFile, processDataStandardFormat);
|
if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List<Shared.Metrology.WS.Results>? wsResults))
|
||||||
|
wsResults = null;
|
||||||
|
ProcessDataStandardFormat.Write(preWith.CheckFile, processDataStandardFormat, wsResults);
|
||||||
File.Delete(preWith.MatchingFile);
|
File.Delete(preWith.MatchingFile);
|
||||||
}
|
}
|
||||||
if (Directory.Exists(preWith.NoWaitDirectory))
|
if (Directory.Exists(preWith.NoWaitDirectory))
|
||||||
@ -353,7 +355,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
processDataStandardFormat = null;
|
processDataStandardFormat = null;
|
||||||
}
|
}
|
||||||
if (!_IsEAFHosted && processDataStandardFormat is not null)
|
if (!_IsEAFHosted && processDataStandardFormat is not null)
|
||||||
ProcessDataStandardFormat.Write(".pdsf", processDataStandardFormat);
|
ProcessDataStandardFormat.Write(".pdsf", processDataStandardFormat, wsResults: null);
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
int numberLength = 2;
|
int numberLength = 2;
|
||||||
long ticks = dateTime.Ticks;
|
long ticks = dateTime.Ticks;
|
||||||
|
@ -21,7 +21,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _OpenInsightFilePattern;
|
private readonly string _OpenInsightFilePattern;
|
||||||
private readonly string _OpenInsightApiECDirectory;
|
private readonly string _OpenInsightApiECDirectory;
|
||||||
|
|
||||||
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) :
|
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<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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
@ -172,25 +172,26 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string lines = GetLines(_Logistics, descriptions);
|
string lines = GetLines(_Logistics, descriptions);
|
||||||
if (!string.IsNullOrEmpty(lines))
|
if (!string.IsNullOrEmpty(lines))
|
||||||
{
|
{
|
||||||
long? subGroupId;
|
long? subgroupId;
|
||||||
long breakAfter = dateTime.AddSeconds(_BreakAfterSeconds).Ticks;
|
long breakAfter = dateTime.AddSeconds(_BreakAfterSeconds).Ticks;
|
||||||
long preWait = _FileConnectorConfiguration?.FileHandleWaitTime is null ? dateTime.AddMilliseconds(1234).Ticks : dateTime.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).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))
|
if (string.IsNullOrEmpty(descriptions[0].Reactor) || string.IsNullOrEmpty(descriptions[0].PSN))
|
||||||
subGroupId = null;
|
subgroupId = null;
|
||||||
else
|
else
|
||||||
(subGroupId, int? _, string _) = FromIQS.GetCommandText(_IqsConnectionString, _Logistics, descriptions[0], breakAfter, preWait);
|
(subgroupId, int? _, string _) = FromIQS.GetCommandText(_IqsConnectionString, _Logistics, descriptions[0], breakAfter, preWait);
|
||||||
if (subGroupId is null)
|
if (subgroupId is null)
|
||||||
collection.Add(new(new ScopeInfo(tests[0], _OpenInsightFilePattern), lines));
|
collection.Add(new(new ScopeInfo(tests[0], _OpenInsightFilePattern), lines));
|
||||||
else
|
else
|
||||||
collection.Add(new(new ScopeInfo(tests[0], $"{subGroupId.Value} {_OpenInsightFilePattern}"), lines));
|
collection.Add(new(new ScopeInfo(tests[0], $"{subgroupId.Value} {_OpenInsightFilePattern}"), lines));
|
||||||
if (_StaticRuns.TryGetValue(_Logistics.Sequence, out List<string> values))
|
if (_StaticRuns.TryGetValue(_Logistics.Sequence, out List<WS.Results> wsResults))
|
||||||
{
|
{
|
||||||
if (values.Count != 1)
|
if (wsResults is null || wsResults.Count != 1)
|
||||||
throw new Exception($"{nameof(_StaticRuns)} {values.Count} != 1 {_Logistics.Sequence}!");
|
throw new NullReferenceException($"{nameof(wsResults)} {wsResults?.Count} != 1 {_Logistics.Sequence}!");
|
||||||
values[0] = $"{values[0]}|{subGroupId}";
|
lock (_StaticRuns)
|
||||||
|
wsResults[0] = WS.Results.Get(wsResults[0], subgroupId);
|
||||||
}
|
}
|
||||||
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||||
FromIQS.Save(_OpenInsightApiECDirectory, _Logistics, reportFullPath, processDataStandardFormat, descriptions.First(), lines, subGroupId, weekOfYear);
|
FromIQS.Save(_OpenInsightApiECDirectory, _Logistics, reportFullPath, processDataStandardFormat, descriptions.First(), lines, subgroupId, weekOfYear);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||||
|
@ -19,7 +19,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _OpenInsightMetrologyViewerAPI;
|
private readonly string _OpenInsightMetrologyViewerAPI;
|
||||||
private readonly string _OpenInsightMetrologyViewerFileShare;
|
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) :
|
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<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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
@ -121,16 +121,16 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
File.Copy(reportFullPath, Path.Combine(checkDirectory, Path.GetFileName(reportFullPath)), overwrite: true);
|
File.Copy(reportFullPath, Path.Combine(checkDirectory, Path.GetFileName(reportFullPath)), overwrite: true);
|
||||||
(string jsonResults, WS.Results wsResults) = WS.SendData(_OpenInsightMetrologyViewerAPI, _Logistics.Sequence, directory, wsRequest);
|
(string jsonResults, WS.Results wsResults) = WS.SendData(_OpenInsightMetrologyViewerAPI, _Logistics.Sequence, directory, wsRequest);
|
||||||
if (!wsResults.Success)
|
if (wsResults.Success is null || !wsResults.Success.Value)
|
||||||
throw new Exception(wsResults.ToString());
|
throw new Exception(jsonResults);
|
||||||
_Log.Debug(wsResults.HeaderID);
|
_Log.Debug(wsResults.HeaderId);
|
||||||
lock (_StaticRuns)
|
lock (_StaticRuns)
|
||||||
{
|
{
|
||||||
if (!_StaticRuns.ContainsKey(_Logistics.Sequence))
|
if (!_StaticRuns.ContainsKey(_Logistics.Sequence))
|
||||||
_StaticRuns.Add(_Logistics.Sequence, new());
|
_StaticRuns.Add(_Logistics.Sequence, new());
|
||||||
_StaticRuns[_Logistics.Sequence].Add(jsonResults);
|
_StaticRuns[_Logistics.Sequence].Add(wsResults);
|
||||||
}
|
}
|
||||||
checkDirectory = Path.Combine(directory, $"-{wsResults.HeaderID}");
|
checkDirectory = Path.Combine(directory, $"-{wsResults.HeaderId}");
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
File.Copy(reportFullPath, Path.Combine(checkDirectory, Path.GetFileName(reportFullPath)), overwrite: true);
|
File.Copy(reportFullPath, Path.Combine(checkDirectory, Path.GetFileName(reportFullPath)), overwrite: true);
|
||||||
|
@ -4,7 +4,6 @@ using Adaptation.Shared.Properties;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
|
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
|
||||||
|
|
||||||
@ -106,29 +105,30 @@ public class WSRequest
|
|||||||
FilePath = onlyWSRequest;
|
FilePath = onlyWSRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string openInsightMetrologyViewerFileShare, int weekOfYear, string json, List<RsM.Description> descriptions)
|
internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string openInsightMetrologyViewerFileShare, int weekOfYear, WS.Results results, List<RsM.Description> descriptions)
|
||||||
{
|
{
|
||||||
long result;
|
long result;
|
||||||
if (string.IsNullOrEmpty(json))
|
if (results is not null && results.HeaderId is not null)
|
||||||
|
result = results.HeaderId.Value;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
WSRequest wsRequest = new(fileRead, logistics, descriptions);
|
WSRequest wsRequest = new(fileRead, logistics, descriptions);
|
||||||
string directory = Path.Combine(openInsightMetrologyViewerFileShare, logistics.DateTimeFromSequence.Year.ToString(), $"WW{weekOfYear:00}");
|
string directory = Path.Combine(openInsightMetrologyViewerFileShare, logistics.DateTimeFromSequence.Year.ToString(), $"WW{weekOfYear:00}");
|
||||||
(json, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, logistics.Sequence, directory, wsRequest);
|
(_, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, logistics.Sequence, directory, wsRequest);
|
||||||
if (!wsResults.Success)
|
if (wsResults.Success is null || !wsResults.Success.Value)
|
||||||
throw new Exception(wsResults.ToString());
|
throw new Exception(wsResults.ToString());
|
||||||
|
result = wsResults.HeaderId.Value;
|
||||||
}
|
}
|
||||||
WS.Results metrologyWSRequest = JsonSerializer.Deserialize<WS.Results>(json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
|
||||||
result = metrologyWSRequest.HeaderID;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060
|
#pragma warning disable IDE0060
|
||||||
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, List<RsM.Description> descriptions, string matchDirectory, string subGroupId, long headerId, string headerIdDirectory)
|
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, List<RsM.Description> descriptions, string matchDirectory, WS.Results results, string headerIdDirectory)
|
||||||
#pragma warning restore IDE0060
|
#pragma warning restore IDE0060
|
||||||
{
|
{
|
||||||
string[] txtFiles = Directory.GetFiles(matchDirectory, "*.txt", SearchOption.TopDirectoryOnly);
|
string[] txtFiles = Directory.GetFiles(matchDirectory, "*.txt", SearchOption.TopDirectoryOnly);
|
||||||
if (txtFiles.Length != 1)
|
if (txtFiles.Length != 1)
|
||||||
throw new Exception($"Invalid source file count for <{headerId}>!");
|
throw new Exception($"Invalid source file count for <{results.HeaderId}>!");
|
||||||
List<string> pdfFiles = new();
|
List<string> pdfFiles = new();
|
||||||
pdfFiles.AddRange(Directory.GetFiles(matchDirectory, "*.pdf_old", SearchOption.TopDirectoryOnly));
|
pdfFiles.AddRange(Directory.GetFiles(matchDirectory, "*.pdf_old", SearchOption.TopDirectoryOnly));
|
||||||
foreach (string pdfFile in pdfFiles)
|
foreach (string pdfFile in pdfFiles)
|
||||||
@ -142,7 +142,7 @@ public class WSRequest
|
|||||||
throw new Exception("Invalid *.pdf file count!");
|
throw new Exception("Invalid *.pdf file count!");
|
||||||
List<WS.Attachment> headerAttachments = new()
|
List<WS.Attachment> headerAttachments = new()
|
||||||
{
|
{
|
||||||
new WS.Attachment(subGroupId, headerId, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}", "Data.pdf", pdfFiles[0])
|
new WS.Attachment(results, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}", "Data.pdf", pdfFiles[0])
|
||||||
};
|
};
|
||||||
WS.AttachFiles(openInsightMetrologyViewerAPI, headerAttachments, dataAttachments: null);
|
WS.AttachFiles(openInsightMetrologyViewerAPI, headerAttachments, dataAttachments: null);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _OpenInsightMetrologyViewerAPI;
|
private readonly string _OpenInsightMetrologyViewerAPI;
|
||||||
private readonly string _OpenInsightMetrologyViewerFileShare;
|
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
@ -137,30 +137,25 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
|
|
||||||
private void PostOpenInsightMetrologyViewerAttachments(List<RsM.Description> descriptions)
|
private void PostOpenInsightMetrologyViewerAttachments(List<RsM.Description> descriptions)
|
||||||
{
|
{
|
||||||
string? json;
|
Shared.Metrology.WS.Results? results;
|
||||||
string? subGroupId;
|
|
||||||
string jobIdDirectory = Path.Combine(Path.GetDirectoryName(_FileConnectorConfiguration.AlternateTargetFolder) ?? throw new Exception(), _Logistics.JobID);
|
string jobIdDirectory = Path.Combine(Path.GetDirectoryName(_FileConnectorConfiguration.AlternateTargetFolder) ?? throw new Exception(), _Logistics.JobID);
|
||||||
if (!Directory.Exists(jobIdDirectory))
|
if (!Directory.Exists(jobIdDirectory))
|
||||||
_ = Directory.CreateDirectory(jobIdDirectory);
|
_ = Directory.CreateDirectory(jobIdDirectory);
|
||||||
string[] matchDirectories = GetInProcessDirectory(jobIdDirectory);
|
string[] matchDirectories = GetInProcessDirectory(jobIdDirectory);
|
||||||
if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List<string>? values))
|
if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List<Shared.Metrology.WS.Results>? wsResults))
|
||||||
(json, subGroupId) = (null, null);
|
results = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (values.Count != 1)
|
if (wsResults is null || wsResults.Count != 1)
|
||||||
throw new Exception($"{nameof(_StaticRuns)} {values.Count} != 1 {_Logistics.Sequence}!");
|
throw new NullReferenceException($"{nameof(wsResults)} {wsResults?.Count} != 1 {_Logistics.Sequence}!");
|
||||||
string[] segments = values[0].Split(new string[] { "|" }, StringSplitOptions.None);
|
results = wsResults[0];
|
||||||
json = segments[0];
|
|
||||||
subGroupId = segments.Length > 1 ? segments[1] : null;
|
|
||||||
lock (_StaticRuns)
|
|
||||||
_ = _StaticRuns.Remove(_Logistics.Sequence);
|
|
||||||
}
|
}
|
||||||
int weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
int weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||||
long headerId = !_IsEAFHosted ? -1 : OpenInsightMetrologyViewer.WSRequest.GetHeaderId(this, _Logistics, _OpenInsightMetrologyViewerAPI, _OpenInsightMetrologyViewerFileShare, weekOfYear, json, descriptions);
|
long headerId = !_IsEAFHosted ? -1 : OpenInsightMetrologyViewer.WSRequest.GetHeaderId(this, _Logistics, _OpenInsightMetrologyViewerAPI, _OpenInsightMetrologyViewerFileShare, weekOfYear, results, descriptions);
|
||||||
string? headerIdDirectory = GetHeaderIdDirectory(headerId);
|
string? headerIdDirectory = GetHeaderIdDirectory(headerId);
|
||||||
if (string.IsNullOrEmpty(headerIdDirectory))
|
if (string.IsNullOrEmpty(headerIdDirectory))
|
||||||
throw new Exception($"Didn't find header id directory <{headerId}>");
|
throw new Exception($"Didn't find header id directory <{headerId}>");
|
||||||
OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, descriptions, matchDirectories[0], subGroupId, headerId, headerIdDirectory);
|
OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, descriptions, matchDirectories[0], results, headerIdDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||||
|
@ -17,7 +17,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _JobIdParentDirectory;
|
private readonly string _JobIdParentDirectory;
|
||||||
private readonly string _JobIdProcessParentDirectory;
|
private readonly string _JobIdProcessParentDirectory;
|
||||||
|
|
||||||
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
@ -135,6 +135,8 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
_ = Directory.CreateDirectory(sequenceDirectory);
|
_ = Directory.CreateDirectory(sequenceDirectory);
|
||||||
File.Copy(reportFullPath, Path.Combine(sequenceDirectory, Path.GetFileName(reportFullPath)), overwrite: true);
|
File.Copy(reportFullPath, Path.Combine(sequenceDirectory, Path.GetFileName(reportFullPath)), overwrite: true);
|
||||||
File.WriteAllText(jsonFileName, json);
|
File.WriteAllText(jsonFileName, json);
|
||||||
|
lock (_StaticRuns)
|
||||||
|
_ = _StaticRuns.Remove(_Logistics.Sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MoveMatchingFile(string jobIdDirectory, string matchDirectory)
|
private static void MoveMatchingFile(string jobIdDirectory, string matchDirectory)
|
||||||
|
@ -15,7 +15,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
|
|
||||||
private long? _TickOffset;
|
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<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
|
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(), true, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
base(new Description(), true, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
|
@ -14,7 +14,7 @@ namespace Adaptation.FileHandlers.SPaCe;
|
|||||||
public class FileRead : Shared.FileRead, IFileRead
|
public class FileRead : Shared.FileRead, IFileRead
|
||||||
{
|
{
|
||||||
|
|
||||||
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_MinFileLength = 10;
|
_MinFileLength = 10;
|
||||||
|
@ -44,9 +44,9 @@ public class FileRead : Properties.IFileRead
|
|||||||
protected readonly string _CellInstanceConnectionNameBase;
|
protected readonly string _CellInstanceConnectionNameBase;
|
||||||
protected readonly Dictionary<string, List<long>> _DummyRuns;
|
protected readonly Dictionary<string, List<long>> _DummyRuns;
|
||||||
protected readonly Dictionary<string, string> _FileParameter;
|
protected readonly Dictionary<string, string> _FileParameter;
|
||||||
protected readonly Dictionary<long, List<string>> _StaticRuns;
|
|
||||||
protected readonly string _ParameterizedModelObjectDefinitionType;
|
protected readonly string _ParameterizedModelObjectDefinitionType;
|
||||||
protected readonly FileConnectorConfiguration _FileConnectorConfiguration;
|
protected readonly FileConnectorConfiguration _FileConnectorConfiguration;
|
||||||
|
protected readonly Dictionary<long, List<Metrology.WS.Results>> _StaticRuns;
|
||||||
protected readonly IList<ModelObjectParameterDefinition> _ModelObjectParameterDefinitions;
|
protected readonly IList<ModelObjectParameterDefinition> _ModelObjectParameterDefinitions;
|
||||||
|
|
||||||
bool Properties.IFileRead.IsEvent => _IsEvent;
|
bool Properties.IFileRead.IsEvent => _IsEvent;
|
||||||
@ -203,7 +203,7 @@ public class FileRead : Properties.IFileRead
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileRead(IDescription description, bool isEvent, 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)
|
public FileRead(IDescription description, bool isEvent, 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<Metrology.WS.Results>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted)
|
||||||
{
|
{
|
||||||
_SMTP = smtp;
|
_SMTP = smtp;
|
||||||
_IsEvent = isEvent;
|
_IsEvent = isEvent;
|
||||||
@ -377,17 +377,25 @@ public class FileRead : Properties.IFileRead
|
|||||||
|
|
||||||
internal string[] GetInProcessDirectory(string jobIdDirectory)
|
internal string[] GetInProcessDirectory(string jobIdDirectory)
|
||||||
{
|
{
|
||||||
string[] results;
|
List<string> results = new();
|
||||||
if (!_IsEAFHosted)
|
if (!_IsEAFHosted)
|
||||||
results = new string[] { jobIdDirectory };
|
results = new string[] { jobIdDirectory }.ToList();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
string[] files;
|
||||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||||
results = Directory.GetDirectories(jobIdDirectory, $"*{logisticsSequence}*", SearchOption.TopDirectoryOnly);
|
string[] directories = Directory.GetDirectories(jobIdDirectory, $"*{logisticsSequence}*", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string directory in directories)
|
||||||
|
{
|
||||||
|
files = Directory.GetFiles(directory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
if (files.Length == 0)
|
||||||
|
continue;
|
||||||
|
results.Add(directory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((results is null) || results.Length != 1)
|
if ((results is null) || results.Count != 1)
|
||||||
throw new Exception("Didn't find directory by logistics sequence");
|
throw new Exception("Didn't find directory by logistics sequence");
|
||||||
return results;
|
return results.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static string[] GetMatches(FileConnectorConfiguration fileConnectorConfiguration)
|
protected static string[] GetMatches(FileConnectorConfiguration fileConnectorConfiguration)
|
||||||
@ -616,6 +624,9 @@ public class FileRead : Properties.IFileRead
|
|||||||
case FileConnectorConfiguration.PostProcessingModeEnum.Delete:
|
case FileConnectorConfiguration.PostProcessingModeEnum.Delete:
|
||||||
File.Delete(sourceFile.FullName);
|
File.Delete(sourceFile.FullName);
|
||||||
break;
|
break;
|
||||||
|
case FileConnectorConfiguration.PostProcessingModeEnum.None:
|
||||||
|
File.Move(sourceFile.FullName, itemFile);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
@ -6,23 +6,25 @@ public partial class WS
|
|||||||
public class Attachment
|
public class Attachment
|
||||||
{
|
{
|
||||||
|
|
||||||
public string SubGroupId { get; set; }
|
#nullable enable
|
||||||
public long HeaderId { get; set; }
|
|
||||||
public string HeaderIdDirectory { get; set; }
|
|
||||||
public string UniqueId { get; set; }
|
|
||||||
public string DestinationFileName { get; set; }
|
|
||||||
public string SourceFileName { get; set; }
|
|
||||||
public string AttachmentId { get; set; }
|
|
||||||
|
|
||||||
public Attachment(string subGroupId, long headerId, string headerIdDirectory, string uniqueId, string destinationFileName, string sourceFileName)
|
public long HeaderId { get; set; }
|
||||||
|
public string UniqueId { get; set; }
|
||||||
|
public string SubGroupId { get; set; }
|
||||||
|
public string AttachmentId { get; set; }
|
||||||
|
public string SourceFileName { get; set; }
|
||||||
|
public string HeaderIdDirectory { get; set; }
|
||||||
|
public string DestinationFileName { get; set; }
|
||||||
|
|
||||||
|
public Attachment(Results? results, string headerIdDirectory, string uniqueId, string destinationFileName, string sourceFileName)
|
||||||
{
|
{
|
||||||
SubGroupId = subGroupId;
|
|
||||||
HeaderId = headerId;
|
|
||||||
HeaderIdDirectory = headerIdDirectory;
|
|
||||||
UniqueId = uniqueId;
|
UniqueId = uniqueId;
|
||||||
DestinationFileName = destinationFileName;
|
|
||||||
SourceFileName = sourceFileName;
|
SourceFileName = sourceFileName;
|
||||||
|
HeaderIdDirectory = headerIdDirectory;
|
||||||
|
DestinationFileName = destinationFileName;
|
||||||
AttachmentId = System.Guid.NewGuid().ToString();
|
AttachmentId = System.Guid.NewGuid().ToString();
|
||||||
|
HeaderId = results?.HeaderId is null ? -1 : results.HeaderId.Value;
|
||||||
|
SubGroupId = results?.SubgroupId is null ? string.Empty : results.SubgroupId.Value.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,75 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Adaptation.Shared.Metrology;
|
namespace Adaptation.Shared.Metrology;
|
||||||
|
|
||||||
public partial class WS
|
public partial class WS
|
||||||
{
|
{
|
||||||
// this class represents the response from the Inbound API endpoint
|
|
||||||
public class Results
|
public class Results
|
||||||
{
|
{
|
||||||
// true or false if data was written to the database
|
|
||||||
public bool Success { get; set; }
|
|
||||||
|
|
||||||
// if true, contains ID of the Header record in the database
|
#nullable enable
|
||||||
public long HeaderID { get; set; }
|
|
||||||
|
|
||||||
// if false, this collection will contain a list of errors
|
[JsonConstructor]
|
||||||
public List<string> Errors { get; set; }
|
public Results(List<string>? errors,
|
||||||
|
long? headerId,
|
||||||
|
long? subgroupId,
|
||||||
|
bool? success,
|
||||||
|
List<string>? warnings)
|
||||||
|
{
|
||||||
|
Errors = errors;
|
||||||
|
Success = success;
|
||||||
|
HeaderId = headerId;
|
||||||
|
Warnings = warnings;
|
||||||
|
SubgroupId = subgroupId;
|
||||||
|
}
|
||||||
|
|
||||||
// this collection will contain a list of warnings, they will not prevent data from being saved
|
[JsonPropertyName("errors")] public List<string>? Errors { get; set; }
|
||||||
public List<string> Warnings { get; set; }
|
[JsonPropertyName("headerID")] public long? HeaderId { get; set; }
|
||||||
|
[JsonPropertyName("subgroupId")] public long? SubgroupId { get; set; }
|
||||||
|
[JsonPropertyName("success")] public bool? Success { get; set; }
|
||||||
|
[JsonPropertyName("warnings")] public List<string>? Warnings { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, ResultsSourceGenerationContext.Default.Results);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static Results Get(Results results, long? subgroupId) =>
|
||||||
|
new(results.Errors, results.HeaderId, subgroupId, results.Success, results.Warnings);
|
||||||
|
|
||||||
|
internal static Results Get(string resultsJson, Exception e)
|
||||||
|
{
|
||||||
|
Results results;
|
||||||
|
Exception? exception = e;
|
||||||
|
List<string> errors = new();
|
||||||
|
StringBuilder stringBuilder = new();
|
||||||
|
while (exception is not null)
|
||||||
|
{
|
||||||
|
_ = stringBuilder.AppendLine(exception.Message);
|
||||||
|
exception = exception.InnerException;
|
||||||
|
}
|
||||||
|
errors.Add(resultsJson);
|
||||||
|
errors.Add(stringBuilder.ToString());
|
||||||
|
results = new(errors: errors,
|
||||||
|
headerId: null,
|
||||||
|
subgroupId: null,
|
||||||
|
success: false,
|
||||||
|
warnings: new());
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
// this is just a helper function to make displaying the results easier
|
|
||||||
public override string ToString() => JsonSerializer.Serialize(this, GetType());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(WS.Results))]
|
||||||
|
internal partial class ResultsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
}
|
}
|
@ -10,9 +10,11 @@ namespace Adaptation.Shared.Metrology;
|
|||||||
public partial class WS
|
public partial class WS
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
public static (string, Results) SendData(string url, long sequence, string directory, object payload, int timeoutSeconds = 120)
|
public static (string, Results) SendData(string url, long sequence, string directory, object payload, int timeoutSeconds = 120)
|
||||||
{
|
{
|
||||||
Results results = new();
|
Results? wsResults = null;
|
||||||
string resultsJson = string.Empty;
|
string resultsJson = string.Empty;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -30,29 +32,20 @@ public partial class WS
|
|||||||
};
|
};
|
||||||
HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead).Result;
|
HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead).Result;
|
||||||
resultsJson = httpResponseMessage.Content.ReadAsStringAsync().Result;
|
resultsJson = httpResponseMessage.Content.ReadAsStringAsync().Result;
|
||||||
results = JsonSerializer.Deserialize<Results>(resultsJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
wsResults = JsonSerializer.Deserialize(resultsJson, ResultsSourceGenerationContext.Default.Results);
|
||||||
string checkDirectory = Path.Combine(directory, $"-{results.HeaderID}");
|
if (wsResults is null)
|
||||||
|
throw new NullReferenceException(nameof(wsResults));
|
||||||
|
string checkDirectory = Path.Combine(directory, $"-{wsResults.HeaderId}");
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
File.WriteAllText(Path.Combine(checkDirectory, $"{sequence}.json"), json);
|
File.WriteAllText(Path.Combine(checkDirectory, $"{sequence}.json"), json);
|
||||||
}
|
}
|
||||||
if (!results.Success)
|
if (wsResults.Success is null || !wsResults.Success.Value)
|
||||||
results.Errors.Add(results.ToString());
|
wsResults.Errors?.Add(wsResults.ToString());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{ wsResults ??= Results.Get(resultsJson, e); }
|
||||||
Exception exception = e;
|
return new(resultsJson, wsResults);
|
||||||
StringBuilder stringBuilder = new();
|
|
||||||
while (exception is not null)
|
|
||||||
{
|
|
||||||
_ = stringBuilder.AppendLine(exception.Message);
|
|
||||||
exception = exception.InnerException;
|
|
||||||
}
|
|
||||||
results.Errors ??= new List<string>();
|
|
||||||
results.Errors.Add(resultsJson);
|
|
||||||
results.Errors.Add(stringBuilder.ToString());
|
|
||||||
}
|
|
||||||
return new(resultsJson, results);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AttachFile(string url, Attachment attachment, int timeoutSeconds = 60)
|
public static void AttachFile(string url, Attachment attachment, int timeoutSeconds = 60)
|
||||||
@ -69,16 +62,20 @@ public partial class WS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AttachFiles(string url, List<Attachment> headerAttachments = null, List<Attachment> dataAttachments = null)
|
public static void AttachFiles(string url, List<Attachment>? headerAttachments = null, List<Attachment>? dataAttachments = null)
|
||||||
{
|
{
|
||||||
string directory;
|
string directory;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
string? directoryName;
|
||||||
if (headerAttachments is not null)
|
if (headerAttachments is not null)
|
||||||
{
|
{
|
||||||
foreach (Attachment attachment in headerAttachments)
|
foreach (Attachment attachment in headerAttachments)
|
||||||
{
|
{
|
||||||
directory = Path.Combine(Path.GetDirectoryName(attachment.HeaderIdDirectory), attachment.AttachmentId) ?? throw new Exception();
|
directoryName = Path.GetDirectoryName(attachment.HeaderIdDirectory);
|
||||||
|
if (string.IsNullOrEmpty(directoryName))
|
||||||
|
continue;
|
||||||
|
directory = Path.Combine(directoryName, attachment.AttachmentId) ?? throw new Exception();
|
||||||
if (!Directory.Exists(directory))
|
if (!Directory.Exists(directory))
|
||||||
_ = Directory.CreateDirectory(directory);
|
_ = Directory.CreateDirectory(directory);
|
||||||
File.Copy(attachment.SourceFileName, Path.Combine(directory, attachment.DestinationFileName), overwrite: true);
|
File.Copy(attachment.SourceFileName, Path.Combine(directory, attachment.DestinationFileName), overwrite: true);
|
||||||
@ -88,7 +85,10 @@ public partial class WS
|
|||||||
{
|
{
|
||||||
foreach (Attachment attachment in dataAttachments)
|
foreach (Attachment attachment in dataAttachments)
|
||||||
{
|
{
|
||||||
directory = Path.Combine(Path.GetDirectoryName(attachment.HeaderIdDirectory.Replace("Header", "Data")), attachment.AttachmentId) ?? throw new Exception();
|
directoryName = Path.GetDirectoryName(attachment.HeaderIdDirectory.Replace("Header", "Data"));
|
||||||
|
if (string.IsNullOrEmpty(directoryName))
|
||||||
|
continue;
|
||||||
|
directory = Path.Combine(directoryName, attachment.AttachmentId) ?? throw new Exception();
|
||||||
if (!Directory.Exists(directory))
|
if (!Directory.Exists(directory))
|
||||||
_ = Directory.CreateDirectory(directory);
|
_ = Directory.CreateDirectory(directory);
|
||||||
File.Copy(attachment.SourceFileName, Path.Combine(directory, attachment.DestinationFileName), overwrite: true);
|
File.Copy(attachment.SourceFileName, Path.Combine(directory, attachment.DestinationFileName), overwrite: true);
|
||||||
@ -108,7 +108,7 @@ public partial class WS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Exception exception = e;
|
Exception? exception = e;
|
||||||
StringBuilder stringBuilder = new();
|
StringBuilder stringBuilder = new();
|
||||||
while (exception is not null)
|
while (exception is not null)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ internal class ProcessDataStandardFormat
|
|||||||
GetString(SearchFor.Archive, addSpaces, separator);
|
GetString(SearchFor.Archive, addSpaces, separator);
|
||||||
|
|
||||||
internal static ProcessDataStandardFormat GetEmpty() =>
|
internal static ProcessDataStandardFormat GetEmpty() =>
|
||||||
new(new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), null, new(Array.Empty<string>()), null);
|
new(new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), null, new(new string[] { "LOGISTICS_1" }), null);
|
||||||
|
|
||||||
internal static List<string> PDSFToFixedWidth(string reportFullPath)
|
internal static List<string> PDSFToFixedWidth(string reportFullPath)
|
||||||
{
|
{
|
||||||
@ -379,7 +379,7 @@ internal class ProcessDataStandardFormat
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Write(string path, ProcessDataStandardFormat processDataStandardFormat)
|
internal static void Write(string path, ProcessDataStandardFormat processDataStandardFormat, List<Metrology.WS.Results>? wsResults)
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
List<string> results = new();
|
||||||
if (processDataStandardFormat.Sequence is null)
|
if (processDataStandardFormat.Sequence is null)
|
||||||
@ -404,7 +404,20 @@ internal class ProcessDataStandardFormat
|
|||||||
results.Add($"START_TIME\t{startTime}");
|
results.Add($"START_TIME\t{startTime}");
|
||||||
results.Add("LOGISTICS_COLUMN\tA_LOGISTICS");
|
results.Add("LOGISTICS_COLUMN\tA_LOGISTICS");
|
||||||
results.Add("LOGISTICS_COLUMN\tB_LOGISTICS");
|
results.Add("LOGISTICS_COLUMN\tB_LOGISTICS");
|
||||||
results.AddRange(processDataStandardFormat.Logistics);
|
if (wsResults is null || wsResults.Count != 1)
|
||||||
|
results.AddRange(processDataStandardFormat.Logistics);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string[] segments;
|
||||||
|
foreach (string logistics in processDataStandardFormat.Logistics)
|
||||||
|
{
|
||||||
|
segments = logistics.Split(new string[] { "\t" }, StringSplitOptions.None);
|
||||||
|
if (segments.Length != 2 || string.IsNullOrEmpty(segments[1]))
|
||||||
|
results.Add(logistics);
|
||||||
|
else
|
||||||
|
results.Add($"{segments[0]}\t{segments[1][0]}_HeaderId={wsResults[0].HeaderId};{segments[1][0]}_SubgroupId={wsResults[0].SubgroupId};{segments[1]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
results.Add("EOF");
|
results.Add("EOF");
|
||||||
if (processDataStandardFormat.InputPDSF is not null)
|
if (processDataStandardFormat.InputPDSF is not null)
|
||||||
{
|
{
|
||||||
|
@ -977,7 +977,7 @@ public class AdaptationTesting : ISMTP
|
|||||||
if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
|
if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
|
||||||
_ = Directory.CreateDirectory(fileInfo.Directory.FullName);
|
_ = Directory.CreateDirectory(fileInfo.Directory.FullName);
|
||||||
Dictionary<string, List<long>> dummyRuns = new();
|
Dictionary<string, List<long>> dummyRuns = new();
|
||||||
Dictionary<long, List<string>> staticRuns = new();
|
Dictionary<long, List<Adaptation.Shared.Metrology.WS.Results>> staticRuns = new();
|
||||||
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName);
|
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName);
|
||||||
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, mbn.CellInstanceConnectionName);
|
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, mbn.CellInstanceConnectionName);
|
||||||
Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName);
|
Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName);
|
||||||
|
@ -37,7 +37,7 @@ public partial class FileRead : FileReaderHandler, ISMTP
|
|||||||
private FilePathGenerator _FilePathGeneratorForTarget;
|
private FilePathGenerator _FilePathGeneratorForTarget;
|
||||||
private readonly List<EquipmentParameter> _EquipmentParameters;
|
private readonly List<EquipmentParameter> _EquipmentParameters;
|
||||||
private static readonly Dictionary<string, List<long>> _DummyRuns;
|
private static readonly Dictionary<string, List<long>> _DummyRuns;
|
||||||
private static readonly Dictionary<long, List<string>> _StaticRuns;
|
private static readonly Dictionary<long, List<Adaptation.Shared.Metrology.WS.Results>> _StaticRuns;
|
||||||
|
|
||||||
static FileRead()
|
static FileRead()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user