_Hyphens == (int)Hyphen

This commit is contained in:
Mike Phares 2022-02-18 14:21:21 -07:00
parent cee505f79d
commit 54161602da
3 changed files with 34 additions and 39 deletions

View File

@ -9,6 +9,7 @@
"Irng", "Irng",
"ISMTP", "ISMTP",
"JOBID", "JOBID",
"messa",
"pdsf", "pdsf",
"pdsfc", "pdsfc",
"PPID", "PPID",

View File

@ -227,7 +227,7 @@ public class FileRead : Shared.FileRead, IFileRead
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now;
if (!_FileConnectorConfiguration.TargetFileLocation.Contains(_FileConnectorConfiguration.SourceFileLocation)) if (!_FileConnectorConfiguration.TargetFileLocation.Contains(_FileConnectorConfiguration.SourceFileLocation))
throw new Exception("Target must start with source"); throw new Exception("Target must start with source");
bool check = (dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday); bool check = dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday;
if (!_IsEAFHosted || check) if (!_IsEAFHosted || check)
{ {
string checkSegment; string checkSegment;

View File

@ -20,22 +20,22 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE;
public class FileRead : Shared.FileRead, IFileRead public class FileRead : Shared.FileRead, IFileRead
{ {
private readonly Timer _Timer; private readonly Timer _Timer;
private int _LastDummyRunIndex; private int _LastDummyRunIndex;
private readonly bool _IsDummy;
private readonly bool _IsNaEDA;
private readonly bool _IsXToAPC;
private readonly string _IqsFile; private readonly string _IqsFile;
private readonly int _HyphenIsDummy; private readonly bool _IsXToIQSSi;
private readonly int _HyphenIsNaEDA; private readonly bool _IsXToSPaCe;
private readonly string _MemoryPath; private readonly string _MemoryPath;
private readonly int _HyphenIsXToAPC; private readonly bool _IsXToOpenInsight;
private readonly int _HyphenIsXToIQSSi;
private readonly int _HyphenIsXToSPaCe;
private readonly int _HyphenIsXToOpenInsight;
private readonly string _OpenInsightFilePattern; private readonly string _OpenInsightFilePattern;
private readonly string _OpenInsightMetrologyViewerAPI; private readonly bool _IsXToOpenInsightMetrologyViewer;
private readonly Dictionary<string, string> _CellNames; private readonly Dictionary<string, string> _CellNames;
private readonly int _HyphenIsXToOpenInsightMetrologyViewer; private readonly string _OpenInsightMetrologyViewerAPI;
private readonly int _HyphenIsXToOpenInsightMetrologyViewerAttachments; private readonly bool _IsXToOpenInsightMetrologyViewerAttachments;
public FileRead(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, bool useCyclicalForDescription, bool isEAFHosted) : public FileRead(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, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted) base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
@ -50,29 +50,23 @@ public class FileRead : Shared.FileRead, IFileRead
if (!_IsDuplicator) if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
_LastDummyRunIndex = -1; _LastDummyRunIndex = -1;
if (_HyphenIsNaEDA == 0) _IsDummy = _Hyphens == (int)Hyphen.IsDummy;
{ } _IsNaEDA = _Hyphens == (int)Hyphen.IsNaEDA;
if (_HyphenIsXToSPaCe == 0) _IsXToAPC = _Hyphens == (int)Hyphen.IsXToAPC;
{ }
if (_HyphenIsXToIQSSi == 0)
{ }
_CellNames = new Dictionary<string, string>(); _CellNames = new Dictionary<string, string>();
_HyphenIsNaEDA = (int)Hyphen.IsNaEDA; _IsXToIQSSi = _Hyphens == (int)Hyphen.IsXToIQSSi;
_HyphenIsDummy = (int)Hyphen.IsDummy; _IsXToSPaCe = _Hyphens == (int)Hyphen.IsXToSPaCe;
_HyphenIsXToAPC = (int)Hyphen.IsXToAPC; _IsXToOpenInsight = _Hyphens == (int)Hyphen.IsXToOpenInsight;
_HyphenIsXToIQSSi = (int)Hyphen.IsXToIQSSi;
_HyphenIsXToSPaCe = (int)Hyphen.IsXToSPaCe;
_HyphenIsXToOpenInsight = (int)Hyphen.IsXToOpenInsight;
_IqsFile = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.File"); _IqsFile = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.File");
_MemoryPath = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory"); _MemoryPath = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory");
_HyphenIsXToOpenInsightMetrologyViewer = (int)Hyphen.IsXToOpenInsightMetrologyViewer; _IsXToOpenInsightMetrologyViewer = _Hyphens == (int)Hyphen.IsXToOpenInsightMetrologyViewer;
_HyphenIsXToOpenInsightMetrologyViewerAttachments = (int)Hyphen.IsXToOpenInsightMetrologyViewerAttachments; _IsXToOpenInsightMetrologyViewerAttachments = _Hyphens == (int)Hyphen.IsXToOpenInsightMetrologyViewerAttachments;
_OpenInsightFilePattern = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.FilePattern"); _OpenInsightFilePattern = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.FilePattern");
_OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI"); _OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI");
ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Path"); ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Path");
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection) foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection)
_CellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1], modelObjectParameterDefinition.Value); _CellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1], modelObjectParameterDefinition.Value);
if (_Hyphens == _HyphenIsDummy) if (_IsDummy)
{ {
if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process) if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process)
{ {
@ -82,7 +76,7 @@ public class FileRead : Shared.FileRead, IFileRead
else else
{ {
int milliSeconds; int milliSeconds;
milliSeconds = (int)((fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000) / 2); milliSeconds = (int)(fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000 / 2);
_Timer = new Timer(Callback, null, milliSeconds, Timeout.Infinite); _Timer = new Timer(Callback, null, milliSeconds, Timeout.Infinite);
milliSeconds += 2000; milliSeconds += 2000;
} }
@ -188,7 +182,7 @@ public class FileRead : Shared.FileRead, IFileRead
List<pcl.Description> descriptions = GetDescriptions(jsonElements); List<pcl.Description> descriptions = GetDescriptions(jsonElements);
Tuple<Test[], Dictionary<Test, List<Shared.Properties.IDescription>>> tuple = GetTuple(this, from l in descriptions select (Shared.Properties.IDescription)l, extra: false); Tuple<Test[], Dictionary<Test, List<Shared.Properties.IDescription>>> tuple = GetTuple(this, from l in descriptions select (Shared.Properties.IDescription)l, extra: false);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tuple.Item1, jsonElements, new List<FileInfo>()); results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tuple.Item1, jsonElements, new List<FileInfo>());
bool isNotUsedInsightMetrologyViewerAttachments = !(_FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) && _Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments; bool isNotUsedInsightMetrologyViewerAttachments = !(_FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) && _IsXToOpenInsightMetrologyViewerAttachments;
bool isDummyRun = _DummyRuns.Any() && _DummyRuns.ContainsKey(_Logistics.JobID) && _DummyRuns[_Logistics.JobID].Any() && (from l in _DummyRuns[_Logistics.JobID] where l == _Logistics.Sequence select 1).Any(); bool isDummyRun = _DummyRuns.Any() && _DummyRuns.ContainsKey(_Logistics.JobID) && _DummyRuns[_Logistics.JobID].Any() && (from l in _DummyRuns[_Logistics.JobID] where l == _Logistics.Sequence select 1).Any();
if (isDummyRun) if (isDummyRun)
{ {
@ -197,9 +191,9 @@ public class FileRead : Shared.FileRead, IFileRead
catch (Exception) { } catch (Exception) { }
} }
string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_'); string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_');
if (_Hyphens == _HyphenIsXToIQSSi) if (_IsXToIQSSi)
duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\All"); duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\All");
else if (_Hyphens != _HyphenIsXToOpenInsight) else if (!_IsXToOpenInsight)
duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", segments[0]); duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", segments[0]);
else else
duplicateDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\Data"); duplicateDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\Data");
@ -212,7 +206,7 @@ public class FileRead : Shared.FileRead, IFileRead
if (!Directory.Exists(duplicateDirectory)) if (!Directory.Exists(duplicateDirectory))
_ = Directory.CreateDirectory(duplicateDirectory); _ = Directory.CreateDirectory(duplicateDirectory);
string successDirectory; string successDirectory;
if (_Hyphens != _HyphenIsXToAPC) if (!_IsXToAPC)
successDirectory = string.Empty; successDirectory = string.Empty;
else else
{ {
@ -227,14 +221,14 @@ public class FileRead : Shared.FileRead, IFileRead
string logisticsSequenceMemoryDirectory = string.Concat(_MemoryPath, @"\", _EquipmentType, @"\Source\", weekDirectory, @"\", _Logistics.Sequence); string logisticsSequenceMemoryDirectory = string.Concat(_MemoryPath, @"\", _EquipmentType, @"\Source\", weekDirectory, @"\", _Logistics.Sequence);
if (!Directory.Exists(logisticsSequenceMemoryDirectory)) if (!Directory.Exists(logisticsSequenceMemoryDirectory))
_ = Directory.CreateDirectory(logisticsSequenceMemoryDirectory); _ = Directory.CreateDirectory(logisticsSequenceMemoryDirectory);
if (_Hyphens == _HyphenIsXToAPC) if (_IsXToAPC)
{ {
if (!isDummyRun && _IsEAFHosted) if (!isDummyRun && _IsEAFHosted)
File.Copy(reportFullPath, duplicateFile, overwrite: true); File.Copy(reportFullPath, duplicateFile, overwrite: true);
} }
else else
{ {
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewer) if (_IsXToOpenInsightMetrologyViewer)
{ {
WSRequest wsRequest = new(this, _Logistics, descriptions); WSRequest wsRequest = new(this, _Logistics, descriptions);
if (!isDummyRun && _IsEAFHosted) if (!isDummyRun && _IsEAFHosted)
@ -255,7 +249,7 @@ public class FileRead : Shared.FileRead, IFileRead
{ {
test = keyValuePair.Key; test = keyValuePair.Key;
//scopeInfo = new ScopeInfo(test); //scopeInfo = new ScopeInfo(test);
if (_Hyphens != _HyphenIsXToOpenInsight) if (!_IsXToOpenInsight)
scopeInfo = new ScopeInfo(test, _IqsFile); scopeInfo = new ScopeInfo(test, _IqsFile);
else else
scopeInfo = new ScopeInfo(test, _OpenInsightFilePattern); scopeInfo = new ScopeInfo(test, _OpenInsightFilePattern);
@ -264,17 +258,17 @@ public class FileRead : Shared.FileRead, IFileRead
tuples.Add(new Tuple<Shared.Properties.IScopeInfo, string>(scopeInfo, lines)); tuples.Add(new Tuple<Shared.Properties.IScopeInfo, string>(scopeInfo, lines));
} }
} }
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments) if (_IsXToOpenInsightMetrologyViewerAttachments)
{ {
string[] matchDirectories = Shared1567(reportFullPath, tuples); string[] matchDirectories = Shared1567(reportFullPath, tuples);
if (!isDummyRun && _IsEAFHosted && !isNotUsedInsightMetrologyViewerAttachments) if (!isDummyRun && _IsEAFHosted && !isNotUsedInsightMetrologyViewerAttachments)
ProcessData.PostOpenInsightMetrologyViewerAttachments(this, dateTime, logisticsSequenceMemoryDirectory, descriptions, matchDirectories[0]); ProcessData.PostOpenInsightMetrologyViewerAttachments(this, dateTime, logisticsSequenceMemoryDirectory, descriptions, matchDirectories[0]);
} }
} }
if (_Hyphens != _HyphenIsXToOpenInsightMetrologyViewer && _Hyphens != _HyphenIsXToOpenInsightMetrologyViewerAttachments) if (!_IsXToOpenInsightMetrologyViewer && !_IsXToOpenInsightMetrologyViewerAttachments)
Shared0413(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile); Shared0413(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile);
} }
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments) if (_IsXToOpenInsightMetrologyViewerAttachments)
{ {
string destinationDirectory; string destinationDirectory;
//string destinationDirectory = WriteScopeInfo(_ProgressPath, _Logistics, dateTime, duplicateDirectory, tuples); //string destinationDirectory = WriteScopeInfo(_ProgressPath, _Logistics, dateTime, duplicateDirectory, tuples);
@ -392,12 +386,12 @@ public class FileRead : Shared.FileRead, IFileRead
private void Callback(object state) private void Callback(object state)
{ {
if (_Hyphens != _HyphenIsDummy) if (!_IsDummy)
throw new Exception(); throw new Exception();
try try
{ {
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now;
bool check = (dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday); bool check = dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday;
if (check) if (check)
{ {
int fileCount; int fileCount;