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/MET08THFTIRQS408M/FileRead.cs b/Adaptation/FileHandlers/MET08THFTIRQS408M/FileRead.cs index 5c6e0c1..59a2cb5 100644 --- a/Adaptation/FileHandlers/MET08THFTIRQS408M/FileRead.cs +++ b/Adaptation/FileHandlers/MET08THFTIRQS408M/FileRead.cs @@ -25,19 +25,19 @@ 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 int _HyphenIsXToOpenInsight; + private readonly bool _IsXToOpenInsight; 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) @@ -52,29 +52,23 @@ public class FileRead : Shared.FileRead, IFileRead if (!_IsDuplicator) throw new Exception(cellInstanceConnectionName); _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) { @@ -84,7 +78,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; } @@ -190,7 +184,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) { @@ -199,9 +193,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"); @@ -214,7 +208,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 { @@ -229,14 +223,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) @@ -257,7 +251,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); @@ -266,17 +260,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, 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); @@ -394,12 +388,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; diff --git a/Adaptation/Helpers/ConfigData.cs b/Adaptation/Helpers/ConfigData.cs index 471daa5..b471975 100644 --- a/Adaptation/Helpers/ConfigData.cs +++ b/Adaptation/Helpers/ConfigData.cs @@ -340,7 +340,7 @@ // private void CallbackIsDummy() // { // 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;