diff --git a/.gitignore b/.gitignore index 1629816..96748f3 100644 --- a/.gitignore +++ b/.gitignore @@ -342,4 +342,4 @@ ASALocalRun/ *.lnk -.kanbn/**/* \ No newline at end of file +.kanbn \ No newline at end of file diff --git a/.vscode/mklink.md b/.vscode/mklink.md index 7a8fc3a..57c59a7 100644 --- a/.vscode/mklink.md +++ b/.vscode/mklink.md @@ -7,5 +7,5 @@ updated: "2023-10-20T03:53:49.161Z" # mklink ```bash -mklink /J "L:\Workspaces\33_CS29_79_72\MIT_EAF_Adaptations\Trunk\MESAFIBACKLOG\06_SourceCode\MESAFIBACKLOG\.kanbn" "D:\Documents\Kanban\MESAFIBACKLOG" +mklink /J "L:\Workspaces\33_CS29_79_72\MIT_EAF_Adaptations\Trunk\MESAFIBACKLOG\06_SourceCode\MESAFIBACKLOG\.kanbn" "D:\5-Other-Small\Kanban\MESAFIBACKLOG" ``` diff --git a/Adaptation/.editorconfig b/Adaptation/.editorconfig index b45701e..bd60911 100644 --- a/Adaptation/.editorconfig +++ b/Adaptation/.editorconfig @@ -1,3 +1,19 @@ +[*.md] +end_of_line = crlf +file_header_template = unset +indent_size = 2 +indent_style = space +insert_final_newline = false +root = true +tab_width = 2 +[*.csproj] +end_of_line = crlf +file_header_template = unset +indent_size = 2 +indent_style = space +insert_final_newline = false +root = true +tab_width = 2 [*.cs] csharp_indent_block_contents = true csharp_indent_braces = false @@ -82,13 +98,29 @@ 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.CA1862.severity = none # CA1862: Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison, but keep in mind that this might cause subtle changes in behavior, so make sure to conduct thorough testing after applying the suggestion, or if culturally sensitive comparison is not required, consider using 'StringComparison.OrdinalIgnoreCase' +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 dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2"); dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary +dotnet_diagnostic.IDE0028.severity = none # IDE0028: Collection initialization can be simplified +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: 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/.vscode/mklink.md b/Adaptation/.vscode/mklink.md index 931ca61..00621a3 100644 --- a/Adaptation/.vscode/mklink.md +++ b/Adaptation/.vscode/mklink.md @@ -7,7 +7,7 @@ updated: "2023-10-20T03:57:15.006Z" # mklink ```bash -mklink /J "T:\MESAFIBACKLOG\06_SourceCode\MESAFIBACKLOG\Adaptation\.kanbn" "D:\Documents\Kanban\MESAFIBACKLOG" +mklink /J "T:\MESAFIBACKLOG\06_SourceCode\MESAFIBACKLOG\Adaptation\.kanbn" "D:\5-Other-Small\Kanban\MESAFIBACKLOG" ``` ```bash diff --git a/Adaptation/.vscode/tasks.json b/Adaptation/.vscode/tasks.json index 3fe87f9..e6fe202 100644 --- a/Adaptation/.vscode/tasks.json +++ b/Adaptation/.vscode/tasks.json @@ -57,7 +57,7 @@ { "label": "File-Folder-Helper AOT s M .Kanbn Tasks", "type": "shell", - "command": "& L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net7.0/win-x64/publish/File-Folder-Helper.exe s M T:/MESAFIBACKLOG/06_SourceCode/MESAFIBACKLOG/Adaptation -s T:/MESAFIBACKLOG/06_SourceCode/MESAFIBACKLOG/Adaptation/.kanbn/tasks", + "command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s M T:/MESAFIBACKLOG/06_SourceCode/MESAFIBACKLOG/Adaptation -s T:/MESAFIBACKLOG/06_SourceCode/MESAFIBACKLOG/Adaptation/.kanbn/tasks", "problemMatcher": [] }, { diff --git a/Adaptation/FileHandlers/Archive/FileRead.cs b/Adaptation/FileHandlers/Archive/FileRead.cs index d1b13df..ae322c7 100644 --- a/Adaptation/FileHandlers/Archive/FileRead.cs +++ b/Adaptation/FileHandlers/Archive/FileRead.cs @@ -127,7 +127,7 @@ public class FileRead : Shared.FileRead, IFileRead string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID); if (!Directory.Exists(jobIdDirectory)) _ = Directory.CreateDirectory(jobIdDirectory); - if (!Directory.GetDirectories(jobIdDirectory).Any()) + if (Directory.GetDirectories(jobIdDirectory).Length == 0) File.Copy(reportFullPath, Path.Combine(destinationArchiveDirectory, Path.GetFileName(reportFullPath))); else { diff --git a/Adaptation/FileHandlers/ConvertExcelToJson/FileRead.cs b/Adaptation/FileHandlers/ConvertExcelToJson/FileRead.cs index c0f16c3..0bf0f27 100644 --- a/Adaptation/FileHandlers/ConvertExcelToJson/FileRead.cs +++ b/Adaptation/FileHandlers/ConvertExcelToJson/FileRead.cs @@ -6,7 +6,6 @@ using Adaptation.Shared.Methods; using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text.Json; using System.Threading; @@ -109,7 +108,7 @@ public class FileRead : Shared.FileRead, IFileRead else { IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _SheetName); - if (!iProcessData.Details.Any()) + if (iProcessData.Details.Count == 0) throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks)); string json = iProcessData.Details[0].ToString(); string fileName = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, $"{Path.GetFileNameWithoutExtension(reportFullPath)} - {_SheetName}{_FileConnectorConfiguration.TargetFileName}"); diff --git a/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs b/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs index 05f4bb2..6fd5e28 100644 --- a/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs +++ b/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs @@ -160,7 +160,7 @@ public class ProcessData : IProcessData if (!fileRead.IsEAFHosted) File.WriteAllText(".json", json); JsonElement[]? jsonElements = JsonSerializer.Deserialize(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); - if (jsonElements is null || !jsonElements.Any()) + if (jsonElements is null || jsonElements.Length == 0) throw new NullReferenceException(); if (!fileRead.ReportFullPath.Contains("Backlog")) json = JsonSerializer.Serialize(jsonElements, new JsonSerializerOptions() { WriteIndented = true }); diff --git a/Adaptation/FileHandlers/Dummy/FileRead.cs b/Adaptation/FileHandlers/Dummy/FileRead.cs index 79eda27..916f5d7 100644 --- a/Adaptation/FileHandlers/Dummy/FileRead.cs +++ b/Adaptation/FileHandlers/Dummy/FileRead.cs @@ -157,7 +157,7 @@ public class FileRead : Shared.FileRead, IFileRead if (!Directory.Exists(inProcessDirectory)) _ = Directory.CreateDirectory(inProcessDirectory); files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.AllDirectories); - if (files.Any()) + if (files.Length != 0) { if (files.Length > 250) throw new Exception("Safety net!"); diff --git a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs index 39f8d62..2d8a495 100644 --- a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs +++ b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs @@ -6,7 +6,6 @@ using Adaptation.Shared.Methods; using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Text.Json; using System.Threading; @@ -129,7 +128,7 @@ public class FileRead : Shared.FileRead, IFileRead for (int i = 0; i < int.MaxValue; i++) { found = Directory.GetFiles(searchDirectory, fileName, SearchOption.AllDirectories); - if (found.Any()) + if (found.Length != 0) { results.AddRange(found); break; @@ -205,7 +204,7 @@ public class FileRead : Shared.FileRead, IFileRead Thread.Sleep(500); } } - if (postCollection.Any()) + if (postCollection.Count != 0) { Thread.Sleep(500); StringBuilder stringBuilder = new(); diff --git a/Adaptation/FileHandlers/json/FileRead.cs b/Adaptation/FileHandlers/json/FileRead.cs index dc345c0..62a02e1 100644 --- a/Adaptation/FileHandlers/json/FileRead.cs +++ b/Adaptation/FileHandlers/json/FileRead.cs @@ -10,7 +10,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Text; @@ -182,7 +181,7 @@ public class FileRead : Shared.FileRead, IFileRead forceDeleteUpdatedBy); if (iProcessData is not ProcessData _) throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks)); - if (!iProcessData.Details.Any()) + if (iProcessData.Details.Count == 0) throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks)); results = iProcessData.GetResults(this, _Logistics, results.Item4); Json = json; diff --git a/Adaptation/FileHandlers/json/ProcessData.cs b/Adaptation/FileHandlers/json/ProcessData.cs index 0837e3f..17fc8b1 100644 --- a/Adaptation/FileHandlers/json/ProcessData.cs +++ b/Adaptation/FileHandlers/json/ProcessData.cs @@ -81,7 +81,7 @@ public class ProcessData : IProcessData string key; FIBacklogMesa[]? fiBacklogMesaCollection; fiBacklogMesaCollection = JsonSerializer.Deserialize(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); - if (fiBacklogMesaCollection is null || !fiBacklogMesaCollection.Any()) + if (fiBacklogMesaCollection is null || fiBacklogMesaCollection.Length == 0) throw new NullReferenceException(); foreach (FIBacklogMesa fiBacklogMesa in fiBacklogMesaCollection) { @@ -138,7 +138,7 @@ public class ProcessData : IProcessData if (!fileRead.IsEAFHosted) File.WriteAllText("../../example.json", jsonElement.Value.EnumerateObject().Last().Value.ToString()); results = JsonSerializer.Deserialize(jsonElement.Value.EnumerateObject().Last().Value); - if (results is null || !results.Any()) + if (results is null || results.Length == 0) throw new NullReferenceException(nameof(results)); return results; } @@ -726,7 +726,7 @@ public class ProcessData : IProcessData string forceUpdatedByComment = "Force updated by"; string? directory = Path.GetDirectoryName(fileRead.ReportFullPath) ?? throw new Exception(); string[] checkFiles = Directory.GetFiles(directory, "*.csv", SearchOption.TopDirectoryOnly); - if (checkFiles.Any()) + if (checkFiles.Length != 0) UpdateIds(httpClient, basePage, api, checkFiles); else { 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/MESAFIBACKLOG-Development.yml b/Adaptation/MESAFIBACKLOG-Development.yml index 1c1a388..671e666 100644 --- a/Adaptation/MESAFIBACKLOG-Development.yml +++ b/Adaptation/MESAFIBACKLOG-Development.yml @@ -133,18 +133,18 @@ 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 - task: CopyFiles@2 - displayName: 'Copy Files to: \\messv02ecc1.ec.local\EC_EAFRepository' + displayName: 'Copy Files to: \\mesfs.infineon.com\EC_EAFRepository' inputs: - SourceFolder: 'bin\$(Configuration)' Contents: "*$(Build.Repository.Name)*" - TargetFolder: '\\messv02ecc1.ec.local\EC_EAFRepository\Staging\DeploymentStorage\Adaptation_$(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/MESAFIBACKLOG.Tests.csproj b/Adaptation/MESAFIBACKLOG.Tests.csproj index fe18da2..9374e8b 100644 --- a/Adaptation/MESAFIBACKLOG.Tests.csproj +++ b/Adaptation/MESAFIBACKLOG.Tests.csproj @@ -8,10 +8,9 @@ disable false - 10.0 disable win-x64 - net7.0 + net8.0 trx @@ -43,30 +42,32 @@ NU1701 NU1701 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + NU1701 - - - + + + - - + + + + + diff --git a/Adaptation/MESAFIBACKLOG.yml b/Adaptation/MESAFIBACKLOG.yml index 58f4890..98b1e8a 100644 --- a/Adaptation/MESAFIBACKLOG.yml +++ b/Adaptation/MESAFIBACKLOG.yml @@ -134,16 +134,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: \\messv02ecc1.ec.local\EC_EAFRepository' + displayName: 'Copy Files to: \\mesfs.infineon.com\EC_EAFRepository' inputs: - SourceFolder: 'bin\$(Configuration)' Contents: "*$(Build.Repository.Name)*" + SourceFolder: 'bin\$(Configuration)' TargetFolder: 'D:\EAF\EAF Deployment Storage\Adaptation_$(Build.Repository.Name)' OverWrite: true diff --git a/Adaptation/Shared/FileRead.cs b/Adaptation/Shared/FileRead.cs index f66b29b..16fcf8a 100644 --- a/Adaptation/Shared/FileRead.cs +++ b/Adaptation/Shared/FileRead.cs @@ -163,7 +163,7 @@ public class FileRead : Properties.IFileRead protected static ModelObjectParameterDefinition[] GetProperties(string cellInstanceConnectionName, IList modelObjectParameters, string propertyNamePrefix) { ModelObjectParameterDefinition[] results = (from l in modelObjectParameters where l.Name.StartsWith(propertyNamePrefix) select l).ToArray(); - if (!results.Any()) + if (results.Length == 0) throw new Exception(cellInstanceConnectionName); return results; } @@ -171,7 +171,7 @@ public class FileRead : Properties.IFileRead protected static ModelObjectParameterDefinition[] GetProperties(string cellInstanceConnectionName, IList modelObjectParameters, string propertyNamePrefix, string propertyNameSuffix) { ModelObjectParameterDefinition[] results = (from l in modelObjectParameters where l.Name.StartsWith(propertyNamePrefix) && l.Name.EndsWith(propertyNameSuffix) select l).ToArray(); - if (!results.Any()) + if (results.Length == 0) throw new Exception(cellInstanceConnectionName); return results; } @@ -203,7 +203,7 @@ public class FileRead : Properties.IFileRead } lock (threadExceptions) { - if (threadExceptions.Any()) + if (threadExceptions.Count != 0) { foreach (Exception item in threadExceptions) _Log.Error(string.Concat(item.Message, Environment.NewLine, Environment.NewLine, item.StackTrace)); @@ -241,7 +241,7 @@ public class FileRead : Properties.IFileRead if (!_IsDuplicator) WriteAllLines(to, results); } - if (extractResults is not null && extractResults.Item4 is not null && extractResults.Item4.Any()) + if (extractResults is not null && extractResults.Item4 is not null && extractResults.Item4.Count != 0) { string itemFile; List directories = new(); @@ -268,7 +268,7 @@ public class FileRead : Properties.IFileRead string dateValue; string rdsPlaceholder = "%RDS%"; string mesEntityPlaceholder = "%MesEntity%"; - if (!descriptions.Any() || string.IsNullOrEmpty(descriptions[0].RDS)) + if (descriptions.Count == 0 || string.IsNullOrEmpty(descriptions[0].RDS)) rds = logistics.MID; else rds = descriptions[0].RDS; @@ -312,7 +312,7 @@ public class FileRead : Properties.IFileRead preWait = dateTime.AddMilliseconds(1234).Ticks; else preWait = dateTime.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks; - if (!collection.Any()) + if (collection.Count == 0) duplicateFiles.Add(duplicateFile); string fileName = Path.GetFileNameWithoutExtension(logistics.ReportFullPath); string successFile = string.Concat(successDirectory, @"\", Path.GetFileName(logistics.ReportFullPath)); @@ -422,10 +422,12 @@ public class FileRead : Properties.IFileRead protected void WritePDSF(IFileRead fileRead, JsonElement[] jsonElements) { string directory; + string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); + string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}"; if (!_CellInstanceConnectionName.StartsWith(_CellInstanceName) && _CellInstanceConnectionNameBase == _EquipmentType) - directory = Path.Combine(_TracePath, _EquipmentType, "Target", _CellInstanceName, _CellInstanceConnectionName); + directory = Path.Combine(_TracePath, _EquipmentType, "Target", weekDirectory, _CellInstanceName, _CellInstanceConnectionName); else - directory = Path.Combine(_TracePath, _EquipmentType, "Source", _CellInstanceName, _CellInstanceConnectionName); + directory = Path.Combine(_TracePath, _EquipmentType, "Source", weekDirectory, _CellInstanceName, _CellInstanceConnectionName); if (!Directory.Exists(directory)) _ = Directory.CreateDirectory(directory); string file = Path.Combine(directory, string.Concat(_Logistics.MesEntity, "_", _Logistics.Sequence, ".ipdsf")); @@ -460,6 +462,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 +470,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 @@ -502,10 +505,10 @@ public class FileRead : Properties.IFileRead matches = Directory.GetFiles(_FileConnectorConfiguration.SourceFileLocation, segments.Last(), SearchOption.AllDirectories); else matches = Directory.GetFiles(_FileConnectorConfiguration.SourceFileLocation, segments.Last(), SearchOption.TopDirectoryOnly); - if (matches.Any()) + if (matches.Length != 0) break; } - if (matches is null || !matches.Any()) + if (matches is null || matches.Length == 0) results = null; else { @@ -568,16 +571,99 @@ public class FileRead : Properties.IFileRead } } + internal static List GetDirectoryNames(string directory) + { +#nullable enable + List results = new(); + string? fileName; + string? checkDirectory = directory; + string? pathRoot = Path.GetPathRoot(directory); + string extension = Path.GetExtension(directory); + if (string.IsNullOrEmpty(pathRoot)) + throw new NullReferenceException(nameof(pathRoot)); + if (Directory.Exists(directory)) + { + fileName = Path.GetFileName(directory); + if (!string.IsNullOrEmpty(fileName)) + results.Add(fileName); + } + else if ((string.IsNullOrEmpty(extension) || extension.Length > 3) && !File.Exists(directory)) + { + fileName = Path.GetFileName(directory); + if (!string.IsNullOrEmpty(fileName)) + results.Add(fileName); + } + for (int i = 0; i < int.MaxValue; i++) + { + checkDirectory = Path.GetDirectoryName(checkDirectory); + if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == pathRoot) + break; + fileName = Path.GetFileName(checkDirectory); + if (string.IsNullOrEmpty(fileName)) + continue; + results.Add(fileName); + } + results.Add(pathRoot); + results.Reverse(); + return results; +#nullable disable + } + + private string GetJobIdDirectory(string path) + { + string result; + List directoryNames = GetDirectoryNames(path); + if (!directoryNames.Contains(_Logistics.JobID)) + result = Path.GetDirectoryName(path); + else + { + result = string.Empty; + foreach (string directoryName in directoryNames) + { + result = Path.Combine(result, directoryName); + if (directoryName == _Logistics.JobID) + break; + } + } + return result; + } + + private static void DeleteEmptyTopDirectories(string rootDirectory) + { + if (Directory.Exists(rootDirectory)) + { + string[] files; + string[] directories; + string[] subDirectories = Directory.GetDirectories(rootDirectory, "*", SearchOption.TopDirectoryOnly); + foreach (string subDirectory in subDirectories) + { + files = Directory.GetFiles(subDirectory, "*", SearchOption.AllDirectories); + if (files.Length > 0) + continue; + directories = Directory.GetDirectories(subDirectory, "*", SearchOption.TopDirectoryOnly); + if (directories.Length > 0) + continue; + try + { Directory.Delete(subDirectory); } + catch (UnauthorizedAccessException) + { + new DirectoryInfo(subDirectory).Attributes = FileAttributes.Normal; + Directory.Delete(subDirectory); + } + } + } + } + private void Shared1811(string to, FileInfo sourceFile) { if (!_IsDuplicator && _FileConnectorConfiguration.SourceFileFilter != "*" && sourceFile.Exists && sourceFile.Length < _MinFileLength) { string directoryName = Path.GetFileName(to); - string jobIdDirectory = Path.GetDirectoryName(to); + string jobIdDirectory = GetJobIdDirectory(to); DateTime dateTime = DateTime.Now.AddMinutes(-15); string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}"; - string destinationDirectory = string.Concat(jobIdDirectory, @"\_ Ignore 100 bytes\", weekDirectory, @"\", directoryName); + string destinationDirectory = Path.Combine(jobIdDirectory, "_ Ignore 100 bytes", weekDirectory, directoryName); if (!Directory.Exists(destinationDirectory)) _ = Directory.CreateDirectory(destinationDirectory); File.Move(sourceFile.FullName, string.Concat(destinationDirectory, @"\", sourceFile.Name)); @@ -588,13 +674,13 @@ public class FileRead : Properties.IFileRead { if (!checkDirectory.Contains('_')) continue; - if (Directory.GetDirectories(checkDirectory, "*", SearchOption.TopDirectoryOnly).Any()) + if (Directory.GetDirectories(checkDirectory, "*", SearchOption.TopDirectoryOnly).Length != 0) continue; - if (Directory.GetFiles(checkDirectory, "*", SearchOption.TopDirectoryOnly).Any()) + if (Directory.GetFiles(checkDirectory, "*", SearchOption.TopDirectoryOnly).Length != 0) continue; - if (Directory.GetDirectories(checkDirectory, "*", SearchOption.AllDirectories).Any()) + if (Directory.GetDirectories(checkDirectory, "*", SearchOption.AllDirectories).Length != 0) continue; - if (Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories).Any()) + if (Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories).Length != 0) continue; if (new DirectoryInfo(checkDirectory).CreationTime > dateTime) continue; @@ -602,6 +688,7 @@ public class FileRead : Properties.IFileRead } } catch (Exception) { throw; } + DeleteEmptyTopDirectories(jobIdDirectory); } } @@ -611,7 +698,7 @@ public class FileRead : Properties.IFileRead { foreach (string directory in (from l in directories orderby l.Split('\\').Length descending select l).Distinct()) { - if (Directory.Exists(directory) && !Directory.GetFiles(directory).Any()) + if (Directory.Exists(directory) && Directory.GetFiles(directory).Length == 0) Directory.Delete(directory); } } diff --git a/Adaptation/Shared/Logistics.cs b/Adaptation/Shared/Logistics.cs index a6ca882..cb1f805 100644 --- a/Adaptation/Shared/Logistics.cs +++ b/Adaptation/Shared/Logistics.cs @@ -91,7 +91,7 @@ public class Logistics : ILogistics string[] segments; _FileInfo = new(reportFullPath); _Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); - if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1")) + if (Logistics1.Count == 0 || !Logistics1[0].StartsWith("LOGISTICS_1")) { _NullData = null; _JobID = "null"; diff --git a/Adaptation/Shared/ProcessDataStandardFormat.cs b/Adaptation/Shared/ProcessDataStandardFormat.cs index c165a7e..6101d68 100644 --- a/Adaptation/Shared/ProcessDataStandardFormat.cs +++ b/Adaptation/Shared/ProcessDataStandardFormat.cs @@ -23,7 +23,7 @@ public class ProcessDataStandardFormat public static string GetPDSFText(IFileRead fileRead, Logistics logistics, JsonElement[] jsonElements, string logisticsText) { string result; - if (!jsonElements.Any()) + if (jsonElements.Length == 0) result = string.Empty; else { @@ -146,7 +146,7 @@ public class ProcessDataStandardFormat string logistics = pdsf.Item1; string[] columns = pdsf.Item2; string[] bodyLines = pdsf.Item3; - if (!bodyLines.Any() || !bodyLines[0].Contains('\t')) + if (bodyLines.Length == 0 || !bodyLines[0].Contains('\t')) results = JsonSerializer.Deserialize("[]"); else { @@ -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)) { @@ -325,7 +326,7 @@ public class ProcessDataStandardFormat _ = line.Append(';'); } } - if (!pairedParameterNames.Any()) + if (pairedParameterNames.Count == 0) { _ = line.Remove(line.Length - 1, 1); _ = result.AppendLine(line.ToString()); diff --git a/Adaptation/Shared/Test.cs b/Adaptation/Shared/Test.cs index 3aa3552..169f05b 100644 --- a/Adaptation/Shared/Test.cs +++ b/Adaptation/Shared/Test.cs @@ -14,6 +14,7 @@ public enum Test CandelaPSL = 38, CandelaVerify = 37, CDE = 24, + Climatec = 54, //Largest CV = 3, DailyRPMAverage = 19, DailyRPMPLRatio = 20, @@ -38,7 +39,7 @@ public enum Test RPMPLRatio = 17, RPMXY = 15, SP1 = 8, - SRP2100 = 53, //Largest + SRP2100 = 53, Tencor = 7, UV = 35, VerificationLehighton = 14, diff --git a/Adaptation/_Tests/Shared/AdaptationTesting.cs b/Adaptation/_Tests/Shared/AdaptationTesting.cs index 0771b8b..178b9ea 100644 --- a/Adaptation/_Tests/Shared/AdaptationTesting.cs +++ b/Adaptation/_Tests/Shared/AdaptationTesting.cs @@ -305,7 +305,7 @@ public class AdaptationTesting : ISMTP else { results = Directory.GetFiles(mbn.TextFileDirectory, "*.txt", SearchOption.TopDirectoryOnly); - if (!string.IsNullOrEmpty(mbn.Ticks) && _HasWaitForProperty && !results.Any()) + if (!string.IsNullOrEmpty(mbn.Ticks) && _HasWaitForProperty && results.Length == 0) { _ = Process.Start("explorer.exe", mbn.TextFileDirectory); File.WriteAllText(Path.Combine(mbn.TextFileDirectory, "_ Why.why"), string.Empty); @@ -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); @@ -401,7 +399,7 @@ public class AdaptationTesting : ISMTP } } } - if (!results.Any() || (!string.IsNullOrEmpty(cellInstanceConnectionName) && !results.ContainsKey(cellInstanceConnectionName))) + if (results.Count == 0 || (!string.IsNullOrEmpty(cellInstanceConnectionName) && !results.ContainsKey(cellInstanceConnectionName))) throw new Exception("Match not found (check test method name matches Mango)!"); return results; } @@ -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; } @@ -596,7 +593,7 @@ public class AdaptationTesting : ISMTP throw new Exception(); _ = stringBuilder.Clear(); } - if (componentsCellComponentCellComponentEquipmentDictionaryNames.Any() && string.IsNullOrEmpty(cellInstanceVersion.FrozenBy)) + if (componentsCellComponentCellComponentEquipmentDictionaryNames.Count != 0 && string.IsNullOrEmpty(cellInstanceVersion.FrozenBy)) { if (!cellInstanceVersion.CellCommunicatingRule.EndsWith(".Communicating") || !(from l in componentsCellComponentCellComponentEquipmentNames where l == cellInstanceVersion.CellCommunicatingRule.Split('.')[0] select true).Any()) throw new Exception($"{methodName} - CellCommunicatingRule not correct in Mango!"); @@ -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); @@ -763,7 +756,7 @@ public class AdaptationTesting : ISMTP string[] results; string equipmentDictionaryName; string equipmentDictionaryVersionName; - if (_SkipEquipmentDictionary || equipmentTypeVersion?.EventActionSequences is null || !equipmentTypeVersion.EventActionSequences.Any() || !(from l in equipmentTypeVersion.EventActionSequences where l.HandledEvent.StartsWith("Equipment.FileRead") select 1).Any()) + if (_SkipEquipmentDictionary || equipmentTypeVersion?.EventActionSequences is null || equipmentTypeVersion.EventActionSequences.Length == 0 || !(from l in equipmentTypeVersion.EventActionSequences where l.HandledEvent.StartsWith("Equipment.FileRead") select 1).Any()) { equipmentDictionaryName = string.Empty; equipmentDictionaryVersionName = string.Empty; @@ -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>(); @@ -963,25 +955,33 @@ public class AdaptationTesting : ISMTP } if (_TestContext.FullyQualifiedTestClassName.Contains(nameof(Extract))) { - if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation)) + try { - if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation)) - _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation); + if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation)) + { + if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation)) + _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation); + } + if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.SourceFileLocation)) + { + if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.SourceFileLocation)) + _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.SourceFileLocation); + } + if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.TargetFileLocation)) + { + if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.TargetFileLocation)) + _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.TargetFileLocation); + } + if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder)) + { + if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder)) + _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder); + } } - if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.SourceFileLocation)) + catch (IOException ex) { - if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.SourceFileLocation)) - _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.SourceFileLocation); - } - if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.TargetFileLocation)) - { - if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.TargetFileLocation)) - _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.TargetFileLocation); - } - if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder)) - { - if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder)) - _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder); + if (!ex.Message.Contains("SMB1")) + throw; } } result = FileHandlers.CellInstanceConnectionName.Get(this, fileParameter, mbn.CellInstanceName, mbn.CellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryVersionTuple.Item2, dummyRuns, staticRuns, useCyclicalForDescription, connectionCount: cellInstanceVersionTuple.Item2.EquipmentConnections.Length); @@ -1001,7 +1001,7 @@ public class AdaptationTesting : ISMTP string sourceFileLocation = string.Empty; MethodBaseName mbn = GetMethodBaseName(methodBase); string[] textFiles = GetTextFiles(mbn); - if (!textFiles.Any()) + if (textFiles.Length == 0) { if (_HasWaitForProperty) throw new Exception("Set text file!"); @@ -1065,7 +1065,7 @@ public class AdaptationTesting : ISMTP else { string[] files = Directory.GetFiles(ipdsfDirectory, searchPattern, SearchOption.TopDirectoryOnly); - if (files.Any()) + if (files.Length != 0) ipdsfFile = files[0]; else ipdsfFile = searchPattern; @@ -1109,9 +1109,9 @@ public class AdaptationTesting : ISMTP { string[] pdsfFiles; pdsfFiles = Directory.GetFiles(searchDirectory, searchPattern, SearchOption.TopDirectoryOnly); - if (!pdsfFiles.Any()) + if (pdsfFiles.Length == 0) _ = Process.Start("explorer.exe", searchDirectory); - Assert.IsTrue(pdsfFiles.Any(), "GetFiles check"); + Assert.IsTrue(pdsfFiles.Length != 0, "GetFiles check"); results = GetLogisticsColumnsAndBody(pdsfFiles[0]); } Assert.IsFalse(string.IsNullOrEmpty(results.Item1)); diff --git a/Adaptation/_Tests/Shared/UnitTesting.cs b/Adaptation/_Tests/Shared/UnitTesting.cs index f48a51b..00f3718 100644 --- a/Adaptation/_Tests/Shared/UnitTesting.cs +++ b/Adaptation/_Tests/Shared/UnitTesting.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Diagnostics; using System.IO; -using System.Linq; using System.Reflection; using System.Text; using System.Text.Json; @@ -75,7 +74,7 @@ public class UnitTesting if (string.IsNullOrEmpty(result)) break; checkFiles = Directory.GetFiles(result, "*.Tests.*proj", SearchOption.TopDirectoryOnly); - if (checkFiles.Any()) + if (checkFiles.Length != 0) break; result = Path.GetDirectoryName(result); } diff --git a/Adaptation/_Tests/Static/BACKLOG.cs b/Adaptation/_Tests/Static/BACKLOG.cs index b38f973..0252caf 100644 --- a/Adaptation/_Tests/Static/BACKLOG.cs +++ b/Adaptation/_Tests/Static/BACKLOG.cs @@ -2,8 +2,10 @@ using Adaptation._Tests.Shared; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Reflection; using System.Text; @@ -73,7 +75,10 @@ public class BACKLOG : LoggingUnitTesting, IDisposable cellInstanceVersion = AdaptationTesting.GetCellInstanceVersion($"{development}/{cellInstanceName}/{cellInstanceVersionName}/configuration"); _ = results.AppendLine($"{cellInstanceName}\t{cellInstanceVersionName}\t{cellInstanceVersion.EdaConnection.PortNumber}"); } - File.WriteAllText($"D:/Tmp/{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv", results.ToString()); + string sourceDirectory = "D:/Tmp/cellInstanceVersion.EdaConnection.PortNumber"; + if (!Directory.Exists(sourceDirectory)) + _ = Directory.CreateDirectory(sourceDirectory); + File.WriteAllText(Path.Combine(sourceDirectory, $"{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv"), results.ToString()); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); NonThrowTryCatch(); } @@ -86,8 +91,8 @@ public class BACKLOG : LoggingUnitTesting, IDisposable StringBuilder results = new(); (string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[] { - new("BACKLOG", "v2.49.2"), - new("BACKLOG-EQPT", "v2.49.2"), + new("BACKLOG", "v2.52.0"), + new("BACKLOG-EQPT", "v2.52.0"), }; string staging = "http://mestsa07ec.infineon.com:9003/CellInstanceServiceV2"; Shared.PasteSpecialXml.EAF.XML.API.CellInstance.CellInstanceVersion cellInstanceVersion; @@ -97,7 +102,30 @@ public class BACKLOG : LoggingUnitTesting, IDisposable cellInstanceVersion = AdaptationTesting.GetCellInstanceVersion($"{staging}/{cellInstanceName}/{cellInstanceVersionName}/configuration"); _ = results.AppendLine($"{cellInstanceName}\t{cellInstanceVersionName}\t{cellInstanceVersion.EdaConnection.PortNumber}"); } - File.WriteAllText($"D:/Tmp/{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv", results.ToString()); + string sourceDirectory = "D:/Tmp/cellInstanceVersion.EdaConnection.PortNumber"; + if (!Directory.Exists(sourceDirectory)) + _ = Directory.CreateDirectory(sourceDirectory); + File.WriteAllText(Path.Combine(sourceDirectory, $"{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv"), results.ToString()); + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + NonThrowTryCatch(); + } + + [TestMethod] + public void CellInstanceVersionEdaConnectionPortNumber() + { + MethodBase methodBase = new StackFrame().GetMethod(); + string sourceDirectory = "D:/Tmp/cellInstanceVersion.EdaConnection.PortNumber"; + if (Directory.Exists(sourceDirectory)) + { + string destinationDirectory = Path.Combine(sourceDirectory, "All"); + if (!Directory.Exists(destinationDirectory)) + _ = Directory.CreateDirectory(destinationDirectory); + List lines = new(); + string[] files = Directory.GetFiles(sourceDirectory, "*.tsv", SearchOption.TopDirectoryOnly); + foreach (string file in files) + lines.AddRange(File.ReadAllLines(file)); + File.WriteAllLines(Path.Combine(destinationDirectory, $"{DateTime.Now.Ticks}.tsv"), lines.Distinct().OrderBy(l => l)); + } LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); NonThrowTryCatch(); } diff --git a/Adaptation/_Tests/Static/MESAFIBACKLOG.cs b/Adaptation/_Tests/Static/MESAFIBACKLOG.cs index 13ae5f2..f302e42 100644 --- a/Adaptation/_Tests/Static/MESAFIBACKLOG.cs +++ b/Adaptation/_Tests/Static/MESAFIBACKLOG.cs @@ -2,8 +2,10 @@ using Adaptation._Tests.Shared; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Reflection; using System.Text; @@ -24,6 +26,13 @@ public class MESAFIBACKLOG : LoggingUnitTesting, IDisposable throw new Exception(); } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + public MESAFIBACKLOG(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType) { } @@ -55,7 +64,7 @@ public class MESAFIBACKLOG : LoggingUnitTesting, IDisposable StringBuilder results = new(); (string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[] { - new("MESAFIBACKLOG", "v2.49.2"), + new("MESAFIBACKLOG", "v2.52.0"), }; string development = "http://eaf-dev.mes.infineon.com:9003/CellInstanceServiceV2"; Shared.PasteSpecialXml.EAF.XML.API.CellInstance.CellInstanceVersion cellInstanceVersion; @@ -65,7 +74,10 @@ public class MESAFIBACKLOG : LoggingUnitTesting, IDisposable cellInstanceVersion = AdaptationTesting.GetCellInstanceVersion($"{development}/{cellInstanceName}/{cellInstanceVersionName}/configuration"); _ = results.AppendLine($"{cellInstanceName}\t{cellInstanceVersionName}\t{cellInstanceVersion.EdaConnection.PortNumber}"); } - File.WriteAllText($"D:/Tmp/{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv", results.ToString()); + string sourceDirectory = "D:/Tmp/cellInstanceVersion.EdaConnection.PortNumber"; + if (!Directory.Exists(sourceDirectory)) + _ = Directory.CreateDirectory(sourceDirectory); + File.WriteAllText(Path.Combine(sourceDirectory, $"{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv"), results.ToString()); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } @@ -87,8 +99,31 @@ public class MESAFIBACKLOG : LoggingUnitTesting, IDisposable cellInstanceVersion = AdaptationTesting.GetCellInstanceVersion($"{staging}/{cellInstanceName}/{cellInstanceVersionName}/configuration"); _ = results.AppendLine($"{cellInstanceName}\t{cellInstanceVersionName}\t{cellInstanceVersion.EdaConnection.PortNumber}"); } - File.WriteAllText($"D:/Tmp/{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv", results.ToString()); + string sourceDirectory = "D:/Tmp/cellInstanceVersion.EdaConnection.PortNumber"; + if (!Directory.Exists(sourceDirectory)) + _ = Directory.CreateDirectory(sourceDirectory); + File.WriteAllText(Path.Combine(sourceDirectory, $"{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv"), results.ToString()); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } + [TestMethod] + public void CellInstanceVersionEdaConnectionPortNumber() + { + MethodBase methodBase = new StackFrame().GetMethod(); + string sourceDirectory = "D:/Tmp/cellInstanceVersion.EdaConnection.PortNumber"; + if (Directory.Exists(sourceDirectory)) + { + string destinationDirectory = Path.Combine(sourceDirectory, "All"); + if (!Directory.Exists(destinationDirectory)) + _ = Directory.CreateDirectory(destinationDirectory); + List lines = new(); + string[] files = Directory.GetFiles(sourceDirectory, "*.tsv", SearchOption.TopDirectoryOnly); + foreach (string file in files) + lines.AddRange(File.ReadAllLines(file)); + File.WriteAllLines(Path.Combine(destinationDirectory, $"{DateTime.Now.Ticks}.tsv"), lines.Distinct().OrderBy(l => l)); + } + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + NonThrowTryCatch(); + } + } \ No newline at end of file diff --git a/MESAFIBACKLOG.csproj b/MESAFIBACKLOG.csproj index 7225201..2239d0b 100644 --- a/MESAFIBACKLOG.csproj +++ b/MESAFIBACKLOG.csproj @@ -188,9 +188,6 @@ 16.205.1 - - 5.2.7 - 6.0.3