R61 and R65
json in process-data-standard-format process-data-standard-format with HeaderId and SubgroupId process-data-standard-format with pipes UniqueId replacement for attachments Write input PDSF in output after EOF ProcessDataStandardFormat over Tuple MoveMatchingFiles to use ProcessDataStandardFormatMapping
This commit is contained in:
parent
3bb0f8a138
commit
6edfa1e813
@ -121,6 +121,7 @@ dotnet_diagnostic.IDE0290.severity = none # Use primary constructor [Distance]cs
|
|||||||
dotnet_diagnostic.IDE0300.severity = none # IDE0300: Collection initialization can be simplified
|
dotnet_diagnostic.IDE0300.severity = none # IDE0300: Collection initialization can be simplified
|
||||||
dotnet_diagnostic.IDE0301.severity = none #IDE0301: Collection initialization can be simplified
|
dotnet_diagnostic.IDE0301.severity = none #IDE0301: Collection initialization can be simplified
|
||||||
dotnet_diagnostic.IDE0305.severity = none # IDE0305: Collection initialization can be simplified
|
dotnet_diagnostic.IDE0305.severity = none # IDE0305: Collection initialization can be simplified
|
||||||
|
dotnet_diagnostic.MSTEST0037.severity = error # MSTEST0037: Use proper 'Assert' methods
|
||||||
dotnet_diagnostic.SYSLIB1045.severity = none # SYSLIB1045: diagnostics for regex source generation
|
dotnet_diagnostic.SYSLIB1045.severity = none # SYSLIB1045: diagnostics for regex source generation
|
||||||
dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning
|
dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning
|
||||||
dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case
|
dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case
|
||||||
|
20
Adaptation/.vscode/tasks.json
vendored
20
Adaptation/.vscode/tasks.json
vendored
@ -92,6 +92,26 @@
|
|||||||
"command": "code ../DEP08CEPIEPSILON.csproj",
|
"command": "code ../DEP08CEPIEPSILON.csproj",
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Readme",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "code ../README.md",
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "File-Folder-Helper AOT s X Day-Helper-2025-03-20",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe",
|
||||||
|
"args": [
|
||||||
|
"s",
|
||||||
|
"X",
|
||||||
|
"L:/DevOps/EAF-Mesa-Integration/DEP08CEPIEPSILON",
|
||||||
|
"Day-Helper-2025-03-20",
|
||||||
|
"false",
|
||||||
|
"4"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Git Config",
|
"label": "Git Config",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Infineon.Mesa.PDF.Text.Stripper" Version="4.8.0.1"><NoWarn>NU1701</NoWarn></PackageReference>
|
<PackageReference Include="Infineon.Mesa.PDF.Text.Stripper" Version="4.8.0.2"><NoWarn>NU1701</NoWarn></PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Infineon.Yoda.DotNetCore" Version="5.4.3" />
|
<PackageReference Include="Infineon.Yoda.DotNetCore" Version="5.4.3" />
|
||||||
|
@ -9,14 +9,16 @@ 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
|
||||||
{
|
{
|
||||||
nameof(R32) => new R32.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
nameof(R32) => new R32.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||||
nameof(R62) => new R62.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
|
||||||
nameof(R55) => new R55.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
nameof(R55) => new R55.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||||
nameof(R57) => new R57.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
nameof(R57) => new R57.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||||
|
nameof(R61) => new R61.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||||
|
nameof(R62) => new R62.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||||
|
nameof(R65) => new R65.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||||
nameof(R75) => new R75.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
nameof(R75) => new R75.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||||
nameof(R77) => new R77.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
nameof(R77) => new R77.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||||
nameof(Dummy) => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
nameof(Dummy) => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
|
||||||
|
@ -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;
|
||||||
|
@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _TimestampFormat;
|
private readonly string _TimestampFormat;
|
||||||
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
||||||
|
|
||||||
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;
|
||||||
@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
||||||
{
|
{
|
||||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
|
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
||||||
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
||||||
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
||||||
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||||
MoveFile(reportFullPath);
|
MoveFile(reportFullPath);
|
||||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List<FileInfo>());
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _TimestampFormat;
|
private readonly string _TimestampFormat;
|
||||||
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
||||||
|
|
||||||
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;
|
||||||
@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
||||||
{
|
{
|
||||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
|
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
||||||
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
||||||
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
||||||
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||||
MoveFile(reportFullPath);
|
MoveFile(reportFullPath);
|
||||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List<FileInfo>());
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _TimestampFormat;
|
private readonly string _TimestampFormat;
|
||||||
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
||||||
|
|
||||||
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;
|
||||||
@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
||||||
{
|
{
|
||||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
|
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
||||||
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
||||||
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
||||||
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||||
MoveFile(reportFullPath);
|
MoveFile(reportFullPath);
|
||||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List<FileInfo>());
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
238
Adaptation/FileHandlers/R61/FileRead.cs
Normal file
238
Adaptation/FileHandlers/R61/FileRead.cs
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||||
|
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||||
|
using Adaptation.Shared;
|
||||||
|
using Adaptation.Shared.Duplicator;
|
||||||
|
using Adaptation.Shared.Methods;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace Adaptation.FileHandlers.R61;
|
||||||
|
|
||||||
|
public class FileRead : Shared.FileRead, IFileRead
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly string _KeyColumn;
|
||||||
|
private readonly string _TimestampFormat;
|
||||||
|
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
||||||
|
|
||||||
|
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<Shared.Metrology.WS.Results>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
|
||||||
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
|
{
|
||||||
|
_MinFileLength = 10;
|
||||||
|
_NullData = string.Empty;
|
||||||
|
_Logistics = new(this);
|
||||||
|
if (_FileParameter is null)
|
||||||
|
throw new Exception(cellInstanceConnectionName);
|
||||||
|
if (_ModelObjectParameterDefinitions is null)
|
||||||
|
throw new Exception(cellInstanceConnectionName);
|
||||||
|
if (!_IsDuplicator)
|
||||||
|
throw new Exception(cellInstanceConnectionName);
|
||||||
|
string[] segments;
|
||||||
|
Dictionary<string, string> systemStateToNames = new();
|
||||||
|
_KeyColumn = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.KeyColumn");
|
||||||
|
_TimestampFormat = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.TimestampFormat");
|
||||||
|
ModelObjectParameterDefinition[] systemStates = GetProperties(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.SystemState");
|
||||||
|
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in systemStates)
|
||||||
|
{
|
||||||
|
segments = modelObjectParameterDefinition.Value.Split('|');
|
||||||
|
if (segments.Length != 2)
|
||||||
|
continue;
|
||||||
|
systemStateToNames.Add(segments[0], segments[1]);
|
||||||
|
}
|
||||||
|
_SystemStateToNames = new(systemStateToNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
|
||||||
|
{
|
||||||
|
bool isErrorFile = exception is not null;
|
||||||
|
if (!isErrorFile && !string.IsNullOrEmpty(_Logistics.ReportFullPath))
|
||||||
|
{
|
||||||
|
FileInfo fileInfo = new(_Logistics.ReportFullPath);
|
||||||
|
if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
|
||||||
|
File.SetLastWriteTime(_Logistics.ReportFullPath, fileInfo.CreationTime);
|
||||||
|
}
|
||||||
|
Move(extractResults);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
|
||||||
|
|
||||||
|
string IFileRead.GetEventDescription()
|
||||||
|
{
|
||||||
|
string result = _Description.GetEventDescription();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> IFileRead.GetHeaderNames()
|
||||||
|
{
|
||||||
|
List<string> results = _Description.GetHeaderNames();
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||||
|
{
|
||||||
|
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonProperty[] IFileRead.GetDefault()
|
||||||
|
{
|
||||||
|
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||||
|
{
|
||||||
|
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||||
|
{
|
||||||
|
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
|
||||||
|
{
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
|
if (string.IsNullOrEmpty(eventName))
|
||||||
|
throw new Exception();
|
||||||
|
_ReportFullPath = reportFullPath;
|
||||||
|
DateTime dateTime = DateTime.Now;
|
||||||
|
results = GetExtractResult(reportFullPath, dateTime);
|
||||||
|
if (results.Item3 is null)
|
||||||
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
|
||||||
|
if (results.Item3.Length > 0 && _IsEAFHosted)
|
||||||
|
WritePDSF(this, results.Item3);
|
||||||
|
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
|
||||||
|
{
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
|
List<string> headerNames = _Description.GetHeaderNames();
|
||||||
|
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
|
||||||
|
results = ReExtract(this, headerNames, keyValuePairs);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int? GetKeyColumnIndex(string[] columns, string keyColumn)
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
int? result = null;
|
||||||
|
for (int i = 0; i < columns.Length; i++)
|
||||||
|
{
|
||||||
|
if (columns[i] != keyColumn)
|
||||||
|
continue;
|
||||||
|
result = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ReadOnlyCollection<string> GetSystemStateValues(List<string> lines, string[] columns, int keyColumnIndex)
|
||||||
|
{
|
||||||
|
List<string> results = new();
|
||||||
|
string[] values;
|
||||||
|
string? systemState;
|
||||||
|
string keyColumnValue;
|
||||||
|
for (int i = 7; i < lines.Count; i++)
|
||||||
|
{
|
||||||
|
values = lines[i].Split('\t');
|
||||||
|
if (values.Length != columns.Length)
|
||||||
|
continue;
|
||||||
|
keyColumnValue = values[keyColumnIndex];
|
||||||
|
if (string.IsNullOrEmpty(keyColumnValue))
|
||||||
|
continue;
|
||||||
|
if (!_SystemStateToNames.TryGetValue(keyColumnValue, out systemState))
|
||||||
|
continue;
|
||||||
|
if (results.Contains(systemState))
|
||||||
|
continue;
|
||||||
|
results.Add(systemState);
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MoveFile(string reportFullPath)
|
||||||
|
{
|
||||||
|
string equipment;
|
||||||
|
string timestamp;
|
||||||
|
string[] columns;
|
||||||
|
DateTime dateTime;
|
||||||
|
List<string> lines;
|
||||||
|
string systemState;
|
||||||
|
int? keyColumnIndex;
|
||||||
|
string checkFileName;
|
||||||
|
List<string> headerLines = new();
|
||||||
|
ReadOnlyCollection<string> systemStateValues;
|
||||||
|
string missingKeyDirectory = Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, "Missing-Key");
|
||||||
|
if (!Directory.Exists(missingKeyDirectory))
|
||||||
|
_ = Directory.CreateDirectory(missingKeyDirectory);
|
||||||
|
string fileName = Path.GetFileName(reportFullPath);
|
||||||
|
string[] segments = fileName.Split('_');
|
||||||
|
for (int z = 0; z < 1; z++)
|
||||||
|
{
|
||||||
|
if (segments.Length != 2)
|
||||||
|
continue;
|
||||||
|
equipment = segments[0];
|
||||||
|
timestamp = segments[1].Split('.')[0];
|
||||||
|
if (timestamp.Length != _TimestampFormat.Length)
|
||||||
|
continue;
|
||||||
|
headerLines.Clear();
|
||||||
|
lines = File.ReadAllLines(reportFullPath).ToList();
|
||||||
|
if (lines.Count < 8)
|
||||||
|
continue;
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
headerLines.Add(lines[0]);
|
||||||
|
lines.RemoveAt(0);
|
||||||
|
}
|
||||||
|
if (lines[0].Length < 1 || lines[0][0] != '"' || !lines[0].StartsWith("\"Time\""))
|
||||||
|
continue;
|
||||||
|
columns = lines[0].Split('\t');
|
||||||
|
if (columns.Length < 3)
|
||||||
|
continue;
|
||||||
|
keyColumnIndex = GetKeyColumnIndex(columns, _KeyColumn);
|
||||||
|
if (keyColumnIndex is null)
|
||||||
|
{
|
||||||
|
File.Move(reportFullPath, Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, missingKeyDirectory, fileName));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
systemStateValues = GetSystemStateValues(lines, columns, keyColumnIndex.Value);
|
||||||
|
if (systemStateValues.Count == 0)
|
||||||
|
{
|
||||||
|
File.Move(reportFullPath, Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, missingKeyDirectory, fileName));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
lines.AddRange(headerLines);
|
||||||
|
systemState = string.Join("-", systemStateValues);
|
||||||
|
checkFileName = Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, $"{equipment}-{timestamp}-{systemState}.pdsf");
|
||||||
|
File.WriteAllLines(checkFileName, lines);
|
||||||
|
// File.Delete(reportFullPath);
|
||||||
|
if (DateTime.TryParseExact(timestamp, _TimestampFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
|
||||||
|
File.SetLastWriteTime(checkFileName, dateTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
||||||
|
{
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
|
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||||
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
|
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
||||||
|
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
||||||
|
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
||||||
|
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||||
|
MoveFile(reportFullPath);
|
||||||
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List<FileInfo>());
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _TimestampFormat;
|
private readonly string _TimestampFormat;
|
||||||
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
||||||
|
|
||||||
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;
|
||||||
@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
||||||
{
|
{
|
||||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
|
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
||||||
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
||||||
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
||||||
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||||
MoveFile(reportFullPath);
|
MoveFile(reportFullPath);
|
||||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List<FileInfo>());
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
238
Adaptation/FileHandlers/R65/FileRead.cs
Normal file
238
Adaptation/FileHandlers/R65/FileRead.cs
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||||
|
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||||
|
using Adaptation.Shared;
|
||||||
|
using Adaptation.Shared.Duplicator;
|
||||||
|
using Adaptation.Shared.Methods;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace Adaptation.FileHandlers.R65;
|
||||||
|
|
||||||
|
public class FileRead : Shared.FileRead, IFileRead
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly string _KeyColumn;
|
||||||
|
private readonly string _TimestampFormat;
|
||||||
|
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
||||||
|
|
||||||
|
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<Shared.Metrology.WS.Results>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
|
||||||
|
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
|
||||||
|
{
|
||||||
|
_MinFileLength = 10;
|
||||||
|
_NullData = string.Empty;
|
||||||
|
_Logistics = new(this);
|
||||||
|
if (_FileParameter is null)
|
||||||
|
throw new Exception(cellInstanceConnectionName);
|
||||||
|
if (_ModelObjectParameterDefinitions is null)
|
||||||
|
throw new Exception(cellInstanceConnectionName);
|
||||||
|
if (!_IsDuplicator)
|
||||||
|
throw new Exception(cellInstanceConnectionName);
|
||||||
|
string[] segments;
|
||||||
|
Dictionary<string, string> systemStateToNames = new();
|
||||||
|
_KeyColumn = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.KeyColumn");
|
||||||
|
_TimestampFormat = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.TimestampFormat");
|
||||||
|
ModelObjectParameterDefinition[] systemStates = GetProperties(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.SystemState");
|
||||||
|
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in systemStates)
|
||||||
|
{
|
||||||
|
segments = modelObjectParameterDefinition.Value.Split('|');
|
||||||
|
if (segments.Length != 2)
|
||||||
|
continue;
|
||||||
|
systemStateToNames.Add(segments[0], segments[1]);
|
||||||
|
}
|
||||||
|
_SystemStateToNames = new(systemStateToNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
|
||||||
|
{
|
||||||
|
bool isErrorFile = exception is not null;
|
||||||
|
if (!isErrorFile && !string.IsNullOrEmpty(_Logistics.ReportFullPath))
|
||||||
|
{
|
||||||
|
FileInfo fileInfo = new(_Logistics.ReportFullPath);
|
||||||
|
if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
|
||||||
|
File.SetLastWriteTime(_Logistics.ReportFullPath, fileInfo.CreationTime);
|
||||||
|
}
|
||||||
|
Move(extractResults);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
|
||||||
|
|
||||||
|
string IFileRead.GetEventDescription()
|
||||||
|
{
|
||||||
|
string result = _Description.GetEventDescription();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> IFileRead.GetHeaderNames()
|
||||||
|
{
|
||||||
|
List<string> results = _Description.GetHeaderNames();
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||||
|
{
|
||||||
|
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonProperty[] IFileRead.GetDefault()
|
||||||
|
{
|
||||||
|
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||||
|
{
|
||||||
|
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||||
|
{
|
||||||
|
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
|
||||||
|
{
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
|
if (string.IsNullOrEmpty(eventName))
|
||||||
|
throw new Exception();
|
||||||
|
_ReportFullPath = reportFullPath;
|
||||||
|
DateTime dateTime = DateTime.Now;
|
||||||
|
results = GetExtractResult(reportFullPath, dateTime);
|
||||||
|
if (results.Item3 is null)
|
||||||
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
|
||||||
|
if (results.Item3.Length > 0 && _IsEAFHosted)
|
||||||
|
WritePDSF(this, results.Item3);
|
||||||
|
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
|
||||||
|
{
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
|
List<string> headerNames = _Description.GetHeaderNames();
|
||||||
|
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
|
||||||
|
results = ReExtract(this, headerNames, keyValuePairs);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int? GetKeyColumnIndex(string[] columns, string keyColumn)
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
int? result = null;
|
||||||
|
for (int i = 0; i < columns.Length; i++)
|
||||||
|
{
|
||||||
|
if (columns[i] != keyColumn)
|
||||||
|
continue;
|
||||||
|
result = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ReadOnlyCollection<string> GetSystemStateValues(List<string> lines, string[] columns, int keyColumnIndex)
|
||||||
|
{
|
||||||
|
List<string> results = new();
|
||||||
|
string[] values;
|
||||||
|
string? systemState;
|
||||||
|
string keyColumnValue;
|
||||||
|
for (int i = 7; i < lines.Count; i++)
|
||||||
|
{
|
||||||
|
values = lines[i].Split('\t');
|
||||||
|
if (values.Length != columns.Length)
|
||||||
|
continue;
|
||||||
|
keyColumnValue = values[keyColumnIndex];
|
||||||
|
if (string.IsNullOrEmpty(keyColumnValue))
|
||||||
|
continue;
|
||||||
|
if (!_SystemStateToNames.TryGetValue(keyColumnValue, out systemState))
|
||||||
|
continue;
|
||||||
|
if (results.Contains(systemState))
|
||||||
|
continue;
|
||||||
|
results.Add(systemState);
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MoveFile(string reportFullPath)
|
||||||
|
{
|
||||||
|
string equipment;
|
||||||
|
string timestamp;
|
||||||
|
string[] columns;
|
||||||
|
DateTime dateTime;
|
||||||
|
List<string> lines;
|
||||||
|
string systemState;
|
||||||
|
int? keyColumnIndex;
|
||||||
|
string checkFileName;
|
||||||
|
List<string> headerLines = new();
|
||||||
|
ReadOnlyCollection<string> systemStateValues;
|
||||||
|
string missingKeyDirectory = Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, "Missing-Key");
|
||||||
|
if (!Directory.Exists(missingKeyDirectory))
|
||||||
|
_ = Directory.CreateDirectory(missingKeyDirectory);
|
||||||
|
string fileName = Path.GetFileName(reportFullPath);
|
||||||
|
string[] segments = fileName.Split('_');
|
||||||
|
for (int z = 0; z < 1; z++)
|
||||||
|
{
|
||||||
|
if (segments.Length != 2)
|
||||||
|
continue;
|
||||||
|
equipment = segments[0];
|
||||||
|
timestamp = segments[1].Split('.')[0];
|
||||||
|
if (timestamp.Length != _TimestampFormat.Length)
|
||||||
|
continue;
|
||||||
|
headerLines.Clear();
|
||||||
|
lines = File.ReadAllLines(reportFullPath).ToList();
|
||||||
|
if (lines.Count < 8)
|
||||||
|
continue;
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
headerLines.Add(lines[0]);
|
||||||
|
lines.RemoveAt(0);
|
||||||
|
}
|
||||||
|
if (lines[0].Length < 1 || lines[0][0] != '"' || !lines[0].StartsWith("\"Time\""))
|
||||||
|
continue;
|
||||||
|
columns = lines[0].Split('\t');
|
||||||
|
if (columns.Length < 3)
|
||||||
|
continue;
|
||||||
|
keyColumnIndex = GetKeyColumnIndex(columns, _KeyColumn);
|
||||||
|
if (keyColumnIndex is null)
|
||||||
|
{
|
||||||
|
File.Move(reportFullPath, Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, missingKeyDirectory, fileName));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
systemStateValues = GetSystemStateValues(lines, columns, keyColumnIndex.Value);
|
||||||
|
if (systemStateValues.Count == 0)
|
||||||
|
{
|
||||||
|
File.Move(reportFullPath, Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, missingKeyDirectory, fileName));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
lines.AddRange(headerLines);
|
||||||
|
systemState = string.Join("-", systemStateValues);
|
||||||
|
checkFileName = Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, $"{equipment}-{timestamp}-{systemState}.pdsf");
|
||||||
|
File.WriteAllLines(checkFileName, lines);
|
||||||
|
// File.Delete(reportFullPath);
|
||||||
|
if (DateTime.TryParseExact(timestamp, _TimestampFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
|
||||||
|
File.SetLastWriteTime(checkFileName, dateTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
||||||
|
{
|
||||||
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
|
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||||
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
|
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
||||||
|
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
||||||
|
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
||||||
|
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||||
|
MoveFile(reportFullPath);
|
||||||
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List<FileInfo>());
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _TimestampFormat;
|
private readonly string _TimestampFormat;
|
||||||
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
||||||
|
|
||||||
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;
|
||||||
@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
||||||
{
|
{
|
||||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
|
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
||||||
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
||||||
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
||||||
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||||
MoveFile(reportFullPath);
|
MoveFile(reportFullPath);
|
||||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List<FileInfo>());
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private readonly string _TimestampFormat;
|
private readonly string _TimestampFormat;
|
||||||
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
private readonly ReadOnlyDictionary<string, string> _SystemStateToNames;
|
||||||
|
|
||||||
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;
|
||||||
@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime _)
|
||||||
{
|
{
|
||||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
|
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
||||||
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
||||||
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
||||||
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||||
MoveFile(reportFullPath);
|
MoveFile(reportFullPath);
|
||||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
|
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List<FileInfo>());
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ public class Description : IDescription, Properties.IDescription
|
|||||||
public int Test { get; set; }
|
public int Test { get; set; }
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public int Index { get; set; }
|
public int Index { get; set; }
|
||||||
public string Lot { get; set; }
|
public string RDS { get; set; }
|
||||||
//
|
//
|
||||||
public string EventName { get; set; }
|
public string EventName { get; set; }
|
||||||
public string NullData { get; set; }
|
public string NullData { get; set; }
|
||||||
@ -141,7 +141,7 @@ public class Description : IDescription, Properties.IDescription
|
|||||||
MID = logistics.MID,
|
MID = logistics.MID,
|
||||||
//
|
//
|
||||||
Date = DateTime.Now.ToString(GetDateFormat()),
|
Date = DateTime.Now.ToString(GetDateFormat()),
|
||||||
Lot = string.Empty,
|
RDS = string.Empty,
|
||||||
};
|
};
|
||||||
results.Add(description);
|
results.Add(description);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -35,6 +35,9 @@ public class Logistics : ILogistics
|
|||||||
public long Sequence => _Sequence;
|
public long Sequence => _Sequence;
|
||||||
public double TotalSecondsSinceLastWriteTimeFromSequence => _TotalSecondsSinceLastWriteTimeFromSequence;
|
public double TotalSecondsSinceLastWriteTimeFromSequence => _TotalSecondsSinceLastWriteTimeFromSequence;
|
||||||
|
|
||||||
|
private static string DefaultMesEntity(DateTime dateTime) =>
|
||||||
|
string.Concat(dateTime.Ticks, "_MES_ENTITY");
|
||||||
|
|
||||||
public Logistics(IFileRead fileRead)
|
public Logistics(IFileRead fileRead)
|
||||||
{
|
{
|
||||||
DateTime dateTime = DateTime.Now;
|
DateTime dateTime = DateTime.Now;
|
||||||
@ -84,13 +87,13 @@ public class Logistics : ILogistics
|
|||||||
_Logistics2 = new List<Logistics2>();
|
_Logistics2 = new List<Logistics2>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Logistics(string reportFullPath, string logistics)
|
internal Logistics(string reportFullPath, ProcessDataStandardFormat processDataStandardFormat)
|
||||||
{
|
{
|
||||||
string key;
|
string key;
|
||||||
DateTime dateTime;
|
DateTime dateTime;
|
||||||
string[] segments;
|
string[] segments;
|
||||||
_FileInfo = new(reportFullPath);
|
_FileInfo = new(reportFullPath);
|
||||||
_Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
_Logistics1 = processDataStandardFormat.Logistics.ToList();
|
||||||
if (Logistics1.Count == 0 || !Logistics1[0].StartsWith("LOGISTICS_1"))
|
if (Logistics1.Count == 0 || !Logistics1[0].StartsWith("LOGISTICS_1"))
|
||||||
{
|
{
|
||||||
_NullData = null;
|
_NullData = null;
|
||||||
@ -190,8 +193,6 @@ public class Logistics : ILogistics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
|
|
||||||
|
|
||||||
internal void Update(string mid, string processJobID)
|
internal void Update(string mid, string processJobID)
|
||||||
{
|
{
|
||||||
_MID = mid;
|
_MID = mid;
|
||||||
|
@ -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 long HeaderId { get; set; }
|
||||||
public string HeaderIdDirectory { get; set; }
|
|
||||||
public string UniqueId { get; set; }
|
public string UniqueId { get; set; }
|
||||||
public string DestinationFileName { get; set; }
|
public string SubGroupId { get; set; }
|
||||||
public string SourceFileName { get; set; }
|
|
||||||
public string AttachmentId { get; set; }
|
public string AttachmentId { get; set; }
|
||||||
|
public string SourceFileName { get; set; }
|
||||||
|
public string HeaderIdDirectory { get; set; }
|
||||||
|
public string DestinationFileName { get; set; }
|
||||||
|
|
||||||
public Attachment(string subGroupId, long headerId, string headerIdDirectory, string uniqueId, string destinationFileName, string sourceFileName)
|
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; }
|
||||||
|
|
||||||
// this is just a helper function to make displaying the results easier
|
public override string ToString()
|
||||||
public override string ToString() => JsonSerializer.Serialize(this, GetType());
|
{
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[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)
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
33
Adaptation/Shared/ProcessDataStandardFormatMapping.cs
Normal file
33
Adaptation/Shared/ProcessDataStandardFormatMapping.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Adaptation.Shared;
|
||||||
|
|
||||||
|
public class ProcessDataStandardFormatMapping
|
||||||
|
{
|
||||||
|
|
||||||
|
public ReadOnlyCollection<string> BackfillColumns { get; private set; }
|
||||||
|
public ReadOnlyCollection<int> ColumnIndices { get; private set; }
|
||||||
|
public ReadOnlyCollection<string> IgnoreColumns { get; private set; }
|
||||||
|
public ReadOnlyCollection<string> IndexOnlyColumns { get; private set; }
|
||||||
|
public ReadOnlyDictionary<string, string> KeyValuePairs { get; private set; }
|
||||||
|
public ReadOnlyCollection<string> NewColumnNames { get; private set; }
|
||||||
|
public ReadOnlyCollection<string> OldColumnNames { get; private set; }
|
||||||
|
|
||||||
|
public ProcessDataStandardFormatMapping(ReadOnlyCollection<string> backfillColumns,
|
||||||
|
ReadOnlyCollection<int> columnIndices,
|
||||||
|
ReadOnlyCollection<string> ignoreColumns,
|
||||||
|
ReadOnlyCollection<string> indexOnlyColumns,
|
||||||
|
ReadOnlyDictionary<string, string> keyValuePairs,
|
||||||
|
ReadOnlyCollection<string> newColumnNames,
|
||||||
|
ReadOnlyCollection<string> oldColumnNames)
|
||||||
|
{
|
||||||
|
BackfillColumns = backfillColumns;
|
||||||
|
ColumnIndices = columnIndices;
|
||||||
|
IgnoreColumns = ignoreColumns;
|
||||||
|
IndexOnlyColumns = indexOnlyColumns;
|
||||||
|
KeyValuePairs = keyValuePairs;
|
||||||
|
NewColumnNames = newColumnNames;
|
||||||
|
OldColumnNames = oldColumnNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,6 +6,6 @@ public interface IDescription
|
|||||||
int Test { get; }
|
int Test { get; }
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
int Index { get; }
|
int Index { get; }
|
||||||
string Lot { get; }
|
string RDS { get; }
|
||||||
|
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -51,7 +51,7 @@ public class DEP08CEPIEPSILON : LoggingUnitTesting, IDisposable
|
|||||||
public void TestDateTime()
|
public void TestDateTime()
|
||||||
{
|
{
|
||||||
DateTime dateTime = DateTime.Now;
|
DateTime dateTime = DateTime.Now;
|
||||||
Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString());
|
Assert.AreEqual(dateTime.ToString(), dateTime.ToString("M/d/yyyy h:mm:ss tt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -106,7 +106,9 @@
|
|||||||
<Compile Include="Adaptation\FileHandlers\CellInstanceConnectionName.cs" />
|
<Compile Include="Adaptation\FileHandlers\CellInstanceConnectionName.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\Dummy\FileRead.cs" />
|
<Compile Include="Adaptation\FileHandlers\Dummy\FileRead.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\R32\FileRead.cs" />
|
<Compile Include="Adaptation\FileHandlers\R32\FileRead.cs" />
|
||||||
|
<Compile Include="Adaptation\FileHandlers\R61\FileRead.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\R62\FileRead.cs" />
|
<Compile Include="Adaptation\FileHandlers\R62\FileRead.cs" />
|
||||||
|
<Compile Include="Adaptation\FileHandlers\R65\FileRead.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\R55\FileRead.cs" />
|
<Compile Include="Adaptation\FileHandlers\R55\FileRead.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\R57\FileRead.cs" />
|
<Compile Include="Adaptation\FileHandlers\R57\FileRead.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\R75\FileRead.cs" />
|
<Compile Include="Adaptation\FileHandlers\R75\FileRead.cs" />
|
||||||
@ -141,6 +143,7 @@
|
|||||||
<Compile Include="Adaptation\Shared\Metrology\WS.Results.cs" />
|
<Compile Include="Adaptation\Shared\Metrology\WS.Results.cs" />
|
||||||
<Compile Include="Adaptation\Shared\ParameterType.cs" />
|
<Compile Include="Adaptation\Shared\ParameterType.cs" />
|
||||||
<Compile Include="Adaptation\Shared\ProcessDataStandardFormat.cs" />
|
<Compile Include="Adaptation\Shared\ProcessDataStandardFormat.cs" />
|
||||||
|
<Compile Include="Adaptation\Shared\ProcessDataStandardFormatMapping.cs" />
|
||||||
<Compile Include="Adaptation\Shared\Properties\IDescription.cs" />
|
<Compile Include="Adaptation\Shared\Properties\IDescription.cs" />
|
||||||
<Compile Include="Adaptation\Shared\Properties\IFileRead.cs" />
|
<Compile Include="Adaptation\Shared\Properties\IFileRead.cs" />
|
||||||
<Compile Include="Adaptation\Shared\Properties\ILogistics.cs" />
|
<Compile Include="Adaptation\Shared\Properties\ILogistics.cs" />
|
||||||
|
@ -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