From e5ac612eeed3af2db1a5b44f2d83f9bca73d0db8 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Fri, 18 Feb 2022 14:21:57 -0700 Subject: [PATCH] _Hyphens == (int)Hyphen --- Adaptation/FileHandlers/Dummy/FileRead.cs | 2 +- .../MET08THFTIRSTRATUS/FileRead.cs | 68 +++++++++---------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/Adaptation/FileHandlers/Dummy/FileRead.cs b/Adaptation/FileHandlers/Dummy/FileRead.cs index 55e61a9..b33618f 100644 --- a/Adaptation/FileHandlers/Dummy/FileRead.cs +++ b/Adaptation/FileHandlers/Dummy/FileRead.cs @@ -227,7 +227,7 @@ public class FileRead : Shared.FileRead, IFileRead DateTime dateTime = DateTime.Now; if (!_FileConnectorConfiguration.TargetFileLocation.Contains(_FileConnectorConfiguration.SourceFileLocation)) 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) { string checkSegment; diff --git a/Adaptation/FileHandlers/MET08THFTIRSTRATUS/FileRead.cs b/Adaptation/FileHandlers/MET08THFTIRSTRATUS/FileRead.cs index 451e53c..667fc72 100644 --- a/Adaptation/FileHandlers/MET08THFTIRSTRATUS/FileRead.cs +++ b/Adaptation/FileHandlers/MET08THFTIRSTRATUS/FileRead.cs @@ -25,20 +25,20 @@ public class FileRead : Shared.FileRead, IFileRead private readonly Timer _Timer; private int _LastDummyRunIndex; + private readonly bool _IsDummy; + private readonly bool _IsNaEDA; + private readonly bool _IsXToAPC; private readonly string _IqsFile; - private readonly int _HyphenIsDummy; - private readonly int _HyphenIsNaEDA; + private readonly bool _IsXToIQSSi; + private readonly bool _IsXToSPaCe; private readonly string _MemoryPath; - private readonly int _HyphenIsXToAPC; - private readonly int _HyphenIsXToIQSSi; - private readonly int _HyphenIsXToSPaCe; + private readonly bool _IsXToOpenInsight; private readonly string _OriginalDataBioRad; - private readonly int _HyphenIsXToOpenInsight; private readonly string _OpenInsightFilePattern; - private readonly string _OpenInsightMetrologyViewerAPI; + private readonly bool _IsXToOpenInsightMetrologyViewer; private readonly Dictionary _CellNames; - private readonly int _HyphenIsXToOpenInsightMetrologyViewer; - private readonly int _HyphenIsXToOpenInsightMetrologyViewerAttachments; + private readonly string _OpenInsightMetrologyViewerAPI; + private readonly bool _IsXToOpenInsightMetrologyViewerAttachments; public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) : base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted) @@ -54,29 +54,23 @@ public class FileRead : Shared.FileRead, IFileRead throw new Exception(cellInstanceConnectionName); _OriginalDataBioRad = "OriginalDataBioRad_"; _LastDummyRunIndex = -1; - if (_HyphenIsNaEDA == 0) - { } - if (_HyphenIsXToSPaCe == 0) - { } - if (_HyphenIsXToIQSSi == 0) - { } + _IsDummy = _Hyphens == (int)Hyphen.IsDummy; + _IsNaEDA = _Hyphens == (int)Hyphen.IsNaEDA; + _IsXToAPC = _Hyphens == (int)Hyphen.IsXToAPC; _CellNames = new Dictionary(); - _HyphenIsNaEDA = (int)Hyphen.IsNaEDA; - _HyphenIsDummy = (int)Hyphen.IsDummy; - _HyphenIsXToAPC = (int)Hyphen.IsXToAPC; - _HyphenIsXToIQSSi = (int)Hyphen.IsXToIQSSi; - _HyphenIsXToSPaCe = (int)Hyphen.IsXToSPaCe; - _HyphenIsXToOpenInsight = (int)Hyphen.IsXToOpenInsight; + _IsXToIQSSi = _Hyphens == (int)Hyphen.IsXToIQSSi; + _IsXToSPaCe = _Hyphens == (int)Hyphen.IsXToSPaCe; + _IsXToOpenInsight = _Hyphens == (int)Hyphen.IsXToOpenInsight; _IqsFile = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.File"); _MemoryPath = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory"); - _HyphenIsXToOpenInsightMetrologyViewer = (int)Hyphen.IsXToOpenInsightMetrologyViewer; - _HyphenIsXToOpenInsightMetrologyViewerAttachments = (int)Hyphen.IsXToOpenInsightMetrologyViewerAttachments; + _IsXToOpenInsightMetrologyViewer = _Hyphens == (int)Hyphen.IsXToOpenInsightMetrologyViewer; + _IsXToOpenInsightMetrologyViewerAttachments = _Hyphens == (int)Hyphen.IsXToOpenInsightMetrologyViewerAttachments; _OpenInsightFilePattern = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.FilePattern"); _OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI"); ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Path"); foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection) _CellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1], modelObjectParameterDefinition.Value); - if (_Hyphens == _HyphenIsDummy) + if (_IsDummy) { if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process) { @@ -86,7 +80,7 @@ public class FileRead : Shared.FileRead, IFileRead else { int milliSeconds; - milliSeconds = (int)((fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000) / 2); + milliSeconds = (int)(fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000 / 2); _Timer = new Timer(Callback, null, milliSeconds, Timeout.Infinite); milliSeconds += 2000; } @@ -192,7 +186,7 @@ public class FileRead : Shared.FileRead, IFileRead List descriptions = GetDescriptions(jsonElements); Tuple>> tuple = GetTuple(this, from l in descriptions select (Shared.Properties.IDescription)l, extra: false); results = new Tuple>(pdsf.Item1, tuple.Item1, jsonElements, new List()); - 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(); if (isDummyRun) { @@ -201,9 +195,9 @@ public class FileRead : Shared.FileRead, IFileRead catch (Exception) { } } string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_'); - if (_Hyphens == _HyphenIsXToIQSSi) + if (_IsXToIQSSi) duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\All"); - else if (_Hyphens != _HyphenIsXToOpenInsight) + else if (!_IsXToOpenInsight) duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", segments[0]); else duplicateDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\Data"); @@ -216,7 +210,7 @@ public class FileRead : Shared.FileRead, IFileRead if (!Directory.Exists(duplicateDirectory)) _ = Directory.CreateDirectory(duplicateDirectory); string successDirectory; - if (_Hyphens != _HyphenIsXToAPC) + if (!_IsXToAPC) successDirectory = string.Empty; else { @@ -231,14 +225,14 @@ public class FileRead : Shared.FileRead, IFileRead string logisticsSequenceMemoryDirectory = string.Concat(_MemoryPath, @"\", _EquipmentType, @"\Source\", weekDirectory, @"\", _Logistics.Sequence); if (!Directory.Exists(logisticsSequenceMemoryDirectory)) _ = Directory.CreateDirectory(logisticsSequenceMemoryDirectory); - if (_Hyphens == _HyphenIsXToAPC) + if (_IsXToAPC) { if (!isDummyRun && _IsEAFHosted) File.Copy(reportFullPath, duplicateFile, overwrite: true); } else { - if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewer) + if (_IsXToOpenInsightMetrologyViewer) { WSRequest wsRequest = new(this, _Logistics, descriptions); if (!isDummyRun && _IsEAFHosted) @@ -259,7 +253,7 @@ public class FileRead : Shared.FileRead, IFileRead { test = keyValuePair.Key; //scopeInfo = new ScopeInfo(test); - if (_Hyphens != _HyphenIsXToOpenInsight) + if (!_IsXToOpenInsight) scopeInfo = new ScopeInfo(test, _IqsFile); else scopeInfo = new ScopeInfo(test, _OpenInsightFilePattern); @@ -268,17 +262,17 @@ public class FileRead : Shared.FileRead, IFileRead tuples.Add(new Tuple(scopeInfo, lines)); } } - if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments) + if (_IsXToOpenInsightMetrologyViewerAttachments) { string[] matchDirectories = Shared1567(reportFullPath, tuples); if (!isDummyRun && _IsEAFHosted && !isNotUsedInsightMetrologyViewerAttachments) ProcessData.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, _OriginalDataBioRad, dateTime, logisticsSequenceMemoryDirectory, descriptions, matchDirectories[0]); } } - if (_Hyphens != _HyphenIsXToOpenInsightMetrologyViewer && _Hyphens != _HyphenIsXToOpenInsightMetrologyViewerAttachments) + if (!_IsXToOpenInsightMetrologyViewer && !_IsXToOpenInsightMetrologyViewerAttachments) Shared0413(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile); } - if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments) + if (_IsXToOpenInsightMetrologyViewerAttachments) { string destinationDirectory; //string destinationDirectory = WriteScopeInfo(_ProgressPath, _Logistics, dateTime, duplicateDirectory, tuples); @@ -396,12 +390,12 @@ public class FileRead : Shared.FileRead, IFileRead private void Callback(object state) { - if (_Hyphens != _HyphenIsDummy) + if (!_IsDummy) throw new Exception(); try { 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) { int fileCount;