Compare commits
1 Commits
2c811fae7b
...
04-16-b
Author | SHA1 | Date | |
---|---|---|---|
e86294226c |
@ -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<Shared.Metrology.WS.Results>> 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<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)
|
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<Shared.Metrology.WS.Results>> 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<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)
|
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<Shared.Metrology.WS.Results>> 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<string>> staticRuns, bool useCyclicalForDescription, int? connectionCount)
|
||||||
{
|
{
|
||||||
IFileRead result = cellInstanceConnectionName switch
|
IFileRead result = cellInstanceConnectionName switch
|
||||||
{
|
{
|
||||||
|
@ -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<Shared.Metrology.WS.Results>> 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<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)
|
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;
|
||||||
|
@ -17,7 +17,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
|
|
||||||
private readonly string _IQSFile;
|
private readonly string _IQSFile;
|
||||||
|
|
||||||
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) :
|
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)
|
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;
|
||||||
|
@ -22,21 +22,17 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
internal class PreWith
|
internal class PreWith
|
||||||
{
|
{
|
||||||
|
|
||||||
internal string ErrFile { get; private set; }
|
|
||||||
internal string CheckFile { get; private set; }
|
|
||||||
internal string MatchingFile { get; private set; }
|
internal string MatchingFile { get; private set; }
|
||||||
|
internal string CheckFile { get; private set; }
|
||||||
|
internal string ErrFile { get; private set; }
|
||||||
internal string CheckDirectory { get; private set; }
|
internal string CheckDirectory { get; private set; }
|
||||||
internal string NoWaitDirectory { get; private set; }
|
internal string NoWaitDirectory { get; private set; }
|
||||||
|
|
||||||
internal PreWith(string checkDirectory,
|
internal PreWith(string matchingFile, string checkFile, string errFile, string checkDirectory, string noWaitDirectory)
|
||||||
string checkFile,
|
|
||||||
string errFile,
|
|
||||||
string matchingFile,
|
|
||||||
string noWaitDirectory)
|
|
||||||
{
|
{
|
||||||
ErrFile = errFile;
|
|
||||||
CheckFile = checkFile;
|
|
||||||
MatchingFile = matchingFile;
|
MatchingFile = matchingFile;
|
||||||
|
CheckFile = checkFile;
|
||||||
|
ErrFile = errFile;
|
||||||
CheckDirectory = checkDirectory;
|
CheckDirectory = checkDirectory;
|
||||||
NoWaitDirectory = noWaitDirectory;
|
NoWaitDirectory = noWaitDirectory;
|
||||||
}
|
}
|
||||||
@ -73,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<Shared.Metrology.WS.Results>> 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<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)
|
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;
|
||||||
@ -225,11 +221,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
noWaitDirectory = Path.Combine(checkDirectory, "NoWaitDirectory");
|
noWaitDirectory = Path.Combine(checkDirectory, "NoWaitDirectory");
|
||||||
preWith = new(checkDirectory: checkDirectory,
|
preWith = new(pre.MatchingFile, pre.CheckFile, errFile, checkDirectory, noWaitDirectory);
|
||||||
checkFile: pre.CheckFile,
|
|
||||||
errFile: errFile,
|
|
||||||
matchingFile: pre.MatchingFile,
|
|
||||||
noWaitDirectory: noWaitDirectory);
|
|
||||||
results.Add(preWith);
|
results.Add(preWith);
|
||||||
}
|
}
|
||||||
return results.AsReadOnly();
|
return results.AsReadOnly();
|
||||||
@ -268,7 +260,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<Pre> GetPreCollection(int numberLength, string parentDirectory, ReadOnlyCollection<string> matchingFiles, bool _)
|
private static ReadOnlyCollection<Pre> GetPreCollection(int numberLength, string parentDirectory, ReadOnlyCollection<string> matchingFiles)
|
||||||
{
|
{
|
||||||
List<Pre> results = new();
|
List<Pre> results = new();
|
||||||
Pre pre;
|
Pre pre;
|
||||||
@ -283,7 +275,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return results.AsReadOnly();
|
return results.AsReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveCollection(DateTime dateTime, ProcessDataStandardFormat processDataStandardFormat, ReadOnlyCollection<PreWith> preWithCollection)
|
private void MoveCollection(DateTime dateTime, ProcessDataStandardFormat? processDataStandardFormat, ReadOnlyCollection<PreWith> preWithCollection)
|
||||||
{
|
{
|
||||||
ReadOnlyCollection<Post> postCollection = GetPostCollection(dateTime, processDataStandardFormat, preWithCollection);
|
ReadOnlyCollection<Post> postCollection = GetPostCollection(dateTime, processDataStandardFormat, preWithCollection);
|
||||||
if (postCollection.Count != 0)
|
if (postCollection.Count != 0)
|
||||||
@ -302,19 +294,20 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReadOnlyCollection<Post> GetPostCollection(DateTime dateTime, ProcessDataStandardFormat processDataStandardFormat, ReadOnlyCollection<PreWith> preWithCollection)
|
private ReadOnlyCollection<Post> GetPostCollection(DateTime dateTime, ProcessDataStandardFormat? processDataStandardFormat, ReadOnlyCollection<PreWith> preWithCollection)
|
||||||
{
|
{
|
||||||
List<Post> results = new();
|
List<Post> results = new();
|
||||||
Post post;
|
Post post;
|
||||||
long preWait;
|
long preWait;
|
||||||
foreach (PreWith preWith in preWithCollection)
|
foreach (PreWith preWith in preWithCollection)
|
||||||
{
|
{
|
||||||
if (!_IsEAFHosted)
|
if (processDataStandardFormat is null)
|
||||||
continue;
|
File.Move(preWith.MatchingFile, preWith.CheckFile);
|
||||||
if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List<Shared.Metrology.WS.Results>? wsResults))
|
else
|
||||||
wsResults = null;
|
{
|
||||||
ProcessDataStandardFormat.Write(preWith.CheckFile, processDataStandardFormat, wsResults);
|
ProcessDataStandardFormat.Write(preWith.CheckFile, processDataStandardFormat);
|
||||||
File.Delete(preWith.MatchingFile);
|
File.Delete(preWith.MatchingFile);
|
||||||
|
}
|
||||||
if (Directory.Exists(preWith.NoWaitDirectory))
|
if (Directory.Exists(preWith.NoWaitDirectory))
|
||||||
{
|
{
|
||||||
post = new(preWith.CheckFile, preWith.ErrFile);
|
post = new(preWith.CheckFile, preWith.ErrFile);
|
||||||
@ -348,10 +341,15 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||||
{
|
{
|
||||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, Array.Empty<Test>(), Array.Empty<JsonElement>(), new List<FileInfo>());
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, Array.Empty<Test>(), Array.Empty<JsonElement>(), new List<FileInfo>());
|
||||||
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath, _ProcessDataStandardFormatMapping);
|
ProcessDataStandardFormat? processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath, _ProcessDataStandardFormatMapping);
|
||||||
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
if (processDataStandardFormat is not null)
|
||||||
if (!_IsEAFHosted)
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
ProcessDataStandardFormat.Write("../../.pdsf", processDataStandardFormat, wsResults: null);
|
else
|
||||||
|
{
|
||||||
|
processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||||
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
|
processDataStandardFormat = null;
|
||||||
|
}
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
int numberLength = 2;
|
int numberLength = 2;
|
||||||
long ticks = dateTime.Ticks;
|
long ticks = dateTime.Ticks;
|
||||||
@ -360,16 +358,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
ReadOnlyCollection<string> matchingFiles = GetMatchingFiles(ticks, reportFullPath, searchDirectories);
|
ReadOnlyCollection<string> matchingFiles = GetMatchingFiles(ticks, reportFullPath, searchDirectories);
|
||||||
if (matchingFiles.Count != searchDirectories.Count)
|
if (matchingFiles.Count != searchDirectories.Count)
|
||||||
throw new Exception($"Didn't find all files after {_BreakAfterSeconds} second(s)!");
|
throw new Exception($"Didn't find all files after {_BreakAfterSeconds} second(s)!");
|
||||||
if (_IsEAFHosted)
|
try
|
||||||
{
|
{ CreatePointerFile(numberLength, parentParentDirectory, matchingFiles); }
|
||||||
try
|
catch (Exception) { }
|
||||||
{ CreatePointerFile(numberLength, parentParentDirectory, matchingFiles); }
|
ReadOnlyCollection<Pre> preCollection = GetPreCollection(numberLength, parentParentDirectory, matchingFiles);
|
||||||
catch (Exception) { }
|
|
||||||
}
|
|
||||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
|
||||||
List<pcl.Description> descriptions = pcl.ProcessData.GetDescriptions(jsonElements);
|
|
||||||
bool mesEntityMatchesProcess = descriptions.Count > 0 && descriptions[0].MesEntity == descriptions[0].Reactor;
|
|
||||||
ReadOnlyCollection<Pre> preCollection = GetPreCollection(numberLength, parentParentDirectory, matchingFiles, mesEntityMatchesProcess);
|
|
||||||
ReadOnlyCollection<PreWith> preWithCollection = GetPreWithCollection(preCollection);
|
ReadOnlyCollection<PreWith> preWithCollection = GetPreWithCollection(preCollection);
|
||||||
MoveCollection(dateTime, processDataStandardFormat, preWithCollection);
|
MoveCollection(dateTime, processDataStandardFormat, preWithCollection);
|
||||||
return results;
|
return results;
|
||||||
|
@ -24,7 +24,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _OpenInsightApiECDirectory;
|
private readonly string _OpenInsightApiECDirectory;
|
||||||
private readonly ReadOnlyCollection<ModelObjectParameterDefinition> _IQSCopyCollection;
|
private readonly ReadOnlyCollection<ModelObjectParameterDefinition> _IQSCopyCollection;
|
||||||
|
|
||||||
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) :
|
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)
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
{
|
{
|
||||||
_LastIndex = -1;
|
_LastIndex = -1;
|
||||||
@ -238,6 +238,34 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return result.ToString();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetJson(int columnsLine, string[] columns, string[] body)
|
||||||
|
{
|
||||||
|
#pragma warning disable CA1845, IDE0057
|
||||||
|
string result = "[\n";
|
||||||
|
string line;
|
||||||
|
string value;
|
||||||
|
string[] segments;
|
||||||
|
if (columns.Length == 0)
|
||||||
|
columns = body[columnsLine].Trim().Split('\t');
|
||||||
|
for (int i = columnsLine + 1; i < body.Length; i++)
|
||||||
|
{
|
||||||
|
line = "{";
|
||||||
|
segments = body[i].Trim().Split('\t');
|
||||||
|
if (segments.Length != columns.Length)
|
||||||
|
break;
|
||||||
|
for (int c = 1; c < segments.Length; c++)
|
||||||
|
{
|
||||||
|
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
|
||||||
|
line += '"' + columns[c].Trim('"') + '"' + ':' + '"' + value + '"' + ',';
|
||||||
|
}
|
||||||
|
line = line.Substring(0, line.Length - 1) + '}' + ',' + '\n';
|
||||||
|
result += line;
|
||||||
|
}
|
||||||
|
result = result.Substring(0, result.Length - 1) + ']';
|
||||||
|
return result;
|
||||||
|
#pragma warning restore CA1845, IDE0057
|
||||||
|
}
|
||||||
|
|
||||||
private void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, ProcessDataStandardFormat processDataStandardFormat, List<pcl.Description> descriptions, Test[] tests)
|
private void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, ProcessDataStandardFormat processDataStandardFormat, List<pcl.Description> descriptions, Test[] tests)
|
||||||
{
|
{
|
||||||
bool isDummyRun = false;
|
bool isDummyRun = false;
|
||||||
@ -262,29 +290,28 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
if (!string.IsNullOrEmpty(lines))
|
if (!string.IsNullOrEmpty(lines))
|
||||||
{
|
{
|
||||||
_LastIndex += 1;
|
_LastIndex += 1;
|
||||||
long? subgroupId;
|
long? subGroupId;
|
||||||
if (_LastIndex >= _IQSCopyCollection.Count)
|
if (_LastIndex >= _IQSCopyCollection.Count)
|
||||||
_LastIndex = 0;
|
_LastIndex = 0;
|
||||||
long breakAfter = dateTime.AddSeconds(_BreakAfterSeconds).Ticks;
|
long breakAfter = dateTime.AddSeconds(_BreakAfterSeconds).Ticks;
|
||||||
ModelObjectParameterDefinition modelObjectParameterDefinition = _IQSCopyCollection[_LastIndex];
|
ModelObjectParameterDefinition modelObjectParameterDefinition = _IQSCopyCollection[_LastIndex];
|
||||||
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<WS.Results> wsResults))
|
if (_StaticRuns.TryGetValue(_Logistics.Sequence, out List<string> values))
|
||||||
{
|
{
|
||||||
if (wsResults is null || wsResults.Count != 1)
|
if (values.Count != 1)
|
||||||
throw new NullReferenceException($"{nameof(wsResults)} {wsResults?.Count} != 1 {_Logistics.Sequence}!");
|
throw new Exception($"{nameof(_StaticRuns)} {values.Count} != 1 {_Logistics.Sequence}!");
|
||||||
lock (_StaticRuns)
|
values[0] = $"{values[0]}|{subGroupId}";
|
||||||
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);
|
||||||
try
|
try
|
||||||
{ FromIQS.SaveCopy(_FileConnectorConfiguration.SourceFileLocation, _IqsConnectionString, modelObjectParameterDefinition.Name, modelObjectParameterDefinition.Value.Split('|')); }
|
{ FromIQS.SaveCopy(_FileConnectorConfiguration.SourceFileLocation, _IqsConnectionString, modelObjectParameterDefinition.Name, modelObjectParameterDefinition.Value.Split('|')); }
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
@ -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<WS.Results>> 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<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)
|
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 is null || !wsResults.Success.Value)
|
if (!wsResults.Success)
|
||||||
throw new Exception(jsonResults);
|
throw new Exception(wsResults.ToString());
|
||||||
_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(wsResults);
|
_StaticRuns[_Logistics.Sequence].Add(jsonResults);
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
|
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
|
||||||
|
|
||||||
@ -290,32 +291,31 @@ public class WSRequest
|
|||||||
pdDocument.close();
|
pdDocument.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string openInsightMetrologyViewerFileShare, int weekOfYear, WS.Results results, List<pcl.Description> descriptions)
|
internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string openInsightMetrologyViewerFileShare, int weekOfYear, string json, List<pcl.Description> descriptions)
|
||||||
{
|
{
|
||||||
long result;
|
long result;
|
||||||
if (results is not null && results.HeaderId is not null)
|
if (string.IsNullOrEmpty(json))
|
||||||
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}");
|
||||||
(_, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, logistics.Sequence, directory, wsRequest);
|
(json, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, logistics.Sequence, directory, wsRequest);
|
||||||
if (wsResults.Success is null || !wsResults.Success.Value)
|
if (!wsResults.Success)
|
||||||
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<pcl.Description> descriptions, string matchDirectory, WS.Results results, string headerIdDirectory)
|
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
|
#pragma warning restore IDE0060
|
||||||
{
|
{
|
||||||
string checkFileName;
|
string checkFileName;
|
||||||
pcl.Description description;
|
pcl.Description description;
|
||||||
string[] pclFiles = Directory.GetFiles(matchDirectory, "*.pcl", SearchOption.TopDirectoryOnly);
|
string[] pclFiles = Directory.GetFiles(matchDirectory, "*.pcl", SearchOption.TopDirectoryOnly);
|
||||||
if (pclFiles.Length != 1)
|
if (pclFiles.Length != 1)
|
||||||
throw new Exception($"Invalid source file count for <{results.HeaderId}>!");
|
throw new Exception($"Invalid source file count for <{headerId}>!");
|
||||||
string sourceFileNameNoExt = Path.GetFileNameWithoutExtension(pclFiles[0]);
|
string sourceFileNameNoExt = Path.GetFileNameWithoutExtension(pclFiles[0]);
|
||||||
List<WS.Attachment> dataAttachments = new();
|
List<WS.Attachment> dataAttachments = new();
|
||||||
List<WS.Attachment> headerAttachments = new();
|
List<WS.Attachment> headerAttachments = new();
|
||||||
@ -325,19 +325,19 @@ public class WSRequest
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateDataPDF(descriptions, checkFileName);
|
UpdateDataPDF(descriptions, checkFileName);
|
||||||
headerAttachments.Add(new WS.Attachment(results, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}", "Data.pdf", checkFileName));
|
headerAttachments.Add(new WS.Attachment(subGroupId, headerId, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}", "Data.pdf", checkFileName));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < descriptions.Count; i++)
|
for (int i = 0; i < descriptions.Count; i++)
|
||||||
{
|
{
|
||||||
description = descriptions[i];
|
description = descriptions[i];
|
||||||
checkFileName = Path.Combine(matchDirectory, $"{sourceFileNameNoExt}_s{description.Slot}_image.pdf");
|
checkFileName = Path.Combine(matchDirectory, $"{sourceFileNameNoExt}_s{description.Slot}_image.pdf");
|
||||||
if (File.Exists(checkFileName))
|
if (File.Exists(checkFileName))
|
||||||
dataAttachments.Add(new WS.Attachment(results, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}_Item-{i + 1}", "Image.pdf", checkFileName));
|
dataAttachments.Add(new WS.Attachment(subGroupId, headerId, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}_Item-{i + 1}", "Image.pdf", checkFileName));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
checkFileName = Path.Combine(matchDirectory, $"{sourceFileNameNoExt}_s{description.Slot}_data.pdf");
|
checkFileName = Path.Combine(matchDirectory, $"{sourceFileNameNoExt}_s{description.Slot}_data.pdf");
|
||||||
if (File.Exists(checkFileName))
|
if (File.Exists(checkFileName))
|
||||||
dataAttachments.Add(new WS.Attachment(results, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}_Item-{i + 1}", "Image.pdf", checkFileName));
|
dataAttachments.Add(new WS.Attachment(subGroupId, headerId, headerIdDirectory, $"{logistics.JobID}_{logistics.MID}_{logistics.DateTimeFromSequence:yyyyMMddHHmmssffff}_Item-{i + 1}", "Image.pdf", checkFileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dataAttachments.Count == 0 || dataAttachments.Count != descriptions.Count)
|
if (dataAttachments.Count == 0 || dataAttachments.Count != descriptions.Count)
|
||||||
|
@ -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<Shared.Metrology.WS.Results>> 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<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)
|
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,25 +137,30 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
|
|
||||||
private void PostOpenInsightMetrologyViewerAttachments(List<pcl.Description> descriptions)
|
private void PostOpenInsightMetrologyViewerAttachments(List<pcl.Description> descriptions)
|
||||||
{
|
{
|
||||||
Shared.Metrology.WS.Results? results;
|
string? json;
|
||||||
|
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<Shared.Metrology.WS.Results>? wsResults))
|
if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List<string>? values))
|
||||||
results = null;
|
(json, subGroupId) = (null, null);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (wsResults is null || wsResults.Count != 1)
|
if (values.Count != 1)
|
||||||
throw new NullReferenceException($"{nameof(wsResults)} {wsResults?.Count} != 1 {_Logistics.Sequence}!");
|
throw new Exception($"{nameof(_StaticRuns)} {values.Count} != 1 {_Logistics.Sequence}!");
|
||||||
results = wsResults[0];
|
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);
|
||||||
}
|
}
|
||||||
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, results, descriptions);
|
long headerId = !_IsEAFHosted ? -1 : OpenInsightMetrologyViewer.WSRequest.GetHeaderId(this, _Logistics, _OpenInsightMetrologyViewerAPI, _OpenInsightMetrologyViewerFileShare, weekOfYear, json, 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], results, headerIdDirectory);
|
OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, descriptions, matchDirectories[0], subGroupId, headerId, 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<Shared.Metrology.WS.Results>> 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<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)
|
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,8 +135,6 @@ 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)
|
||||||
|
@ -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<Shared.Metrology.WS.Results>> 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<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)
|
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 _GhostPCLFileName;
|
private readonly string _GhostPCLFileName;
|
||||||
private readonly string _PDFTextStripperFileName;
|
private readonly string _PDFTextStripperFileName;
|
||||||
|
|
||||||
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) :
|
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(), 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 = 15;
|
_MinFileLength = 15;
|
||||||
|
@ -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<Metrology.WS.Results>> 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<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted)
|
||||||
{
|
{
|
||||||
_SMTP = smtp;
|
_SMTP = smtp;
|
||||||
_IsEvent = isEvent;
|
_IsEvent = isEvent;
|
||||||
@ -377,25 +377,17 @@ public class FileRead : Properties.IFileRead
|
|||||||
|
|
||||||
internal string[] GetInProcessDirectory(string jobIdDirectory)
|
internal string[] GetInProcessDirectory(string jobIdDirectory)
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
string[] results;
|
||||||
if (!_IsEAFHosted)
|
if (!_IsEAFHosted)
|
||||||
results = new string[] { jobIdDirectory }.ToList();
|
results = new string[] { jobIdDirectory };
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string[] files;
|
|
||||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||||
string[] directories = Directory.GetDirectories(jobIdDirectory, $"*{logisticsSequence}*", SearchOption.TopDirectoryOnly);
|
results = 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.Count != 1)
|
if ((results is null) || results.Length != 1)
|
||||||
throw new Exception("Didn't find directory by logistics sequence");
|
throw new Exception("Didn't find directory by logistics sequence");
|
||||||
return results.ToArray();
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static string[] GetMatches(FileConnectorConfiguration fileConnectorConfiguration)
|
protected static string[] GetMatches(FileConnectorConfiguration fileConnectorConfiguration)
|
||||||
@ -624,9 +616,6 @@ 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,25 +6,23 @@ public partial class WS
|
|||||||
public class Attachment
|
public class Attachment
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
public long HeaderId { get; set; }
|
|
||||||
public string UniqueId { get; set; }
|
|
||||||
public string SubGroupId { get; set; }
|
public string SubGroupId { get; set; }
|
||||||
public string AttachmentId { get; set; }
|
public long HeaderId { get; set; }
|
||||||
public string SourceFileName { get; set; }
|
|
||||||
public string HeaderIdDirectory { get; set; }
|
public string HeaderIdDirectory { get; set; }
|
||||||
|
public string UniqueId { get; set; }
|
||||||
public string DestinationFileName { get; set; }
|
public string DestinationFileName { get; set; }
|
||||||
|
public string SourceFileName { get; set; }
|
||||||
|
public string AttachmentId { get; set; }
|
||||||
|
|
||||||
public Attachment(Results? results, string headerIdDirectory, string uniqueId, string destinationFileName, string sourceFileName)
|
public Attachment(string subGroupId, long headerId, string headerIdDirectory, string uniqueId, string destinationFileName, string sourceFileName)
|
||||||
{
|
{
|
||||||
UniqueId = uniqueId;
|
SubGroupId = subGroupId;
|
||||||
SourceFileName = sourceFileName;
|
HeaderId = headerId;
|
||||||
HeaderIdDirectory = headerIdDirectory;
|
HeaderIdDirectory = headerIdDirectory;
|
||||||
|
UniqueId = uniqueId;
|
||||||
DestinationFileName = destinationFileName;
|
DestinationFileName = destinationFileName;
|
||||||
|
SourceFileName = sourceFileName;
|
||||||
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,75 +1,27 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
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; }
|
||||||
|
|
||||||
#nullable enable
|
// if true, contains ID of the Header record in the database
|
||||||
|
public long HeaderID { get; set; }
|
||||||
|
|
||||||
[JsonConstructor]
|
// if false, this collection will contain a list of errors
|
||||||
public Results(List<string>? errors,
|
public List<string> Errors { get; set; }
|
||||||
long? headerId,
|
|
||||||
long? subgroupId,
|
|
||||||
bool? success,
|
|
||||||
List<string>? warnings)
|
|
||||||
{
|
|
||||||
Errors = errors;
|
|
||||||
Success = success;
|
|
||||||
HeaderId = headerId;
|
|
||||||
Warnings = warnings;
|
|
||||||
SubgroupId = subgroupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonPropertyName("errors")] public List<string>? Errors { get; set; }
|
// this collection will contain a list of warnings, they will not prevent data from being saved
|
||||||
[JsonPropertyName("headerID")] public long? HeaderId { get; set; }
|
public List<string> Warnings { 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,11 +10,9 @@ 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? wsResults = null;
|
Results results = new();
|
||||||
string resultsJson = string.Empty;
|
string resultsJson = string.Empty;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -32,20 +30,29 @@ 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;
|
||||||
wsResults = JsonSerializer.Deserialize(resultsJson, ResultsSourceGenerationContext.Default.Results);
|
results = JsonSerializer.Deserialize<Results>(resultsJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||||
if (wsResults is null)
|
string checkDirectory = Path.Combine(directory, $"-{results.HeaderID}");
|
||||||
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 (wsResults.Success is null || !wsResults.Success.Value)
|
if (!results.Success)
|
||||||
wsResults.Errors?.Add(wsResults.ToString());
|
results.Errors.Add(results.ToString());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{ wsResults ??= Results.Get(resultsJson, e); }
|
{
|
||||||
return new(resultsJson, wsResults);
|
Exception exception = e;
|
||||||
|
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)
|
||||||
@ -62,20 +69,16 @@ 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)
|
||||||
{
|
{
|
||||||
directoryName = Path.GetDirectoryName(attachment.HeaderIdDirectory);
|
directory = Path.Combine(Path.GetDirectoryName(attachment.HeaderIdDirectory), attachment.AttachmentId) ?? throw new Exception();
|
||||||
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);
|
||||||
@ -85,10 +88,7 @@ public partial class WS
|
|||||||
{
|
{
|
||||||
foreach (Attachment attachment in dataAttachments)
|
foreach (Attachment attachment in dataAttachments)
|
||||||
{
|
{
|
||||||
directoryName = Path.GetDirectoryName(attachment.HeaderIdDirectory.Replace("Header", "Data"));
|
directory = Path.Combine(Path.GetDirectoryName(attachment.HeaderIdDirectory.Replace("Header", "Data")), attachment.AttachmentId) ?? throw new Exception();
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -26,25 +26,19 @@ internal class ProcessDataStandardFormat
|
|||||||
|
|
||||||
internal long? Sequence { get; private set; }
|
internal long? Sequence { get; private set; }
|
||||||
internal ReadOnlyCollection<string> Body { get; private set; }
|
internal ReadOnlyCollection<string> Body { get; private set; }
|
||||||
internal ReadOnlyCollection<string> Footer { get; private set; }
|
|
||||||
internal ReadOnlyCollection<string> Header { get; private set; }
|
|
||||||
internal ReadOnlyCollection<string> Columns { get; private set; }
|
internal ReadOnlyCollection<string> Columns { get; private set; }
|
||||||
internal ProcessDataStandardFormat? InputPDSF { get; private set; }
|
|
||||||
internal ReadOnlyCollection<string> Logistics { get; private set; }
|
internal ReadOnlyCollection<string> Logistics { get; private set; }
|
||||||
|
internal ReadOnlyCollection<string> InputLines { get; private set; }
|
||||||
|
|
||||||
internal ProcessDataStandardFormat(ReadOnlyCollection<string> body,
|
internal ProcessDataStandardFormat(ReadOnlyCollection<string> body,
|
||||||
ReadOnlyCollection<string> columns,
|
ReadOnlyCollection<string> columns,
|
||||||
ReadOnlyCollection<string> footer,
|
ReadOnlyCollection<string> inputLines,
|
||||||
ReadOnlyCollection<string> header,
|
|
||||||
ProcessDataStandardFormat? inputPDSF,
|
|
||||||
ReadOnlyCollection<string> logistics,
|
ReadOnlyCollection<string> logistics,
|
||||||
long? sequence)
|
long? sequence)
|
||||||
{
|
{
|
||||||
Body = body;
|
Body = body;
|
||||||
Columns = columns;
|
Columns = columns;
|
||||||
Footer = footer;
|
InputLines = inputLines;
|
||||||
Header = header;
|
|
||||||
InputPDSF = inputPDSF;
|
|
||||||
Logistics = logistics;
|
Logistics = logistics;
|
||||||
Sequence = sequence;
|
Sequence = sequence;
|
||||||
}
|
}
|
||||||
@ -61,8 +55,8 @@ internal class ProcessDataStandardFormat
|
|||||||
internal static string Archive(bool addSpaces = true, char separator = ' ') =>
|
internal static string Archive(bool addSpaces = true, char separator = ' ') =>
|
||||||
GetString(SearchFor.Archive, addSpaces, separator);
|
GetString(SearchFor.Archive, addSpaces, separator);
|
||||||
|
|
||||||
internal static ProcessDataStandardFormat GetEmpty(Logistics logistics) =>
|
internal static ProcessDataStandardFormat GetEmpty() =>
|
||||||
new(new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), null, new(logistics.Logistics1), null);
|
new(new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), null);
|
||||||
|
|
||||||
internal static List<string> PDSFToFixedWidth(string reportFullPath)
|
internal static List<string> PDSFToFixedWidth(string reportFullPath)
|
||||||
{
|
{
|
||||||
@ -133,26 +127,19 @@ internal class ProcessDataStandardFormat
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ProcessDataStandardFormat GetProcessDataStandardFormat(string reportFullPath, string[]? lines = null, int columnsLine = 6)
|
internal static ProcessDataStandardFormat GetProcessDataStandardFormat(string reportFullPath, string[]? lines = null)
|
||||||
{
|
{
|
||||||
ProcessDataStandardFormat result;
|
ProcessDataStandardFormat result;
|
||||||
string segment;
|
string segment;
|
||||||
string[] segments;
|
|
||||||
bool addToFooter = false;
|
|
||||||
List<string> body = new();
|
List<string> body = new();
|
||||||
List<string> header = new();
|
List<string> logistics = new();
|
||||||
List<string> footer = new();
|
|
||||||
List<string> columns = new();
|
|
||||||
ReadOnlyCollection<string> logistics;
|
|
||||||
lines ??= File.ReadAllLines(reportFullPath);
|
lines ??= File.ReadAllLines(reportFullPath);
|
||||||
if (lines.Length < columnsLine + 1)
|
string[] segments;
|
||||||
|
if (lines.Length < 7)
|
||||||
segments = Array.Empty<string>();
|
segments = Array.Empty<string>();
|
||||||
else
|
else
|
||||||
{
|
segments = lines[6].Trim().Split('\t');
|
||||||
segments = lines[columnsLine].Trim().Split('\t');
|
List<string> columns = new();
|
||||||
for (int i = 0; i < columnsLine; i++)
|
|
||||||
header.Add(lines[i]);
|
|
||||||
}
|
|
||||||
for (int c = 0; c < segments.Length; c++)
|
for (int c = 0; c < segments.Length; c++)
|
||||||
{
|
{
|
||||||
segment = segments[c].Substring(1, segments[c].Length - 2);
|
segment = segments[c].Substring(1, segments[c].Length - 2);
|
||||||
@ -171,102 +158,93 @@ internal class ProcessDataStandardFormat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int r = columnsLine + 1; r < lines.Length; r++)
|
bool lookForLogistics = false;
|
||||||
|
for (int r = 7; r < lines.Length; r++)
|
||||||
{
|
{
|
||||||
if (lines[r].StartsWith("NUM_DATA_ROWS"))
|
if (lines[r].StartsWith("NUM_DATA_ROWS"))
|
||||||
addToFooter = true;
|
lookForLogistics = true;
|
||||||
if (!addToFooter)
|
if (!lookForLogistics)
|
||||||
body.Add(lines[r]);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
footer.Add(lines[r]);
|
body.Add(lines[r]);
|
||||||
if (lines[r].StartsWith("END_HEADER"))
|
continue;
|
||||||
break;
|
}
|
||||||
|
if (lines[r].StartsWith("LOGISTICS_1"))
|
||||||
|
{
|
||||||
|
for (int i = r; i < lines.Length; i++)
|
||||||
|
{
|
||||||
|
if (!lines[i].StartsWith("LOGISTICS_") || lines[i].StartsWith("END_HEADER"))
|
||||||
|
break;
|
||||||
|
logistics.Add(lines[i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string? linesOne = lines.Length > 0 && body.Count == 0 && columns.Count == 0 ? lines[1] : null;
|
if (lines.Length > 0 && body.Count == 0 && columns.Count == 0 && logistics.Count == 0)
|
||||||
logistics = GetLogistics(footer, linesOne: linesOne);
|
logistics.Add(lines[1]);
|
||||||
result = new(body: body.AsReadOnly(),
|
result = new(body: body.AsReadOnly(),
|
||||||
columns: columns.AsReadOnly(),
|
columns: columns.AsReadOnly(),
|
||||||
footer: footer.AsReadOnly(),
|
inputLines: lines.ToList().AsReadOnly(),
|
||||||
header: header.AsReadOnly(),
|
logistics: logistics.AsReadOnly(),
|
||||||
inputPDSF: null,
|
|
||||||
logistics: logistics,
|
|
||||||
sequence: null);
|
sequence: null);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<string> GetLogistics(List<string> footer, string? linesOne)
|
internal static ProcessDataStandardFormat? GetProcessDataStandardFormat(string reportFullPath, ProcessDataStandardFormatMapping pdsfMapping)
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
ProcessDataStandardFormat? result;
|
||||||
bool foundLogistics1 = false;
|
|
||||||
foreach (string line in footer)
|
|
||||||
{
|
|
||||||
if (line.StartsWith("END_HEADER"))
|
|
||||||
break;
|
|
||||||
if (line.StartsWith("LOGISTICS_1"))
|
|
||||||
foundLogistics1 = true;
|
|
||||||
if (foundLogistics1 && line.StartsWith("LOGISTICS_"))
|
|
||||||
results.Add(line);
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(linesOne) && results.Count == 0)
|
|
||||||
results.Add(linesOne);
|
|
||||||
return results.AsReadOnly();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static ProcessDataStandardFormat GetProcessDataStandardFormat(string reportFullPath, ProcessDataStandardFormatMapping pdsfMapping)
|
|
||||||
{
|
|
||||||
ProcessDataStandardFormat result;
|
|
||||||
const int columnsLine = 6;
|
const int columnsLine = 6;
|
||||||
FileInfo fileInfo = new(reportFullPath);
|
FileInfo fileInfo = new(reportFullPath);
|
||||||
ProcessDataStandardFormat processDataStandardFormat = GetProcessDataStandardFormat(fileInfo.LastWriteTime, columnsLine, fileInfo.FullName, lines: null);
|
ProcessDataStandardFormat processDataStandardFormat = GetProcessDataStandardFormat(fileInfo.LastWriteTime, pdsfMapping.NewColumnNames.Count, columnsLine, fileInfo.FullName, lines: null);
|
||||||
JsonElement[]? jsonElements = pdsfMapping.OldColumnNames.Count != pdsfMapping.ColumnIndices.Count ? null : GetFullArray(processDataStandardFormat);
|
JsonElement[]? jsonElements = GetArray(pdsfMapping.NewColumnNames.Count, processDataStandardFormat, lookForNumbers: false);
|
||||||
JsonProperty[]? jsonProperties = jsonElements is null || jsonElements.Length == 0 ? null : jsonElements[0].EnumerateObject().ToArray();
|
if (jsonElements is null || pdsfMapping.OldColumnNames.Count != pdsfMapping.ColumnIndices.Count)
|
||||||
if (jsonElements is null || jsonProperties is null || jsonProperties.Length != pdsfMapping.NewColumnNames.Count)
|
result = null;
|
||||||
result = processDataStandardFormat;
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = GetProcessDataStandardFormat(pdsfMapping, jsonElements, processDataStandardFormat);
|
result = GetProcessDataStandardFormat(pdsfMapping, jsonElements, processDataStandardFormat);
|
||||||
if (result.Sequence is null || result.Columns.Count == 0 || result.Body.Count == 0 || result.Logistics.Count == 0)
|
if (result.Sequence is null || result.Columns.Count == 0 || result.Body.Count == 0 || result.Logistics.Count == 0)
|
||||||
result = processDataStandardFormat;
|
result = null;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ProcessDataStandardFormat GetProcessDataStandardFormat(DateTime lastWriteTime, int columnsLine, string path, string[]? lines)
|
private static ProcessDataStandardFormat GetProcessDataStandardFormat(DateTime lastWriteTime, int expectedColumns, int columnsLine, string path, string[]? lines)
|
||||||
{
|
{
|
||||||
ProcessDataStandardFormat result;
|
ProcessDataStandardFormat result;
|
||||||
long sequence;
|
long sequence;
|
||||||
string[] segments;
|
string[] segments;
|
||||||
bool addToFooter = false;
|
|
||||||
List<string> body = new();
|
List<string> body = new();
|
||||||
List<string> header = new();
|
bool lookForLogistics = false;
|
||||||
List<string> footer = new();
|
List<string> logistics = new();
|
||||||
ReadOnlyCollection<string> logistics;
|
|
||||||
lines ??= File.ReadAllLines(path);
|
lines ??= File.ReadAllLines(path);
|
||||||
if (lines.Length <= columnsLine)
|
if (lines.Length <= columnsLine)
|
||||||
segments = Array.Empty<string>();
|
segments = Array.Empty<string>();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
segments = lines[columnsLine].Split('\t');
|
segments = lines[columnsLine].Split('\t');
|
||||||
for (int i = 0; i < columnsLine; i++)
|
if (segments.Length != expectedColumns)
|
||||||
header.Add(lines[i]);
|
segments = Array.Empty<string>();
|
||||||
}
|
}
|
||||||
string[] columns = segments.Select(l => l.Trim('"')).ToArray();
|
string[] columns = segments.Select(l => l.Trim('"')).ToArray();
|
||||||
for (int r = columnsLine + 1; r < lines.Length; r++)
|
for (int r = columnsLine + 1; r < lines.Length; r++)
|
||||||
{
|
{
|
||||||
if (lines[r].StartsWith("NUM_DATA_ROWS"))
|
if (lines[r].StartsWith("NUM_DATA_ROWS"))
|
||||||
addToFooter = true;
|
lookForLogistics = true;
|
||||||
if (!addToFooter)
|
if (!lookForLogistics)
|
||||||
body.Add(lines[r]);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
footer.Add(lines[r]);
|
body.Add(lines[r]);
|
||||||
if (lines[r].StartsWith("END_HEADER"))
|
continue;
|
||||||
break;
|
}
|
||||||
|
if (lines[r].StartsWith("LOGISTICS_1"))
|
||||||
|
{
|
||||||
|
for (int i = r; i < lines.Length; i++)
|
||||||
|
{
|
||||||
|
if (!lines[i].StartsWith("LOGISTICS_") || lines[i].StartsWith("END_HEADER"))
|
||||||
|
break;
|
||||||
|
logistics.Add(lines[i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logistics = GetLogistics(footer, linesOne: null);
|
|
||||||
if (logistics.Count == 0)
|
if (logistics.Count == 0)
|
||||||
sequence = lastWriteTime.Ticks;
|
sequence = lastWriteTime.Ticks;
|
||||||
else
|
else
|
||||||
@ -276,15 +254,13 @@ internal class ProcessDataStandardFormat
|
|||||||
}
|
}
|
||||||
result = new(body: body.AsReadOnly(),
|
result = new(body: body.AsReadOnly(),
|
||||||
columns: new(columns),
|
columns: new(columns),
|
||||||
footer: footer.AsReadOnly(),
|
inputLines: lines.ToList().AsReadOnly(),
|
||||||
header: header.AsReadOnly(),
|
logistics: logistics.AsReadOnly(),
|
||||||
inputPDSF: null,
|
|
||||||
logistics: logistics,
|
|
||||||
sequence: sequence);
|
sequence: sequence);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JsonElement[]? GetFullArray(ProcessDataStandardFormat processDataStandardFormat)
|
private static JsonElement[]? GetArray(int expectedColumns, ProcessDataStandardFormat processDataStandardFormat, bool lookForNumbers)
|
||||||
{
|
{
|
||||||
JsonElement[]? results;
|
JsonElement[]? results;
|
||||||
if (processDataStandardFormat.Body.Count == 0 || !processDataStandardFormat.Body[0].Contains('\t'))
|
if (processDataStandardFormat.Body.Count == 0 || !processDataStandardFormat.Body[0].Contains('\t'))
|
||||||
@ -292,18 +268,36 @@ internal class ProcessDataStandardFormat
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string value;
|
string value;
|
||||||
List<string> segments;
|
string[] segments;
|
||||||
List<string> lines = new();
|
List<string> lines = new();
|
||||||
StringBuilder stringBuilder = new();
|
StringBuilder stringBuilder = new();
|
||||||
foreach (string bodyLine in processDataStandardFormat.Body)
|
foreach (string bodyLine in processDataStandardFormat.Body)
|
||||||
{
|
{
|
||||||
_ = stringBuilder.Clear();
|
_ = stringBuilder.Clear();
|
||||||
_ = stringBuilder.Append('{');
|
_ = stringBuilder.Append('{');
|
||||||
segments = bodyLine.Split('\t').ToList();
|
segments = bodyLine.Split('\t');
|
||||||
for (int c = 0; c < segments.Count; c++)
|
if (segments.Length != expectedColumns)
|
||||||
|
continue;
|
||||||
|
if (!lookForNumbers)
|
||||||
{
|
{
|
||||||
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
|
for (int c = 0; c < segments.Length; c++)
|
||||||
_ = stringBuilder.Append('"').Append(processDataStandardFormat.Columns[c]).Append("\":\"").Append(value).Append("\",");
|
{
|
||||||
|
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
|
||||||
|
_ = stringBuilder.Append('"').Append(processDataStandardFormat.Columns[c]).Append("\":\"").Append(value).Append("\",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int c = 0; c < segments.Length; c++)
|
||||||
|
{
|
||||||
|
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
_ = stringBuilder.Append('"').Append(processDataStandardFormat.Columns[c]).Append("\":").Append(value).Append("null,");
|
||||||
|
else if (value.All(char.IsDigit))
|
||||||
|
_ = stringBuilder.Append('"').Append(processDataStandardFormat.Columns[c]).Append("\":").Append(value).Append(',');
|
||||||
|
else
|
||||||
|
_ = stringBuilder.Append('"').Append(processDataStandardFormat.Columns[c]).Append("\":\"").Append(value).Append("\",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
|
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
|
||||||
_ = stringBuilder.AppendLine("}");
|
_ = stringBuilder.AppendLine("}");
|
||||||
@ -352,72 +346,13 @@ internal class ProcessDataStandardFormat
|
|||||||
}
|
}
|
||||||
result = new(body: new(results),
|
result = new(body: new(results),
|
||||||
columns: processDataStandardFormatMapping.OldColumnNames,
|
columns: processDataStandardFormatMapping.OldColumnNames,
|
||||||
footer: processDataStandardFormat.Footer,
|
inputLines: processDataStandardFormat.InputLines,
|
||||||
header: processDataStandardFormat.Header,
|
|
||||||
inputPDSF: processDataStandardFormat,
|
|
||||||
logistics: processDataStandardFormat.Logistics,
|
logistics: processDataStandardFormat.Logistics,
|
||||||
sequence: processDataStandardFormat.Sequence);
|
sequence: processDataStandardFormat.Sequence);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetJson(ProcessDataStandardFormat processDataStandardFormat)
|
internal static void Write(string path, ProcessDataStandardFormat processDataStandardFormat)
|
||||||
{
|
|
||||||
if (processDataStandardFormat.InputPDSF is null)
|
|
||||||
throw new NullReferenceException(nameof(processDataStandardFormat.InputPDSF));
|
|
||||||
#pragma warning disable CA1845, IDE0057
|
|
||||||
string result;
|
|
||||||
string line;
|
|
||||||
string value;
|
|
||||||
string[] segments;
|
|
||||||
List<string> lines = new();
|
|
||||||
for (int i = 0; i < processDataStandardFormat.InputPDSF.Body.Count; i++)
|
|
||||||
{
|
|
||||||
line = "{";
|
|
||||||
segments = processDataStandardFormat.InputPDSF.Body[i].Trim().Split('\t');
|
|
||||||
if (segments.Length != processDataStandardFormat.InputPDSF.Columns.Count)
|
|
||||||
break;
|
|
||||||
for (int c = 0; c < segments.Length; c++)
|
|
||||||
{
|
|
||||||
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
|
|
||||||
line += string.Concat('"', processDataStandardFormat.InputPDSF.Columns[c].Trim('"'), '"', ':', '"', value, '"', ',');
|
|
||||||
}
|
|
||||||
line = string.Concat(line.Substring(0, line.Length - 1), '}');
|
|
||||||
lines.Add(line);
|
|
||||||
}
|
|
||||||
result = string.Concat(
|
|
||||||
'{',
|
|
||||||
Environment.NewLine,
|
|
||||||
'"',
|
|
||||||
"Count",
|
|
||||||
'"',
|
|
||||||
": ",
|
|
||||||
processDataStandardFormat.Body.Count,
|
|
||||||
',',
|
|
||||||
Environment.NewLine,
|
|
||||||
'"',
|
|
||||||
"Records",
|
|
||||||
'"',
|
|
||||||
": ",
|
|
||||||
Environment.NewLine,
|
|
||||||
'[',
|
|
||||||
Environment.NewLine,
|
|
||||||
string.Join($",{Environment.NewLine}", lines),
|
|
||||||
Environment.NewLine,
|
|
||||||
']',
|
|
||||||
',',
|
|
||||||
Environment.NewLine,
|
|
||||||
'"',
|
|
||||||
"Sequence",
|
|
||||||
'"',
|
|
||||||
": ",
|
|
||||||
processDataStandardFormat.Sequence,
|
|
||||||
Environment.NewLine,
|
|
||||||
'}');
|
|
||||||
return result;
|
|
||||||
#pragma warning restore CA1845, IDE0057
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
@ -442,39 +377,9 @@ 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");
|
||||||
if (wsResults is null || wsResults.Count != 1)
|
results.AddRange(processDataStandardFormat.Logistics);
|
||||||
results.AddRange(processDataStandardFormat.Logistics);
|
results.Add("EOF");
|
||||||
else
|
results.AddRange(processDataStandardFormat.InputLines.Select(l => l.Replace('\t', '|')));
|
||||||
{
|
|
||||||
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("END_HEADER");
|
|
||||||
if (processDataStandardFormat.InputPDSF is not null)
|
|
||||||
{
|
|
||||||
results.Add(string.Empty);
|
|
||||||
List<char> hyphens = new();
|
|
||||||
results.AddRange(processDataStandardFormat.InputPDSF.Header.Select(l => l.Replace('\t', '|')));
|
|
||||||
results.Add($"|{string.Join("|", processDataStandardFormat.InputPDSF.Columns)}|");
|
|
||||||
for (int i = 0; i < processDataStandardFormat.InputPDSF.Columns.Count; i++)
|
|
||||||
hyphens.Add('-');
|
|
||||||
results.Add($"|{string.Join("|", hyphens)}|");
|
|
||||||
results.AddRange(processDataStandardFormat.InputPDSF.Body.Select(l => l.Replace('\t', '|')));
|
|
||||||
results.Add(string.Empty);
|
|
||||||
results.AddRange(processDataStandardFormat.InputPDSF.Footer.Select(l => l.Replace('\t', '|')));
|
|
||||||
results.Add(string.Empty);
|
|
||||||
results.Add("EOF");
|
|
||||||
results.Add(string.Empty);
|
|
||||||
string json = GetJson(processDataStandardFormat);
|
|
||||||
results.Add(json);
|
|
||||||
}
|
|
||||||
File.WriteAllText(path, string.Join(Environment.NewLine, results));
|
File.WriteAllText(path, string.Join(Environment.NewLine, results));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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<Adaptation.Shared.Metrology.WS.Results>> staticRuns = new();
|
Dictionary<long, List<string>> 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);
|
||||||
@ -1182,7 +1182,7 @@ public class AdaptationTesting : ISMTP
|
|||||||
Assert.IsNotNull(extractResult.Item3);
|
Assert.IsNotNull(extractResult.Item3);
|
||||||
Assert.IsNotNull(extractResult.Item4);
|
Assert.IsNotNull(extractResult.Item4);
|
||||||
if (!validatePDSF)
|
if (!validatePDSF)
|
||||||
_ = GetProcessDataStandardFormat(fileRead, logistics, extractResult, ProcessDataStandardFormat.GetEmpty(logistics));
|
_ = GetProcessDataStandardFormat(fileRead, logistics, extractResult, ProcessDataStandardFormat.GetEmpty());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
|
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
|
||||||
|
@ -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<Adaptation.Shared.Metrology.WS.Results>> _StaticRuns;
|
private static readonly Dictionary<long, List<string>> _StaticRuns;
|
||||||
|
|
||||||
static FileRead()
|
static FileRead()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user