diff --git a/Adaptation/.editorconfig b/Adaptation/.editorconfig index 3c9827a..96d9a58 100644 --- a/Adaptation/.editorconfig +++ b/Adaptation/.editorconfig @@ -98,8 +98,10 @@ dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer AsSpan over Substring dotnet_diagnostic.CA1847.severity = none # CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters +dotnet_diagnostic.CA1854.severity = warning # CA1854: Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup dotnet_diagnostic.CA1860.severity = error # CA1860: Prefer comparing 'Count' to 0 rather than using 'Any()', both for clarity and for performance dotnet_diagnostic.CA1864.severity = none # CA1864: To avoid double lookup, call 'TryAdd' instead of calling 'Add' with a 'ContainsKey' guard +dotnet_diagnostic.CA1866.severity = none # CA1866: Use 'string.EndsWith(char)' instead of 'string.EndsWith(string)' when you have a string with a single char dotnet_diagnostic.CA1869.severity = none # CA1869: Avoid creating a new 'JsonSerializerOptions' instance for every serialization operation. Cache and reuse instances instead. dotnet_diagnostic.CA2254.severity = none # CA2254: The logging message template should not vary between calls to 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name @@ -111,12 +113,13 @@ dotnet_diagnostic.IDE0031.severity = warning # Use null propagation (IDE0031) dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049) dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter +dotnet_diagnostic.IDE0200.severity = warning # IDE0200: Lambda expression can be removed dotnet_diagnostic.IDE0270.severity = none # IDE0270: Null check can be simplified dotnet_diagnostic.IDE0290.severity = none # Use primary constructor [Distance]csharp(IDE0290) dotnet_diagnostic.IDE0300.severity = none # IDE0300: 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.SYSLIB1045.severity = none # SYSLIB1045: +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.style = pascal_case dotnet_naming_rule.abstract_method_should_be_pascal_case.symbols = abstract_method diff --git a/Adaptation/FileHandlers/IQSSi/FileRead.cs b/Adaptation/FileHandlers/IQSSi/FileRead.cs index 12bc214..6eddb9e 100644 --- a/Adaptation/FileHandlers/IQSSi/FileRead.cs +++ b/Adaptation/FileHandlers/IQSSi/FileRead.cs @@ -103,6 +103,36 @@ public class FileRead : Shared.FileRead, IFileRead return results; } + private void WriteFirstLineTabSeparatedValuesFile(string reportFullPath, DateTime dateTime, List descriptions, string[] pdsfColumns, string[] pdsfBodyLines) where T : Shared.Properties.IDescription + { + string[] segments; + bool isDummyRun = false; + string successDirectory = string.Empty; + string[] firstLine = pdsfBodyLines[0].Split('\t'); + List<(Shared.Properties.IScopeInfo, string)> collection = new(); + foreach (string line in pdsfBodyLines) + { + segments = line.Split('\t'); + if (segments.Length != firstLine.Length) + continue; + for (int i = 0; i < segments.Length; i++) + { + if (string.IsNullOrEmpty(segments[i])) + continue; + if (segments[i] == firstLine[i]) + continue; + firstLine[i] = string.Empty; + } + } + string duplicateDirectory = Path.Combine(_FileConnectorConfiguration.SourceFileLocation, _CellInstanceName); + if (!Directory.Exists(duplicateDirectory)) + _ = Directory.CreateDirectory(duplicateDirectory); + string duplicateFile = Path.Combine(duplicateDirectory, $"{Path.GetFileName(reportFullPath)}.tsv"); + string[] lines = new string[] { string.Join("\t", pdsfColumns), string.Join("\t", firstLine) }; + File.WriteAllLines(duplicateFile, lines); + WaitForFileConsumption(dateTime, descriptions, isDummyRun, successDirectory, duplicateDirectory, collection, duplicateFile); + } + private void FileCopy(string reportFullPath, DateTime dateTime, List descriptions) where T : Shared.Properties.IDescription { bool isDummyRun = false; @@ -126,7 +156,11 @@ public class FileRead : Shared.FileRead, IFileRead List descriptions = GetDuplicatorDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) + { + if (tests.Length > 0) + WriteFirstLineTabSeparatedValuesFile(reportFullPath, dateTime, descriptions, pdsf.Item2, pdsf.Item3); FileCopy(reportFullPath, dateTime, descriptions); + } results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs index a29de9a..9977d61 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs @@ -117,6 +117,8 @@ public class FileRead : Shared.FileRead, IFileRead if (!Directory.Exists(directory)) _ = Directory.CreateDirectory(directory); string fullPath = Path.Combine(directory, Path.GetFileName(reportFullPath)); + if (File.Exists(fullPath)) + File.Delete(fullPath); File.Copy(reportFullPath, fullPath); WSRequest wsRequest = new(this, _Logistics, descriptions, fullPath); (string json, WS.Results wsResults) = WS.SendData(_OpenInsightMetrologyViewerAPI, wsRequest); diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs index c7823a3..0f59937 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs @@ -118,13 +118,13 @@ public class FileRead : Shared.FileRead, IFileRead _ = Directory.CreateDirectory(jobIdDirectory); string json; string[] matchDirectories = GetInProcessDirectory(jobIdDirectory); - if (!_StaticRuns.ContainsKey(_Logistics.Sequence)) + if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List collection)) json = string.Empty; else { - if (_StaticRuns[_Logistics.Sequence].Count != 1) + if (collection.Count != 1) throw new Exception($"{nameof(_StaticRuns)} has too many values for {_Logistics.Sequence}!"); - json = _StaticRuns[_Logistics.Sequence][0]; + json = collection[0]; lock (_StaticRuns) _ = _StaticRuns.Remove(_Logistics.Sequence); } diff --git a/Adaptation/FileHandlers/QS408M/Description.cs b/Adaptation/FileHandlers/QS408M/Description.cs index 8837a9f..1df606b 100644 --- a/Adaptation/FileHandlers/QS408M/Description.cs +++ b/Adaptation/FileHandlers/QS408M/Description.cs @@ -55,21 +55,6 @@ public class Description : IDescription, Shared.Properties.IDescription public string ThicknessFourteenCriticalPointsAverage { get; set; } public string ThicknessFourteenCriticalPointsStdDev { get; set; } public string ThicknessFourteenMeanFrom { get; set; } - // - public string Thickness01 { get; set; } - public string Thickness02 { get; set; } - public string Thickness03 { get; set; } - public string Thickness04 { get; set; } - public string Thickness05 { get; set; } - public string Thickness06 { get; set; } - public string Thickness07 { get; set; } - public string Thickness08 { get; set; } - public string Thickness09 { get; set; } - public string Thickness10 { get; set; } - public string Thickness11 { get; set; } - public string Thickness12 { get; set; } - public string Thickness13 { get; set; } - public string Thickness14 { get; set; } string IDescription.GetEventDescription() => "File Has been read and parsed"; @@ -254,20 +239,6 @@ public class Description : IDescription, Shared.Properties.IDescription ThicknessFourteenCriticalPointsAverage = processData.ThicknessFourteenCriticalPointsAverage, ThicknessFourteenCriticalPointsStdDev = processData.ThicknessFourteenCriticalPointsStdDev, ThicknessFourteenMeanFrom = processData.ThicknessFourteenMeanFrom, - Thickness01 = iProcessData.Details.Count < 1 || iProcessData.Details[0] is not Detail thickness01 ? string.Empty : thickness01.Thickness, - Thickness02 = iProcessData.Details.Count < 2 || iProcessData.Details[1] is not Detail thickness02 ? string.Empty : thickness02.Thickness, - Thickness03 = iProcessData.Details.Count < 3 || iProcessData.Details[2] is not Detail thickness03 ? string.Empty : thickness03.Thickness, - Thickness04 = iProcessData.Details.Count < 4 || iProcessData.Details[3] is not Detail thickness04 ? string.Empty : thickness04.Thickness, - Thickness05 = iProcessData.Details.Count < 5 || iProcessData.Details[4] is not Detail thickness05 ? string.Empty : thickness05.Thickness, - Thickness06 = iProcessData.Details.Count < 6 || iProcessData.Details[5] is not Detail thickness06 ? string.Empty : thickness06.Thickness, - Thickness07 = iProcessData.Details.Count < 7 || iProcessData.Details[6] is not Detail thickness07 ? string.Empty : thickness07.Thickness, - Thickness08 = iProcessData.Details.Count < 8 || iProcessData.Details[7] is not Detail thickness08 ? string.Empty : thickness08.Thickness, - Thickness09 = iProcessData.Details.Count < 9 || iProcessData.Details[8] is not Detail thickness09 ? string.Empty : thickness09.Thickness, - Thickness10 = iProcessData.Details.Count < 10 || iProcessData.Details[9] is not Detail thickness10 ? string.Empty : thickness10.Thickness, - Thickness11 = iProcessData.Details.Count < 11 || iProcessData.Details[10] is not Detail thickness11 ? string.Empty : thickness11.Thickness, - Thickness12 = iProcessData.Details.Count < 12 || iProcessData.Details[11] is not Detail thickness12 ? string.Empty : thickness12.Thickness, - Thickness13 = iProcessData.Details.Count < 13 || iProcessData.Details[12] is not Detail thickness13 ? string.Empty : thickness13.Thickness, - Thickness14 = iProcessData.Details.Count < 14 || iProcessData.Details[13] is not Detail thickness14 ? string.Empty : thickness14.Thickness, }; results.Add(description); } @@ -330,21 +301,6 @@ public class Description : IDescription, Shared.Properties.IDescription ThicknessFourteenCriticalPointsAverage = nameof(ThicknessFourteenCriticalPointsAverage), ThicknessFourteenCriticalPointsStdDev = nameof(ThicknessFourteenCriticalPointsStdDev), ThicknessFourteenMeanFrom = nameof(ThicknessFourteenMeanFrom), - // - Thickness01 = nameof(Thickness01), - Thickness02 = nameof(Thickness02), - Thickness03 = nameof(Thickness03), - Thickness04 = nameof(Thickness04), - Thickness05 = nameof(Thickness05), - Thickness06 = nameof(Thickness06), - Thickness07 = nameof(Thickness07), - Thickness08 = nameof(Thickness08), - Thickness09 = nameof(Thickness09), - Thickness10 = nameof(Thickness10), - Thickness11 = nameof(Thickness11), - Thickness12 = nameof(Thickness12), - Thickness13 = nameof(Thickness13), - Thickness14 = nameof(Thickness14), }; return result; } diff --git a/Adaptation/Infineon/Monitoring/MonA/MonIn.cs b/Adaptation/Infineon/Monitoring/MonA/MonIn.cs index e9ffce8..7a8a711 100644 --- a/Adaptation/Infineon/Monitoring/MonA/MonIn.cs +++ b/Adaptation/Infineon/Monitoring/MonA/MonIn.cs @@ -18,21 +18,12 @@ public class MonIn : IMonIn, IDisposable public static MonIn GetInstance(string url = "http://moninhttp.{0}.infineon.com/input/text") { MonIn instance; - if (_Instances.ContainsKey(url)) + lock (_Instances) { - instance = _Instances[url]; - } - else - { - lock (_Instances) + if (_Instances.TryGetValue(url, out instance)) { - if (!_Instances.ContainsKey(url)) - { - instance = new MonIn(url); - _Instances.Add(url, instance); - } - else - instance = _Instances[url]; + instance = new MonIn(url); + _Instances.Add(url, instance); } } return instance; diff --git a/Adaptation/MET08THFTIRQS408M-Development.yml b/Adaptation/MET08THFTIRQS408M-Development.yml index 7e61036..2bdf8ea 100644 --- a/Adaptation/MET08THFTIRQS408M-Development.yml +++ b/Adaptation/MET08THFTIRQS408M-Development.yml @@ -68,6 +68,7 @@ steps: - task: CopyFiles@2 displayName: "Copy Files to: - GhostPCL" inputs: + Contents: '*' SourceFolder: '\\mesfs.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\GhostPCL\gpcl6win64' TargetFolder: 'Adaptation\bin\$(Configuration)\net6.0\win-x64' OverWrite: true @@ -76,6 +77,7 @@ steps: - task: CopyFiles@2 displayName: "Copy Files to: - LincPDFC" inputs: + Contents: '*' SourceFolder: '\\mesfs.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\LincPDFC\v2.6.6.21' TargetFolder: 'Adaptation\bin\$(Configuration)\net6.0\win-x64' OverWrite: true @@ -84,6 +86,7 @@ steps: - task: CopyFiles@2 displayName: "Copy Files to: - PDF-Text-Stripper" inputs: + Contents: '*' SourceFolder: '\\mesfs.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\PDF-Text-Stripper\v4.8.0.1' TargetFolder: 'Adaptation\bin\$(Configuration)\net6.0\win-x64' OverWrite: true @@ -157,8 +160,8 @@ steps: - task: CopyFiles@2 displayName: 'Copy Files to: D:\Framework4.8' inputs: - SourceFolder: 'bin\$(Configuration)' Contents: "*$(Build.Repository.Name)*" + SourceFolder: 'bin\$(Configuration)' TargetFolder: 'D:\Framework4.8\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)' OverWrite: true enabled: false @@ -166,8 +169,8 @@ steps: - task: CopyFiles@2 displayName: 'Copy Files to: \\mesfs.infineon.com\EC_EAFRepository' inputs: - SourceFolder: 'bin\$(Configuration)' Contents: "*$(Build.Repository.Name)*" + SourceFolder: 'bin\$(Configuration)' TargetFolder: '\\mesfs.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\Adaptation_$(Build.Repository.Name)' OverWrite: true enabled: false diff --git a/Adaptation/MET08THFTIRQS408M.yml b/Adaptation/MET08THFTIRQS408M.yml index 214799e..0a62c31 100644 --- a/Adaptation/MET08THFTIRQS408M.yml +++ b/Adaptation/MET08THFTIRQS408M.yml @@ -68,6 +68,7 @@ steps: - task: CopyFiles@2 displayName: "Copy Files to: - GhostPCL" inputs: + Contents: '*' SourceFolder: '\\mesfs.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\GhostPCL\gpcl6win64' TargetFolder: 'Adaptation\bin\$(Configuration)\net6.0\win-x64' OverWrite: true @@ -75,6 +76,7 @@ steps: - task: CopyFiles@2 displayName: "Copy Files to: - LincPDFC" inputs: + Contents: '*' SourceFolder: '\\mesfs.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\LincPDFC\v2.6.6.21' TargetFolder: 'Adaptation\bin\$(Configuration)\net6.0\win-x64' OverWrite: true @@ -82,6 +84,7 @@ steps: - task: CopyFiles@2 displayName: "Copy Files to: - PDF-Text-Stripper" inputs: + Contents: '*' SourceFolder: '\\mesfs.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\PDF-Text-Stripper\v4.8.0.1' TargetFolder: 'Adaptation\bin\$(Configuration)\net6.0\win-x64' OverWrite: true @@ -154,16 +157,16 @@ steps: - task: CopyFiles@2 displayName: 'Copy Files to: D:\Framework4.8' inputs: - SourceFolder: 'bin\$(Configuration)' Contents: "*$(Build.Repository.Name)*" + SourceFolder: 'bin\$(Configuration)' TargetFolder: 'D:\Framework4.8\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)' OverWrite: true - task: CopyFiles@2 displayName: 'Copy Files to: \\mesfs.infineon.com\EC_EAFRepository' inputs: - SourceFolder: 'bin\$(Configuration)' Contents: "*$(Build.Repository.Name)*" + SourceFolder: 'bin\$(Configuration)' TargetFolder: '\\mesfs.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\Adaptation_$(Build.Repository.Name)' OverWrite: true diff --git a/Adaptation/Shared/FileRead.cs b/Adaptation/Shared/FileRead.cs index 6788118..b58c1e9 100644 --- a/Adaptation/Shared/FileRead.cs +++ b/Adaptation/Shared/FileRead.cs @@ -377,7 +377,7 @@ public class FileRead : Properties.IFileRead _ = stringBuilder.Append('<').Append(duplicateFiles[i]).Append("> "); } } - throw new Exception(string.Concat("After {", _BreakAfterSeconds, "} seconds, right side of {", sourceDirectoryCloaking, "} didn'fileName consume file(s) ", stringBuilder)); + throw new Exception(string.Concat("After {", _BreakAfterSeconds, "} seconds, right side of {", sourceDirectoryCloaking, "} didn't consume file(s) ", stringBuilder)); } Thread.Sleep(250); } @@ -460,6 +460,7 @@ public class FileRead : Properties.IFileRead protected void TriggerEvents(Tuple> extractResults, List headerNames, Dictionary keyValuePairs) { object value; + string segments; string description; List list; for (int i = 0; i < extractResults.Item3.Length; i++) @@ -467,10 +468,10 @@ public class FileRead : Properties.IFileRead _Log.Debug(string.Concat("TriggerEvent - {", _Logistics.ReportFullPath, "} ", i, " of ", extractResults.Item3.Length)); foreach (JsonProperty jsonProperty in extractResults.Item3[i].EnumerateObject()) { - if (jsonProperty.Value.ValueKind != JsonValueKind.String || !keyValuePairs.ContainsKey(jsonProperty.Name)) + if (jsonProperty.Value.ValueKind != JsonValueKind.String || !keyValuePairs.TryGetValue(jsonProperty.Name, out segments)) description = string.Empty; else - description = keyValuePairs[jsonProperty.Name].Split('|')[0]; + description = segments.Split('|')[0]; if (!_UseCyclicalForDescription || headerNames.Contains(jsonProperty.Name)) value = jsonProperty.Value.ToString(); else diff --git a/Adaptation/Shared/ProcessDataStandardFormat.cs b/Adaptation/Shared/ProcessDataStandardFormat.cs index e9691b1..136ccae 100644 --- a/Adaptation/Shared/ProcessDataStandardFormat.cs +++ b/Adaptation/Shared/ProcessDataStandardFormat.cs @@ -211,9 +211,10 @@ public class ProcessDataStandardFormat public static Tuple>>> GetTestDictionary(Tuple pdsf) { Dictionary>> results = new(); + List collection; string testColumn = nameof(Test); Dictionary> keyValuePairs = GetDictionary(pdsf); - if (!keyValuePairs.ContainsKey(testColumn)) + if (!keyValuePairs.TryGetValue(testColumn, out collection)) throw new Exception(); int min; int max; @@ -221,9 +222,9 @@ public class ProcessDataStandardFormat List vs; string columnKey; Dictionary> tests = new(); - for (int i = 0; i < keyValuePairs[testColumn].Count; i++) + for (int i = 0; i < collection.Count; i++) { - if (Enum.TryParse(keyValuePairs[testColumn][i], out Test test)) + if (Enum.TryParse(collection[i], out Test test)) { if (!results.ContainsKey(test)) { diff --git a/Adaptation/_Tests/Extract/Staging/v2.52.0/MET08THFTIRQS408M.cs b/Adaptation/_Tests/Extract/Staging/v2.52.0/MET08THFTIRQS408M.cs index 974a2b2..95fb80f 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.52.0/MET08THFTIRQS408M.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.52.0/MET08THFTIRQS408M.cs @@ -41,6 +41,26 @@ public class MET08THFTIRQS408M [TestMethod] public void Staging__v2_52_0__MET08THFTIRQS408M__IQSSi() => _MET08THFTIRQS408M.Staging__v2_52_0__MET08THFTIRQS408M__IQSSi(); +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_52_0__MET08THFTIRQS408M__IQSSi638402505394171507__IqsSql() + { + DateTime dateTime; + string check = "*.pdsf"; + MethodBase methodBase = new StackFrame().GetMethod(); + _MET08THFTIRQS408M.Staging__v2_52_0__MET08THFTIRQS408M__IQSSi(); + string[] variables = _MET08THFTIRQS408M.AdaptationTesting.GetVariables(methodBase, check, validatePDSF: false); + IFileRead fileRead = _MET08THFTIRQS408M.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); + Logistics logistics = new(fileRead); + dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: string.Empty); + Assert.IsTrue(dateTime == logistics.DateTimeFromSequence); + dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: "Tue Nov 10 12:03:56 1970"); + Assert.IsTrue(dateTime == logistics.DateTimeFromSequence); + _ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics); + } + #if DEBUG [Ignore] #endif diff --git a/Adaptation/_Tests/Shared/AdaptationTesting.cs b/Adaptation/_Tests/Shared/AdaptationTesting.cs index 2249c59..178b9ea 100644 --- a/Adaptation/_Tests/Shared/AdaptationTesting.cs +++ b/Adaptation/_Tests/Shared/AdaptationTesting.cs @@ -373,9 +373,7 @@ public class AdaptationTesting : ISMTP Tuple result; CellInstanceVersion cellInstanceVersion; string cellInstanceServiceV2 = string.Concat("http://", _HostNameAndPort, "/CellInstanceServiceV2/", cellInstanceName, "/", cellInstanceVersionName, "/configuration"); - if (_CellInstanceVersions.ContainsKey(cellInstanceServiceV2)) - cellInstanceVersion = _CellInstanceVersions[cellInstanceServiceV2]; - else + if (!_CellInstanceVersions.TryGetValue(cellInstanceServiceV2, out cellInstanceVersion)) { cellInstanceVersion = GetCellInstanceVersion(cellInstanceServiceV2); _CellInstanceVersions.Add(cellInstanceServiceV2, cellInstanceVersion); @@ -413,9 +411,8 @@ public class AdaptationTesting : ISMTP result = componentModelComponentsIndexes.ElementAt(0).Value; else { - if (componentModelComponentsIndexes is null || !componentModelComponentsIndexes.ContainsKey(cellInstanceConnectionName)) + if (componentModelComponentsIndexes is null || !componentModelComponentsIndexes.TryGetValue(cellInstanceConnectionName, out result)) throw new Exception(); - result = componentModelComponentsIndexes[cellInstanceConnectionName]; } return result; } @@ -648,9 +645,7 @@ public class AdaptationTesting : ISMTP Tuple result; FileConnectorConfiguration fileConnectorConfiguration; string cellInstanceServiceV2With = string.Concat(cellInstanceVersionTuple.Item1, '/', cellInstanceConnectionName); - if (_FileConnectorConfigurations.ContainsKey(cellInstanceServiceV2With)) - fileConnectorConfiguration = _FileConnectorConfigurations[cellInstanceServiceV2With]; - else + if (!_FileConnectorConfigurations.TryGetValue(cellInstanceServiceV2With, out fileConnectorConfiguration)) { Dictionary componentModelComponentsIndexes = GetComponentModelComponentsIndexes(cellInstanceVersionTuple.Item2, cellInstanceConnectionName); int[] cellInstanceConnectionNameIndexes = GetCellInstanceConnectionNameIndexes(cellInstanceConnectionName, componentModelComponentsIndexes); @@ -696,9 +691,7 @@ public class AdaptationTesting : ISMTP int[] cellInstanceConnectionNameIndexes = GetCellInstanceConnectionNameIndexes(cellInstanceConnectionName, componentModelComponentsIndexes); ComponentsCellComponentCellComponent componentsCellComponentCellComponent = cellInstanceVersion.ComponentModel.Components[cellInstanceConnectionNameIndexes[0]].Children[cellInstanceConnectionNameIndexes[1]]; string equipmentTypeServiceV2 = string.Concat("http://", _HostNameAndPort, "/EquipmentTypeServiceV2/", componentsCellComponentCellComponent.Equipment.EquipmentType.Name, "/", componentsCellComponentCellComponent.Equipment.EquipmentType.Version, "/configuration"); - if (_EquipmentTypeVersions.ContainsKey(equipmentTypeServiceV2)) - equipmentTypeVersion = _EquipmentTypeVersions[equipmentTypeServiceV2]; - else + if (!_EquipmentTypeVersions.TryGetValue(equipmentTypeServiceV2, out equipmentTypeVersion)) { equipmentTypeVersion = GetEquipmentTypeVersion(equipmentTypeServiceV2); _EquipmentTypeVersions.Add(equipmentTypeServiceV2, equipmentTypeVersion); @@ -834,9 +827,7 @@ public class AdaptationTesting : ISMTP equipmentDictionaryVersion = null; else { - if (_EquipmentDictionaryVersions.ContainsKey(equipmentDictionaryServiceV2)) - equipmentDictionaryVersion = _EquipmentDictionaryVersions[equipmentDictionaryServiceV2]; - else + if (!_EquipmentDictionaryVersions.TryGetValue(equipmentDictionaryServiceV2, out equipmentDictionaryVersion)) { equipmentDictionaryVersion = GetEquipmentDictionaryVersion(equipmentDictionaryServiceV2); _EquipmentDictionaryVersions.Add(equipmentDictionaryServiceV2, equipmentDictionaryVersion); @@ -850,14 +841,15 @@ public class AdaptationTesting : ISMTP { Tuple>> result; List> results; + List> collection; if (_SkipEquipmentDictionary) results = new List>(); else if (string.IsNullOrEmpty(equipmentDictionaryVersionTuple.Item1)) throw new Exception(); else if (equipmentDictionaryVersionTuple?.Item4?.Events?.Event is null) results = new List>(); - else if (_EquipmentDictionaryEventDescriptions.ContainsKey(equipmentDictionaryVersionTuple.Item1)) - results = _EquipmentDictionaryEventDescriptions[equipmentDictionaryVersionTuple.Item1]; + else if (_EquipmentDictionaryEventDescriptions.TryGetValue(equipmentDictionaryVersionTuple.Item1, out collection)) + results = collection; else { results = new List>();