From c7995ffd4f9a01add37273f01cb679df7d4f8ba5 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Sat, 22 Apr 2023 21:42:57 -0700 Subject: [PATCH] Inititial Commit --- .gitignore | 11 +- Adaptation/.config/dotnet-tools.json | 12 ++ Adaptation/.editorconfig | 5 +- Adaptation/.vscode/format-report.json | 201 +----------------- Adaptation/.vscode/settings.json | 23 +- Adaptation/FileHandlers/APC/FileRead.cs | 4 +- Adaptation/FileHandlers/Archive/FileRead.cs | 30 +-- .../CellInstanceConnectionName.cs | 27 +-- .../ConvertExcelToJson/FileRead.cs | 12 +- .../ConvertExcelToJson/ProcessData.cs | 2 +- .../DownloadExcelFile/FileRead.cs | 166 +++++++++++++++ Adaptation/FileHandlers/Dummy/FileRead.cs | 4 +- Adaptation/FileHandlers/IQSSi/FileRead.cs | 6 +- .../MoveMatchingFiles/FileRead.cs | 67 +++++- .../FileHandlers/OpenInsight/FileRead.cs | 14 +- .../OpenInsightMetrologyViewer/FileRead.cs | 10 +- .../FileRead.cs | 12 +- Adaptation/FileHandlers/Processed/FileRead.cs | 15 +- Adaptation/FileHandlers/SPaCe/FileRead.cs | 6 +- Adaptation/FileHandlers/json/FileRead.cs | 21 +- Adaptation/FileHandlers/json/ProcessData.cs | 169 ++++++++++----- .../FileHandlers/json/ViewModels/WorkItem.cs | 79 ------- .../FileHandlers/json/WorkItems/Avatar.cs | 2 +- .../FileHandlers/json/WorkItems/Fields.cs | 125 +++-------- .../FileHandlers/json/WorkItems/Html.cs | 2 +- .../FileHandlers/json/WorkItems/Links.cs | 31 +-- .../FileHandlers/json/WorkItems/Root.cs | 30 --- .../FileHandlers/json/WorkItems/Self.cs | 13 -- .../json/WorkItems/SystemAssignedTo.cs | 47 ++++ .../json/WorkItems/SystemChangedBy.cs | 47 ++++ .../json/WorkItems/SystemCreatedBy.cs | 47 ++++ .../FileHandlers/json/WorkItems/User.cs | 34 --- .../FileHandlers/json/WorkItems/Value.cs | 32 +++ .../json/WorkItems/WorkItemComments.cs | 13 -- .../json/WorkItems/WorkItemRevisions.cs | 13 -- .../json/WorkItems/WorkItemType.cs | 13 -- .../json/WorkItems/WorkItemUpdates.cs | 13 -- Adaptation/MESAFIBACKLOG-Development.yml | 163 ++++++++++++++ Adaptation/MESAFIBACKLOG.Tests.csproj | 85 ++++---- Adaptation/MESAFIBACKLOG.yml | 161 ++++++++++++++ Adaptation/Shared/FileRead.cs | 9 +- Adaptation/Shared/Logistics.cs | 2 +- Adaptation/Shared/Metrology/WS.cs | 5 +- .../Shared/ProcessDataStandardFormat.cs | 11 +- .../{v2.43.0 => v2.49.0}/BACKLOG-EQPT.cs | 17 +- .../Staging/{v2.43.0 => v2.49.0}/BACKLOG.cs | 17 +- .../Staging/v2.49.0/MESAFIBACKLOG.cs | 63 ++++++ .../Extract/Staging/v2.43.0/BACKLOG-EQPT.cs | 54 ----- .../Extract/Staging/v2.49.0/BACKLOG-EQPT.cs | 54 +++++ .../Staging/{v2.43.0 => v2.49.0}/BACKLOG.cs | 42 ++-- .../Extract/Staging/v2.49.0/MESAFIBACKLOG.cs | 62 ++++++ Adaptation/_Tests/Shared/AdaptationTesting.cs | 14 +- .../_Tests/Shared/LoggingUnitTesting.cs | 2 +- Adaptation/_Tests/Shared/UnitTesting.cs | 53 ++--- Adaptation/_Tests/Static/BACKLOG.cs | 16 +- FileHandlers/FileRead.cs | 4 +- MESAFIBACKLOG.csproj | 21 +- Properties/AssemblyInfo.cs | 4 +- 58 files changed, 1312 insertions(+), 905 deletions(-) create mode 100644 Adaptation/.config/dotnet-tools.json create mode 100644 Adaptation/FileHandlers/DownloadExcelFile/FileRead.cs delete mode 100644 Adaptation/FileHandlers/json/ViewModels/WorkItem.cs delete mode 100644 Adaptation/FileHandlers/json/WorkItems/Root.cs delete mode 100644 Adaptation/FileHandlers/json/WorkItems/Self.cs create mode 100644 Adaptation/FileHandlers/json/WorkItems/SystemAssignedTo.cs create mode 100644 Adaptation/FileHandlers/json/WorkItems/SystemChangedBy.cs create mode 100644 Adaptation/FileHandlers/json/WorkItems/SystemCreatedBy.cs delete mode 100644 Adaptation/FileHandlers/json/WorkItems/User.cs create mode 100644 Adaptation/FileHandlers/json/WorkItems/Value.cs delete mode 100644 Adaptation/FileHandlers/json/WorkItems/WorkItemComments.cs delete mode 100644 Adaptation/FileHandlers/json/WorkItems/WorkItemRevisions.cs delete mode 100644 Adaptation/FileHandlers/json/WorkItems/WorkItemType.cs delete mode 100644 Adaptation/FileHandlers/json/WorkItems/WorkItemUpdates.cs create mode 100644 Adaptation/MESAFIBACKLOG-Development.yml create mode 100644 Adaptation/MESAFIBACKLOG.yml rename Adaptation/_Tests/CreateSelfDescription/Staging/{v2.43.0 => v2.49.0}/BACKLOG-EQPT.cs (79%) rename Adaptation/_Tests/CreateSelfDescription/Staging/{v2.43.0 => v2.49.0}/BACKLOG.cs (79%) create mode 100644 Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/MESAFIBACKLOG.cs delete mode 100644 Adaptation/_Tests/Extract/Staging/v2.43.0/BACKLOG-EQPT.cs create mode 100644 Adaptation/_Tests/Extract/Staging/v2.49.0/BACKLOG-EQPT.cs rename Adaptation/_Tests/Extract/Staging/{v2.43.0 => v2.49.0}/BACKLOG.cs (64%) create mode 100644 Adaptation/_Tests/Extract/Staging/v2.49.0/MESAFIBACKLOG.cs diff --git a/.gitignore b/.gitignore index eab1f67..c19d760 100644 --- a/.gitignore +++ b/.gitignore @@ -331,10 +331,11 @@ ASALocalRun/ ## ## Visual Studio Code ## -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json +*/!.vscode/extensions.json +*/!.vscode/launch.json +*/!.vscode/settings.json +*/!.vscode/tasks.json +*/.vscode/* +*/.vscode/ReportGenerator/* *.lnk diff --git a/Adaptation/.config/dotnet-tools.json b/Adaptation/.config/dotnet-tools.json new file mode 100644 index 0000000..cd368e1 --- /dev/null +++ b/Adaptation/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-reportgenerator-globaltool": { + "version": "5.1.15", + "commands": [ + "reportgenerator" + ] + } + } +} \ No newline at end of file diff --git a/Adaptation/.editorconfig b/Adaptation/.editorconfig index b84fca4..b45701e 100644 --- a/Adaptation/.editorconfig +++ b/Adaptation/.editorconfig @@ -76,12 +76,15 @@ csharp_using_directive_placement = outside_namespace dotnet_code_quality_unused_parameters = all dotnet_code_quality_unused_parameters = non_public # IDE0060: Remove unused parameter dotnet_code_quality.CAXXXX.api_surface = private, internal +dotnet_diagnostic.CA1816.severity = none # CA1816: Call GC.SuppressFinalize correctly dotnet_diagnostic.CA1825.severity = warning # CA1823: Avoid zero-length array allocations dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available 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.IDE0001.severity = warning # IDE0001: Simplify name -dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. 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.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) diff --git a/Adaptation/.vscode/format-report.json b/Adaptation/.vscode/format-report.json index fcec3ef..0637a08 100644 --- a/Adaptation/.vscode/format-report.json +++ b/Adaptation/.vscode/format-report.json @@ -1,200 +1 @@ -[ - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "9e6e3881-2c77-41ba-83c3-c15a21699111" - }, - "FileName": "ProcessData.cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\ProcessData.cs", - "FileChanges": [ - { - "LineNumber": 1, - "CharNumber": 1, - "DiagnosticId": "WHITESPACE", - "FormatDescription": "Fix whitespace formatting." - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "a32feb09-3c35-4534-8f83-436319852545" - }, - "FileName": "FileRead.cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\OpenInsightMetrologyViewerAttachments\\FileRead.cs", - "FileChanges": [ - { - "LineNumber": 111, - "CharNumber": 120, - "DiagnosticId": "IDE0060", - "FormatDescription": "warning IDE0060: Remove unused parameter \u0027descriptions\u0027" - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "d629cdaf-aa21-4193-ae17-aecafca36ca6" - }, - "FileName": "FileRead.cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\FileRead.cs", - "FileChanges": [ - { - "LineNumber": 13, - "CharNumber": 1, - "DiagnosticId": "IDE0005", - "FormatDescription": "warning IDE0005: Using directive is unnecessary." - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "d629cdaf-aa21-4193-ae17-aecafca36ca6" - }, - "FileName": "FileRead.cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\FileRead.cs", - "FileChanges": [ - { - "LineNumber": 53, - "CharNumber": 24, - "DiagnosticId": "IDE0002", - "FormatDescription": "warning IDE0002: Name can be simplified." - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "0d78829b-6f7b-4313-95dd-ca86ae3e359f" - }, - "FileName": ".cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\.cs", - "FileChanges": [ - { - "LineNumber": 16, - "CharNumber": 33, - "DiagnosticId": "IDE1006", - "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "0d78829b-6f7b-4313-95dd-ca86ae3e359f" - }, - "FileName": ".cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\.cs", - "FileChanges": [ - { - "LineNumber": 15, - "CharNumber": 36, - "DiagnosticId": "IDE1006", - "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "0d78829b-6f7b-4313-95dd-ca86ae3e359f" - }, - "FileName": ".cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\.cs", - "FileChanges": [ - { - "LineNumber": 17, - "CharNumber": 36, - "DiagnosticId": "IDE1006", - "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "0d78829b-6f7b-4313-95dd-ca86ae3e359f" - }, - "FileName": ".cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\.cs", - "FileChanges": [ - { - "LineNumber": 19, - "CharNumber": 36, - "DiagnosticId": "IDE1006", - "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "0d78829b-6f7b-4313-95dd-ca86ae3e359f" - }, - "FileName": ".cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\.cs", - "FileChanges": [ - { - "LineNumber": 18, - "CharNumber": 36, - "DiagnosticId": "IDE1006", - "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "0d78829b-6f7b-4313-95dd-ca86ae3e359f" - }, - "FileName": ".cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\.cs", - "FileChanges": [ - { - "LineNumber": 21, - "CharNumber": 24, - "DiagnosticId": "IDE1006", - "FormatDescription": "warning IDE1006: Naming rule violation: These words must begin with upper case characters: dd" - } - ] - }, - { - "DocumentId": { - "ProjectId": { - "Id": "7e6bb579-a63b-4b11-9de5-f86fc2f09c8d" - }, - "Id": "d629cdaf-aa21-4193-ae17-aecafca36ca6" - }, - "FileName": "FileRead.cs", - "FilePath": "T:\\MESAFIBACKLOG\\06_SourceCode\\MESAFIBACKLOG\\Adaptation\\FileHandlers\\json\\FileRead.cs", - "FileChanges": [ - { - "LineNumber": 1, - "CharNumber": 1, - "DiagnosticId": "IDE0005", - "FormatDescription": "Remove unnecessary import." - } - ] - } -] \ No newline at end of file +[] \ No newline at end of file diff --git a/Adaptation/.vscode/settings.json b/Adaptation/.vscode/settings.json index cf354c7..cf920fe 100644 --- a/Adaptation/.vscode/settings.json +++ b/Adaptation/.vscode/settings.json @@ -21,26 +21,27 @@ "Villach", "Vrng" ], + "coverage-gutters.coverageBaseDir": "../../../../MESAFIBACKLOG/05_TestResults/TestResults/**", "workbench.colorCustomizations": { - "activityBar.activeBackground": "#9885b1", + "activityBar.activeBackground": "#5d8f9e", "activityBar.activeBorder": "#dacec5", - "activityBar.background": "#9885b1", + "activityBar.background": "#5d8f9e", "activityBar.foreground": "#15202b", "activityBar.inactiveForeground": "#15202b99", - "activityBarBadge.background": "#dacec5", - "activityBarBadge.foreground": "#15202b", - "sash.hoverBorder": "#9885b1", - "statusBar.background": "#7e669d", + "activityBarBadge.background": "#78476d", + "activityBarBadge.foreground": "#e7e7e7", + "sash.hoverBorder": "#5d8f9e", + "statusBar.background": "#4a727e", "statusBar.foreground": "#e7e7e7", - "statusBarItem.hoverBackground": "#9885b1", - "statusBarItem.remoteBackground": "#7e669d", + "statusBarItem.hoverBackground": "#5d8f9e", + "statusBarItem.remoteBackground": "#4a727e", "statusBarItem.remoteForeground": "#e7e7e7", - "titleBar.activeBackground": "#7e669d", + "titleBar.activeBackground": "#4a727e", "titleBar.activeForeground": "#e7e7e7", - "titleBar.inactiveBackground": "#7e669d99", + "titleBar.inactiveBackground": "#4a727e99", "titleBar.inactiveForeground": "#e7e7e799", "commandCenter.border": "#e7e7e799" }, - "peacock.color": "#7e669d", + "peacock.color": "#4a727e", "cSpell.enabled": false } \ No newline at end of file diff --git a/Adaptation/FileHandlers/APC/FileRead.cs b/Adaptation/FileHandlers/APC/FileRead.cs index 516a83f..5e2ab67 100644 --- a/Adaptation/FileHandlers/APC/FileRead.cs +++ b/Adaptation/FileHandlers/APC/FileRead.cs @@ -14,8 +14,8 @@ namespace Adaptation.FileHandlers.APC; public class FileRead : Shared.FileRead, IFileRead { - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; diff --git a/Adaptation/FileHandlers/Archive/FileRead.cs b/Adaptation/FileHandlers/Archive/FileRead.cs index 6584c7f..d1b13df 100644 --- a/Adaptation/FileHandlers/Archive/FileRead.cs +++ b/Adaptation/FileHandlers/Archive/FileRead.cs @@ -18,8 +18,8 @@ public class FileRead : Shared.FileRead, IFileRead private readonly string _JobIdParentDirectory; private readonly string _JobIdArchiveParentDirectory; - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; @@ -114,11 +114,10 @@ public class FileRead : Shared.FileRead, IFileRead } } } - - private void MoveArchive(DateTime dateTime) +#pragma warning disable IDE0060 + private void MoveArchive(string reportFullPath, DateTime dateTime) +#pragma warning restore IDE0060 { - if (dateTime == DateTime.MinValue) - { } string logisticsSequence = _Logistics.Sequence.ToString(); string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}"; @@ -128,12 +127,17 @@ public class FileRead : Shared.FileRead, IFileRead string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID); if (!Directory.Exists(jobIdDirectory)) _ = Directory.CreateDirectory(jobIdDirectory); - string[] matchDirectories = new string[] { GetDirectoriesRecursively(jobIdDirectory, logisticsSequence).FirstOrDefault() }; - if ((matchDirectories is null) || matchDirectories.Length != 1) - throw new Exception("Didn't find directory by logistics sequence"); - string sourceDirectory = Path.GetDirectoryName(matchDirectories[0]); - destinationArchiveDirectory = Path.Combine(destinationArchiveDirectory, Path.GetFileName(sourceDirectory)); - Directory.Move(sourceDirectory, destinationArchiveDirectory); + if (!Directory.GetDirectories(jobIdDirectory).Any()) + File.Copy(reportFullPath, Path.Combine(destinationArchiveDirectory, Path.GetFileName(reportFullPath))); + else + { + string[] matchDirectories = GetDirectoriesRecursively(jobIdDirectory, logisticsSequence).ToArray(); + if (matchDirectories.Length != 1) + throw new Exception("Didn't find directory by logistics sequence"); + string sourceDirectory = Path.GetDirectoryName(matchDirectories[0]); + destinationArchiveDirectory = Path.Combine(destinationArchiveDirectory, Path.GetFileName(sourceDirectory)); + Directory.Move(sourceDirectory, destinationArchiveDirectory); + } } private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) @@ -146,7 +150,7 @@ 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) - MoveArchive(dateTime); + MoveArchive(reportFullPath, dateTime); results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/CellInstanceConnectionName.cs b/Adaptation/FileHandlers/CellInstanceConnectionName.cs index 48527ab..cee542a 100644 --- a/Adaptation/FileHandlers/CellInstanceConnectionName.cs +++ b/Adaptation/FileHandlers/CellInstanceConnectionName.cs @@ -9,22 +9,23 @@ namespace Adaptation.FileHandlers; public class CellInstanceConnectionName { - internal static IFileRead Get(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) + internal static IFileRead Get(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, int? connectionCount) { IFileRead result = cellInstanceConnectionName switch { - nameof(APC) => new APC.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(Archive) => new Archive.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(ConvertExcelToJson) => new ConvertExcelToJson.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(Dummy) => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(IQSSi) => new IQSSi.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(MoveMatchingFiles) => new MoveMatchingFiles.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(OpenInsight) => new OpenInsight.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(OpenInsightMetrologyViewer) => new OpenInsightMetrologyViewer.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(OpenInsightMetrologyViewerAttachments) => new OpenInsightMetrologyViewerAttachments.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(Processed) => new Processed.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(json) => new json.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), - nameof(SPaCe) => new SPaCe.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), + nameof(APC) => new APC.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(Archive) => new Archive.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(ConvertExcelToJson) => new ConvertExcelToJson.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(DownloadExcelFile) => new DownloadExcelFile.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(Dummy) => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(IQSSi) => new IQSSi.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(MoveMatchingFiles) => new MoveMatchingFiles.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(OpenInsight) => new OpenInsight.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(OpenInsightMetrologyViewer) => new OpenInsightMetrologyViewer.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(OpenInsightMetrologyViewerAttachments) => new OpenInsightMetrologyViewerAttachments.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(Processed) => new Processed.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(json) => new json.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), + nameof(SPaCe) => new SPaCe.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null), _ => throw new Exception($"\"{cellInstanceConnectionName}\" not mapped") }; return result; diff --git a/Adaptation/FileHandlers/ConvertExcelToJson/FileRead.cs b/Adaptation/FileHandlers/ConvertExcelToJson/FileRead.cs index 985445b..c0f16c3 100644 --- a/Adaptation/FileHandlers/ConvertExcelToJson/FileRead.cs +++ b/Adaptation/FileHandlers/ConvertExcelToJson/FileRead.cs @@ -18,8 +18,8 @@ public class FileRead : Shared.FileRead, IFileRead private long? _TickOffset; private readonly string _SheetName; - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; @@ -112,13 +112,15 @@ public class FileRead : Shared.FileRead, IFileRead if (!iProcessData.Details.Any()) throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks)); string json = iProcessData.Details[0].ToString(); - string fileName = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, $"{_SheetName}.json"); + string fileName = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, $"{Path.GetFileNameWithoutExtension(reportFullPath)} - {_SheetName}{_FileConnectorConfiguration.TargetFileName}"); if (File.Exists(fileName)) { - File.Delete(fileName); + if (_IsEAFHosted) + File.Delete(fileName); Thread.Sleep(500); } - File.WriteAllText(fileName, json); + if (_IsEAFHosted) + File.WriteAllText(fileName, json); results = iProcessData.GetResults(this, _Logistics, results.Item4); } return results; diff --git a/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs b/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs index acced3d..d2889ce 100644 --- a/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs +++ b/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs @@ -134,7 +134,7 @@ public class ProcessData : IProcessData FIBacklogMesa[]? fIBacklogMesaCollection = JsonSerializer.Deserialize(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); if (fIBacklogMesaCollection is null || !fIBacklogMesaCollection.Any()) throw new NullReferenceException(); - json = JsonSerializer.Serialize(fIBacklogMesaCollection, new JsonSerializerOptions() { WriteIndented = true }); + json = JsonSerializer.Serialize(fIBacklogMesaCollection.OrderBy(l => l.Req), new JsonSerializerOptions() { WriteIndented = true }); _Details.Add(json); } diff --git a/Adaptation/FileHandlers/DownloadExcelFile/FileRead.cs b/Adaptation/FileHandlers/DownloadExcelFile/FileRead.cs new file mode 100644 index 0000000..dd1fe6d --- /dev/null +++ b/Adaptation/FileHandlers/DownloadExcelFile/FileRead.cs @@ -0,0 +1,166 @@ +using Adaptation.Eaf.Management.ConfigurationData.CellAutomation; +using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration; +using Adaptation.Shared; +using Adaptation.Shared.Duplicator; +using Adaptation.Shared.Methods; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Net.Http; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; + +namespace Adaptation.FileHandlers.DownloadExcelFile; + +public class FileRead : Shared.FileRead, IFileRead +{ + + private readonly Timer _Timer; + private readonly string _IShareLink; + private readonly HttpClient _HttpClient; + + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) + { + _MinFileLength = 10; + _NullData = string.Empty; + _Logistics = new(this); + if (_FileParameter is null) + throw new Exception(cellInstanceConnectionName); + if (_ModelObjectParameterDefinitions is null) + throw new Exception(cellInstanceConnectionName); + if (_IsDuplicator) + throw new Exception(cellInstanceConnectionName); + _HttpClient = new(new HttpClientHandler() { UseDefaultCredentials = true }); + _IShareLink = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, string.Concat("CellInstance.", cellInstanceName, ".iShare.Link")); + if (!Debugger.IsAttached && fileConnectorConfiguration.PreProcessingMode != FileConnectorConfiguration.PreProcessingModeEnum.Process) + _Timer = new Timer(Callback, null, (int)(fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000), Timeout.Infinite); + else + { + _Timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite); + Callback(null); + } + } + + void IFileRead.Move(Tuple> extractResults, Exception exception) => Move(extractResults); + + void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null); + + string IFileRead.GetEventDescription() + { + string result = _Description.GetEventDescription(); + return result; + } + + List IFileRead.GetHeaderNames() + { + List results = _Description.GetHeaderNames(); + return results; + } + + string[] IFileRead.Move(Tuple> extractResults, string to, string from, string resolvedFileLocation, Exception exception) + { + string[] results = Move(extractResults, to, from, resolvedFileLocation, exception); + return results; + } + + JsonProperty[] IFileRead.GetDefault() + { + JsonProperty[] results = _Description.GetDefault(this, _Logistics); + return results; + } + + Dictionary IFileRead.GetDisplayNamesJsonElement() + { + Dictionary results = _Description.GetDisplayNamesJsonElement(this); + return results; + } + + List IFileRead.GetDescriptions(IFileRead fileRead, List tests, IProcessData processData) + { + List results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData); + return results; + } + + Tuple> IFileRead.GetExtractResult(string reportFullPath, string eventName) + { + Tuple> results; + if (string.IsNullOrEmpty(eventName)) + throw new Exception(); + _ReportFullPath = reportFullPath; + DateTime dateTime = DateTime.Now; + results = GetExtractResult(reportFullPath, dateTime); + if (results.Item3 is null) + results = new Tuple>(results.Item1, Array.Empty(), JsonSerializer.Deserialize("[]"), results.Item4); + if (results.Item3.Length > 0 && _IsEAFHosted) + WritePDSF(this, results.Item3); + UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks); + return results; + } + + Tuple> IFileRead.ReExtract() + { + Tuple> results; + List headerNames = _Description.GetHeaderNames(); + Dictionary keyValuePairs = _Description.GetDisplayNamesJsonElement(this); + results = ReExtract(this, headerNames, keyValuePairs); + return results; + } + + private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) => throw new Exception(string.Concat("See ", nameof(Callback))); + + private void DownloadExcelFileAsync() + { + if (_HttpClient is null) + throw new Exception(); + if (string.IsNullOrEmpty(_IShareLink)) + throw new Exception(); + string fileName = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, _FileConnectorConfiguration.SourceFileFilter); + if (File.Exists(fileName)) + File.Delete(fileName); + Task httpResponseMessageTask = _HttpClient.GetAsync(_IShareLink); + httpResponseMessageTask.Wait(); + if (!httpResponseMessageTask.Result.IsSuccessStatusCode) + throw new Exception(httpResponseMessageTask.Result.StatusCode.ToString()); + Task streamTask = httpResponseMessageTask.Result.Content.ReadAsStreamAsync(); + streamTask.Wait(); + if (!streamTask.Result.CanRead) + throw new NullReferenceException(nameof(streamTask)); + using FileStream fileStream = new(fileName, FileMode.CreateNew); + Task task = streamTask.Result.CopyToAsync(fileStream); + task.Wait(); + } + + private void Callback(object state) + { + try + { + if (_IsEAFHosted) + DownloadExcelFileAsync(); + } + catch (Exception exception) + { + string subject = string.Concat("Exception:", _CellInstanceConnectionName); + string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace); + try + { _SMTP.SendHighPriorityEmailMessage(subject, body); } + catch (Exception) { } + } + try + { + TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks); + _ = _Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite); + } + catch (Exception exception) + { + string subject = string.Concat("Exception:", _CellInstanceConnectionName); + string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace); + try + { _SMTP.SendHighPriorityEmailMessage(subject, body); } + catch (Exception) { } + } + } + +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/Dummy/FileRead.cs b/Adaptation/FileHandlers/Dummy/FileRead.cs index 7692d3d..79eda27 100644 --- a/Adaptation/FileHandlers/Dummy/FileRead.cs +++ b/Adaptation/FileHandlers/Dummy/FileRead.cs @@ -23,8 +23,8 @@ public class FileRead : Shared.FileRead, IFileRead private int _LastDummyRunIndex; private readonly string[] _CellNames; - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; diff --git a/Adaptation/FileHandlers/IQSSi/FileRead.cs b/Adaptation/FileHandlers/IQSSi/FileRead.cs index a0563cf..12bc214 100644 --- a/Adaptation/FileHandlers/IQSSi/FileRead.cs +++ b/Adaptation/FileHandlers/IQSSi/FileRead.cs @@ -14,8 +14,8 @@ namespace Adaptation.FileHandlers.IQSSi; public class FileRead : Shared.FileRead, IFileRead { - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; @@ -118,8 +118,6 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { - if (dateTime == DateTime.MinValue) - { } Tuple> results; Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); _Logistics = new Logistics(reportFullPath, pdsf.Item1); diff --git a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs index ad68b87..39f8d62 100644 --- a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs +++ b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using System.Text.Json; using System.Threading; @@ -15,8 +16,8 @@ namespace Adaptation.FileHandlers.MoveMatchingFiles; public class FileRead : Shared.FileRead, IFileRead { - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; @@ -153,18 +154,36 @@ public class FileRead : Shared.FileRead, IFileRead return results; } - private void MoveCollection(DateTime dateTime, List<(string matchingFile, string checkFile)> collection) + private static List<(string, string, string, string, string)> GetCollection(List<(string matchingFile, string checkFile)> collection) { - long preWait; + List<(string, string, string, string, string)> results = new(); string errFile; string checkDirectory; + string noWaitDirectory; foreach ((string matchingFile, string checkFile) in collection) { errFile = string.Concat(checkFile, ".err"); checkDirectory = Path.GetDirectoryName(checkFile); if (!Directory.Exists(checkDirectory)) _ = Directory.CreateDirectory(checkDirectory); + noWaitDirectory = Path.Combine(checkDirectory, "NoWaitDirectory"); + results.Add(new(matchingFile, checkFile, errFile, checkDirectory, noWaitDirectory)); + } + return results; + } + + private void MoveCollection(DateTime dateTime, List<(string matchingFile, string checkFile)> collection) + { + long preWait; + List<(string checkFile, string errFile)> postCollection = new(); + foreach ((string matchingFile, string checkFile, string errFile, string checkDirectory, string noWaitDirectory) in GetCollection(collection)) + { File.Move(matchingFile, checkFile); + if (Directory.Exists(noWaitDirectory)) + { + postCollection.Add(new(checkFile, errFile)); + continue; + } if (_FileConnectorConfiguration?.FileHandleWaitTime is null) preWait = DateTime.Now.AddMilliseconds(1234).Ticks; else @@ -182,10 +201,45 @@ public class FileRead : Shared.FileRead, IFileRead if (!File.Exists(checkFile)) break; if (new TimeSpan(DateTime.Now.Ticks - dateTime.Ticks).TotalSeconds > _BreakAfterSeconds) - throw new Exception($"Not all files were consumned after {_BreakAfterSeconds} second(s)!"); + throw new Exception($"Not all files were consumed after {_BreakAfterSeconds} second(s)!"); Thread.Sleep(500); } } + if (postCollection.Any()) + { + Thread.Sleep(500); + StringBuilder stringBuilder = new(); + foreach ((string checkFile, string errFile) in postCollection) + { + if (File.Exists(errFile)) + _ = stringBuilder.AppendLine(File.ReadAllText(errFile)); + if (File.Exists(checkFile)) + _ = stringBuilder.AppendLine($"<{checkFile}> was not consumed by the end!"); + } + if (stringBuilder.Length > 0) + throw new Exception(stringBuilder.ToString()); + } + } + + private static void CreatePointerFile(int numberLength, string parentDirectory, List matchingFiles) + { +#nullable enable + string checkFile; + string writeFile; + string? directoryName; + int parentDirectoryLength = parentDirectory.Length; + foreach (string matchingFile in matchingFiles) + { + directoryName = Path.GetDirectoryName(matchingFile); + if (directoryName is null) + continue; + checkFile = $"{matchingFile[0]}{directoryName.Substring(parentDirectoryLength + numberLength + 1)}"; + writeFile = Path.Combine(parentDirectory, $"{directoryName.Substring(parentDirectory.Length + 1, numberLength)}.txt"); + if (File.Exists(writeFile)) + continue; + File.AppendAllLines(writeFile, new string[] { parentDirectory, matchingFile, directoryName, checkFile }); + } +#nullable disable } private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) @@ -201,6 +255,9 @@ public class FileRead : Shared.FileRead, IFileRead List matchingFiles = GetMatchingFiles(ticks, reportFullPath, searchDirectories); if (matchingFiles.Count != searchDirectories.Count) throw new Exception($"Didn't find all files after {_BreakAfterSeconds} second(s)!"); + try + { CreatePointerFile(numberLength, parentParentDirectory, matchingFiles); } + catch (Exception) { } List<(string matchingFile, string checkFile)> collection = GetCollection(numberLength, parentParentDirectory, matchingFiles); MoveCollection(dateTime, collection); return results; diff --git a/Adaptation/FileHandlers/OpenInsight/FileRead.cs b/Adaptation/FileHandlers/OpenInsight/FileRead.cs index 88a1c04..bd299b2 100644 --- a/Adaptation/FileHandlers/OpenInsight/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsight/FileRead.cs @@ -14,8 +14,8 @@ namespace Adaptation.FileHandlers.OpenInsight; public class FileRead : Shared.FileRead, IFileRead { - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; @@ -103,16 +103,10 @@ public class FileRead : Shared.FileRead, IFileRead return results; } +#pragma warning disable IDE0060 private static void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, List descriptions, Test[] tests) +#pragma warning restore IDE0060 { - if (reportFullPath is null) - { } - if (dateTime == DateTime.MinValue) - { } - if (descriptions is null) - { } - if (tests is null) - { } } private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs index 700246a..007208f 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs @@ -16,8 +16,8 @@ public class FileRead : Shared.FileRead, IFileRead private readonly string _OpenInsightMetrologyViewerAPI; - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; @@ -106,11 +106,11 @@ public class FileRead : Shared.FileRead, IFileRead return results; } +#pragma warning disable IDE0060 private void SendData(DateTime dateTime, List descriptions) +#pragma warning restore IDE0060 { - if (dateTime == DateTime.MinValue) - { } - if (descriptions is null) + if (_OpenInsightMetrologyViewerAPI is null) { } // WSRequest wsRequest = new(this, _Logistics, descriptions); // (string json, WS.Results wsResults) = WS.SendData(_OpenInsightMetrologyViewerAPI, wsRequest); diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs index 6350021..df579ba 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs @@ -17,8 +17,8 @@ public class FileRead : Shared.FileRead, IFileRead private readonly string _JobIdParentDirectory; private readonly string _OpenInsightMetrologyViewerAPI; - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; @@ -108,12 +108,10 @@ public class FileRead : Shared.FileRead, IFileRead return results; } +#pragma warning disable IDE0060 private void PostOpenInsightMetrologyViewerAttachments(string reportFullPath, DateTime dateTime, List descriptions) +#pragma warning restore IDE0060 { - if (string.IsNullOrEmpty(reportFullPath)) - { } - if (dateTime == DateTime.MinValue) - { } string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID); if (!Directory.Exists(jobIdDirectory)) _ = Directory.CreateDirectory(jobIdDirectory); @@ -129,6 +127,8 @@ public class FileRead : Shared.FileRead, IFileRead lock (_StaticRuns) _ = _StaticRuns.Remove(_Logistics.Sequence); } + if (_OpenInsightMetrologyViewerAPI is null) + { } // OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, dateTime, json, descriptions, matchDirectories[0]); } diff --git a/Adaptation/FileHandlers/Processed/FileRead.cs b/Adaptation/FileHandlers/Processed/FileRead.cs index 1b5d2bc..53595ba 100644 --- a/Adaptation/FileHandlers/Processed/FileRead.cs +++ b/Adaptation/FileHandlers/Processed/FileRead.cs @@ -17,8 +17,8 @@ public class FileRead : Shared.FileRead, IFileRead private readonly string _JobIdParentDirectory; private readonly string _JobIdProcessParentDirectory; - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; @@ -108,23 +108,22 @@ public class FileRead : Shared.FileRead, IFileRead return results; } +#pragma warning disable IDE0060 private void DirectoryMove(string reportFullPath, DateTime dateTime, List descriptions) +#pragma warning restore IDE0060 { - if (dateTime == DateTime.MinValue) - { } - if (descriptions is null) - { } FileInfo fileInfo = new(reportFullPath); - _ = _Logistics.Sequence.ToString(); string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID); if (!Directory.Exists(jobIdDirectory)) _ = Directory.CreateDirectory(jobIdDirectory); string[] matchDirectories = GetInProcessDirectory(jobIdDirectory); - if ((matchDirectories is null) || matchDirectories.Length != 1) + if (matchDirectories.Length != 1) throw new Exception("Didn't find directory by logistics sequence"); if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime) File.SetLastWriteTime(reportFullPath, fileInfo.CreationTime); + if (_JobIdProcessParentDirectory is null) + { } // OpenInsightMetrologyViewer.WSRequest wsRequest = new(this, _Logistics, descriptions); // JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true }; // string json = JsonSerializer.Serialize(wsRequest, wsRequest.GetType(), jsonSerializerOptions); diff --git a/Adaptation/FileHandlers/SPaCe/FileRead.cs b/Adaptation/FileHandlers/SPaCe/FileRead.cs index a6c47a1..a8155b6 100644 --- a/Adaptation/FileHandlers/SPaCe/FileRead.cs +++ b/Adaptation/FileHandlers/SPaCe/FileRead.cs @@ -14,8 +14,8 @@ namespace Adaptation.FileHandlers.SPaCe; public class FileRead : Shared.FileRead, IFileRead { - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; _NullData = string.Empty; @@ -116,8 +116,6 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { - if (dateTime == DateTime.MinValue) - { } Tuple> results; Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); _Logistics = new Logistics(reportFullPath, pdsf.Item1); diff --git a/Adaptation/FileHandlers/json/FileRead.cs b/Adaptation/FileHandlers/json/FileRead.cs index 853cf96..2f07f46 100644 --- a/Adaptation/FileHandlers/json/FileRead.cs +++ b/Adaptation/FileHandlers/json/FileRead.cs @@ -20,7 +20,7 @@ namespace Adaptation.FileHandlers.json; public class FileRead : Shared.FileRead, IFileRead { - private long? _TickOffset; + private string _Json; private readonly string _API; private readonly string _Query; private readonly string _Project; @@ -28,17 +28,18 @@ public class FileRead : Shared.FileRead, IFileRead private readonly HttpClient _HttpClient; private readonly WorkItemTrackingHttpClient _WorkItemTrackingHttpClient; - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : - base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted) + public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : + base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { _MinFileLength = 10; + _Json = string.Empty; _NullData = string.Empty; _Logistics = new(this); if (_FileParameter is null) throw new Exception(cellInstanceConnectionName); if (_ModelObjectParameterDefinitions is null) throw new Exception(cellInstanceConnectionName); - if (_IsDuplicator) + if (!_IsDuplicator) throw new Exception(cellInstanceConnectionName); string cellInstanceNamed = string.Concat("CellInstance.", cellInstanceName); MediaTypeWithQualityHeaderValue mediaTypeWithQualityHeaderValue = new("application/json"); @@ -50,7 +51,7 @@ public class FileRead : Shared.FileRead, IFileRead string baseAddress = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, $"{cellInstanceNamed}.HttpClient.BaseAddress"); byte[] bytes = Encoding.ASCII.GetBytes($":{pat}"); string base64 = Convert.ToBase64String(bytes); - _HttpClient = new() { BaseAddress = new(baseAddress) }; + _HttpClient = new(new HttpClientHandler() { UseDefaultCredentials = true }) { BaseAddress = new(baseAddress) }; _HttpClient.DefaultRequestHeaders.Authorization = new("Basic", base64); _HttpClient.DefaultRequestHeaders.Accept.Add(mediaTypeWithQualityHeaderValue); VssBasicCredential credential = new("", pat); @@ -127,19 +128,19 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results = new(string.Empty, null, null, new List()); - _TickOffset ??= new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks; - _Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true); - SetFileParameterLotIDToLogisticsMID(); - if (_Logistics.FileInfo.Length < _MinFileLength) + _Logistics = new Logistics(this); + string json = File.ReadAllText(reportFullPath); + if (_Json == json) results.Item4.Add(_Logistics.FileInfo); else { - IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _HttpClient, _BasePage, _API, _Query, _WorkItemTrackingHttpClient, _Project); + IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _HttpClient, _BasePage, _API, _Query, _WorkItemTrackingHttpClient, _Project, json); if (iProcessData is not ProcessData _) throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks)); if (!iProcessData.Details.Any()) throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks)); results = iProcessData.GetResults(this, _Logistics, results.Item4); + _Json = json; } return results; } diff --git a/Adaptation/FileHandlers/json/ProcessData.cs b/Adaptation/FileHandlers/json/ProcessData.cs index 072930c..865667f 100644 --- a/Adaptation/FileHandlers/json/ProcessData.cs +++ b/Adaptation/FileHandlers/json/ProcessData.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; +using System.Text; using System.Text.Json; using System.Threading.Tasks; @@ -23,11 +24,11 @@ public class ProcessData : IProcessData List Shared.Properties.IProcessData.Details => _Details; - public ProcessData(IFileRead fileRead, Logistics logistics, List fileInfoCollection, HttpClient httpClient, string basePage, string api, string query, WorkItemTrackingHttpClient workItemTrackingHttpClient, string project) + public ProcessData(IFileRead fileRead, Logistics logistics, List fileInfoCollection, HttpClient httpClient, string basePage, string api, string query, WorkItemTrackingHttpClient workItemTrackingHttpClient, string project, string json) { fileInfoCollection.Clear(); _Details = new List(); - Parse(fileRead, logistics, fileInfoCollection, httpClient, basePage, api, query, workItemTrackingHttpClient, project); + Parse(fileRead, logistics, fileInfoCollection, httpClient, basePage, api, query, workItemTrackingHttpClient, project, json); } string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary reactors) @@ -40,45 +41,33 @@ public class ProcessData : IProcessData #nullable enable - private static Root GetRoot(HttpClient httpClient, string basePage, string api, int id) - { - Root result; - Task httpResponseMessageTask = httpClient.GetAsync(string.Concat(basePage, api, "/workItems/", id)); - httpResponseMessageTask.Wait(); - if (!httpResponseMessageTask.Result.IsSuccessStatusCode) - throw new Exception(httpResponseMessageTask.Result.StatusCode.ToString()); - Task streamTask = httpResponseMessageTask.Result.Content.ReadAsStreamAsync(); - streamTask.Wait(); - if (!streamTask.Result.CanRead) - { - JsonElement? jsonElement = JsonSerializer.Deserialize(streamTask.Result); - if (jsonElement is null) - throw new NullReferenceException(nameof(jsonElement)); - } - Root? root = JsonSerializer.Deserialize(streamTask.Result, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); - streamTask.Result.Dispose(); - if (root is null || root.Fields is null) - throw new NullReferenceException(nameof(root)); - result = root; - return result; - } - private static void AddPatch(JsonPatchDocument document, string path, object value) => document.Add(new JsonPatchOperation { From = null, Operation = Operation.Add, Path = path, Value = value }); - private void Parse(IFileRead fileRead, Logistics logistics, List fileInfoCollection, HttpClient httpClient, string basePage, string api, string query, WorkItemTrackingHttpClient workItemTrackingHttpClient, string project) + private static Dictionary GetFIBacklogMesaCollection(string json, string keySection) { - if (fileRead is null) - throw new NullReferenceException(); - if (logistics is null) - throw new NullReferenceException(); - if (fileInfoCollection is null) - throw new NullReferenceException(); - Root raw; - ViewModels.WorkItem view; - string json = File.ReadAllText(logistics.ReportFullPath); - FIBacklogMesa[]? fIBacklogMesaCollection = JsonSerializer.Deserialize(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); - if (fIBacklogMesaCollection is null || !fIBacklogMesaCollection.Any()) + Dictionary results = new(); + string key; + FIBacklogMesa[]? fiBacklogMesaCollection; + fiBacklogMesaCollection = JsonSerializer.Deserialize(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); + if (fiBacklogMesaCollection is null || !fiBacklogMesaCollection.Any()) throw new NullReferenceException(); + foreach (FIBacklogMesa fIBacklogMesa in fiBacklogMesaCollection) + { + if (string.IsNullOrEmpty(fIBacklogMesa.Requestor)) + continue; + if (string.IsNullOrEmpty(fIBacklogMesa.Req)) + continue; + key = $"{fIBacklogMesa.Requestor.Split(' ').First()}{keySection}{fIBacklogMesa.Req}"; + if (results.ContainsKey(key)) + continue; + results.Add(key, fIBacklogMesa); + } + return results; + } + + private static string GetIds(HttpClient httpClient, string basePage, string api, string query) + { + StringBuilder result = new(); Task httpResponseMessageTask = httpClient.GetAsync(string.Concat(basePage, api, query)); httpResponseMessageTask.Wait(); if (!httpResponseMessageTask.Result.IsSuccessStatusCode) @@ -86,35 +75,101 @@ public class ProcessData : IProcessData Task streamTask = httpResponseMessageTask.Result.Content.ReadAsStreamAsync(); streamTask.Wait(); if (!streamTask.Result.CanRead) - { - JsonElement? jsonElement = JsonSerializer.Deserialize(streamTask.Result); - if (jsonElement is null) - throw new NullReferenceException(nameof(jsonElement)); - } + throw new NullReferenceException(nameof(streamTask)); WIQL.Root? root = JsonSerializer.Deserialize(streamTask.Result, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); streamTask.Result.Dispose(); if (root is null || root.WorkItems is null) throw new NullReferenceException(nameof(root)); foreach (WIQL.WorkItem workItem in root.WorkItems) + _ = result.Append(workItem.Id).Append(','); + if (result.Length > 0) + _ = result.Remove(result.Length - 1, 1); + return result.ToString(); + } + + private static Value[] GetWorkItems(HttpClient httpClient, string basePage, string api, string ids) + { + Value[]? results; + // List results = new(); + // Value? value; + Task httpResponseMessageTask = httpClient.GetAsync(string.Concat(basePage, api, $"/workitems?ids={ids}")); + httpResponseMessageTask.Wait(); + if (!httpResponseMessageTask.Result.IsSuccessStatusCode) + throw new Exception(httpResponseMessageTask.Result.StatusCode.ToString()); + Task streamTask = httpResponseMessageTask.Result.Content.ReadAsStreamAsync(); + streamTask.Wait(); + if (!streamTask.Result.CanRead) + throw new NullReferenceException(nameof(streamTask)); + JsonElement? jsonElement = JsonSerializer.Deserialize(streamTask.Result); + if (jsonElement is null || jsonElement.Value.ValueKind != JsonValueKind.Object) + throw new NullReferenceException(nameof(jsonElement)); + results = JsonSerializer.Deserialize(jsonElement.Value.EnumerateObject().Last().Value); + if (results is null || !results.Any()) + throw new NullReferenceException(nameof(results)); + return results; + } + + private static Value[] GetExtra(string keySection, IReadOnlyList workItems, Dictionary keyToFIBacklogMesa) + { + List results = new(); + foreach (Value value in workItems) { - raw = GetRoot(httpClient, basePage, api, workItem.Id); - view = new(raw); - _Details.Add(view); - if (workItem.Id == 308759) - break; + if (!value.Fields.SystemTitle.Contains(keySection)) + continue; + if (keyToFIBacklogMesa.Remove(value.Fields.SystemTitle)) + continue; + results.Add(value); } - JsonPatchDocument document = new(); - AddPatch(document, "/fields/System.Title", "Title"); - AddPatch(document, "/fields/System.Description", "Description"); - AddPatch(document, "/fields/System.AssignedTo", "Mike.Phares@infineon.com"); - AddPatch(document, "/fields/System.AreaPath", string.Concat(project, @"\OI")); - AddPatch(document, "/fields/System.IterationPath", string.Concat(project, @"\CMP")); + return results.ToArray(); + } + + private static string GetDescription(FIBacklogMesa fiBacklogMesa, DateTime dateTime) => + $"Req:{fiBacklogMesa.Req}; Submitted:{(dateTime == DateTime.MinValue ? fiBacklogMesa.Submitted : dateTime.ToString("d-MMM-yy"))}; Requestor:{fiBacklogMesa.Requestor}; AssignedTo:{fiBacklogMesa.AssignedTo}; SecondResource:{fiBacklogMesa.SecondResource}; Systems:{fiBacklogMesa.SystemS}; "; + + private void Parse(IFileRead fileRead, Logistics logistics, List fileInfoCollection, HttpClient httpClient, string basePage, string api, string query, WorkItemTrackingHttpClient workItemTrackingHttpClient, string project, string json) + { + if (fileRead is null) + throw new NullReferenceException(); + if (logistics is null) + throw new NullReferenceException(); + if (fileInfoCollection is null) + throw new NullReferenceException(); + int counter = 0; + DateTime dateTime; + string description; + string keySection = " UAT for "; + string ids = GetIds(httpClient, basePage, api, query); + Value[] workItems = GetWorkItems(httpClient, basePage, api, ids); Task workItemTask; - workItemTask = workItemTrackingHttpClient.CreateWorkItemAsync(document, project, "Bug"); - workItemTask.Wait(); - if (workItemTask.Result is null) + Dictionary keyToFIBacklogMesa = GetFIBacklogMesaCollection(json, keySection); + int count = keyToFIBacklogMesa.Count; + Value[] extra = GetExtra(keySection, workItems, keyToFIBacklogMesa); + if (count != extra.Length) { } - // workItemTask = workItemTrackingHttpClient.UpdateWorkItemAsync(document, project, "Bug"); + if (count != keyToFIBacklogMesa.Count) + { } + _Details.AddRange(workItems); + foreach (KeyValuePair keyValuePair in keyToFIBacklogMesa) + { + if (counter > 5) + break; + JsonPatchDocument document = new(); + if (!DateTime.TryParse(keyValuePair.Value.Submitted, out dateTime)) + dateTime = DateTime.MinValue; + AddPatch(document, "/fields/System.AreaPath", project); + description = GetDescription(keyValuePair.Value, dateTime); + AddPatch(document, "/fields/System.Title", keyValuePair.Key); + AddPatch(document, "/fields/System.Description", description); + AddPatch(document, "/fields/System.IterationPath", $"{project}\\(Default)"); + // AddPatch(document, "/fields/System.AssignedTo", "Mike.Phares@infineon.com"); + if (!fileRead.IsEAFHosted) + continue; + workItemTask = workItemTrackingHttpClient.CreateWorkItemAsync(document, project, "Task"); + workItemTask.Wait(); + counter++; + if (workItemTask.Result is null) + continue; + } } } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/ViewModels/WorkItem.cs b/Adaptation/FileHandlers/json/ViewModels/WorkItem.cs deleted file mode 100644 index f997c46..0000000 --- a/Adaptation/FileHandlers/json/ViewModels/WorkItem.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Adaptation.FileHandlers.json.WorkItems; -using System; - -namespace Adaptation.FileHandlers.json.ViewModels; - -public class WorkItem -{ - - public string AreaPath { get; set; } // { init; get; } - public string AssignedToDisplayName { get; set; } // { init; get; } - public int CommentCount { get; set; } // { init; get; } - public string CreatedDate { get; set; } // { init; get; } - public string ClosedDate { get; set; } // { init; get; } - public string Description { get; set; } // { init; get; } - public string Discussion { get; set; } // { init; get; } - public string Effort { get; set; } // { init; get; } - public string HypertextReference { get; set; } // { init; get; } - public int Id { get; set; } // { init; get; } - public string IterationPath { get; set; } // { init; get; } - public string Req { get; set; } // { init; get; } - public string ResolvedDate { get; set; } // { init; get; } - public string Priority { get; set; } // { init; get; } - public string State { get; set; } // { init; get; } - public string Tags { get; set; } // { init; get; } - public string TargetDate { get; set; } // { init; get; } - public string Title { get; set; } // { init; get; } - public string WorkItemType { get; set; } // { init; get; } - - public WorkItem(Root raw) - { - string req; - string[] words; - if (string.IsNullOrEmpty(raw.Fields.SystemHistory)) - words = Array.Empty(); - else - words = raw.Fields.SystemHistory.Split(' '); - if (words.Length < 3 || words[0] != "Req" || words[1] != ":") - req = raw.Id.ToString(); - else - req = words[2].Split('<')[0]; - string systemAreaPath = raw.Fields.SystemAreaPath.Replace(@"Mesa_FI\", string.Empty); - string iterationPath = raw.Fields.SystemIterationPath.Replace(@"Mesa_FI\", string.Empty); - string hypertextReference = string.IsNullOrEmpty(raw.Links?.Html?.Href) ? string.Empty : raw.Links.Html.Href; - string systemAssignedToDisplayName = raw.Fields.SystemAssignedTo is null ? string.Empty : raw.Fields.SystemAssignedTo.DisplayName; - string effort = raw.Fields.MicrosoftVSTSSchedulingEffort < 0.1 ? "" : Math.Floor(raw.Fields.MicrosoftVSTSSchedulingEffort).ToString("0"); - string createdDate = raw.Fields.SystemCreatedDate == DateTime.MinValue ? string.Empty : raw.Fields.SystemCreatedDate.ToString("dd-MMM-yy"); - string closedDate = raw.Fields.MicrosoftVSTSCommonClosedDate == DateTime.MinValue ? string.Empty : raw.Fields.MicrosoftVSTSCommonClosedDate.ToString("dd-MMM-yy"); - string resolvedDate = raw.Fields.MicrosoftVSTSCommonResolvedDate == DateTime.MinValue ? string.Empty : raw.Fields.MicrosoftVSTSCommonResolvedDate.ToString("dd-MMM-yy"); - string targetDate = raw.Fields.MicrosoftVSTSSchedulingTargetDate == DateTime.MinValue ? string.Empty : raw.Fields.MicrosoftVSTSSchedulingTargetDate.ToString("dd-MMM-yy"); - string priority = raw.Fields.SystemWorkItemType == "Bug" ? "BugFix" : raw.Fields.MicrosoftVSTSCommonPriority switch - { - 1 => "High", - 2 => "Med", - 3 => "Low", - 4 => "TBD", - _ => throw new NotImplementedException(), - }; - AreaPath = systemAreaPath; - AssignedToDisplayName = systemAssignedToDisplayName; - CommentCount = raw.Fields.SystemCommentCount; - CreatedDate = createdDate; - ClosedDate = closedDate; - Description = raw.Fields.SystemDescription; - Discussion = raw.Fields.SystemHistory; - Effort = effort; - HypertextReference = hypertextReference; - Id = raw.Id; - IterationPath = iterationPath; - Priority = priority; - Req = req; - ResolvedDate = resolvedDate; - State = raw.Fields.SystemState; - Tags = raw.Fields.SystemTags; - TargetDate = targetDate; - Title = raw.Fields.SystemTitle; - WorkItemType = raw.Fields.SystemWorkItemType; - } - -} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Avatar.cs b/Adaptation/FileHandlers/json/WorkItems/Avatar.cs index e2dd6c4..d140194 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Avatar.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Avatar.cs @@ -9,5 +9,5 @@ public class Avatar string href ) => Href = href; - public string Href { get; set; } // { init; get; } + public string Href { get; } // { init; get; } } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Fields.cs b/Adaptation/FileHandlers/json/WorkItems/Fields.cs index a83c125..f7c74d6 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Fields.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Fields.cs @@ -6,39 +6,25 @@ namespace Adaptation.FileHandlers.json.WorkItems; public class Fields { [JsonConstructor] - public Fields(string systemAreaPath, + public Fields( + string systemAreaPath, string systemTeamProject, string systemIterationPath, string systemWorkItemType, string systemState, string systemReason, - User systemAssignedTo, + SystemAssignedTo systemAssignedTo, DateTime systemCreatedDate, - User systemCreatedBy, + SystemCreatedBy systemCreatedBy, DateTime systemChangedDate, - User systemChangedBy, + SystemChangedBy systemChangedBy, int systemCommentCount, string systemTitle, - string systemBoardColumn, - bool systemBoardColumnDone, DateTime microsoftVSTSCommonStateChangeDate, - DateTime microsoftVSTSCommonActivatedDate, - User microsoftVSTSCommonActivatedBy, - DateTime microsoftVSTSCommonResolvedDate, - User microsoftVSTSCommonResolvedBy, - DateTime microsoftVSTSCommonClosedDate, - User microsoftVSTSCommonClosedBy, int microsoftVSTSCommonPriority, - double microsoftVSTSSchedulingEffort, - DateTime microsoftVSTSSchedulingTargetDate, - double microsoftVSTSCommonStackRank, - string microsoftVSTSCommonValueArea, - string wEF81590F0A22C04FEF834957660F5F0C58KanbanColumn, - bool wEF81590F0A22C04FEF834957660F5F0C58KanbanColumnDone, string systemDescription, - string systemHistory, - string systemTags, - string href) + string systemTags + ) { SystemAreaPath = systemAreaPath; SystemTeamProject = systemTeamProject; @@ -53,123 +39,60 @@ public class Fields SystemChangedBy = systemChangedBy; SystemCommentCount = systemCommentCount; SystemTitle = systemTitle; - SystemBoardColumn = systemBoardColumn; - SystemBoardColumnDone = systemBoardColumnDone; MicrosoftVSTSCommonStateChangeDate = microsoftVSTSCommonStateChangeDate; - MicrosoftVSTSCommonActivatedDate = microsoftVSTSCommonActivatedDate; - MicrosoftVSTSCommonActivatedBy = microsoftVSTSCommonActivatedBy; - MicrosoftVSTSCommonResolvedDate = microsoftVSTSCommonResolvedDate; - MicrosoftVSTSCommonResolvedBy = microsoftVSTSCommonResolvedBy; - MicrosoftVSTSCommonClosedDate = microsoftVSTSCommonClosedDate; - MicrosoftVSTSCommonClosedBy = microsoftVSTSCommonClosedBy; MicrosoftVSTSCommonPriority = microsoftVSTSCommonPriority; - MicrosoftVSTSSchedulingEffort = microsoftVSTSSchedulingEffort; - MicrosoftVSTSSchedulingTargetDate = microsoftVSTSSchedulingTargetDate; - MicrosoftVSTSCommonStackRank = microsoftVSTSCommonStackRank; - MicrosoftVSTSCommonValueArea = microsoftVSTSCommonValueArea; - WEF81590F0A22C04FEF834957660F5F0C58KanbanColumn = wEF81590F0A22C04FEF834957660F5F0C58KanbanColumn; - WEF81590F0A22C04FEF834957660F5F0C58KanbanColumnDone = wEF81590F0A22C04FEF834957660F5F0C58KanbanColumnDone; SystemDescription = systemDescription; - SystemHistory = systemHistory; SystemTags = systemTags; - Href = href; } [JsonPropertyName("System.AreaPath")] - public string SystemAreaPath { get; set; } // { init; get; } + public string SystemAreaPath { get; } // { init; get; } [JsonPropertyName("System.TeamProject")] - public string SystemTeamProject { get; set; } // { init; get; } + public string SystemTeamProject { get; } // { init; get; } [JsonPropertyName("System.IterationPath")] - public string SystemIterationPath { get; set; } // { init; get; } + public string SystemIterationPath { get; } // { init; get; } [JsonPropertyName("System.WorkItemType")] - public string SystemWorkItemType { get; set; } // { init; get; } + public string SystemWorkItemType { get; } // { init; get; } [JsonPropertyName("System.State")] - public string SystemState { get; set; } // { init; get; } + public string SystemState { get; } // { init; get; } [JsonPropertyName("System.Reason")] - public string SystemReason { get; set; } // { init; get; } + public string SystemReason { get; } // { init; get; } [JsonPropertyName("System.AssignedTo")] - public User SystemAssignedTo { get; set; } // { init; get; } + public SystemAssignedTo SystemAssignedTo { get; } // { init; get; } [JsonPropertyName("System.CreatedDate")] - public DateTime SystemCreatedDate { get; set; } // { init; get; } + public DateTime SystemCreatedDate { get; } // { init; get; } [JsonPropertyName("System.CreatedBy")] - public User SystemCreatedBy { get; set; } // { init; get; } + public SystemCreatedBy SystemCreatedBy { get; } // { init; get; } [JsonPropertyName("System.ChangedDate")] - public DateTime SystemChangedDate { get; set; } // { init; get; } + public DateTime SystemChangedDate { get; } // { init; get; } [JsonPropertyName("System.ChangedBy")] - public User SystemChangedBy { get; set; } // { init; get; } + public SystemChangedBy SystemChangedBy { get; } // { init; get; } [JsonPropertyName("System.CommentCount")] - public int SystemCommentCount { get; set; } // { init; get; } + public int SystemCommentCount { get; } // { init; get; } [JsonPropertyName("System.Title")] - public string SystemTitle { get; set; } // { init; get; } - - [JsonPropertyName("System.BoardColumn")] - public string SystemBoardColumn { get; set; } // { init; get; } - - [JsonPropertyName("System.BoardColumnDone")] - public bool SystemBoardColumnDone { get; set; } // { init; get; } + public string SystemTitle { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Common.StateChangeDate")] - public DateTime MicrosoftVSTSCommonStateChangeDate { get; set; } // { init; get; } - - [JsonPropertyName("Microsoft.VSTS.Common.ActivatedDate")] - public DateTime MicrosoftVSTSCommonActivatedDate { get; set; } // { init; get; } - - [JsonPropertyName("Microsoft.VSTS.Common.ActivatedBy")] - public User MicrosoftVSTSCommonActivatedBy { get; set; } // { init; get; } - - [JsonPropertyName("Microsoft.VSTS.Common.ResolvedDate")] - public DateTime MicrosoftVSTSCommonResolvedDate { get; set; } // { init; get; } - - [JsonPropertyName("Microsoft.VSTS.Common.ResolvedBy")] - public User MicrosoftVSTSCommonResolvedBy { get; set; } // { init; get; } - - [JsonPropertyName("Microsoft.VSTS.Common.ClosedDate")] - public DateTime MicrosoftVSTSCommonClosedDate { get; } - - [JsonPropertyName("Microsoft.VSTS.Common.ClosedBy")] - public User MicrosoftVSTSCommonClosedBy { get; } + public DateTime MicrosoftVSTSCommonStateChangeDate { get; } // { init; get; } [JsonPropertyName("Microsoft.VSTS.Common.Priority")] - public int MicrosoftVSTSCommonPriority { get; set; } // { init; get; } - - [JsonPropertyName("Microsoft.VSTS.Scheduling.Effort")] - public double MicrosoftVSTSSchedulingEffort { get; set; } // { init; get; } - - [JsonPropertyName("Microsoft.VSTS.Scheduling.TargetDate")] - public DateTime MicrosoftVSTSSchedulingTargetDate { get; set; } // { init; get; } - - [JsonPropertyName("Microsoft.VSTS.Common.StackRank")] - public double MicrosoftVSTSCommonStackRank { get; set; } // { init; get; } - - [JsonPropertyName("Microsoft.VSTS.Common.ValueArea")] - public string MicrosoftVSTSCommonValueArea { get; set; } // { init; get; } - - [JsonPropertyName("WEF_81590F0A22C04FEF834957660F5F0C58_Kanban.Column")] - public string WEF81590F0A22C04FEF834957660F5F0C58KanbanColumn { get; set; } // { init; get; } - - [JsonPropertyName("WEF_81590F0A22C04FEF834957660F5F0C58_Kanban.Column.Done")] - public bool WEF81590F0A22C04FEF834957660F5F0C58KanbanColumnDone { get; set; } // { init; get; } + public int MicrosoftVSTSCommonPriority { get; } // { init; get; } [JsonPropertyName("System.Description")] - public string SystemDescription { get; set; } // { init; get; } - - [JsonPropertyName("System.History")] - public string SystemHistory { get; set; } // { init; get; } + public string SystemDescription { get; } // { init; get; } [JsonPropertyName("System.Tags")] - public string SystemTags { get; set; } // { init; get; } - - public string Href { get; set; } // { init; get; } + public string SystemTags { get; } // { init; get; } } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Html.cs b/Adaptation/FileHandlers/json/WorkItems/Html.cs index f6642ce..b523964 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Html.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Html.cs @@ -9,5 +9,5 @@ public class Html string href ) => Href = href; - public string Href { get; set; } // { init; get; } + public string Href { get; } // { init; get; } } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Links.cs b/Adaptation/FileHandlers/json/WorkItems/Links.cs index 564e35c..522a2eb 100644 --- a/Adaptation/FileHandlers/json/WorkItems/Links.cs +++ b/Adaptation/FileHandlers/json/WorkItems/Links.cs @@ -6,32 +6,9 @@ public class Links { [JsonConstructor] public Links( - Avatar avatar, - Self self, - WorkItemUpdates workItemUpdates, - WorkItemRevisions workItemRevisions, - WorkItemComments workItemComments, - Html html, - WorkItemType workItemType, - Fields fields - ) - { - Avatar = avatar; - Self = self; - WorkItemUpdates = workItemUpdates; - WorkItemRevisions = workItemRevisions; - WorkItemComments = workItemComments; - Html = html; - WorkItemType = workItemType; - Fields = fields; - } + Avatar avatar + ) => Avatar = avatar; - public Avatar Avatar { get; set; } // { init; get; } - public Self Self { get; set; } // { init; get; } - public WorkItemUpdates WorkItemUpdates { get; set; } // { init; get; } - public WorkItemRevisions WorkItemRevisions { get; set; } // { init; get; } - public WorkItemComments WorkItemComments { get; set; } // { init; get; } - public Html Html { get; set; } // { init; get; } - public WorkItemType WorkItemType { get; set; } // { init; get; } - public Fields Fields { get; set; } // { init; get; } + [JsonPropertyName("avatar")] + public Avatar Avatar { get; } } \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Root.cs b/Adaptation/FileHandlers/json/WorkItems/Root.cs deleted file mode 100644 index bf60e30..0000000 --- a/Adaptation/FileHandlers/json/WorkItems/Root.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Adaptation.FileHandlers.json.WorkItems; - -public class Root -{ - [JsonConstructor] - public Root( - int id, - int rev, - Fields fields, - Links links, - string url - ) - { - Id = id; - Rev = rev; - Fields = fields; - Links = links; - Url = url; - } - - public int Id { get; set; } // { init; get; } - public int Rev { get; set; } // { init; get; } - public Fields Fields { get; set; } // { init; get; } - - [JsonPropertyName("_links")] - public Links Links { get; set; } // { init; get; } - public string Url { get; set; } // { init; get; } -} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Self.cs b/Adaptation/FileHandlers/json/WorkItems/Self.cs deleted file mode 100644 index bb364b1..0000000 --- a/Adaptation/FileHandlers/json/WorkItems/Self.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Adaptation.FileHandlers.json.WorkItems; - -public class Self -{ - [JsonConstructor] - public Self( - string href - ) => Href = href; - - public string Href { get; set; } // { init; get; } -} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/SystemAssignedTo.cs b/Adaptation/FileHandlers/json/WorkItems/SystemAssignedTo.cs new file mode 100644 index 0000000..6a1d58f --- /dev/null +++ b/Adaptation/FileHandlers/json/WorkItems/SystemAssignedTo.cs @@ -0,0 +1,47 @@ +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.json.WorkItems; + +public class SystemAssignedTo +{ + [JsonConstructor] + public SystemAssignedTo( + string displayName, + string url, + Links links, + string id, + string uniqueName, + string imageUrl, + string descriptor + ) + { + DisplayName = displayName; + Url = url; + Links = links; + Id = id; + UniqueName = uniqueName; + ImageUrl = imageUrl; + Descriptor = descriptor; + } + + [JsonPropertyName("displayName")] + public string DisplayName { get; } + + [JsonPropertyName("url")] + public string Url { get; } + + [JsonPropertyName("_links")] + public Links Links { get; } + + [JsonPropertyName("id")] + public string Id { get; } + + [JsonPropertyName("uniqueName")] + public string UniqueName { get; } + + [JsonPropertyName("imageUrl")] + public string ImageUrl { get; } + + [JsonPropertyName("descriptor")] + public string Descriptor { get; } +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/SystemChangedBy.cs b/Adaptation/FileHandlers/json/WorkItems/SystemChangedBy.cs new file mode 100644 index 0000000..84e3eb9 --- /dev/null +++ b/Adaptation/FileHandlers/json/WorkItems/SystemChangedBy.cs @@ -0,0 +1,47 @@ +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.json.WorkItems; + +public class SystemChangedBy +{ + [JsonConstructor] + public SystemChangedBy( + string displayName, + string url, + Links links, + string id, + string uniqueName, + string imageUrl, + string descriptor + ) + { + DisplayName = displayName; + Url = url; + Links = links; + Id = id; + UniqueName = uniqueName; + ImageUrl = imageUrl; + Descriptor = descriptor; + } + + [JsonPropertyName("displayName")] + public string DisplayName { get; } + + [JsonPropertyName("url")] + public string Url { get; } + + [JsonPropertyName("_links")] + public Links Links { get; } + + [JsonPropertyName("id")] + public string Id { get; } + + [JsonPropertyName("uniqueName")] + public string UniqueName { get; } + + [JsonPropertyName("imageUrl")] + public string ImageUrl { get; } + + [JsonPropertyName("descriptor")] + public string Descriptor { get; } +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/SystemCreatedBy.cs b/Adaptation/FileHandlers/json/WorkItems/SystemCreatedBy.cs new file mode 100644 index 0000000..7b76091 --- /dev/null +++ b/Adaptation/FileHandlers/json/WorkItems/SystemCreatedBy.cs @@ -0,0 +1,47 @@ +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.json.WorkItems; + +public class SystemCreatedBy +{ + [JsonConstructor] + public SystemCreatedBy( + string displayName, + string url, + Links links, + string id, + string uniqueName, + string imageUrl, + string descriptor + ) + { + DisplayName = displayName; + Url = url; + Links = links; + Id = id; + UniqueName = uniqueName; + ImageUrl = imageUrl; + Descriptor = descriptor; + } + + [JsonPropertyName("displayName")] + public string DisplayName { get; } + + [JsonPropertyName("url")] + public string Url { get; } + + [JsonPropertyName("_links")] + public Links Links { get; } + + [JsonPropertyName("id")] + public string Id { get; } + + [JsonPropertyName("uniqueName")] + public string UniqueName { get; } + + [JsonPropertyName("imageUrl")] + public string ImageUrl { get; } + + [JsonPropertyName("descriptor")] + public string Descriptor { get; } +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/User.cs b/Adaptation/FileHandlers/json/WorkItems/User.cs deleted file mode 100644 index 75ad040..0000000 --- a/Adaptation/FileHandlers/json/WorkItems/User.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Adaptation.FileHandlers.json.WorkItems; - -public class User -{ - [JsonConstructor] - public User( - string displayName, - string url, - Links links, - string id, - string uniqueName, - string imageUrl, - string descriptor - ) - { - DisplayName = displayName; - Url = url; - Links = links; - Id = id; - UniqueName = uniqueName; - ImageUrl = imageUrl; - Descriptor = descriptor; - } - - public string DisplayName { get; set; } // { init; get; } - public string Url { get; set; } // { init; get; } - public Links Links { get; set; } // { init; get; } - public string Id { get; set; } // { init; get; } - public string UniqueName { get; set; } // { init; get; } - public string ImageUrl { get; set; } // { init; get; } - public string Descriptor { get; set; } // { init; get; } -} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/Value.cs b/Adaptation/FileHandlers/json/WorkItems/Value.cs new file mode 100644 index 0000000..5dbcf9d --- /dev/null +++ b/Adaptation/FileHandlers/json/WorkItems/Value.cs @@ -0,0 +1,32 @@ +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.json.WorkItems; + +public class Value +{ + [JsonConstructor] + public Value( + int id, + int rev, + Fields fields, + string url + ) + { + Id = id; + Rev = rev; + Fields = fields; + Url = url; + } + + [JsonPropertyName("id")] + public int Id { get; } + + [JsonPropertyName("rev")] + public int Rev { get; } + + [JsonPropertyName("fields")] + public Fields Fields { get; } + + [JsonPropertyName("url")] + public string Url { get; } +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/WorkItemComments.cs b/Adaptation/FileHandlers/json/WorkItems/WorkItemComments.cs deleted file mode 100644 index b7d1ef4..0000000 --- a/Adaptation/FileHandlers/json/WorkItems/WorkItemComments.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Adaptation.FileHandlers.json.WorkItems; - -public class WorkItemComments -{ - [JsonConstructor] - public WorkItemComments( - string href - ) => Href = href; - - public string Href { get; set; } // { init; get; } -} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/WorkItemRevisions.cs b/Adaptation/FileHandlers/json/WorkItems/WorkItemRevisions.cs deleted file mode 100644 index a2102a1..0000000 --- a/Adaptation/FileHandlers/json/WorkItems/WorkItemRevisions.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Adaptation.FileHandlers.json.WorkItems; - -public class WorkItemRevisions -{ - [JsonConstructor] - public WorkItemRevisions( - string href - ) => Href = href; - - public string Href { get; set; } // { init; get; } -} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/WorkItemType.cs b/Adaptation/FileHandlers/json/WorkItems/WorkItemType.cs deleted file mode 100644 index cd6ef91..0000000 --- a/Adaptation/FileHandlers/json/WorkItems/WorkItemType.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Adaptation.FileHandlers.json.WorkItems; - -public class WorkItemType -{ - [JsonConstructor] - public WorkItemType( - string href - ) => Href = href; - - public string Href { get; set; } // { init; get; } -} \ No newline at end of file diff --git a/Adaptation/FileHandlers/json/WorkItems/WorkItemUpdates.cs b/Adaptation/FileHandlers/json/WorkItems/WorkItemUpdates.cs deleted file mode 100644 index c5025d3..0000000 --- a/Adaptation/FileHandlers/json/WorkItems/WorkItemUpdates.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Adaptation.FileHandlers.json.WorkItems; - -public class WorkItemUpdates -{ - [JsonConstructor] - public WorkItemUpdates( - string href - ) => Href = href; - - public string Href { get; set; } // { init; get; } -} \ No newline at end of file diff --git a/Adaptation/MESAFIBACKLOG-Development.yml b/Adaptation/MESAFIBACKLOG-Development.yml new file mode 100644 index 0000000..ada105f --- /dev/null +++ b/Adaptation/MESAFIBACKLOG-Development.yml @@ -0,0 +1,163 @@ +trigger: + branches: + include: + - Development + paths: + include: + - "Adaptation/*" + +pool: + name: Mesa-Windows-Service + demands: MESAFIBACKLOG-Development + +steps: + - script: | + set coreVersion=net7.0 + echo %coreVersion% + echo ##vso[task.setvariable variable=CoreVersion;]%coreVersion% + echo $(CoreVersion) + displayName: CoreVersion + + - script: | + set configuration=Debug + echo %configuration% + echo ##vso[task.setvariable variable=Configuration;]%configuration% + echo $(Configuration) + displayName: Configuration + + - script: | + set nugetSource=https://messa017.infineon.com/v3/index.json + echo %nugetSource% + echo ##vso[task.setvariable variable=NugetSource;]%nugetSource% + echo $(NugetSource) + displayName: NugetSource + + - script: | + set gitCommit=$(Build.SourceVersion) + set gitCommitSeven=%gitCommit:~0,7% + echo %gitCommitSeven% + echo ##vso[task.setvariable variable=GitCommitSeven;]%gitCommitSeven% + echo $(GitCommitSeven) + displayName: GitCommitSeven + + - script: | + echo $(Build.BuildId) + echo $(Build.Reason) + echo $(Build.Repository.Id) + echo $(Build.Repository.Name) + echo $(Build.SourceVersion) + echo $(CoreVersion) + echo $(Configuration) + echo $(NugetSource) + echo $(GitCommitSeven) + REM echo $(pipelinePassword) + displayName: "Echo Check" + + - script: '"C:\program files\dotnet\dotnet.exe" nuget locals all --clear' + displayName: "Nuget Clear" + enabled: false + + - script: | + "C:\program files\dotnet\dotnet.exe" user-secrets init + "C:\program files\dotnet\dotnet.exe" user-secrets set "BuildNumber" "$(Build.BuildId)" + "C:\program files\dotnet\dotnet.exe" user-secrets set "GitCommitSeven" "$(GitCommitSeven)" + "C:\program files\dotnet\dotnet.exe" user-secrets list + workingDirectory: Adaptation + displayName: "Safe storage of app secrets - Adaptation" + + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' + workingDirectory: Adaptation + displayName: "Core Build - Adaptation" + + - powershell: Get-ChildItem .\ -include TestResults -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } + workingDirectory: "$(System.DefaultWorkingDirectory)/../../../$(Build.Repository.Name)" + displayName: "PowerShell Script" + continueOnError: true + + - script: "dotnet test --configuration $(Configuration)" + workingDirectory: Adaptation + displayName: "Core Test" + + - script: 'move /y "$(System.DefaultWorkingDirectory)/../../../$(Build.Repository.Name)/05_TestResults/TestResults" $(System.DefaultWorkingDirectory)' + displayName: "Move Results" + + - script: '"C:\program files\dotnet\dotnet.exe" tool restore' + workingDirectory: Adaptation + displayName: "Tool Restore" + enabled: false + + - script: '"C:\program files\dotnet\dotnet.exe" ReportGenerator -reports:$(System.DefaultWorkingDirectory)/TestResults/**/coverage.cobertura.xml -targetDir:$(Build.ArtifactStagingDirectory)\Coverage -reportTypes:Html_Dark' + workingDirectory: Adaptation + displayName: "Report Generator" + enabled: false + + - task: PublishTestResults@2 + displayName: "Publish Test Results **/*.trx" + inputs: + testResultsFormat: VSTest + testResultsFiles: "**/*.trx" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/TestResults" + + - task: PublishTestResults@2 + displayName: "Publish Test Results */coverage.cobertura.xml" + inputs: + testResultsFormat: VSTest + testResultsFiles: "*/coverage.cobertura.xml" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/TestResults" + + - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 + displayName: "Create work item" + inputs: + teamProject: "Mesa_FI" + workItemType: Bug + title: $(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration) + assignedTo: "$(Build.RequestedForId)" + enabled: false + + - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o $(Build.ArtifactStagingDirectory)\Adaptation --source $(NugetSource)' + workingDirectory: Adaptation + displayName: "Core Publish" + enabled: false + + - script: '"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe" /target:Restore /detailedsummary /consoleloggerparameters:PerformanceSummary;ErrorsOnly; /property:Configuration=$(Configuration);TargetFrameworkVersion=v4.8 /p:RestoreSources=$(NugetSource)' + displayName: "MSBuild Restore" + + - script: '"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe" /target:Build /detailedsummary /consoleloggerparameters:PerformanceSummary;ErrorsOnly; /property:Configuration=$(Configuration);TargetFrameworkVersion=v4.8' + displayName: MSBuild + + - script: 'echo $(Build.SourceVersion)-$(Build.BuildId)-$(Build.Repository.Name)>bin\$(Configuration)\$(Build.Repository.Name).txt' + displayName: "Commit Id" + + - task: CopyFiles@2 + displayName: 'Copy Files to: D:\Framework4.8' + inputs: + SourceFolder: 'bin\$(Configuration)' + Contents: "*$(Build.Repository.Name)*" + 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' + inputs: + SourceFolder: 'bin\$(Configuration)' + Contents: "*$(Build.Repository.Name)*" + TargetFolder: '\\messv02ecc1.ec.local\EC_EAFRepository\Staging\DeploymentStorage\Adaptation_$(Build.Repository.Name)' + OverWrite: true + enabled: false + + - script: | + "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) + workingDirectory: Adaptation + displayName: "Core Clean - Tests" + + - script: | + "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) + workingDirectory: Adaptation + displayName: "Core Clean - Adaptation" + + - script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\$(Configuration)\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt' + displayName: "Force Fail" + enabled: false diff --git a/Adaptation/MESAFIBACKLOG.Tests.csproj b/Adaptation/MESAFIBACKLOG.Tests.csproj index 9b11117..cf1a026 100644 --- a/Adaptation/MESAFIBACKLOG.Tests.csproj +++ b/Adaptation/MESAFIBACKLOG.Tests.csproj @@ -11,7 +11,7 @@ 10.0 disable win-x64 - net6.0 + net7.0 trx @@ -33,51 +33,8 @@ Linux - - - - - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - NU1701 - NU1701 - NU1701 - - - NU1701 + + NU1701 NU1701 NU1701 @@ -85,6 +42,42 @@ NU1701 NU1701 NU1701 + + + + + + + + + + + + + + + + + NU1701 + + + + + + + + + + + + + + NU1701 + + + NU1701 + NU1701 + NU1701 diff --git a/Adaptation/MESAFIBACKLOG.yml b/Adaptation/MESAFIBACKLOG.yml new file mode 100644 index 0000000..744b3d0 --- /dev/null +++ b/Adaptation/MESAFIBACKLOG.yml @@ -0,0 +1,161 @@ +trigger: + branches: + include: + - master + paths: + include: + - "Adaptation/*" + +pool: + name: Mesa-Windows-Service + demands: MESAFIBACKLOG + +steps: + - script: | + set coreVersion=net7.0 + echo %coreVersion% + echo ##vso[task.setvariable variable=CoreVersion;]%coreVersion% + echo $(CoreVersion) + displayName: CoreVersion + + - script: | + set configuration=Release + echo %configuration% + echo ##vso[task.setvariable variable=Configuration;]%configuration% + echo $(Configuration) + displayName: Configuration + + - script: | + set nugetSource=https://eaf-prod.mes.infineon.com/v3/index.json + echo %nugetSource% + echo ##vso[task.setvariable variable=NugetSource;]%nugetSource% + echo $(NugetSource) + displayName: NugetSource + + - script: | + set gitCommit=$(Build.SourceVersion) + set gitCommitSeven=%gitCommit:~0,7% + echo %gitCommitSeven% + echo ##vso[task.setvariable variable=GitCommitSeven;]%gitCommitSeven% + echo $(GitCommitSeven) + displayName: GitCommitSeven + + - script: | + echo $(Build.BuildId) + echo $(Build.Reason) + echo $(Build.Repository.Id) + echo $(Build.Repository.Name) + echo $(Build.SourceVersion) + echo $(CoreVersion) + echo $(Configuration) + echo $(NugetSource) + echo $(GitCommitSeven) + REM echo $(pipelinePassword) + displayName: "Echo Check" + + - script: '"C:\program files\dotnet\dotnet.exe" nuget locals all --clear' + displayName: "Nuget Clear" + enabled: false + + - script: | + "C:\program files\dotnet\dotnet.exe" user-secrets init + "C:\program files\dotnet\dotnet.exe" user-secrets set "BuildNumber" "$(Build.BuildId)" + "C:\program files\dotnet\dotnet.exe" user-secrets set "GitCommitSeven" "$(GitCommitSeven)" + "C:\program files\dotnet\dotnet.exe" user-secrets list + workingDirectory: Adaptation + displayName: "Safe storage of app secrets - Adaptation" + + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' + workingDirectory: Adaptation + displayName: "Core Build - Adaptation" + + - powershell: Get-ChildItem .\ -include TestResults -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } + workingDirectory: "$(System.DefaultWorkingDirectory)/../../../$(Build.Repository.Name)" + displayName: "PowerShell Script" + continueOnError: true + + - script: "dotnet test --configuration $(Configuration)" + workingDirectory: Adaptation + displayName: "Core Test" + + - script: 'move /y "$(System.DefaultWorkingDirectory)/../../../$(Build.Repository.Name)/05_TestResults/TestResults" $(System.DefaultWorkingDirectory)' + displayName: "Move Results" + + - script: '"C:\program files\dotnet\dotnet.exe" tool restore' + workingDirectory: Adaptation + displayName: "Tool Restore" + enabled: false + + - script: '"C:\program files\dotnet\dotnet.exe" ReportGenerator -reports:$(System.DefaultWorkingDirectory)/TestResults/**/coverage.cobertura.xml -targetDir:$(Build.ArtifactStagingDirectory)\Coverage -reportTypes:Html_Dark' + workingDirectory: Adaptation + displayName: "Report Generator" + enabled: false + + - task: PublishTestResults@2 + displayName: "Publish Test Results **/*.trx" + inputs: + testResultsFormat: VSTest + testResultsFiles: "**/*.trx" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/TestResults" + + - task: PublishTestResults@2 + displayName: "Publish Test Results */coverage.cobertura.xml" + inputs: + testResultsFormat: VSTest + testResultsFiles: "*/coverage.cobertura.xml" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/TestResults" + + - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 + displayName: "Create work item" + inputs: + teamProject: "Mesa_FI" + workItemType: Bug + title: $(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration) + assignedTo: "$(Build.RequestedForId)" + enabled: false + + - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o $(Build.ArtifactStagingDirectory)\Adaptation --source $(NugetSource)' + workingDirectory: Adaptation + displayName: "Core Publish" + enabled: false + + - script: '"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe" /target:Restore /detailedsummary /consoleloggerparameters:PerformanceSummary;ErrorsOnly; /property:Configuration=$(Configuration);TargetFrameworkVersion=v4.8 /p:RestoreSources=$(NugetSource)' + displayName: "MSBuild Restore" + + - script: '"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe" /target:Build /detailedsummary /consoleloggerparameters:PerformanceSummary;ErrorsOnly; /property:Configuration=$(Configuration);TargetFrameworkVersion=v4.8' + displayName: MSBuild + + - script: 'echo $(Build.SourceVersion)-$(Build.BuildId)-$(Build.Repository.Name)>bin\$(Configuration)\$(Build.Repository.Name).txt' + displayName: "Commit Id" + + - task: CopyFiles@2 + displayName: 'Copy Files to: D:\Framework4.8' + inputs: + SourceFolder: 'bin\$(Configuration)' + Contents: "*$(Build.Repository.Name)*" + 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' + inputs: + SourceFolder: 'bin\$(Configuration)' + Contents: "*$(Build.Repository.Name)*" + TargetFolder: '\\messv02ecc1.ec.local\EC_EAFRepository\Staging\DeploymentStorage\Adaptation_$(Build.Repository.Name)' + OverWrite: true + + - script: | + "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) + workingDirectory: Adaptation + displayName: "Core Clean - Tests" + + - script: | + "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) + workingDirectory: Adaptation + displayName: "Core Clean - Adaptation" + + - script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\$(Configuration)\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt' + displayName: "Force Fail" + enabled: false diff --git a/Adaptation/Shared/FileRead.cs b/Adaptation/Shared/FileRead.cs index 48122f8..90ed6e6 100644 --- a/Adaptation/Shared/FileRead.cs +++ b/Adaptation/Shared/FileRead.cs @@ -63,7 +63,7 @@ public class FileRead : Properties.IFileRead string Properties.IFileRead.CellInstanceConnectionName => _CellInstanceConnectionName; string Properties.IFileRead.ParameterizedModelObjectDefinitionType => _ParameterizedModelObjectDefinitionType; - public FileRead(IDescription description, bool isEvent, ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) + public FileRead(IDescription description, bool isEvent, ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) { _SMTP = smtp; _IsEvent = isEvent; @@ -106,7 +106,7 @@ public class FileRead : Properties.IFileRead throw new Exception(cellInstanceConnectionName); if (string.IsNullOrEmpty(equipmentDictionaryName) && isEvent) throw new Exception(cellInstanceConnectionName); - if (!string.IsNullOrEmpty(equipmentDictionaryName) && !isEvent) + if (!string.IsNullOrEmpty(equipmentDictionaryName) && !isEvent && connectionCount > 1) throw new Exception(cellInstanceConnectionName); // if (string.IsNullOrEmpty(equipmentDictionaryName) && !isEvent) // throw new Exception(cellInstanceConnectionName); @@ -266,13 +266,14 @@ public class FileRead : Properties.IFileRead string rds; string dateValue; string rdsPlaceholder = "%RDS%"; + string mesEntityPlaceholder = "%MesEntity%"; if (!descriptions.Any() || string.IsNullOrEmpty(descriptions[0].RDS)) rds = logistics.MID; else rds = descriptions[0].RDS; string[] segments = scopeInfo.FileName.Split(new string[] { "DateTime:" }, StringSplitOptions.RemoveEmptyEntries); if (segments.Length == 0) - result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileNameWithoutExtension.Replace(rdsPlaceholder, rds)); + result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileNameWithoutExtension.Replace(rdsPlaceholder, rds).Replace(mesEntityPlaceholder, logistics.MesEntity)); else { segments = segments[1].Split('%'); @@ -284,7 +285,7 @@ public class FileRead : Properties.IFileRead continue; datePlaceholder = string.Concat('%', segment, '%'); } - result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileName.Replace(rdsPlaceholder, rds).Replace(datePlaceholder, dateValue)); + result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileName.Replace(rdsPlaceholder, rds).Replace(mesEntityPlaceholder, logistics.MesEntity).Replace(datePlaceholder, dateValue)); } if (result.Contains('%')) throw new Exception("Placeholder exists!"); diff --git a/Adaptation/Shared/Logistics.cs b/Adaptation/Shared/Logistics.cs index 43d66b4..a6ca882 100644 --- a/Adaptation/Shared/Logistics.cs +++ b/Adaptation/Shared/Logistics.cs @@ -59,7 +59,7 @@ public class Logistics : ILogistics throw new Exception(); _NullData = fileRead.NullData; _FileInfo = new(reportFullPath); - DateTime dateTime = new (_FileInfo.LastWriteTime.Ticks + tickOffset); + DateTime dateTime = new(_FileInfo.LastWriteTime.Ticks + tickOffset); if (fileInfoLength.HasValue && _FileInfo.Length < fileInfoLength.Value) dateTime = dateTime.AddTicks(-1); _JobID = fileRead.CellInstanceName; diff --git a/Adaptation/Shared/Metrology/WS.cs b/Adaptation/Shared/Metrology/WS.cs index b892219..cd22a89 100644 --- a/Adaptation/Shared/Metrology/WS.cs +++ b/Adaptation/Shared/Metrology/WS.cs @@ -30,7 +30,7 @@ public partial class WS }; HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead).Result; resultsJson = httpResponseMessage.Content.ReadAsStringAsync().Result; - results = JsonSerializer.Deserialize(resultsJson); + results = JsonSerializer.Deserialize(resultsJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); } if (!results.Success) results.Errors.Add(results.ToString()); @@ -44,8 +44,7 @@ public partial class WS _ = stringBuilder.AppendLine(exception.Message); exception = exception.InnerException; } - if (results.Errors is null) - results.Errors = new List(); + results.Errors ??= new List(); results.Errors.Add(stringBuilder.ToString()); } return new(resultsJson, results); diff --git a/Adaptation/Shared/ProcessDataStandardFormat.cs b/Adaptation/Shared/ProcessDataStandardFormat.cs index 9dcdb0a..c165a7e 100644 --- a/Adaptation/Shared/ProcessDataStandardFormat.cs +++ b/Adaptation/Shared/ProcessDataStandardFormat.cs @@ -91,8 +91,7 @@ public class ProcessDataStandardFormat string segment; List body = new(); StringBuilder logistics = new(); - if (lines is null) - lines = File.ReadAllLines(reportFullPath); + lines ??= File.ReadAllLines(reportFullPath); string[] segments; if (lines.Length < 7) segments = Array.Empty(); @@ -276,8 +275,7 @@ public class ProcessDataStandardFormat public static string GetLines(Logistics logistics, Properties.IScopeInfo scopeInfo, List names, Dictionary> keyValuePairs, string dateFormat, string timeFormat, List pairedParameterNames, bool useDateTimeFromSequence = true, string format = "", List ignoreParameterNames = null) { StringBuilder result = new(); - if (ignoreParameterNames is null) - ignoreParameterNames = new List(); + ignoreParameterNames ??= new List(); if (useDateTimeFromSequence && !string.IsNullOrEmpty(format)) throw new Exception(); else if (!useDateTimeFromSequence && string.IsNullOrEmpty(format)) @@ -318,7 +316,7 @@ public class ProcessDataStandardFormat _ = line.Append(logistics.DateTimeFromSequence.ToString(timeFormat)); else if (!useDateTimeFromSequence && keyValuePair.Key == columnDate && keyValuePair.Value[r].Length == format.Length) _ = line.Append(DateTime.ParseExact(keyValuePair.Value[r], format, CultureInfo.InvariantCulture).ToString(dateFormat)); - else if (!useDateTimeFromSequence && keyValuePair.Key == columnTime && keyValuePairs.ContainsKey(string.Concat(keyValuePair.Key, firstDuplicate)) && keyValuePairs[string.Concat(keyValuePair.Key, firstDuplicate)][r].Length == format.Length) + else if (!useDateTimeFromSequence && keyValuePair.Key == columnTime && keyValuePairs.TryGetValue(string.Concat(keyValuePair.Key, firstDuplicate), out List value) && value[r].Length == format.Length) _ = line.Append(DateTime.ParseExact(keyValuePairs[string.Concat(keyValuePair.Key, firstDuplicate)][r], format, CultureInfo.InvariantCulture).ToString(timeFormat)); else if (string.IsNullOrEmpty(keyValuePair.Value[r]) || keyValuePair.Value[r] == nullData) _ = line.Append(nullData); @@ -357,8 +355,7 @@ public class ProcessDataStandardFormat if (string.IsNullOrEmpty(lines[i])) continue; segments = lines[i].Split(inputSeparator); - if (currentGroup is null) - currentGroup = segments.Length; + currentGroup ??= segments.Length; if (segments.Length != currentGroup) { currentGroup = segments.Length; diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BACKLOG-EQPT.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/BACKLOG-EQPT.cs similarity index 79% rename from Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BACKLOG-EQPT.cs rename to Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/BACKLOG-EQPT.cs index 646c2db..b1a684e 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BACKLOG-EQPT.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/BACKLOG-EQPT.cs @@ -6,7 +6,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; -namespace Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0; +namespace Adaptation._Tests.CreateSelfDescription.Staging.v2_49_0; [TestClass] public class BACKLOG_EQPT : EAFLoggingUnitTesting @@ -33,8 +33,7 @@ public class BACKLOG_EQPT : EAFLoggingUnitTesting [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - if (EAFLoggingUnitTesting is null) - EAFLoggingUnitTesting = new BACKLOG_EQPT(testContext); + EAFLoggingUnitTesting ??= new BACKLOG_EQPT(testContext); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); @@ -44,19 +43,17 @@ public class BACKLOG_EQPT : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - if (EAFLoggingUnitTesting.Logger is not null) - EAFLoggingUnitTesting.Logger.LogInformation("Cleanup"); - if (EAFLoggingUnitTesting is not null) - EAFLoggingUnitTesting.Dispose(); + EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Dispose(); } -#if true +#if DEBUG [Ignore] #endif [TestMethod] - public void Staging__v2_43_0__BACKLOG_EQPT__ConvertExcelToJson() + public void Staging__v2_49_0__BACKLOG_EQPT__DownloadExcelFile() { - string check = "*.xlsx"; + string check = ".xlsx"; MethodBase methodBase = new StackFrame().GetMethod(); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); _ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting); diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BACKLOG.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/BACKLOG.cs similarity index 79% rename from Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BACKLOG.cs rename to Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/BACKLOG.cs index 9d30f66..ac92d1d 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BACKLOG.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/BACKLOG.cs @@ -6,7 +6,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; -namespace Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0; +namespace Adaptation._Tests.CreateSelfDescription.Staging.v2_49_0; [TestClass] public class BACKLOG : EAFLoggingUnitTesting @@ -33,8 +33,7 @@ public class BACKLOG : EAFLoggingUnitTesting [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - if (EAFLoggingUnitTesting is null) - EAFLoggingUnitTesting = new BACKLOG(testContext); + EAFLoggingUnitTesting ??= new BACKLOG(testContext); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); @@ -44,19 +43,17 @@ public class BACKLOG : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - if (EAFLoggingUnitTesting.Logger is not null) - EAFLoggingUnitTesting.Logger.LogInformation("Cleanup"); - if (EAFLoggingUnitTesting is not null) - EAFLoggingUnitTesting.Dispose(); + EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Dispose(); } -#if true +#if DEBUG [Ignore] #endif [TestMethod] - public void Staging__v2_43_0__BACKLOG__json() + public void Staging__v2_49_0__BACKLOG__ConvertExcelToJson() { - string check = "*.json"; + string check = "*.xlsx"; MethodBase methodBase = new StackFrame().GetMethod(); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); _ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting); diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/MESAFIBACKLOG.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/MESAFIBACKLOG.cs new file mode 100644 index 0000000..5f36174 --- /dev/null +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.49.0/MESAFIBACKLOG.cs @@ -0,0 +1,63 @@ +using Adaptation._Tests.Shared; +using Microsoft.Extensions.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; + +namespace Adaptation._Tests.CreateSelfDescription.Staging.v2_49_0; + +[TestClass] +public class MESAFIBACKLOG : EAFLoggingUnitTesting +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + internal static string DummyRoot { get; private set; } + internal static MESAFIBACKLOG EAFLoggingUnitTesting { get; private set; } + + static MESAFIBACKLOG() => DummyRoot = @"\\messv02ecc1.ec.local\EC_Characterization_Si\Dummy"; + + public MESAFIBACKLOG() : base(DummyRoot, testContext: null, declaringType: null, skipEquipmentDictionary: false) + { + if (EAFLoggingUnitTesting is null) + throw new Exception(); + } + + public MESAFIBACKLOG(TestContext testContext) : base(DummyRoot, testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) + { + } + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + EAFLoggingUnitTesting ??= new MESAFIBACKLOG(testContext); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); + string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); + File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); + File.WriteAllText(fileNameAndText[2], fileNameAndText[3]); + } + + [ClassCleanup()] + public static void ClassCleanup() + { + EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Dispose(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_49_0__MESAFIBACKLOG__json() + { + string check = "*.json"; + MethodBase methodBase = new StackFrame().GetMethod(); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); + _ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting); + EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + } + +} \ No newline at end of file diff --git a/Adaptation/_Tests/Extract/Staging/v2.43.0/BACKLOG-EQPT.cs b/Adaptation/_Tests/Extract/Staging/v2.43.0/BACKLOG-EQPT.cs deleted file mode 100644 index dcc37a7..0000000 --- a/Adaptation/_Tests/Extract/Staging/v2.43.0/BACKLOG-EQPT.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Adaptation.Shared; -using Adaptation.Shared.Methods; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Reflection; -using System.Text.Json; - -namespace Adaptation._Tests.Extract.Staging.v2_43_0; - -[TestClass] -public class BACKLOG_EQPT -{ - -#pragma warning disable CA2254 -#pragma warning disable IDE0060 - - private static CreateSelfDescription.Staging.v2_43_0.BACKLOG_EQPT _BACKLOG_EQPT; - - [ClassInitialize] - public static void ClassInitialize(TestContext testContext) - { - CreateSelfDescription.Staging.v2_43_0.BACKLOG_EQPT.ClassInitialize(testContext); - _BACKLOG_EQPT = CreateSelfDescription.Staging.v2_43_0.BACKLOG_EQPT.EAFLoggingUnitTesting; - } - -#if true - [Ignore] -#endif - [TestMethod] - public void Staging__v2_43_0__BACKLOG_EQPT__ConvertExcelToJson() => _BACKLOG_EQPT.Staging__v2_43_0__BACKLOG_EQPT__ConvertExcelToJson(); - -#if true - [Ignore] -#endif - [TestMethod] - public void Staging__v2_43_0__BACKLOG_EQPT__ConvertExcelToJson637961178824025822__Normal() - { - string check = "*.xlsx"; - bool validatePDSF = false; - MethodBase methodBase = new StackFrame().GetMethod(); - _BACKLOG_EQPT.Staging__v2_43_0__BACKLOG_EQPT__ConvertExcelToJson(); - Assert.IsFalse(string.IsNullOrEmpty(_BACKLOG_EQPT.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); - string[] variables = _BACKLOG_EQPT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); - IFileRead fileRead = _BACKLOG_EQPT.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); - Tuple> extractResult = fileRead.ReExtract(); - Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); - Assert.IsNotNull(extractResult.Item3); - Assert.IsNotNull(extractResult.Item4); - } - -} \ No newline at end of file diff --git a/Adaptation/_Tests/Extract/Staging/v2.49.0/BACKLOG-EQPT.cs b/Adaptation/_Tests/Extract/Staging/v2.49.0/BACKLOG-EQPT.cs new file mode 100644 index 0000000..b314ea3 --- /dev/null +++ b/Adaptation/_Tests/Extract/Staging/v2.49.0/BACKLOG-EQPT.cs @@ -0,0 +1,54 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.Reflection; +using System.Threading; + +namespace Adaptation._Tests.Extract.Staging.v2_49_0; + +[TestClass] +public class BACKLOG_EQPT +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + private static CreateSelfDescription.Staging.v2_49_0.BACKLOG_EQPT _BACKLOG_EQPT; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + CreateSelfDescription.Staging.v2_49_0.BACKLOG_EQPT.ClassInitialize(testContext); + _BACKLOG_EQPT = CreateSelfDescription.Staging.v2_49_0.BACKLOG_EQPT.EAFLoggingUnitTesting; + } + + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_49_0__BACKLOG_EQPT__DownloadExcelFile() => _BACKLOG_EQPT.Staging__v2_49_0__BACKLOG_EQPT__DownloadExcelFile(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_49_0__BACKLOG_EQPT__DownloadExcelFile637961178824025822__Normal() + { + string check = ".xlsx"; + bool validatePDSF = false; + MethodBase methodBase = new StackFrame().GetMethod(); + _BACKLOG_EQPT.Staging__v2_49_0__BACKLOG_EQPT__DownloadExcelFile(); + _ = _BACKLOG_EQPT.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); + for (int i = 0; i < int.MinValue; i++) + Thread.Sleep(500); + NonThrowTryCatch(); + } + +} \ No newline at end of file diff --git a/Adaptation/_Tests/Extract/Staging/v2.43.0/BACKLOG.cs b/Adaptation/_Tests/Extract/Staging/v2.49.0/BACKLOG.cs similarity index 64% rename from Adaptation/_Tests/Extract/Staging/v2.43.0/BACKLOG.cs rename to Adaptation/_Tests/Extract/Staging/v2.49.0/BACKLOG.cs index 013f1fa..9263a10 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.43.0/BACKLOG.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.49.0/BACKLOG.cs @@ -8,7 +8,7 @@ using System.IO; using System.Reflection; using System.Text.Json; -namespace Adaptation._Tests.Extract.Staging.v2_43_0; +namespace Adaptation._Tests.Extract.Staging.v2_49_0; [TestClass] public class BACKLOG @@ -17,31 +17,38 @@ public class BACKLOG #pragma warning disable CA2254 #pragma warning disable IDE0060 - private static CreateSelfDescription.Staging.v2_43_0.BACKLOG _BACKLOG; + private static CreateSelfDescription.Staging.v2_49_0.BACKLOG _BACKLOG; [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - CreateSelfDescription.Staging.v2_43_0.BACKLOG.ClassInitialize(testContext); - _BACKLOG = CreateSelfDescription.Staging.v2_43_0.BACKLOG.EAFLoggingUnitTesting; + CreateSelfDescription.Staging.v2_49_0.BACKLOG.ClassInitialize(testContext); + _BACKLOG = CreateSelfDescription.Staging.v2_49_0.BACKLOG.EAFLoggingUnitTesting; } -#if true - [Ignore] -#endif - [TestMethod] - public void Staging__v2_43_0__BACKLOG__json() => _BACKLOG.Staging__v2_43_0__BACKLOG__json(); - -#if true - [Ignore] -#endif - [TestMethod] - public void Staging__v2_43_0__BACKLOG__json637961251829737445__Normal() + private static void NonThrowTryCatch() { - string check = "*.json"; + try + { throw new Exception(); } + catch (Exception) { } + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_49_0__BACKLOG__ConvertExcelToJson() => _BACKLOG.Staging__v2_49_0__BACKLOG__ConvertExcelToJson(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_49_0__BACKLOG__ConvertExcelToJson637961178824025822__Normal() + { + string check = "*.xlsx"; bool validatePDSF = false; - _BACKLOG.Staging__v2_43_0__BACKLOG__json(); MethodBase methodBase = new StackFrame().GetMethod(); + _BACKLOG.Staging__v2_49_0__BACKLOG__ConvertExcelToJson(); Assert.IsFalse(string.IsNullOrEmpty(_BACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); string[] variables = _BACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); IFileRead fileRead = _BACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); @@ -49,6 +56,7 @@ public class BACKLOG Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); Assert.IsNotNull(extractResult.Item3); Assert.IsNotNull(extractResult.Item4); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/Adaptation/_Tests/Extract/Staging/v2.49.0/MESAFIBACKLOG.cs b/Adaptation/_Tests/Extract/Staging/v2.49.0/MESAFIBACKLOG.cs new file mode 100644 index 0000000..c7e026f --- /dev/null +++ b/Adaptation/_Tests/Extract/Staging/v2.49.0/MESAFIBACKLOG.cs @@ -0,0 +1,62 @@ +using Adaptation.Shared; +using Adaptation.Shared.Methods; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Text.Json; + +namespace Adaptation._Tests.Extract.Staging.v2_49_0; + +[TestClass] +public class MESAFIBACKLOG +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + private static CreateSelfDescription.Staging.v2_49_0.MESAFIBACKLOG _MESAFIBACKLOG; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + CreateSelfDescription.Staging.v2_49_0.MESAFIBACKLOG.ClassInitialize(testContext); + _MESAFIBACKLOG = CreateSelfDescription.Staging.v2_49_0.MESAFIBACKLOG.EAFLoggingUnitTesting; + } + + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_49_0__MESAFIBACKLOG__json() => _MESAFIBACKLOG.Staging__v2_49_0__MESAFIBACKLOG__json(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_49_0__MESAFIBACKLOG__json637961251829737445__Normal() + { + string check = "*.json"; + bool validatePDSF = false; + _MESAFIBACKLOG.Staging__v2_49_0__MESAFIBACKLOG__json(); + MethodBase methodBase = new StackFrame().GetMethod(); + Assert.IsFalse(string.IsNullOrEmpty(_MESAFIBACKLOG.AdaptationTesting.TestContext.FullyQualifiedTestClassName)); + string[] variables = _MESAFIBACKLOG.AdaptationTesting.GetVariables(methodBase, check, validatePDSF); + IFileRead fileRead = _MESAFIBACKLOG.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); + Tuple> extractResult = fileRead.ReExtract(); + Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); + Assert.IsNotNull(extractResult.Item3); + Assert.IsNotNull(extractResult.Item4); + NonThrowTryCatch(); + } + +} \ No newline at end of file diff --git a/Adaptation/_Tests/Shared/AdaptationTesting.cs b/Adaptation/_Tests/Shared/AdaptationTesting.cs index d4028ef..e55beee 100644 --- a/Adaptation/_Tests/Shared/AdaptationTesting.cs +++ b/Adaptation/_Tests/Shared/AdaptationTesting.cs @@ -621,14 +621,10 @@ public class AdaptationTesting : ISMTP result = JsonSerializer.Deserialize(json, jsonSerializerOptions); if (string.IsNullOrEmpty(result.SourceFileFilter)) result.SourceFileFilter = string.Empty; - if (result.ErrorTargetFileLocation is null) - result.ErrorTargetFileLocation = string.Empty; - if (result.SourceFileLocation is null) - result.SourceFileLocation = string.Empty; - if (result.TargetFileLocation is null) - result.TargetFileLocation = string.Empty; - if (result.FolderAgeCheckIndividualSubFolders is null) - result.FolderAgeCheckIndividualSubFolders = false; + result.ErrorTargetFileLocation ??= string.Empty; + result.SourceFileLocation ??= string.Empty; + result.TargetFileLocation ??= string.Empty; + result.FolderAgeCheckIndividualSubFolders ??= false; result.ConnectionSettings = new List(); result.SourceFileFilters = result.SourceFileFilter.Split('|').ToList(); if (componentsCellComponentCellComponent.Equipment?.ConnectionSettings is not null) @@ -988,7 +984,7 @@ public class AdaptationTesting : ISMTP _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder); } } - result = FileHandlers.CellInstanceConnectionName.Get(this, fileParameter, mbn.CellInstanceName, mbn.CellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryVersionTuple.Item2, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: false); + 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); return result; } diff --git a/Adaptation/_Tests/Shared/LoggingUnitTesting.cs b/Adaptation/_Tests/Shared/LoggingUnitTesting.cs index f5c6a40..9628850 100644 --- a/Adaptation/_Tests/Shared/LoggingUnitTesting.cs +++ b/Adaptation/_Tests/Shared/LoggingUnitTesting.cs @@ -26,7 +26,7 @@ public class LoggingUnitTesting : UnitTesting, IDisposable base(testContext, declaringType) { _LoggerFactory = new LoggerFactory(); - if (testContext is null || declaringType is null) + if (testContext is null || declaringType is null || _IsEnvironment is null) { _ConfigurationRoot = null; _DefaultLogLevel = null; diff --git a/Adaptation/_Tests/Shared/UnitTesting.cs b/Adaptation/_Tests/Shared/UnitTesting.cs index 28df790..f48a51b 100644 --- a/Adaptation/_Tests/Shared/UnitTesting.cs +++ b/Adaptation/_Tests/Shared/UnitTesting.cs @@ -29,41 +29,46 @@ public class UnitTesting { string waitFor = "\"WaitFor\":"; string projectDirectory = GetProjectDirectory(testContext); - _TestContextPropertiesAsJson = JsonSerializer.Serialize(testContext.Properties, new JsonSerializerOptions { WriteIndented = true }); - _HasWaitForProperty = _TestContextPropertiesAsJson.Contains(waitFor); - string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode"); - if (!Directory.Exists(vsCodeDirectory)) - _ = Directory.CreateDirectory(vsCodeDirectory); - string launchText = GetLaunchText(); - File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText); - if (_HasWaitForProperty) + if (string.IsNullOrEmpty(projectDirectory)) + _IsEnvironment = null; + else { - for (int i = 0; i < int.MaxValue; i++) + _TestContextPropertiesAsJson = JsonSerializer.Serialize(testContext.Properties, new JsonSerializerOptions { WriteIndented = true }); + _HasWaitForProperty = _TestContextPropertiesAsJson.Contains(waitFor); + string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode"); + if (!Directory.Exists(vsCodeDirectory)) + _ = Directory.CreateDirectory(vsCodeDirectory); + string launchText = GetLaunchText(); + File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText); + if (_HasWaitForProperty) { - if (!_TestContextPropertiesAsJson.Contains($"{waitFor} \"Debugger.IsAttached\"") || Debugger.IsAttached) - break; - Thread.Sleep(500); + for (int i = 0; i < int.MaxValue; i++) + { + if (!_TestContextPropertiesAsJson.Contains($"{waitFor} \"Debugger.IsAttached\"") || Debugger.IsAttached) + break; + Thread.Sleep(500); + } } - } - MethodBase methodBase = declaringType.GetMethod(testContext.TestName); - if (methodBase is not null) - { - TestCategoryAttribute testCategoryAttribute = methodBase.GetCustomAttribute(); - if (testCategoryAttribute is not null) + MethodBase methodBase = declaringType.GetMethod(testContext.TestName); + if (methodBase is not null) { - foreach (string testCategory in testCategoryAttribute.TestCategories) - _IsEnvironment = new IsEnvironment(testCategory); + TestCategoryAttribute testCategoryAttribute = methodBase.GetCustomAttribute(); + if (testCategoryAttribute is not null) + { + foreach (string testCategory in testCategoryAttribute.TestCategories) + _IsEnvironment = new IsEnvironment(testCategory); + } } + _IsEnvironment ??= new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached); } - if (_IsEnvironment is null) - _IsEnvironment = new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached); + _IsEnvironment ??= new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached); } } internal static string GetProjectDirectory(TestContext testContext) { string result; - string[] checkFiles = null; + string[] checkFiles; result = Path.GetDirectoryName(testContext.DeploymentDirectory); for (int i = 0; i < int.MaxValue; i++) { @@ -74,8 +79,6 @@ public class UnitTesting break; result = Path.GetDirectoryName(result); } - if (string.IsNullOrEmpty(result) || checkFiles is null || !checkFiles.Any()) - throw new Exception(result); return result; } diff --git a/Adaptation/_Tests/Static/BACKLOG.cs b/Adaptation/_Tests/Static/BACKLOG.cs index 35fa84e..bcca2cd 100644 --- a/Adaptation/_Tests/Static/BACKLOG.cs +++ b/Adaptation/_Tests/Static/BACKLOG.cs @@ -34,10 +34,17 @@ public class BACKLOG : LoggingUnitTesting, IDisposable [ClassCleanup()] public static void ClassCleanup() { - LoggingUnitTesting.Logger?.LogInformation("Cleanup"); + LoggingUnitTesting?.Logger?.LogInformation("Cleanup"); LoggingUnitTesting?.Dispose(); } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + [TestMethod] public void TestDateTime() { @@ -45,7 +52,7 @@ public class BACKLOG : LoggingUnitTesting, IDisposable Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString()); } -#if true +#if DEBUG [Ignore] #endif [TestMethod] @@ -55,8 +62,8 @@ public class BACKLOG : LoggingUnitTesting, IDisposable StringBuilder results = new(); (string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[] { - new("BACKLOG", "v2.43.0"), - new("BACKLOG-EQPT", "v2.43.0"), + new("BACKLOG", "v2.49.0"), + new("BACKLOG-EQPT", "v2.49.0"), }; string staging = "http://mestsa07ec.ec.local:9003/CellInstanceServiceV2"; Shared.PasteSpecialXml.EAF.XML.API.CellInstance.CellInstanceVersion cellInstanceVersion; @@ -68,6 +75,7 @@ public class BACKLOG : LoggingUnitTesting, IDisposable } File.WriteAllText($"D:/Tmp/{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv", results.ToString()); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/FileHandlers/FileRead.cs b/FileHandlers/FileRead.cs index 4a205c1..bb032ce 100644 --- a/FileHandlers/FileRead.cs +++ b/FileHandlers/FileRead.cs @@ -197,7 +197,7 @@ public partial class FileRead : FileReaderHandler, ISMTP FileConnectorConfiguration fileConnectorConfiguration = Mapper.Map(Configuration); string parameterizedModelObjectDefinitionType = methodBase.DeclaringType.FullName; IList modelObjectParameters = Mapper.Map(ConfiguredParameters); - _FileRead = CellInstanceConnectionName.Get(this, FileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, _DummyRuns, _StaticRuns, _UseCyclicalForDescription, isEAFHosted: true); + _FileRead = CellInstanceConnectionName.Get(this, FileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, _DummyRuns, _StaticRuns, _UseCyclicalForDescription, connectionCount: null); if (_FileRead.IsEvent) AddParameterRangeAndEvent(); } @@ -338,7 +338,7 @@ public partial class FileRead : FileReaderHandler, ISMTP if (modelObjectParameterDefinitionJsonElement.ValueKind != JsonValueKind.Array) throw new Exception(); IList modelObjectParameters = JsonSerializer.Deserialize>(modelObjectParameterDefinitionJsonElement.ToString(), jsonSerializerOptions); - _FileRead = CellInstanceConnectionName.Get(this, FileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, _DummyRuns, _StaticRuns, _UseCyclicalForDescription, isEAFHosted: false); + _FileRead = CellInstanceConnectionName.Get(this, FileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, _DummyRuns, _StaticRuns, _UseCyclicalForDescription, connectionCount: null); results = _FileRead.ReExtract(); if (results?.Item2 is null) throw new Exception(); diff --git a/MESAFIBACKLOG.csproj b/MESAFIBACKLOG.csproj index 11b0fab..17cc632 100644 --- a/MESAFIBACKLOG.csproj +++ b/MESAFIBACKLOG.csproj @@ -11,7 +11,8 @@ MESAFIBACKLOG MESAFIBACKLOG v4.8 - win-x86 + win-x86 + win 512 @@ -102,11 +103,11 @@ + - @@ -116,13 +117,10 @@ - - - - - - - + + + + @@ -176,7 +174,10 @@ - 2.47.0 + 2.49.0 + + + 16.205.1 6.0.3 diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 6a17abd..ea6447d 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.47.0.0")] -[assembly: AssemblyFileVersion("2.47.0.0")] +[assembly: AssemblyVersion("2.49.0.0")] +[assembly: AssemblyFileVersion("2.49.0.0")]