From 3675677d7803536dfb1e3f567c9840f9af361848 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Wed, 15 Mar 2023 16:31:04 -0700 Subject: [PATCH] Fixed Archive and Added OpenInsight --- .gitignore | 13 +- .groovy | 172 -------- Adaptation/.config/dotnet-tools.json | 12 + Adaptation/.editorconfig | 7 +- Adaptation/.vscode/launch.json | 2 +- Adaptation/.vscode/settings.json | 4 +- Adaptation/FileHandlers/APC/FileRead.cs | 8 +- Adaptation/FileHandlers/Archive/FileRead.cs | 21 +- Adaptation/FileHandlers/IQSSi/FileRead.cs | 8 +- .../MoveMatchingFiles/FileRead.cs | 4 + .../FileHandlers/OpenInsight/FileRead.cs | 69 +++- .../FileHandlers/OpenInsight/FromIQS.cs | 221 +++++++++++ Adaptation/FileHandlers/SPaCe/FileRead.cs | 8 +- .../Infineon/Monitoring/MonA/ExtWebClient.cs | 20 + Adaptation/Infineon/Monitoring/MonA/IMonIn.cs | 167 ++++++++ Adaptation/Infineon/Monitoring/MonA/MonIn.cs | 292 ++++++++++++++ Adaptation/Infineon/Monitoring/MonA/State.cs | 11 + .../MET08ANLYSDIFAAST230-Development.yml | 155 ++++++++ Adaptation/MET08ANLYSDIFAAST230.Tests.csproj | 82 ++-- Adaptation/MET08ANLYSDIFAAST230.yml | 153 ++++++++ Adaptation/Shared/Duplicator/Description.cs | 10 +- Adaptation/Shared/FileRead.cs | 53 ++- Adaptation/Shared/Logistics.cs | 183 +++++---- Adaptation/Shared/Metrology/ScopeInfo.cs | 2 +- Adaptation/Shared/Metrology/WS.cs | 6 +- .../Shared/ProcessDataStandardFormat.cs | 9 +- Adaptation/Shared/Properties/IDescription.cs | 9 + Adaptation/Shared/Properties/IFileRead.cs | 1 + Adaptation/Shared/Properties/ILogistics.cs | 21 +- .../Staging/v2.43.0/MET08ANLYSDIFAAST230.cs | 44 ++- .../Staging/v2.47.5/MET08ANLYSDIFAAST230.cs | 180 +++++++++ .../Staging/v2.43.0/MET08ANLYSDIFAAST230.cs | 36 ++ .../Staging/v2.47.5/MET08ANLYSDIFAAST230.cs | 116 ++++++ Adaptation/_Tests/Shared/AdaptationTesting.cs | 368 +++++++++--------- .../_Tests/Shared/EAFLoggingUnitTesting.cs | 4 +- .../_Tests/Shared/LoggingUnitTesting.cs | 2 +- Adaptation/_Tests/Shared/MethodBaseName.cs | 45 +++ Adaptation/_Tests/Shared/UnitTesting.cs | 57 +-- .../_Tests/Static/MET08ANLYSDIFAAST230.cs | 72 ++++ Adaptation/_Tests/Static/SECS.cs | 72 ++++ Adaptation/appsettings.Development.json | 12 +- Adaptation/appsettings.json | 12 +- Adaptation/package.json | 22 +- Jenkinsfile | 172 -------- MET08ANLYSDIFAAST230.csproj | 12 +- Properties/AssemblyInfo.cs | 4 +- 46 files changed, 2154 insertions(+), 799 deletions(-) delete mode 100644 .groovy create mode 100644 Adaptation/.config/dotnet-tools.json create mode 100644 Adaptation/FileHandlers/OpenInsight/FromIQS.cs create mode 100644 Adaptation/Infineon/Monitoring/MonA/ExtWebClient.cs create mode 100644 Adaptation/Infineon/Monitoring/MonA/IMonIn.cs create mode 100644 Adaptation/Infineon/Monitoring/MonA/MonIn.cs create mode 100644 Adaptation/Infineon/Monitoring/MonA/State.cs create mode 100644 Adaptation/MET08ANLYSDIFAAST230-Development.yml create mode 100644 Adaptation/MET08ANLYSDIFAAST230.yml create mode 100644 Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.5/MET08ANLYSDIFAAST230.cs create mode 100644 Adaptation/_Tests/Extract/Staging/v2.47.5/MET08ANLYSDIFAAST230.cs create mode 100644 Adaptation/_Tests/Shared/MethodBaseName.cs create mode 100644 Adaptation/_Tests/Static/MET08ANLYSDIFAAST230.cs create mode 100644 Adaptation/_Tests/Static/SECS.cs delete mode 100644 Jenkinsfile diff --git a/.gitignore b/.gitignore index 6ba6148..c19d760 100644 --- a/.gitignore +++ b/.gitignore @@ -331,8 +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/.groovy b/.groovy deleted file mode 100644 index 8aaf66f..0000000 --- a/.groovy +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env groovy -/* groovylint-disable CompileStatic, ConsecutiveStringConcatenation, DuplicateNumberLiteral, DuplicateStringLiteral, LineLength, NestedBlockDepth, NoDef, VariableTypeRequired */ -import groovy.transform.Field - -@Field String _DDrive = 'D:/' -@Field String _AssemblyName = '...' -@Field String _TargetLocation = '...' -@Field String _GitCommitSeven = '...' -@Field String _GitName = 'MET08ANLYSDIFAAST230' -@Field String _TestProjectDirectory = 'Adaptation' -@Field String _AgentStaging = 'mestsa07ec-ecmeseaf' -@Field String _DDriveNet = "${_DDrive}Framework4.8" -@Field String _AgentProduction = 'messa08ec-ecmeseaf' -@Field String _AgentDevelopment = 'mestsa003-mesedasvc' -@Field String _ProgramFilesDotnet = 'C:/Program Files/dotnet/dotnet.exe' -@Field String _ProgramFilesMSBuild = 'C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe' - -pipeline { - agent { - label env.JENKINS_ENVIRONMENT == 'Development' ? _AgentDevelopment : env.JENKINS_ENVIRONMENT == 'Staging' ? _AgentStaging : env.JENKINS_ENVIRONMENT == 'Production' ? _AgentProduction : 'Else' - } - parameters { - string(name: 'GIT_SERVER', defaultValue: env.JENKINS_ENVIRONMENT == 'Development' ? 'mestsa003.infineon.com' : 'mestsa07ec.ec.local', description: 'git server') - string(name: 'DEFAULT_FILE_SERVER', defaultValue: env.JENKINS_ENVIRONMENT == 'Development' ? 'messv02ecc1_ec_local' : 'messv02ecc1.ec.local', description: 'Default file server...') - } - stages { - stage('Git') { - steps { - bat(returnStatus: true, script: 'git init') - bat(returnStatus: true, script: 'git remote add origin \\\\' + params.GIT_SERVER + '\\Git\\' + _GitName + '.git') - bat(returnStatus: true, script: 'git pull origin master') - } - } - stage('Setup') { - steps { - script { - _AssemblyName = "${env.JOB_NAME}" - _GitCommitSeven = '1234567' - // _GitCommitSeven = env.GIT_COMMIT.substring(0, 7) - def files = findFiles(glob: '*.csproj') - if (files.length != 1) { - error("Build failed because couldn't find a *.csproj file") - } - echo """ - ${files[0].name} - ${files[0].path} - ${files[0].directory} - ${files[0].length} - ${files[0].lastModified} - """ - _AssemblyName = files[0].name.split('[.]csproj')[0] - _TargetLocation = "\\\\${params.DEFAULT_FILE_SERVER}\\EC_EAFRepository\\${env.JENKINS_ENVIRONMENT}\\DeploymentStorage\\Adaptation_${_AssemblyName}" - } - } - } - stage('Info') { - steps { - echo "_AssemblyName ${_AssemblyName}" // ... - echo "BUILD_NUMBER ${env.BUILD_NUMBER}" // 11 - echo "DEFAULT_FILE_SERVER ${params.DEFAULT_FILE_SERVER}" // 11 - echo "GIT_BRANCH ${env.GIT_BRANCH}" // origin/master - echo "GIT_COMMIT ${env.GIT_COMMIT}" // 73b814069f2cf0173a62a8228815a9bc9ba93c41 - echo "GIT_SERVER ${params.GIT_SERVER}" // ... - echo "GIT_URL ${env.GIT_URL}" // D:\ProgramData\Git\....git - echo "JENKINS_ENVIRONMENT ${env.JENKINS_ENVIRONMENT}" // 11 - echo "JENKINS_URL ${env.JENKINS_URL}" // http://localhost:8080/ - echo "JOB_NAME ${env.JOB_NAME}" // ... - echo "WORKSPACE ${env.WORKSPACE}" // D:\.jenkins\_\... - } - } - // stage('Restore') { - // steps { - // bat(returnStatus: true, script: 'dotnet --info') - // } - // } - stage('Safe storage of app secrets') { - steps { - dir(_TestProjectDirectory) { - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'user-secrets init') - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'user-secrets set "BuildNumber" "' + env.BUILD_NUMBER + '"') - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'user-secrets set "GitCommitSeven" "' + _GitCommitSeven + '"') - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'user-secrets set "Server" "' + params.DEFAULT_FILE_SERVER + '"') - } - } - } - stage('Core Build') { - steps { - echo "Build number is ${currentBuild.number}" - dir(_TestProjectDirectory) { - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'build --runtime win-x64 --self-contained --verbosity quiet') - } - } - } - // stage('Test') { - // options { - // timeout(time: 10, unit: 'MINUTES') - // } - // steps { - // dir(_TestProjectDirectory) { - // bat('dotnet --info') - // } - // } - // } - stage('Framework Build') { - steps { - echo "Build number is ${currentBuild.number}" - bat(returnStatus: true, script: '"' + _ProgramFilesMSBuild + '" ' + - '/target:Restore ' + - '/detailedsummary ' + - '/consoleloggerparameters:PerformanceSummary;ErrorsOnly; ' + - '/property:Configuration=Debug;TargetFrameworkVersion=v4.8 ' + - _AssemblyName + '.csproj') - bat(returnStatus: true, script: '"' + _ProgramFilesMSBuild + '" ' + - '/target:Build ' + - '/detailedsummary ' + - '/consoleloggerparameters:PerformanceSummary;ErrorsOnly; ' + - '/property:Configuration=Debug;TargetFrameworkVersion=v4.8 ' + - _AssemblyName + '.csproj') - } - } - stage('Commit Id') { - steps { - dir('bin/Debug') { - writeFile file: "${_AssemblyName}.txt", text: "${env.GIT_COMMIT}-${env.BUILD_NUMBER}-${env.GIT_URL}" - } - } - } - stage('Package') { - steps { - fileOperations([fileZipOperation(folderPath: 'bin/Debug', outputFolderPath: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${env.JOB_NAME}-Debug")]) - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*", renameFiles: false, sourceCaptureExpression: '', targetLocation: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${env.JOB_NAME}-Debug", targetNameExpression: '')]) - } - } - // stage('Force Fail') { - // steps { - // error("Build failed because of this and that..") - // } - // } - stage('Copy Files to: file-share') { - steps { - dir('bin/Debug') { - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*.txt", renameFiles: false, sourceCaptureExpression: '', targetLocation: _TargetLocation, targetNameExpression: '')]) - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*.dll", renameFiles: false, sourceCaptureExpression: '', targetLocation: _TargetLocation, targetNameExpression: '')]) - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*.exe", renameFiles: false, sourceCaptureExpression: '', targetLocation: _TargetLocation, targetNameExpression: '')]) - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*.pdb", renameFiles: false, sourceCaptureExpression: '', targetLocation: _TargetLocation, targetNameExpression: '')]) - } - } - } - } - post { - always { - dir('bin') { - deleteDir() - } - dir('obj') { - deleteDir() - } - dir(_TestProjectDirectory + '/bin') { - deleteDir() - } - dir(_TestProjectDirectory + '/obj') { - deleteDir() - } - // cleanWs() - } - } -} 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 2220133..b45701e 100644 --- a/Adaptation/.editorconfig +++ b/Adaptation/.editorconfig @@ -76,13 +76,18 @@ 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.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) dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case @@ -215,7 +220,7 @@ dotnet_style_parentheses_in_other_binary_operators = always_for_clarity dotnet_style_parentheses_in_other_operators = never_if_unnecessary dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity dotnet_style_predefined_type_for_locals_parameters_members = true -dotnet_style_predefined_type_for_member_access = true +dotnet_style_predefined_type_for_member_access = true:warning dotnet_style_prefer_auto_properties = true:warning dotnet_style_prefer_compound_assignment = true:warning dotnet_style_prefer_conditional_expression_over_assignment = false diff --git a/Adaptation/.vscode/launch.json b/Adaptation/.vscode/launch.json index 77578c9..971f2d7 100644 --- a/Adaptation/.vscode/launch.json +++ b/Adaptation/.vscode/launch.json @@ -4,7 +4,7 @@ "name": ".NET Core Attach", "type": "coreclr", "request": "attach", - "processId": 20196 + "processId": 25008 } ] } diff --git a/Adaptation/.vscode/settings.json b/Adaptation/.vscode/settings.json index 3c7d3b3..95e1961 100644 --- a/Adaptation/.vscode/settings.json +++ b/Adaptation/.vscode/settings.json @@ -22,6 +22,7 @@ "Villach", "Vrng" ], + "coverage-gutters.coverageBaseDir": "../../../../MET08ANLYSDIFAAST230/05_TestResults/TestResults/**", "workbench.colorCustomizations": { "activityBar.activeBackground": "#0fc5f0", "activityBar.activeBorder": "#d20dac", @@ -39,7 +40,8 @@ "titleBar.activeBackground": "#0c9ec0", "titleBar.activeForeground": "#e7e7e7", "titleBar.inactiveBackground": "#0c9ec099", - "titleBar.inactiveForeground": "#e7e7e799" + "titleBar.inactiveForeground": "#e7e7e799", + "commandCenter.border": "#e7e7e799" }, "peacock.color": "#0c9ec0" } \ No newline at end of file diff --git a/Adaptation/FileHandlers/APC/FileRead.cs b/Adaptation/FileHandlers/APC/FileRead.cs index 9bff0b2..516a83f 100644 --- a/Adaptation/FileHandlers/APC/FileRead.cs +++ b/Adaptation/FileHandlers/APC/FileRead.cs @@ -103,10 +103,10 @@ public class FileRead : Shared.FileRead, IFileRead return results; } - private void FileCopy(string reportFullPath, DateTime dateTime) + private void FileCopy(string reportFullPath, DateTime dateTime, List descriptions) where T : Shared.Properties.IDescription { bool isDummyRun = false; - List<(Shared.Properties.IScopeInfo, string)> tuples = new(); + List<(Shared.Properties.IScopeInfo, string)> collection = new(); string successDirectory = _FileConnectorConfiguration.AlternateTargetFolder; string fileNameAfterUnderscoreSplit = GetFileNameAfterUnderscoreSplit(reportFullPath); string duplicateDirectory = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, fileNameAfterUnderscoreSplit); @@ -114,7 +114,7 @@ public class FileRead : Shared.FileRead, IFileRead _ = Directory.CreateDirectory(duplicateDirectory); string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath)); File.Copy(reportFullPath, duplicateFile, overwrite: true); - WaitForFileConsumption(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile); + WaitForFileConsumption(dateTime, descriptions, isDummyRun, successDirectory, duplicateDirectory, collection, duplicateFile); } private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) @@ -127,7 +127,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) - FileCopy(reportFullPath, dateTime); + FileCopy(reportFullPath, dateTime, descriptions); results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/Archive/FileRead.cs b/Adaptation/FileHandlers/Archive/FileRead.cs index 6584c7f..f2239db 100644 --- a/Adaptation/FileHandlers/Archive/FileRead.cs +++ b/Adaptation/FileHandlers/Archive/FileRead.cs @@ -115,7 +115,7 @@ public class FileRead : Shared.FileRead, IFileRead } } - private void MoveArchive(DateTime dateTime) + private void MoveArchive(string reportFullPath, DateTime dateTime) { if (dateTime == DateTime.MinValue) { } @@ -128,12 +128,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 +151,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/IQSSi/FileRead.cs b/Adaptation/FileHandlers/IQSSi/FileRead.cs index 6bbe58e..a0563cf 100644 --- a/Adaptation/FileHandlers/IQSSi/FileRead.cs +++ b/Adaptation/FileHandlers/IQSSi/FileRead.cs @@ -103,17 +103,17 @@ public class FileRead : Shared.FileRead, IFileRead return results; } - private void FileCopy(string reportFullPath, DateTime dateTime) + private void FileCopy(string reportFullPath, DateTime dateTime, List descriptions) where T : Shared.Properties.IDescription { bool isDummyRun = false; string successDirectory = string.Empty; - List<(Shared.Properties.IScopeInfo, string)> tuples = new(); + List<(Shared.Properties.IScopeInfo, string)> collection = new(); string duplicateDirectory = Path.Combine(_FileConnectorConfiguration.SourceFileLocation, _CellInstanceName); if (!Directory.Exists(duplicateDirectory)) _ = Directory.CreateDirectory(duplicateDirectory); string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath)); File.Copy(reportFullPath, duplicateFile, overwrite: true); - WaitForFileConsumption(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile); + WaitForFileConsumption(dateTime, descriptions, isDummyRun, successDirectory, duplicateDirectory, collection, duplicateFile); } private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) @@ -128,7 +128,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) - FileCopy(reportFullPath, dateTime); + FileCopy(reportFullPath, dateTime, descriptions); results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs index ad68b87..9e72baa 100644 --- a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs +++ b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs @@ -158,6 +158,7 @@ public class FileRead : Shared.FileRead, IFileRead long preWait; string errFile; string checkDirectory; + string noWaitDirectory; foreach ((string matchingFile, string checkFile) in collection) { errFile = string.Concat(checkFile, ".err"); @@ -165,6 +166,9 @@ public class FileRead : Shared.FileRead, IFileRead if (!Directory.Exists(checkDirectory)) _ = Directory.CreateDirectory(checkDirectory); File.Move(matchingFile, checkFile); + noWaitDirectory = Path.Combine(checkDirectory, "NoWaitDirectory"); + if (Directory.Exists(noWaitDirectory)) + continue; if (_FileConnectorConfiguration?.FileHandleWaitTime is null) preWait = DateTime.Now.AddMilliseconds(1234).Ticks; else diff --git a/Adaptation/FileHandlers/OpenInsight/FileRead.cs b/Adaptation/FileHandlers/OpenInsight/FileRead.cs index 16b9fa6..984d09b 100644 --- a/Adaptation/FileHandlers/OpenInsight/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsight/FileRead.cs @@ -3,10 +3,13 @@ using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration; using Adaptation.Shared; using Adaptation.Shared.Duplicator; using Adaptation.Shared.Methods; +using Adaptation.Shared.Metrology; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; +using System.Text; using System.Text.Json; namespace Adaptation.FileHandlers.OpenInsight; @@ -14,6 +17,11 @@ namespace Adaptation.FileHandlers.OpenInsight; public class FileRead : Shared.FileRead, IFileRead { + private readonly string _IqsConnectionString; + private readonly string _OpenInsightFilePattern; + private readonly string _OpenInsightApiECDirectory; + private readonly string _OpenInsightApiIFXDirectory; + 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) { @@ -26,6 +34,10 @@ public class FileRead : Shared.FileRead, IFileRead throw new Exception(cellInstanceConnectionName); if (!_IsDuplicator) throw new Exception(cellInstanceConnectionName); + _IqsConnectionString = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.ConnectionString"); + _OpenInsightApiECDirectory = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "API.EC.Directory"); + _OpenInsightApiIFXDirectory = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "API.IFX.Directory"); + _OpenInsightFilePattern = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.FilePattern"); } void IFileRead.Move(Tuple> extractResults, Exception exception) @@ -103,16 +115,53 @@ public class FileRead : Shared.FileRead, IFileRead return results; } - private static void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, List descriptions, Test[] tests) + internal static string GetLines(Logistics logistics, List descriptions) { - if (reportFullPath is null) - { } - if (dateTime == DateTime.MinValue) - { } - if (descriptions is null) - { } - if (tests is null) - { } + StringBuilder results = new(); + Shared.Properties.IDescription x = descriptions[0]; + char del = x.MesEntity == x.Reactor ? '\t' : '~'; + _ = results.Append(logistics.MesEntity).Append(del) + .Append(x.MesEntity).Append(del); + return results.ToString(); + } + + private void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, string logistics, List descriptions, Test[] tests) + { + bool isDummyRun = false; + List<(Shared.Properties.IScopeInfo, string)> collection = new(); + string successDirectory = _FileConnectorConfiguration.AlternateTargetFolder; + string parentParent = GetParentParent(_FileConnectorConfiguration.SourceFileLocation); + if (parentParent.Contains(_CellInstanceName)) + parentParent = Path.GetDirectoryName(parentParent); + string duplicateDirectory = Path.Combine(parentParent, "Data"); + if (!Directory.Exists(duplicateDirectory)) + _ = Directory.CreateDirectory(duplicateDirectory); + string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath)); + if (descriptions.Any() && tests.Any()) + { + string lines = GetLines(_Logistics, descriptions); + if (!string.IsNullOrEmpty(lines)) + { + int? count; + long? subGroupId; + long breakAfter = dateTime.AddSeconds(_BreakAfterSeconds).Ticks; + long preWait = _FileConnectorConfiguration?.FileHandleWaitTime is null ? dateTime.AddMilliseconds(1234).Ticks : dateTime.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks; + if (string.IsNullOrEmpty(descriptions[0].Reactor) || string.IsNullOrEmpty(descriptions[0].PSN)) + (subGroupId, count) = (null, null); + else + (subGroupId, count, string _) = FromIQS.GetCommandText(_IqsConnectionString, _Logistics, descriptions[0], breakAfter, preWait); + if (subGroupId is null) + collection.Add(new(new ScopeInfo(tests[0], _OpenInsightFilePattern), lines)); + else if (count is null) + collection.Add(new(new ScopeInfo(tests[0], $"{subGroupId.Value} {_OpenInsightFilePattern}"), lines)); + else + collection.Add(new(new ScopeInfo(tests[0], $"{subGroupId.Value} E{count.Value} {_OpenInsightFilePattern}"), lines)); + string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); + FromIQS.Save(_OpenInsightApiECDirectory, _OpenInsightApiIFXDirectory, _Logistics, reportFullPath, logistics, descriptions.First(), lines, subGroupId, weekOfYear); + } + } + if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) + WaitForFileConsumption(dateTime, descriptions, isDummyRun, successDirectory, duplicateDirectory, collection, duplicateFile); } private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) @@ -125,7 +174,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) - SaveOpenInsightFile(reportFullPath, dateTime, descriptions, tests); + SaveOpenInsightFile(reportFullPath, dateTime, pdsf.Item1, descriptions, tests); results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/OpenInsight/FromIQS.cs b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs new file mode 100644 index 0000000..754680a --- /dev/null +++ b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs @@ -0,0 +1,221 @@ +using Adaptation.Shared; +using System; +using System.Data; +using System.Data.SqlClient; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Threading; + +namespace Adaptation.FileHandlers.OpenInsight; + +public class FromIQS +{ + +#nullable enable + + private static string GetCommandText(Logistics logistics, Shared.Properties.IDescription description, string dateTime, long? subGroupId) + { + StringBuilder result = new(); + _ = result + .AppendLine(" select ") + .AppendLine(" se.f_sgrp se_sgrp, ") + .AppendLine(" se.f_sgtm se_sgtm, ") + .AppendLine(" se.f_tsno se_tsno, ") + .AppendLine(" se.f_val se_val, ") + .AppendLine(" rd.f_name rd_name, ") + .AppendLine(" jd.f_name jd_name, ") + .AppendLine(" pl.f_name pl_name, ") + .AppendLine(" pd.f_name pd_name, ") + .AppendLine(" td.f_test td_test, ") + .AppendLine(" td.f_name td_name, ") + .AppendLine(" (select count(ev.f_evnt) ") + .AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ") + .AppendLine(" where ev.f_prcs = rd.f_prcs ") + .AppendLine(" and ev.f_part = pd.f_part ") + .AppendLine(" and ev.f_sgtm = se.f_sgtm) ev_count ") + .AppendLine(" from [spcepiworld].[dbo].[sgrp_ext] se ") + .AppendLine(" join [spcepiworld].[dbo].[prcs_dat] rd ") + .AppendLine(" on se.f_prcs = rd.f_prcs ") + .AppendLine(" join [spcepiworld].[dbo].[job_dat] jd ") + .AppendLine(" on se.f_job = jd.f_job ") + .AppendLine(" join [spcepiworld].[dbo].[part_lot] pl ") + .AppendLine(" on se.f_lot = pl.f_lot ") + .AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ") + .AppendLine(" on se.f_part = pd.f_part ") + .AppendLine(" join [spcepiworld].[dbo].[test_dat] td ") + .AppendLine(" on se.f_test = td.f_test ") + .AppendLine(" where se.f_flag = 0 "); + if (subGroupId is not null) + _ = result.Append(" and se.f_sgrp = ").Append(subGroupId).AppendLine(" "); + if (!string.IsNullOrEmpty(description.RDS)) + _ = result.Append(" and pl.f_name = '").Append(description.RDS).AppendLine("' "); + _ = result + .Append(" and rd.f_name = '").Append(description.Reactor).AppendLine("' ") + .Append(" and pd.f_name = '").Append(description.PSN).AppendLine("' ") + .AppendLine(" and jd.f_name in ('TENCOR1', 'TENCOR2', 'TENCOR3') ") + .Append(" and jd.f_name = '").Append(logistics.MesEntity).AppendLine("' ") + .Append(" and dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgtm), '19700101'))) = '").Append(dateTime).AppendLine("' ") + .AppendLine(" for json path "); + return result.ToString(); + } + + private static StringBuilder GetForJsonPath(string connectionString, string commandText) + { + StringBuilder stringBuilder = new(); + using SqlConnection sqlConnection = new(connectionString); + sqlConnection.Open(); + using SqlCommand sqlCommand = new(commandText, sqlConnection); + SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess); + while (sqlDataReader.Read()) + _ = stringBuilder.Append(sqlDataReader.GetString(0)); + return stringBuilder; + } + + internal static (long?, int?, string) GetCommandText(string connectionString, Logistics logistics, Shared.Properties.IDescription description, long breakAfter, long preWait) + { + string dateTime; + int? count = null; + string commandText; + long? result = null; + string dateFormat = Shared.Duplicator.Description.GetDateFormat(); + if (DateTime.TryParseExact(description.Date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTimeParsed)) + dateTime = dateTimeParsed.ToString("yyyy-MM-dd HH:mm:ss"); + else if (DateTime.TryParse(description.Date, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeParsed)) + dateTime = dateTimeParsed.ToString("yyyy-MM-dd HH:mm:ss"); + else + dateTime = logistics.DateTimeFromSequence.ToString("yyyy-MM-dd HH:mm:ss"); + commandText = GetCommandText(logistics, description, dateTime, subGroupId: null); + for (short i = 0; i < short.MaxValue; i++) + { + if (DateTime.Now.Ticks > preWait) + break; + Thread.Sleep(100); + } + StringBuilder stringBuilder = new(); + for (short z = 0; z < short.MaxValue; z++) + { + stringBuilder = GetForJsonPath(connectionString, commandText); + if (stringBuilder.Length > 0) + break; + if (DateTime.Now.Ticks > breakAfter) + // throw new Exception($"After {breakAfterSeconds} seconds, didn't find sub group id!"); + break; + Thread.Sleep(250); + } + if (stringBuilder.Length == 0) + commandText = stringBuilder.ToString(); + else + { + JsonElement[]? jsonElements = JsonSerializer.Deserialize(stringBuilder.ToString()); + if (jsonElements is null || !jsonElements.Any() || jsonElements[0].ValueKind != JsonValueKind.Object) + commandText = stringBuilder.ToString(); + else + { + JsonProperty[] jsonProperties = jsonElements[0].EnumerateObject().ToArray(); + if (!jsonProperties.Any() || jsonProperties[0].Name != "se_sgrp" || !long.TryParse(jsonProperties[0].Value.ToString(), out long subGroupId)) + commandText = stringBuilder.ToString(); + else + { + result = subGroupId; + commandText = GetCommandText(logistics, description, dateTime, subGroupId); + if (jsonProperties.Any() && jsonProperties[10].Name == "ev_count" && int.TryParse(jsonProperties[10].Value.ToString(), out int evCount)) + count = evCount; + } + } + } + return new(result, count, commandText); + } + + private static string GetJson(Logistics logistics, string logisticLines, Shared.Properties.IDescription description) + { + string result; + StringBuilder stringBuilder = new(); + var @object = new + { + description.MesEntity, + description.Employee, + // description.Layer, + description.PSN, + description.RDS, + description.Reactor, + description.Recipe, + // description.Zone, + logistics.DateTimeFromSequence.Ticks + }; + string[] pair; + string safeValue; + string[] segments; + string serializerValue; + foreach (string line in logisticLines.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) + { + segments = line.Split('\t'); + if (segments.Length < 2) + continue; + segments = segments[1].Split(';'); + _ = stringBuilder.Append('{'); + foreach (string segment in segments) + { + pair = segment.Split('='); + if (pair.Length != 2 || pair[0].Length < 3) + continue; + serializerValue = JsonSerializer.Serialize(pair[1]); + safeValue = serializerValue.Substring(1, serializerValue.Length - 2); + _ = stringBuilder.Append('"').Append(pair[0].Substring(2)).Append('"').Append(':').Append('"').Append(safeValue).Append('"').Append(','); + } + if (stringBuilder.Length > 0) + _ = stringBuilder.Remove(stringBuilder.Length - 1, 1); + _ = stringBuilder.Append('}').Append(','); + } + if (stringBuilder.Length > 0) + _ = stringBuilder.Remove(stringBuilder.Length - 1, 1); + _ = stringBuilder.Append(']').Append('}'); + _ = stringBuilder.Insert(0, ",\"Logistics\":["); + string json = JsonSerializer.Serialize(@object); + _ = stringBuilder.Insert(0, json.Substring(0, json.Length - 1)); + JsonElement? jsonElement = JsonSerializer.Deserialize(stringBuilder.ToString()); + result = jsonElement is null ? "{}" : JsonSerializer.Serialize(jsonElement, new JsonSerializerOptions { WriteIndented = true }); + return result; + } + + internal static void Save(string openInsightApiECDirectory, string openInsightApiIFXDirectory, Logistics logistics, string reportFullPath, string logisticLines, Shared.Properties.IDescription description, string lines, long? subGroupId, string weekOfYear) + { + string checkFile; + string fileName = Path.GetFileName(reportFullPath); + string json = GetJson(logistics, logisticLines, description); + string? ecPathRoot = Path.GetPathRoot(openInsightApiECDirectory); + string? ifxPathRoot = Path.GetPathRoot(openInsightApiIFXDirectory); + bool ecExists = ecPathRoot is not null && Directory.Exists(ecPathRoot); + bool ifxExists = ifxPathRoot is not null && Directory.Exists(ifxPathRoot); + string weekYear = $"{logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}"; + string ecDirectory = Path.Combine(openInsightApiECDirectory, weekYear, $"-{description.PSN}", $"-{description.Reactor}", $"-{description.RDS}", $"-{subGroupId}"); + string ifxDirectory = Path.Combine(openInsightApiIFXDirectory, weekYear, $"-{description.PSN}", $"-{description.Reactor}", $"-{description.RDS}", $"-{subGroupId}"); + if (ecExists && !Directory.Exists(ecDirectory)) + _ = Directory.CreateDirectory(ecDirectory); + if (ifxExists && !Directory.Exists(ifxDirectory)) + _ = Directory.CreateDirectory(ifxDirectory); + checkFile = Path.Combine(ecDirectory, fileName); + if (ecExists && !File.Exists(checkFile)) + File.Copy(reportFullPath, checkFile); + checkFile = Path.Combine(ifxDirectory, fileName); + if (ifxExists && !File.Exists(checkFile)) + File.Copy(reportFullPath, checkFile); + checkFile = Path.Combine(ecDirectory, $"{logistics.DateTimeFromSequence.Ticks}.txt"); + if (ecExists && !File.Exists(checkFile)) + File.WriteAllText(checkFile, lines); + checkFile = Path.Combine(ifxDirectory, $"{logistics.DateTimeFromSequence.Ticks}.txt"); + if (ifxExists && !File.Exists(checkFile)) + File.WriteAllText(checkFile, lines); + checkFile = Path.Combine(ecDirectory, $"{logistics.DateTimeFromSequence.Ticks}.json"); + if (ecExists && !File.Exists(checkFile)) + File.WriteAllText(checkFile, json); + checkFile = Path.Combine(ifxDirectory, $"{logistics.DateTimeFromSequence.Ticks}.json"); + if (ifxExists && !File.Exists(checkFile)) + File.WriteAllText(checkFile, json); + } + +#nullable disable + +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/SPaCe/FileRead.cs b/Adaptation/FileHandlers/SPaCe/FileRead.cs index 15a6c20..a6c47a1 100644 --- a/Adaptation/FileHandlers/SPaCe/FileRead.cs +++ b/Adaptation/FileHandlers/SPaCe/FileRead.cs @@ -103,15 +103,15 @@ public class FileRead : Shared.FileRead, IFileRead return results; } - private void FileCopy(string reportFullPath, DateTime dateTime) + private void FileCopy(string reportFullPath, DateTime dateTime, List descriptions) where T : Shared.Properties.IDescription { bool isDummyRun = false; string successDirectory = string.Empty; - List<(Shared.Properties.IScopeInfo, string)> tuples = new(); + List<(Shared.Properties.IScopeInfo, string)> collection = new(); string duplicateDirectory = _FileConnectorConfiguration.TargetFileLocation; string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath)); File.Copy(reportFullPath, duplicateFile, overwrite: true); - WaitForFileConsumption(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile); + WaitForFileConsumption(dateTime, descriptions, isDummyRun, successDirectory, duplicateDirectory, collection, duplicateFile); } private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) @@ -126,7 +126,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) - FileCopy(reportFullPath, dateTime); + FileCopy(reportFullPath, dateTime, descriptions); results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/Infineon/Monitoring/MonA/ExtWebClient.cs b/Adaptation/Infineon/Monitoring/MonA/ExtWebClient.cs new file mode 100644 index 0000000..7e1ffe0 --- /dev/null +++ b/Adaptation/Infineon/Monitoring/MonA/ExtWebClient.cs @@ -0,0 +1,20 @@ +using System; +using System.Net; + +namespace Infineon.Monitoring.MonA; + +#nullable disable +#pragma warning disable SYSLIB0014 + +public class ExtWebClient : WebClient +{ + protected override WebRequest GetWebRequest(Uri address) + { + WebRequest webRequest = base.GetWebRequest(address); + if (webRequest != null) + webRequest.PreAuthenticate = PreAuthenticate; + return webRequest; + } + + public bool PreAuthenticate { get; set; } +} \ No newline at end of file diff --git a/Adaptation/Infineon/Monitoring/MonA/IMonIn.cs b/Adaptation/Infineon/Monitoring/MonA/IMonIn.cs new file mode 100644 index 0000000..6552d47 --- /dev/null +++ b/Adaptation/Infineon/Monitoring/MonA/IMonIn.cs @@ -0,0 +1,167 @@ +using System; + +namespace Infineon.Monitoring.MonA; + +public interface IMonIn +{ + string SendStatus(string site, string resource, string stateName, State state); + + string SendStatus( + string site, + DateTime timeStamp, + string resource, + string stateName, + State state); + + string SendStatus( + string site, + string resource, + string stateName, + State state, + string description); + + string SendStatus( + string site, + DateTime timeStamp, + string resource, + string stateName, + State state, + string description); + + string SendStatus( + string site, + string resource, + string subresource, + string stateName, + State state); + + string SendStatus( + string site, + DateTime timeStamp, + string resource, + string subresource, + string stateName, + State state); + + string SendStatus( + string site, + string resource, + string subresource, + string stateName, + State state, + string description); + + string SendStatus( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string stateName, + State state, + string description); + + string SendPerformanceMessage( + string site, + string resource, + string performanceName, + double value); + + string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string performanceName, + double value); + + string SendPerformanceMessage( + string site, + string resource, + string performanceName, + double value, + string description); + + string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string performanceName, + double value, + string description); + + string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string performanceName, + double value, + int? interval); + + string SendPerformanceMessage( + string site, + string resource, + DateTime? timeStamp, + string performanceName, + double value, + string unit); + + string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string performanceName, + double value, + string unit, + int? interval); + + string SendPerformanceMessage( + string site, + string resource, + string subresource, + string performanceName, + double value); + + string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string performanceName, + double value); + + string SendPerformanceMessage( + string site, + string resource, + string subresource, + string performanceName, + double value, + string description); + + string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string performanceName, + double value, + int? interval); + + string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string performanceName, + double value, + string unit); + + string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string performanceName, + double value, + string description, + string unit, + int? interval); +} \ No newline at end of file diff --git a/Adaptation/Infineon/Monitoring/MonA/MonIn.cs b/Adaptation/Infineon/Monitoring/MonA/MonIn.cs new file mode 100644 index 0000000..e9ffce8 --- /dev/null +++ b/Adaptation/Infineon/Monitoring/MonA/MonIn.cs @@ -0,0 +1,292 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Net; +using System.Text; + +namespace Infineon.Monitoring.MonA; + +public class MonIn : IMonIn, IDisposable +{ + private static readonly DateTime _Utc1970DateTime = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + public const string MonInUrl = "http://moninhttp.{0}.infineon.com/input/text"; + private static readonly Dictionary _Instances = new(); + private readonly ExtWebClient _WebClient; + private readonly string _MonInUrl; + private static CultureInfo _CultureInfo; + + public static MonIn GetInstance(string url = "http://moninhttp.{0}.infineon.com/input/text") + { + MonIn instance; + if (_Instances.ContainsKey(url)) + { + instance = _Instances[url]; + } + else + { + lock (_Instances) + { + if (!_Instances.ContainsKey(url)) + { + instance = new MonIn(url); + _Instances.Add(url, instance); + } + else + instance = _Instances[url]; + } + } + return instance; + } + + private MonIn(string url) + { + _WebClient = new ExtWebClient(); + _WebClient.Headers[HttpRequestHeader.ContentType] = "application/text"; + _WebClient.Encoding = Encoding.UTF8; + _CultureInfo = new CultureInfo("en-US"); + _MonInUrl = url; + } + + public void SetBasicAuthentication(string username, string password) + { + _WebClient.PreAuthenticate = true; + _WebClient.Headers[HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password)); + } + + public string SendStatus(string site, string resource, string stateName, State state) => SendStatus(site, new DateTime?(), resource, string.Empty, stateName, state, string.Empty); + + public string SendStatus( + string site, + DateTime timeStamp, + string resource, + string stateName, + State state) => SendStatus(site, new DateTime?(timeStamp), resource, string.Empty, stateName, state, string.Empty); + + public string SendStatus( + string site, + string resource, + string stateName, + State state, + string description) => SendStatus(site, new DateTime?(), resource, string.Empty, stateName, state, description); + + public string SendStatus( + string site, + DateTime timeStamp, + string resource, + string stateName, + State state, + string description) => SendStatus(site, new DateTime?(timeStamp), resource, string.Empty, stateName, state, description); + + public string SendStatus( + string site, + string resource, + string subresource, + string stateName, + State state) => SendStatus(site, new DateTime?(), resource, subresource, stateName, state, string.Empty); + + public string SendStatus( + string site, + DateTime timeStamp, + string resource, + string subresource, + string stateName, + State state) => SendStatus(site, new DateTime?(timeStamp), resource, subresource, stateName, state, string.Empty); + + public string SendStatus( + string site, + string resource, + string subresource, + string stateName, + State state, + string description) => SendStatus(site, new DateTime?(), resource, subresource, stateName, state, description); + + public string SendStatus( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string stateName, + State state, + string description) + { + string statusMessage = CreateStatusMessage(site, timeStamp, resource, subresource, stateName, state.ToString(), description); + lock (_WebClient) + return _WebClient.UploadString(string.Format(_MonInUrl, site), statusMessage); + } + + public string SendPerformanceMessage( + string site, + string resource, + string performanceName, + double value) => SendPerformanceMessage(site, new DateTime?(), resource, string.Empty, performanceName, value, string.Empty, string.Empty, new int?()); + + public string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string performanceName, + double value) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, string.Empty, string.Empty, new int?()); + + public string SendPerformanceMessage( + string site, + string resource, + string performanceName, + double value, + string description) => SendPerformanceMessage(site, new DateTime?(), resource, string.Empty, performanceName, value, description, string.Empty, new int?()); + + public string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string performanceName, + double value, + string description) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, description, string.Empty, new int?()); + + public string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string performanceName, + double value, + int? interval) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, string.Empty, string.Empty, interval); + + public string SendPerformanceMessage( + string site, + string resource, + DateTime? timeStamp, + string performanceName, + double value, + string unit) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, string.Empty, unit, new int?()); + + public string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string performanceName, + double value, + string unit, + int? interval) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, string.Empty, unit, interval); + + public string SendPerformanceMessage( + string site, + string resource, + string subresource, + string performanceName, + double value) => SendPerformanceMessage(site, new DateTime?(), resource, subresource, performanceName, value, string.Empty, string.Empty, new int?()); + + public string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string performanceName, + double value) => SendPerformanceMessage(site, timeStamp, resource, subresource, performanceName, value, string.Empty, string.Empty, new int?()); + + public string SendPerformanceMessage( + string site, + string resource, + string subresource, + string performanceName, + double value, + string description) => SendPerformanceMessage(site, new DateTime?(), resource, subresource, performanceName, value, description, string.Empty, new int?()); + + public string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string performanceName, + double value, + int? interval) => SendPerformanceMessage(site, timeStamp, resource, subresource, performanceName, value, string.Empty, string.Empty, interval); + + public string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string performanceName, + double value, + string unit) => SendPerformanceMessage(site, timeStamp, resource, subresource, performanceName, value, string.Empty, unit, new int?()); + + public string SendPerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string performanceName, + double value, + string description, + string unit, + int? interval) + { + string performanceMessage = CreatePerformanceMessage(site, timeStamp, resource, subresource, performanceName, value, description, unit, interval); + lock (_WebClient) + return _WebClient.UploadString(string.Format(_MonInUrl, site), performanceMessage); + } + + private static string CreateStatusMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string stateName, + string state, + string description) + { + StringBuilder stringBuilder = new(); + if (string.IsNullOrEmpty(subresource)) + _ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" {4} \n{5}", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), stateName.Trim(), state.Trim(), description.Trim()); + else + _ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" \"{4}\" {5} \n{6}", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), subresource.Trim(), stateName.Trim(), state.Trim(), description.Trim()); + return stringBuilder.ToString(); + } + + private static string CreatePerformanceMessage( + string site, + DateTime? timeStamp, + string resource, + string subresource, + string performanceName, + double value, + string description, + string unit, + int? interval) + { + StringBuilder stringBuilder = new(); + if (string.IsNullOrEmpty(subresource)) + { + if (unit.Equals(string.Empty) && !interval.HasValue) + _ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" {4} \n{5}", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), performanceName.Trim(), value, description.Trim()); + else + _ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" {4} {5} {{interval={6}, unit={7}}}\n", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), performanceName.Trim(), value, description.Trim(), interval.HasValue ? interval.Value.ToString() : (object)string.Empty, unit.Trim()); + } + else if (unit.Equals(string.Empty) && !interval.HasValue) + _ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" \"{4}\" {5} \n{6}", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), subresource.Trim(), performanceName.Trim(), value, description.Trim()); + else + _ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" \"{4}\" {5} {6} {{interval={7}, unit={8}}}\n", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), subresource.Trim(), performanceName.Trim(), value, description.Trim(), interval.HasValue ? interval.Value.ToString() : (object)string.Empty, unit.Trim()); + return stringBuilder.ToString(); + } + + private static string GetDateTimeNowAsPosix(DateTime timeStamp) + { + if (timeStamp > DateTime.Now) + timeStamp = DateTime.Now; + return ((int)timeStamp.ToUniversalTime().Subtract(_Utc1970DateTime).TotalSeconds).ToString(CultureInfo.InvariantCulture); + } + + public void Dispose() + { + KeyValuePair keyValuePair = new(); + foreach (KeyValuePair instance in _Instances) + { + if (instance.Value == this) + { + keyValuePair = instance; + break; + } + } + _ = _Instances.Remove(keyValuePair.Key); + _WebClient?.Dispose(); + } + +} \ No newline at end of file diff --git a/Adaptation/Infineon/Monitoring/MonA/State.cs b/Adaptation/Infineon/Monitoring/MonA/State.cs new file mode 100644 index 0000000..d6bface --- /dev/null +++ b/Adaptation/Infineon/Monitoring/MonA/State.cs @@ -0,0 +1,11 @@ +namespace Infineon.Monitoring.MonA; + +public enum State +{ + Up, + Ok, + Warning, + Critical, + Down, + Unknown, +} \ No newline at end of file diff --git a/Adaptation/MET08ANLYSDIFAAST230-Development.yml b/Adaptation/MET08ANLYSDIFAAST230-Development.yml new file mode 100644 index 0000000..f4941c8 --- /dev/null +++ b/Adaptation/MET08ANLYSDIFAAST230-Development.yml @@ -0,0 +1,155 @@ +trigger: + branches: + include: + - Development + paths: + include: + - "Adaptation/*" + +pool: + name: Mesa-Windows-Service + demands: MET08ANLYSDIFAAST230-Development + +steps: + - script: | + set coreVersion=net6.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)" + + - 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/MET08ANLYSDIFAAST230.Tests.csproj b/Adaptation/MET08ANLYSDIFAAST230.Tests.csproj index 1ac6e3f..4aa0995 100644 --- a/Adaptation/MET08ANLYSDIFAAST230.Tests.csproj +++ b/Adaptation/MET08ANLYSDIFAAST230.Tests.csproj @@ -15,6 +15,7 @@ trx + XPlat Code Coverage ../../../../MET08ANLYSDIFAAST230/05_TestResults/TestResults @@ -32,50 +33,8 @@ Linux - - - - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - NU1701 - NU1701 - NU1701 - - - NU1701 + + NU1701 NU1701 NU1701 @@ -83,6 +42,41 @@ NU1701 NU1701 NU1701 + + + + + + + + + + + + + + + + NU1701 + + + + + + + + + + + + + + NU1701 + + + NU1701 + NU1701 + NU1701 diff --git a/Adaptation/MET08ANLYSDIFAAST230.yml b/Adaptation/MET08ANLYSDIFAAST230.yml new file mode 100644 index 0000000..f4ddf4f --- /dev/null +++ b/Adaptation/MET08ANLYSDIFAAST230.yml @@ -0,0 +1,153 @@ +trigger: + branches: + include: + - master + paths: + include: + - "Adaptation/*" + +pool: + name: Mesa-Windows-Service + demands: MET08ANLYSDIFAAST230 + +steps: + - script: | + set coreVersion=net6.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://messa08ec.ec.local/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)" + + - 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/Duplicator/Description.cs b/Adaptation/Shared/Duplicator/Description.cs index abbb7a4..42b9fa5 100644 --- a/Adaptation/Shared/Duplicator/Description.cs +++ b/Adaptation/Shared/Duplicator/Description.cs @@ -21,7 +21,13 @@ public class Description : IDescription, Properties.IDescription public string ReportFullPath { get; set; } public string ProcessJobID { get; set; } public string MID { get; set; } - public string Date { get; set; } //2021-10-23 + public string Date { get; set; } + // + public string Employee { get; set; } + public string PSN { get; set; } + public string RDS { get; set; } + public string Reactor { get; set; } + public string Recipe { get; set; } string IDescription.GetEventDescription() => "File Has been read and parsed"; @@ -139,4 +145,6 @@ public class Description : IDescription, Properties.IDescription return result; } + internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt"; + } \ No newline at end of file diff --git a/Adaptation/Shared/FileRead.cs b/Adaptation/Shared/FileRead.cs index d91b636..48122f8 100644 --- a/Adaptation/Shared/FileRead.cs +++ b/Adaptation/Shared/FileRead.cs @@ -54,6 +54,7 @@ public class FileRead : Properties.IFileRead string Properties.IFileRead.EventName => _EventName; string Properties.IFileRead.MesEntity => _MesEntity; bool Properties.IFileRead.IsEAFHosted => _IsEAFHosted; + bool Properties.IFileRead.IsDuplicator => _IsDuplicator; string Properties.IFileRead.EquipmentType => _EquipmentType; string Properties.IFileRead.ReportFullPath => _ReportFullPath; string Properties.IFileRead.CellInstanceName => _CellInstanceName; @@ -259,24 +260,23 @@ public class FileRead : Properties.IFileRead return results; } - protected static string GetTupleFile(Logistics logistics, Properties.IScopeInfo scopeInfo, string duplicateDirectory) + protected static string GetTupleFile(Logistics logistics, List descriptions, Properties.IScopeInfo scopeInfo, string duplicateDirectory) where T : Properties.IDescription { string result; string rds; string dateValue; - string datePlaceholder; - string[] segments = logistics.MID.Split('-'); - if (segments.Length < 2) - rds = "%RDS%"; + string rdsPlaceholder = "%RDS%"; + if (!descriptions.Any() || string.IsNullOrEmpty(descriptions[0].RDS)) + rds = logistics.MID; else - rds = segments[1]; - segments = scopeInfo.FileName.Split(new string[] { "DateTime:" }, StringSplitOptions.RemoveEmptyEntries); + 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("%RDS%", rds)); + result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileNameWithoutExtension.Replace(rdsPlaceholder, rds)); else { - datePlaceholder = "%DateTime%"; segments = segments[1].Split('%'); + string datePlaceholder = "%DateTime%"; dateValue = logistics.DateTimeFromSequence.ToString(segments[0]); foreach (string segment in scopeInfo.FileName.Split('%')) { @@ -284,18 +284,19 @@ public class FileRead : Properties.IFileRead continue; datePlaceholder = string.Concat('%', segment, '%'); } - result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileName.Replace("%RDS%", rds).Replace(datePlaceholder, dateValue)); + result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileName.Replace(rdsPlaceholder, rds).Replace(datePlaceholder, dateValue)); } if (result.Contains('%')) throw new Exception("Placeholder exists!"); return result; } - protected void WaitForFileConsumption(string sourceDirectoryCloaking, Logistics logistics, DateTime dateTime, string successDirectory, string duplicateDirectory, string duplicateFile, List<(Properties.IScopeInfo, string)> tuples) + protected void WaitForFileConsumption(string sourceDirectoryCloaking, Logistics logistics, DateTime dateTime, List descriptions, string successDirectory, string duplicateDirectory, string duplicateFile, List<(Properties.IScopeInfo, string)> collection) where T : Properties.IDescription { bool check; long preWait; string tupleFile; + string tupleFileName = string.Empty; List duplicateFiles = new(); StringBuilder stringBuilder = new(); List consumedFileIndices = new(); @@ -305,26 +306,28 @@ public class FileRead : Properties.IFileRead preWait = dateTime.AddMilliseconds(1234).Ticks; else preWait = dateTime.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks; - if (!tuples.Any()) + if (!collection.Any()) duplicateFiles.Add(duplicateFile); string fileName = Path.GetFileNameWithoutExtension(logistics.ReportFullPath); string successFile = string.Concat(successDirectory, @"\", Path.GetFileName(logistics.ReportFullPath)); - foreach ((Properties.IScopeInfo scopeInfo, string text) in tuples) + foreach ((Properties.IScopeInfo scopeInfo, string text) in collection) { if (scopeInfo.FileName.StartsWith(@"\")) tupleFile = scopeInfo.FileName; else if (!scopeInfo.FileName.Contains('%')) tupleFile = string.Concat(duplicateDirectory, @"\", fileName, "_", scopeInfo.FileNameWithoutExtension, ".pdsfc"); else - tupleFile = GetTupleFile(logistics, scopeInfo, duplicateDirectory); + tupleFile = GetTupleFile(logistics, descriptions, scopeInfo, duplicateDirectory); + tupleFileName = Path.GetFileNameWithoutExtension(tupleFile).Split('.')[0]; duplicateFiles.Add(tupleFile); - File.WriteAllText(tupleFile, text); + if (_IsEAFHosted) + File.WriteAllText(tupleFile, text); } for (short i = 0; i < short.MaxValue; i++) { if (DateTime.Now.Ticks > preWait) break; - Thread.Sleep(500); + Thread.Sleep(100); } if (!moreThanAnHour) { @@ -339,7 +342,17 @@ public class FileRead : Properties.IFileRead for (int i = 0; i < duplicateFiles.Count; i++) { if (!File.Exists(duplicateFiles[i])) - consumedFileIndices.Add(i); + { + if (string.IsNullOrEmpty(tupleFileName)) + consumedFileIndices.Add(i); + else if (duplicateFiles.All(l => Path.GetFileNameWithoutExtension(l).Split('.')[0] == tupleFileName)) + { + for (int j = 0; j < duplicateFiles.Count; j++) + consumedFileIndices.Add(j); + } + else + consumedFileIndices.Add(i); + } } if (consumedFileIndices.Count == duplicateFiles.Count) break; @@ -360,7 +373,7 @@ public class FileRead : Properties.IFileRead } throw new Exception(string.Concat("After {", _BreakAfterSeconds, "} seconds, right side of {", sourceDirectoryCloaking, "} didn't consume file(s) ", stringBuilder)); } - Thread.Sleep(500); + Thread.Sleep(250); } } } @@ -598,10 +611,10 @@ public class FileRead : Properties.IFileRead } } - protected void WaitForFileConsumption(DateTime dateTime, bool isDummyRun, string successDirectory, string duplicateDirectory, List<(Properties.IScopeInfo, string)> tuples, string duplicateFile) + protected void WaitForFileConsumption(DateTime dateTime, List descriptions, bool isDummyRun, string successDirectory, string duplicateDirectory, List<(Properties.IScopeInfo, string)> collection, string duplicateFile) where T : Properties.IDescription { if (!isDummyRun && _IsEAFHosted) - WaitForFileConsumption(_FileConnectorConfiguration.SourceDirectoryCloaking, _Logistics, dateTime, successDirectory, duplicateDirectory, duplicateFile, tuples); + WaitForFileConsumption(_FileConnectorConfiguration.SourceDirectoryCloaking, _Logistics, dateTime, descriptions, successDirectory, duplicateDirectory, duplicateFile, collection); else { long breakAfter = DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks; diff --git a/Adaptation/Shared/Logistics.cs b/Adaptation/Shared/Logistics.cs index c441b3f..a6ca882 100644 --- a/Adaptation/Shared/Logistics.cs +++ b/Adaptation/Shared/Logistics.cs @@ -9,55 +9,67 @@ namespace Adaptation.Shared; public class Logistics : ILogistics { - public object NullData { get; private set; } - public string JobID { get; private set; } //CellName - public long Sequence { get; private set; } //Ticks - public DateTime DateTimeFromSequence { get; private set; } - public double TotalSecondsSinceLastWriteTimeFromSequence { get; private set; } - public string MesEntity { get; private set; } //SPC - public string ReportFullPath { get; private set; } //Extract file - public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics) - public string MID { get; set; } //Lot & Pocket || Lot - public List Tags { get; set; } - public List Logistics1 { get; set; } - public List Logistics2 { get; set; } + protected readonly DateTime _DateTimeFromSequence; + protected readonly FileInfo _FileInfo; + protected readonly string _JobID; + protected readonly List _Logistics1; + protected readonly List _Logistics2; + protected string _MID; + protected readonly string _MesEntity; + protected readonly object _NullData; + protected string _ProcessJobID; + protected readonly string _ReportFullPath; + protected readonly long _Sequence; + protected readonly double _TotalSecondsSinceLastWriteTimeFromSequence; + + public DateTime DateTimeFromSequence => _DateTimeFromSequence; + public FileInfo FileInfo => _FileInfo; + public string JobID => _JobID; + public List Logistics1 => _Logistics1; + public List Logistics2 => _Logistics2; + public string MID => _MID; + public string MesEntity => _MesEntity; + public object NullData => _NullData; + public string ProcessJobID => _ProcessJobID; + public string ReportFullPath => _ReportFullPath; + public long Sequence => _Sequence; + public double TotalSecondsSinceLastWriteTimeFromSequence => _TotalSecondsSinceLastWriteTimeFromSequence; public Logistics(IFileRead fileRead) { DateTime dateTime = DateTime.Now; - NullData = null; - Sequence = dateTime.Ticks; - DateTimeFromSequence = dateTime; - JobID = fileRead.CellInstanceName; - TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; - MesEntity = DefaultMesEntity(dateTime); - ReportFullPath = string.Empty; - ProcessJobID = nameof(ProcessJobID); - MID = nameof(MID); - Tags = new List(); - Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); - Logistics2 = new List(); + _NullData = null; + _Sequence = dateTime.Ticks; + _DateTimeFromSequence = dateTime; + _JobID = fileRead.CellInstanceName; + _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; + _MesEntity = DefaultMesEntity(dateTime); + _ReportFullPath = string.Empty; + _ProcessJobID = nameof(ProcessJobID); + _MID = nameof(MID); + _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); + _Logistics2 = new List(); } - public Logistics(IFileRead fileRead, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null) + public Logistics(IFileRead fileRead, long tickOffset, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null) { if (string.IsNullOrEmpty(fileRead.CellInstanceName)) throw new Exception(); if (string.IsNullOrEmpty(fileRead.MesEntity)) throw new Exception(); - NullData = fileRead.NullData; - FileInfo fileInfo = new(reportFullPath); - DateTime dateTime = fileInfo.LastWriteTime; - if (fileInfoLength.HasValue && fileInfo.Length < fileInfoLength.Value) + _NullData = fileRead.NullData; + _FileInfo = new(reportFullPath); + DateTime dateTime = new(_FileInfo.LastWriteTime.Ticks + tickOffset); + if (fileInfoLength.HasValue && _FileInfo.Length < fileInfoLength.Value) dateTime = dateTime.AddTicks(-1); - JobID = fileRead.CellInstanceName; - Sequence = dateTime.Ticks; - DateTimeFromSequence = dateTime; - TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; - MesEntity = fileRead.MesEntity; - ReportFullPath = fileInfo.FullName; - ProcessJobID = nameof(ProcessJobID); - string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName); + _JobID = fileRead.CellInstanceName; + _Sequence = dateTime.Ticks; + _DateTimeFromSequence = dateTime; + _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; + _MesEntity = fileRead.MesEntity; + _ReportFullPath = _FileInfo.FullName; + _ProcessJobID = nameof(ProcessJobID); + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(_FileInfo.FullName); if (useSplitForMID) { if (fileNameWithoutExtension.IndexOf(".") > -1) @@ -67,10 +79,9 @@ public class Logistics : ILogistics if (fileNameWithoutExtension.IndexOf("-") > -1) fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim(); } - MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower()); - Tags = new List(); - Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); - Logistics2 = new List(); + _MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower()); + _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); + _Logistics2 = new List(); } public Logistics(string reportFullPath, string logistics) @@ -78,57 +89,57 @@ public class Logistics : ILogistics string key; DateTime dateTime; string[] segments; - Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); + _FileInfo = new(reportFullPath); + _Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1")) { - NullData = null; - JobID = "null"; - dateTime = new FileInfo(reportFullPath).LastWriteTime; - Sequence = dateTime.Ticks; - DateTimeFromSequence = dateTime; - TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; - MesEntity = DefaultMesEntity(dateTime); - ReportFullPath = reportFullPath; - ProcessJobID = "R##"; - MID = "null"; - Tags = new List(); - Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); - Logistics2 = new List(); + _NullData = null; + _JobID = "null"; + dateTime = _FileInfo.LastWriteTime; + _Sequence = dateTime.Ticks; + _DateTimeFromSequence = dateTime; + _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; + _MesEntity = DefaultMesEntity(dateTime); + _ReportFullPath = reportFullPath; + _ProcessJobID = "R##"; + _MID = "null"; + _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); + _Logistics2 = new List(); } else { string logistics1Line1 = Logistics1[0]; key = "NULL_DATA="; if (!logistics1Line1.Contains(key)) - NullData = null; + _NullData = null; else { segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); - NullData = segments[1].Split(';')[0]; + _NullData = segments[1].Split(';')[0]; } key = "JOBID="; if (!logistics1Line1.Contains(key)) - JobID = "null"; + _JobID = "null"; else { segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); - JobID = segments[1].Split(';')[0]; + _JobID = segments[1].Split(';')[0]; } key = "SEQUENCE="; if (!logistics1Line1.Contains(key)) - dateTime = new FileInfo(reportFullPath).LastWriteTime; + dateTime = _FileInfo.LastWriteTime; else { segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); if (!long.TryParse(segments[1].Split(';')[0].Split('.')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks) - dateTime = new FileInfo(reportFullPath).LastWriteTime; + dateTime = _FileInfo.LastWriteTime; else dateTime = new DateTime(sequence); } - Sequence = dateTime.Ticks; - DateTimeFromSequence = dateTime; - TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; - DateTime lastWriteTime = new FileInfo(reportFullPath).LastWriteTime; + _Sequence = dateTime.Ticks; + _DateTimeFromSequence = dateTime; + _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; + DateTime lastWriteTime = _FileInfo.LastWriteTime; if (TotalSecondsSinceLastWriteTimeFromSequence > 600) { if (lastWriteTime != dateTime) @@ -138,33 +149,32 @@ public class Logistics : ILogistics } key = "MES_ENTITY="; if (!logistics1Line1.Contains(key)) - MesEntity = DefaultMesEntity(dateTime); + _MesEntity = DefaultMesEntity(dateTime); else { segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); - MesEntity = segments[1].Split(';')[0]; + _MesEntity = segments[1].Split(';')[0]; } - ReportFullPath = reportFullPath; + _ReportFullPath = reportFullPath; key = "PROCESS_JOBID="; if (!logistics1Line1.Contains(key)) - ProcessJobID = "R##"; + _ProcessJobID = "R##"; else { segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); - ProcessJobID = segments[1].Split(';')[0]; + _ProcessJobID = segments[1].Split(';')[0]; } key = "MID="; if (!logistics1Line1.Contains(key)) - MID = "null"; + _MID = "null"; else { segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); - MID = segments[1].Split(';')[0]; + _MID = segments[1].Split(';')[0]; } } Logistics2 logistics2; - Tags = new List(); - Logistics2 = new List(); + _Logistics2 = new List(); for (int i = 1; i < Logistics1.Count; i++) { if (Logistics1[i].StartsWith("LOGISTICS_2")) @@ -180,29 +190,12 @@ public class Logistics : ILogistics } } - public Logistics ShallowCopy() => (Logistics)MemberwiseClone(); - private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY"); - internal string GetLotViaMostCommonMethod() => MID.Substring(0, MID.Length - 2); - - internal string GetPocketNumberViaMostCommonMethod() => MID.Substring(MID.Length - 2); - - internal void Update(string dateTime, string processJobID, string mid) + internal void Update(string mid, string processJobID) { - if (!DateTime.TryParse(dateTime, out DateTime dateTimeCasted)) - dateTimeCasted = DateTime.Now; - NullData = null; - //JobID = Description.GetCellName(); - Sequence = dateTimeCasted.Ticks; - DateTimeFromSequence = dateTimeCasted; - TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTimeCasted).TotalSeconds; - //MesEntity = DefaultMesEntity(dateTime); - //ReportFullPath = string.Empty; - ProcessJobID = processJobID; - MID = mid; - Tags = new List(); - Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); - Logistics2 = new List(); + _MID = mid; + _ProcessJobID = processJobID; } + } \ No newline at end of file diff --git a/Adaptation/Shared/Metrology/ScopeInfo.cs b/Adaptation/Shared/Metrology/ScopeInfo.cs index 2de909e..539bd09 100644 --- a/Adaptation/Shared/Metrology/ScopeInfo.cs +++ b/Adaptation/Shared/Metrology/ScopeInfo.cs @@ -16,7 +16,7 @@ public class ScopeInfo : Properties.IScopeInfo public string QueryFilter { get; private set; } public string FileNameWithoutExtension { get; private set; } - public ScopeInfo(Test test, string fileName, string queryFilter = "", string title = "", string html = "") + public ScopeInfo(Test test, string fileName, string queryFilter = "", string title = "", string html = "", string extraExtension = "") { Enum = test; Test = test; diff --git a/Adaptation/Shared/Metrology/WS.cs b/Adaptation/Shared/Metrology/WS.cs index b892219..844efea 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,8 @@ 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(resultsJson); results.Errors.Add(stringBuilder.ToString()); } return new(resultsJson, results); diff --git a/Adaptation/Shared/ProcessDataStandardFormat.cs b/Adaptation/Shared/ProcessDataStandardFormat.cs index 9dcdb0a..b256f0f 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)) @@ -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/Shared/Properties/IDescription.cs b/Adaptation/Shared/Properties/IDescription.cs index 93e6de5..141a7f6 100644 --- a/Adaptation/Shared/Properties/IDescription.cs +++ b/Adaptation/Shared/Properties/IDescription.cs @@ -7,4 +7,13 @@ public interface IDescription int Count { get; } int Index { get; } + string MesEntity { get; } + string Date { get; } + + string Employee { get; } + string PSN { get; } + string RDS { get; } + string Reactor { get; } + string Recipe { get; } + } \ No newline at end of file diff --git a/Adaptation/Shared/Properties/IFileRead.cs b/Adaptation/Shared/Properties/IFileRead.cs index 2e85ac9..5cf9a69 100644 --- a/Adaptation/Shared/Properties/IFileRead.cs +++ b/Adaptation/Shared/Properties/IFileRead.cs @@ -7,6 +7,7 @@ public interface IFileRead string MesEntity { get; } bool IsEAFHosted { get; } string EventName { get; } + bool IsDuplicator { get; } string EquipmentType { get; } string ReportFullPath { get; } string CellInstanceName { get; } diff --git a/Adaptation/Shared/Properties/ILogistics.cs b/Adaptation/Shared/Properties/ILogistics.cs index dc1a106..398bed9 100644 --- a/Adaptation/Shared/Properties/ILogistics.cs +++ b/Adaptation/Shared/Properties/ILogistics.cs @@ -1,22 +1,23 @@ using System; using System.Collections.Generic; +using System.IO; namespace Adaptation.Shared.Properties; public interface ILogistics { - public object NullData { get; } - public string JobID { get; } //CellName - public long Sequence { get; } //Ticks public DateTime DateTimeFromSequence { get; } + public FileInfo FileInfo { get; } + public string JobID { get; } + public List Logistics1 { get; } + public List Logistics2 { get; } + public string MID { get; } + public string MesEntity { get; } + public object NullData { get; } + public string ProcessJobID { get; } + public string ReportFullPath { get; } + public long Sequence { get; } public double TotalSecondsSinceLastWriteTimeFromSequence { get; } - public string MesEntity { get; } //SPC - public string ReportFullPath { get; } //Extract file - public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics) - public string MID { get; set; } //Lot & Pocket || Lot - public List Tags { get; set; } - public List Logistics1 { get; set; } - public List Logistics2 { get; set; } } \ No newline at end of file diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08ANLYSDIFAAST230.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08ANLYSDIFAAST230.cs index 19d7f69..236b77f 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08ANLYSDIFAAST230.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08ANLYSDIFAAST230.cs @@ -15,23 +15,23 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting #pragma warning disable CA2254 #pragma warning disable IDE0060 + internal static string DummyRoot { get; private set; } internal static MET08ANLYSDIFAAST230 EAFLoggingUnitTesting { get; private set; } - public MET08ANLYSDIFAAST230() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) + public MET08ANLYSDIFAAST230() : base(DummyRoot, testContext: null, declaringType: null, skipEquipmentDictionary: false) { if (EAFLoggingUnitTesting is null) throw new Exception(); } - public MET08ANLYSDIFAAST230(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) + public MET08ANLYSDIFAAST230(TestContext testContext) : base(DummyRoot, testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) { } [ClassInitialize] public static void ClassInitialize(TestContext testContext) { - if (EAFLoggingUnitTesting is null) - EAFLoggingUnitTesting = new MET08ANLYSDIFAAST230(testContext); + EAFLoggingUnitTesting ??= new MET08ANLYSDIFAAST230(testContext); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); @@ -41,12 +41,13 @@ public class MET08ANLYSDIFAAST230 : 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 + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles() { @@ -57,6 +58,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer() { @@ -67,6 +71,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi() { @@ -77,6 +84,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsight() { @@ -87,6 +97,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments() { @@ -97,6 +110,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__APC() { @@ -107,6 +123,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__SPaCe() { @@ -117,6 +136,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Processed() { @@ -127,6 +149,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Archive() { @@ -137,6 +162,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Dummy() { diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.5/MET08ANLYSDIFAAST230.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.5/MET08ANLYSDIFAAST230.cs new file mode 100644 index 0000000..eb9adcb --- /dev/null +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.5/MET08ANLYSDIFAAST230.cs @@ -0,0 +1,180 @@ +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_47_5; + +[TestClass] +public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + internal static string DummyRoot { get; private set; } + internal static MET08ANLYSDIFAAST230 EAFLoggingUnitTesting { get; private set; } + + static MET08ANLYSDIFAAST230() => DummyRoot = @"\\messv02ecc1.ec.local\EC_Characterization_Si\Dummy"; + + public MET08ANLYSDIFAAST230() : base(DummyRoot, testContext: null, declaringType: null, skipEquipmentDictionary: false) + { + if (EAFLoggingUnitTesting is null) + throw new Exception(); + } + + public MET08ANLYSDIFAAST230(TestContext testContext) : base(DummyRoot, testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) + { + } + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + EAFLoggingUnitTesting ??= new MET08ANLYSDIFAAST230(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_47_5__MET08ANLYSDIFAAST230__MoveMatchingFiles() + { + string check = "*.pdsf"; + 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")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer() + { + string check = "*.pdsf"; + 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")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__IQSSi() + { + string check = "*.pdsf"; + 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")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__OpenInsight() + { + string check = "*.pdsf"; + 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")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments() + { + string check = "*.pdsf"; + 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")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__APC() + { + string check = "*.pdsf"; + 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")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__SPaCe() + { + string check = "*.pdsf"; + 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")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__Processed() + { + string check = "*.pdsf"; + 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")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__Archive() + { + string check = "*.pdsf"; + 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")); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__Dummy() + { + string check = "637400762024374000.zip"; + 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/MET08ANLYSDIFAAST230.cs b/Adaptation/_Tests/Extract/Staging/v2.43.0/MET08ANLYSDIFAAST230.cs index d6901b3..f66de58 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.43.0/MET08ANLYSDIFAAST230.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.43.0/MET08ANLYSDIFAAST230.cs @@ -22,9 +22,15 @@ public class MET08ANLYSDIFAAST230 _MET08ANLYSDIFAAST230 = CreateSelfDescription.Staging.v2_43_0.MET08ANLYSDIFAAST230.EAFLoggingUnitTesting; } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles(); +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles637710931421087642__Normal() { @@ -37,12 +43,21 @@ public class MET08ANLYSDIFAAST230 _ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics, validatePDSF: false); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer(); +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi(); +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi637884771880950000__Normal() { @@ -55,24 +70,45 @@ public class MET08ANLYSDIFAAST230 _ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics, validatePDSF: false); } +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsight() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsight(); +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments(); +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__APC() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__APC(); +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__SPaCe() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__SPaCe(); +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Processed() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__Processed(); +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Archive() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__Archive(); +#if true + [Ignore] +#endif [TestMethod] public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Dummy() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__Dummy(); diff --git a/Adaptation/_Tests/Extract/Staging/v2.47.5/MET08ANLYSDIFAAST230.cs b/Adaptation/_Tests/Extract/Staging/v2.47.5/MET08ANLYSDIFAAST230.cs new file mode 100644 index 0000000..287bb10 --- /dev/null +++ b/Adaptation/_Tests/Extract/Staging/v2.47.5/MET08ANLYSDIFAAST230.cs @@ -0,0 +1,116 @@ +using Adaptation._Tests.Shared; +using Adaptation.Shared; +using Adaptation.Shared.Methods; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Diagnostics; +using System.Reflection; + +namespace Adaptation._Tests.Extract.Staging.v2_47_5; + +[TestClass] +public class MET08ANLYSDIFAAST230 +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + private static CreateSelfDescription.Staging.v2_47_5.MET08ANLYSDIFAAST230 _MET08ANLYSDIFAAST230; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + CreateSelfDescription.Staging.v2_47_5.MET08ANLYSDIFAAST230.ClassInitialize(testContext); + _MET08ANLYSDIFAAST230 = CreateSelfDescription.Staging.v2_47_5.MET08ANLYSDIFAAST230.EAFLoggingUnitTesting; + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__MoveMatchingFiles() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__MoveMatchingFiles(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__MoveMatchingFiles637710931421087642__Normal() + { + string check = "*.pdsf"; + MethodBase methodBase = new StackFrame().GetMethod(); + _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__MoveMatchingFiles(); + string[] variables = _MET08ANLYSDIFAAST230.AdaptationTesting.GetVariables(methodBase, check, validatePDSF: false); + IFileRead fileRead = _MET08ANLYSDIFAAST230.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); + Logistics logistics = new(fileRead); + _ = AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics, validatePDSF: false); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__IQSSi() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__IQSSi(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__OpenInsight() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__OpenInsight(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__APC() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__APC(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__SPaCe() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__SPaCe(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__Processed() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__Processed(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__Archive() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__Archive(); + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__Archive638144101790470000__Normal() + { + string check = "*.pdsf"; + MethodBase methodBase = new StackFrame().GetMethod(); + _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__Archive(); + string[] variables = _MET08ANLYSDIFAAST230.AdaptationTesting.GetVariables(methodBase, check, validatePDSF: false); + IFileRead fileRead = _MET08ANLYSDIFAAST230.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); + Logistics logistics = new(fileRead); + _ = AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_47_5__MET08ANLYSDIFAAST230__Dummy() => _MET08ANLYSDIFAAST230.Staging__v2_47_5__MET08ANLYSDIFAAST230__Dummy(); + +} \ No newline at end of file diff --git a/Adaptation/_Tests/Shared/AdaptationTesting.cs b/Adaptation/_Tests/Shared/AdaptationTesting.cs index 997a93e..5741fc3 100644 --- a/Adaptation/_Tests/Shared/AdaptationTesting.cs +++ b/Adaptation/_Tests/Shared/AdaptationTesting.cs @@ -26,10 +26,13 @@ namespace Adaptation._Tests.Shared; public class AdaptationTesting : ISMTP { + protected readonly string _DummyRoot; protected readonly string _Environment; protected readonly string _HostNameAndPort; + protected readonly bool _HasWaitForProperty; protected readonly TestContext _TestContext; protected readonly bool _SkipEquipmentDictionary; + protected readonly string _TestContextPropertiesAsJson; protected readonly Dictionary _CellInstanceVersions; protected readonly Dictionary _EquipmentTypeVersions; protected readonly Dictionary _ParameterizedModelObjectDefinitionTypes; @@ -38,10 +41,13 @@ public class AdaptationTesting : ISMTP protected readonly Dictionary> _ModelObjectParameters; protected readonly Dictionary>> _EquipmentDictionaryEventDescriptions; + public string DummyRoot => _DummyRoot; public string Environment => _Environment; public TestContext TestContext => _TestContext; public string HostNameAndPort => _HostNameAndPort; + public bool HasWaitForProperty => _HasWaitForProperty; public bool SkipEquipmentDictionary => _SkipEquipmentDictionary; + public string TestContextPropertiesAsJson => _TestContextPropertiesAsJson; public Dictionary CellInstanceVersions => _CellInstanceVersions; public Dictionary EquipmentTypeVersions => _EquipmentTypeVersions; public Dictionary> ModelObjectParameters => _ModelObjectParameters; @@ -56,17 +62,22 @@ public class AdaptationTesting : ISMTP void ISMTP.SendNormalPriorityEmailMessage(string subject, string body) => throw new NotImplementedException(); - public AdaptationTesting(TestContext testContext, bool skipEquipmentDictionary) + public AdaptationTesting(string dummyRoot, TestContext testContext, bool skipEquipmentDictionary, string testContextPropertiesAsJson, bool hasWaitForProperty) { string environment = GetEnvironment(testContext); string hostNameAndPort = GetHostNameAndPort(environment); + _DummyRoot = dummyRoot; _TestContext = testContext; _Environment = environment; _HostNameAndPort = hostNameAndPort; + _HasWaitForProperty = hasWaitForProperty; _SkipEquipmentDictionary = skipEquipmentDictionary; + _TestContextPropertiesAsJson = testContextPropertiesAsJson; _CellInstanceVersions = new Dictionary(); _EquipmentTypeVersions = new Dictionary(); + _EquipmentTypeVersions = new Dictionary(); + _ParameterizedModelObjectDefinitionTypes = new Dictionary(); _ParameterizedModelObjectDefinitionTypes = new Dictionary(); _EquipmentDictionaryVersions = new Dictionary(); _FileConnectorConfigurations = new Dictionary(); @@ -94,23 +105,28 @@ public class AdaptationTesting : ISMTP return result; } - protected string GetTestResultsDirectory() + public static string GetTestResultsDirectory(string testContextTestResultsDirectory, bool hasWaitForProperty) { string result = string.Empty; string testResults = "05_TestResults"; - string checkDirectory = _TestContext.TestResultsDirectory; - if (string.IsNullOrEmpty(checkDirectory) || !checkDirectory.Contains(testResults)) - throw new Exception(); - string rootDirectory = Path.GetPathRoot(checkDirectory); - for (int i = 0; i < int.MaxValue; i++) + string checkDirectory = testContextTestResultsDirectory; + if (hasWaitForProperty && (string.IsNullOrEmpty(checkDirectory) || !checkDirectory.Contains(testResults))) + throw new Exception($"A:{checkDirectory}; B:{testResults};"); + else if (!hasWaitForProperty && (string.IsNullOrEmpty(checkDirectory) || !checkDirectory.Contains(testResults))) + result = testContextTestResultsDirectory; + else { - checkDirectory = Path.GetDirectoryName(checkDirectory); - if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == rootDirectory) - break; - if (checkDirectory.EndsWith(testResults) && Directory.Exists(checkDirectory)) + string rootDirectory = Path.GetPathRoot(checkDirectory); + for (int i = 0; i < int.MaxValue; i++) { - result = checkDirectory; - break; + checkDirectory = Path.GetDirectoryName(checkDirectory); + if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == rootDirectory) + break; + if (checkDirectory.EndsWith(testResults) && Directory.Exists(checkDirectory)) + { + result = checkDirectory; + break; + } } } if (string.IsNullOrEmpty(result)) @@ -118,6 +134,12 @@ public class AdaptationTesting : ISMTP return result; } + private string GetTestResultsDirectory(bool hasWaitForProperty) + { + string result = GetTestResultsDirectory(_TestContext.TestResultsDirectory, hasWaitForProperty); + return result; + } + protected static string GetCellInstanceConnectionName(string cellInstanceConnectionName) { string result; @@ -170,28 +192,29 @@ public class AdaptationTesting : ISMTP return results; } - internal string[] GetSegments(string methodBaseName) + public static MethodBaseName GetMethodBaseName(string dummyRoot, string environment, bool hasWaitForProperty, string methodBaseName, string testResultsDirectory) { - List results; - string fileFullName; + MethodBaseName result; string comment; - string[] textFiles; + string fileFullName; + string dummyDirectory; + string withActualCICN; string separator = "__"; + string textFileDirectory; string connectionNameAndTicks; string cellInstanceConnectionName; string ticks = DateTime.Now.Ticks.ToString(); string cellInstanceConnectionNameFromMethodBaseName; - string testResultsDirectory = GetTestResultsDirectory(); string[] segments = methodBaseName.Split(new string[] { separator }, StringSplitOptions.None); - if (segments[0] != _Environment) + if (segments[0] != environment) throw new Exception(); string rawVersionName = segments[1]; string rawCellInstanceName = segments[2]; string cellInstanceVersionName = segments[1].Replace('_', '.'); string cellInstanceName = segments[2].Replace('_', '-').Replace("_EQPT", "-EQPT"); - string before = string.Concat(_Environment, separator, rawVersionName, separator, cellInstanceName, separator); + string before = string.Concat(environment, separator, rawVersionName, separator, cellInstanceName, separator); string after = methodBaseName.Substring(before.Length); - string versionDirectory = Path.Combine(testResultsDirectory, _Environment, cellInstanceName, cellInstanceVersionName); + string versionDirectory = Path.Combine(testResultsDirectory, environment, cellInstanceName, cellInstanceVersionName); if (!Directory.Exists(versionDirectory)) _ = Directory.CreateDirectory(versionDirectory); comment = segments[segments.Length - 1]; @@ -221,87 +244,76 @@ public class AdaptationTesting : ISMTP cellInstanceConnectionNameFromMethodBaseName = after; } cellInstanceConnectionName = GetCellInstanceConnectionName(cellInstanceConnectionNameFromMethodBaseName); - string methodBaseNameWithActualCICN = GetMethodBaseNameWithActualCICN(methodBaseName, rawCellInstanceName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceConnectionName, ticks); + withActualCICN = GetMethodBaseNameWithActualCICN(methodBaseName, rawCellInstanceName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceConnectionName, ticks); + if (hasWaitForProperty) + dummyDirectory = string.Empty; + else if (string.IsNullOrEmpty(ticks)) + dummyDirectory = string.Empty; + else + { + if (string.IsNullOrEmpty(dummyRoot)) + throw new Exception($"{nameof(dummyRoot)} is empty!"); + if (!withActualCICN.Contains(ticks)) + throw new Exception($"{withActualCICN} doesn't contain {ticks}!"); + segments = withActualCICN.Split(new string[] { ticks }, StringSplitOptions.None); + dummyDirectory = Path.Combine(dummyRoot, cellInstanceName, ticks, string.Join(null, segments)); + if (!Directory.Exists(dummyDirectory)) + _ = Directory.CreateDirectory(dummyDirectory); + } if (string.IsNullOrEmpty(ticks)) { - textFiles = Array.Empty(); - fileFullName = Path.Combine(versionDirectory, methodBaseNameWithActualCICN, $"{cellInstanceConnectionNameFromMethodBaseName}.json"); + textFileDirectory = string.Empty; + fileFullName = Path.Combine(versionDirectory, withActualCICN, $"{cellInstanceConnectionNameFromMethodBaseName}.json"); } else { - segments = methodBaseNameWithActualCICN.Split(new string[] { ticks }, StringSplitOptions.None); - string textDirectory = Path.Combine(versionDirectory, segments[0], string.Concat(ticks, segments[1])); + segments = withActualCICN.Split(new string[] { ticks }, StringSplitOptions.None); + textFileDirectory = Path.Combine(versionDirectory, segments[0], string.Concat(ticks, segments[1])); fileFullName = Path.Combine(versionDirectory, segments[0], $"{cellInstanceConnectionNameFromMethodBaseName}.json"); - if (!Directory.Exists(textDirectory)) + } + result = new(after, before, cellInstanceConnectionName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceName, cellInstanceVersionName, comment, dummyDirectory, fileFullName, rawCellInstanceName, rawVersionName, separator, testResultsDirectory, textFileDirectory, ticks, versionDirectory, withActualCICN); + return result; + } + + private MethodBaseName GetMethodBaseName(MethodBase methodBase) + { + MethodBaseName result; + string testResultsDirectory = GetTestResultsDirectory(_HasWaitForProperty); + result = GetMethodBaseName(_DummyRoot, _Environment, _HasWaitForProperty, methodBase.Name, testResultsDirectory); + return result; + } + + private string[] GetTextFiles(MethodBaseName mbn) + { + string[] results; + if (string.IsNullOrEmpty(mbn.TextFileDirectory)) + results = Array.Empty(); + else if (!Directory.Exists(mbn.TextFileDirectory)) + { + results = Array.Empty(); + if (!_HasWaitForProperty) + _ = Directory.CreateDirectory(mbn.TextFileDirectory); + else { - textFiles = Array.Empty(); - string renameDirectory = Path.Combine(Path.GetDirectoryName(textDirectory), $"_Rename - {Path.GetFileName(textDirectory)}"); + string renameDirectory = Path.Combine(Path.GetDirectoryName(mbn.TextFileDirectory), $"_Rename - {Path.GetFileName(mbn.TextFileDirectory)}"); _ = Directory.CreateDirectory(renameDirectory); _ = Process.Start("explorer.exe", renameDirectory); File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileFilter)}.txt"), string.Empty); File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileLocation)}.txt"), string.Empty); } - else + } + else + { + results = Directory.GetFiles(mbn.TextFileDirectory, "*.txt", SearchOption.TopDirectoryOnly); + if (!string.IsNullOrEmpty(mbn.Ticks) && _HasWaitForProperty && !results.Any()) { - textFiles = Directory.GetFiles(textDirectory, "*.txt", SearchOption.TopDirectoryOnly); - if (!textFiles.Any()) - { - _ = Process.Start("explorer.exe", textDirectory); - File.WriteAllText(Path.Combine(textDirectory, "_ Why.why"), string.Empty); - } + _ = Process.Start("explorer.exe", mbn.TextFileDirectory); + File.WriteAllText(Path.Combine(mbn.TextFileDirectory, "_ Why.why"), string.Empty); } } - results = new List - { - _Environment, - rawCellInstanceName, - cellInstanceName, - cellInstanceVersionName, - cellInstanceConnectionNameFromMethodBaseName, - cellInstanceConnectionName, - ticks, - comment, - fileFullName - }; - results.AddRange(textFiles); - return results.ToArray(); - } - - internal string[] GetSegments(MethodBase methodBase) - { - string[] results = GetSegments(methodBase.Name); return results; } - internal static string GetEnvironment(string[] segments) => segments[0]; - - internal static string GetRawCellInstanceName(string[] segments) => segments[1]; - - internal static string GetCellInstanceName(string[] segments) => segments[2]; - - internal static string GetCellInstanceVersionName(string[] segments) => segments[3]; - - internal static string GetCellInstanceConnectionNameFromMethodBaseName(string[] segments) => segments[4]; - - internal static string GetCellInstanceConnectionName(string[] segments) => segments[5]; - - internal static string GetTicks(string[] segments) => segments[6]; - - internal static string GetComment(string[] segments) => segments[7]; - - internal static FileInfo GetFileName(string[] segments) => new(segments[8]); - - internal static string[] GetTextFiles(string[] segments) - { - List results = new(); - if (segments.Length > 8) - { - for (int i = 9; i < segments.Length; i++) - results.Add(segments[i]); - } - return results.ToArray(); - } - protected static Stream ToStream(string @this) { MemoryStream memoryStream = new(); @@ -331,7 +343,7 @@ public class AdaptationTesting : ISMTP return result as T; } - protected static CellInstanceVersion GetCellInstanceVersion(string url) + public static CellInstanceVersion GetCellInstanceVersion(string url) { CellInstanceVersion result; byte[] byteArray; @@ -466,6 +478,7 @@ public class AdaptationTesting : ISMTP AppendLine("#pragma warning disable CA2254"). AppendLine("#pragma warning disable IDE0060"). AppendLine(). + AppendLine("internal static string DummyRoot { get; private set; }"). Append("internal static ").Append(cellInstanceNameWithoutHyphen).AppendLine(" EAFLoggingUnitTesting { get; private set; }"); else throw new Exception(); @@ -474,13 +487,15 @@ public class AdaptationTesting : ISMTP else if (i == 1) _ = stringBuilder. AppendLine(). - Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)"). + Append("static ").Append(cellInstanceNameWithoutHyphen).AppendLine("() => DummyRoot = @\"\\\\messv02ecc1.ec.local\\EC_Characterization_Si\\Dummy\";"). + AppendLine(). + Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("() : base(DummyRoot, testContext: null, declaringType: null, skipEquipmentDictionary: false)"). AppendLine("{"). AppendLine("if (EAFLoggingUnitTesting is null)"). AppendLine("throw new Exception();"). AppendLine("}"). AppendLine(). - Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)"). + Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("(TestContext testContext) : base(DummyRoot, testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)"). AppendLine("{"). AppendLine("}"). AppendLine(); @@ -541,6 +556,9 @@ public class AdaptationTesting : ISMTP if (i == 2) { _ = stringBuilder. + AppendLine("#if true"). + AppendLine("[Ignore]"). + AppendLine("#endif"). AppendLine("[TestMethod]"). Append("public void ").Append(methodName).Append("() => ").Append('_').Append(cellInstanceNameWithoutHyphen).Append('.').Append(methodName).AppendLine("();").AppendLine(); } @@ -550,13 +568,16 @@ public class AdaptationTesting : ISMTP throw new Exception("Versions should match!"); equipmentTypeName = componentsCellComponentCellComponent.Equipment.EquipmentType.Name; _ = stringBuilder. + AppendLine("#if true"). + AppendLine("[Ignore]"). + AppendLine("#endif"). AppendLine("[TestMethod]"). Append("public void ").Append(methodName).AppendLine("()"). AppendLine("{"). Append("string check = \"").Append(check.Split('\\').Last()).AppendLine("\";"). AppendLine("MethodBase methodBase = new StackFrame().GetMethod();"). AppendLine("EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Getting configuration\"));"). - AppendLine("_ = Shared.AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);"). + AppendLine("_ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);"). AppendLine("EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Exit\"));"). AppendLine("}"). AppendLine(); @@ -600,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) @@ -857,7 +874,7 @@ public class AdaptationTesting : ISMTP return result; } - protected Dictionary GetKeyValuePairs(string cellInstanceName, string cellInstanceVersionName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, List> equipmentDictionaryIsAlwaysEnabledEvents) + protected Dictionary GetKeyValuePairs(string cellInstanceName, string cellInstanceVersionName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, List> equipmentDictionaryIsAlwaysEnabledEvents, int edaConnectionPortNumber) { Dictionary results = new() { @@ -866,6 +883,7 @@ public class AdaptationTesting : ISMTP { nameof(cellInstanceName), cellInstanceName }, { nameof(equipmentTypeName), equipmentTypeName }, { nameof(cellInstanceVersionName), cellInstanceVersionName }, + { nameof(edaConnectionPortNumber), edaConnectionPortNumber }, { nameof(equipmentDictionaryName), equipmentDictionaryName }, { nameof(cellInstanceConnectionName), cellInstanceConnectionName }, { nameof(FileConnectorConfiguration), fileConnectorConfiguration }, @@ -879,32 +897,26 @@ public class AdaptationTesting : ISMTP public string[] GetCSharpText(string testName) { string[] results; - string[] segments = GetSegments(testName); - FileInfo fileInfo = GetFileName(segments); - string cellInstanceName = GetCellInstanceName(segments); - string cellInstanceVersionName = GetCellInstanceVersionName(segments); - string cellInstanceConnectionName = GetCellInstanceConnectionName(segments); - if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName)) + string testResultsDirectory = GetTestResultsDirectory(_HasWaitForProperty); + MethodBaseName mbn = GetMethodBaseName(_DummyRoot, _Environment, _HasWaitForProperty, testName, testResultsDirectory); + FileInfo fileInfo = new(mbn.FileFullName); + if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName)) _ = Directory.CreateDirectory(fileInfo.Directory.FullName); - Tuple cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName); - results = GetCSharpTextB(fileInfo, cellInstanceName, cellInstanceVersionName, cellInstanceVersionTuple.Item2); + Tuple cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName); + results = GetCSharpTextB(fileInfo, mbn.CellInstanceName, mbn.CellInstanceVersionName, cellInstanceVersionTuple.Item2); return results; } public string[] GetConfiguration(MethodBase methodBase) { string[] results; - string[] segments = GetSegments(methodBase.Name); - string ticks = GetTicks(segments); - FileInfo fileInfo = GetFileName(segments); - string cellInstanceName = GetCellInstanceName(segments); - string cellInstanceVersionName = GetCellInstanceVersionName(segments); - string cellInstanceConnectionName = GetCellInstanceConnectionName(segments); - if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName)) + MethodBaseName mbn = GetMethodBaseName(methodBase); + FileInfo fileInfo = new(mbn.FileFullName); + if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName)) _ = Directory.CreateDirectory(fileInfo.Directory.FullName); - Tuple cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName); - Tuple fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName); - if (string.IsNullOrEmpty(ticks) && fileConnectorConfigurationTuple.Item2?.FileScanningIntervalInSeconds is not null) + Tuple cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName); + Tuple fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, mbn.CellInstanceConnectionName); + if (string.IsNullOrEmpty(mbn.Ticks) && fileConnectorConfigurationTuple.Item2?.FileScanningIntervalInSeconds is not null) { string fileScanningIntervalInSecondsLine; string versionDirectory = Path.GetDirectoryName(fileInfo.DirectoryName); @@ -914,12 +926,12 @@ public class AdaptationTesting : ISMTP fileScanningIntervalInSecondsLine = $"+\t{fileConnectorConfigurationTuple.Item2.FileScanningIntervalInSeconds.Value:+0000}\t{Path.GetFileName(fileInfo.DirectoryName)}"; File.AppendAllLines(Path.Combine(versionDirectory, "FileScanningIntervalInSeconds.txt"), new string[] { fileScanningIntervalInSecondsLine }); } - Tuple equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName); + Tuple equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName); Tuple parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple); Tuple> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple); - Tuple equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName, equipmentTypeVersionTuple.Item4); + Tuple equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName, equipmentTypeVersionTuple.Item4); Tuple>> equipmentDictionaryIsAlwaysEnabledEventsTuple = GetEquipmentDictionaryIsAlwaysEnabledEventsTuple(equipmentDictionaryVersionTuple); - Dictionary objects = GetKeyValuePairs(cellInstanceName, cellInstanceVersionName, cellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryVersionTuple.Item2, equipmentDictionaryIsAlwaysEnabledEventsTuple.Item2); + Dictionary objects = GetKeyValuePairs(mbn.CellInstanceName, mbn.CellInstanceVersionName, mbn.CellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryVersionTuple.Item2, equipmentDictionaryIsAlwaysEnabledEventsTuple.Item2, cellInstanceVersionTuple.Item2.EdaConnection.PortNumber); string json = JsonSerializer.Serialize(objects, new JsonSerializerOptions { WriteIndented = true }); results = new string[] { fileInfo.FullName, json }; return results; @@ -928,22 +940,19 @@ public class AdaptationTesting : ISMTP public IFileRead Get(MethodBase methodBase, string sourceFileLocation, string sourceFileFilter, bool useCyclicalForDescription) { IFileRead result; - string[] segments = GetSegments(methodBase.Name); - FileInfo fileInfo = GetFileName(segments); - string cellInstanceName = GetCellInstanceName(segments); - string cellInstanceVersionName = GetCellInstanceVersionName(segments); + MethodBaseName mbn = GetMethodBaseName(methodBase); + FileInfo fileInfo = new(mbn.FileFullName); Dictionary fileParameter = new(); - string cellInstanceConnectionName = GetCellInstanceConnectionName(segments); - if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName)) + if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName)) _ = Directory.CreateDirectory(fileInfo.Directory.FullName); Dictionary> dummyRuns = new(); Dictionary> staticRuns = new(); - Tuple cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName); - Tuple fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName); - Tuple equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName); + Tuple cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName); + Tuple fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, mbn.CellInstanceConnectionName); + Tuple equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName); Tuple parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple); Tuple> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple); - Tuple equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName, equipmentTypeVersionTuple.Item4); + Tuple equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName, equipmentTypeVersionTuple.Item4); _ = GetEquipmentDictionaryIsAlwaysEnabledEventsTuple(equipmentDictionaryVersionTuple); if (!string.IsNullOrEmpty(sourceFileLocation) && sourceFileLocation != fileConnectorConfigurationTuple.Item2.SourceFileLocation) fileConnectorConfigurationTuple.Item2.SourceFileLocation = sourceFileLocation; @@ -975,33 +984,29 @@ public class AdaptationTesting : ISMTP _ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder); } } - result = FileHandlers.CellInstanceConnectionName.Get(this, fileParameter, cellInstanceName, 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, isEAFHosted: false); return result; } - public string[] GetVariables(MethodBase methodBase, string check) + public string[] GetVariables(MethodBase methodBase, string check, bool validatePDSF = true) { string[] results; string[] lines; string ipdsfFile; - string textFileDirectory; + string[] segments; string fileNameWithoutExtension; string searchPattern = "*.ipdsf"; + string methodBaseNameWithActualCICN; string sourceFileFilter = string.Empty; string sourceFileLocation = string.Empty; - string[] segments = GetSegments(methodBase); - string ticks = GetTicks(segments); - FileInfo fileInfo = GetFileName(segments); - string[] textFiles = GetTextFiles(segments); - string cellInstanceName = GetCellInstanceName(segments); - string rawCellInstanceName = GetRawCellInstanceName(segments); - string cellInstanceConnectionName = GetCellInstanceConnectionName(segments); - string cellInstanceConnectionNameFromMethodBaseName = GetCellInstanceConnectionNameFromMethodBaseName(segments); - string methodBaseNameWithActualCICN = GetMethodBaseNameWithActualCICN(methodBase.Name, rawCellInstanceName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceConnectionName, ticks); + MethodBaseName mbn = GetMethodBaseName(methodBase); + string[] textFiles = GetTextFiles(mbn); if (!textFiles.Any()) - textFileDirectory = string.Empty; - else - textFileDirectory = Path.GetDirectoryName(textFiles[0]); + { + if (_HasWaitForProperty) + throw new Exception("Set text file!"); + sourceFileLocation = mbn.DummyDirectory; + } foreach (string textFile in textFiles) { lines = File.ReadAllLines(textFile); @@ -1012,18 +1017,20 @@ public class AdaptationTesting : ISMTP sourceFileFilter = lines[0]; else if (fileNameWithoutExtension == nameof(FileConnectorConfiguration.SourceFileLocation)) { - segments = lines[0].Split(new string[] { ticks }, StringSplitOptions.None); + methodBaseNameWithActualCICN = GetMethodBaseNameWithActualCICN(methodBase.Name, mbn.RawCellInstanceName, mbn.CellInstanceConnectionNameFromMethodBaseName, mbn.CellInstanceConnectionName, mbn.Ticks); + segments = lines[0].Split(new string[] { mbn.Ticks }, StringSplitOptions.None); if (segments.Length > 2) throw new Exception("Ticks should only appear once in source file location!"); if (segments.Length != 2) throw new Exception("Ticks missing from source file location!"); - if (segments[1].Contains(ticks)) + if (segments[1].Contains(mbn.Ticks)) throw new Exception("From source file location path should not contain ticks!"); - if (!segments[1].EndsWith(methodBaseNameWithActualCICN.Replace(ticks, string.Empty))) + if (!segments[1].EndsWith(methodBaseNameWithActualCICN.Replace(mbn.Ticks, string.Empty))) throw new Exception("Method name missing from source file location!"); sourceFileLocation = lines[0]; } } + FileInfo fileInfo = new(mbn.FileFullName); if (!Directory.Exists(fileInfo.Directory.FullName)) _ = Directory.CreateDirectory(fileInfo.Directory.FullName); if (!fileInfo.Exists) @@ -1044,25 +1051,30 @@ public class AdaptationTesting : ISMTP fileConnectorConfiguration.SourceFileFilter = sourceFileFilter; if (!string.IsNullOrEmpty(sourceFileLocation)) fileConnectorConfiguration.SourceFileLocation = sourceFileLocation; - if (string.IsNullOrEmpty(sourceFileLocation)) - ipdsfFile = searchPattern; + if (!validatePDSF) + ipdsfFile = string.Empty; else { - string ipdsfDirectory = Path.Combine(sourceFileLocation, "ipdsf"); - if (!Directory.Exists(ipdsfDirectory)) + if (string.IsNullOrEmpty(sourceFileLocation)) ipdsfFile = searchPattern; else { - string[] files = Directory.GetFiles(ipdsfDirectory, searchPattern, SearchOption.TopDirectoryOnly); - if (files.Any()) - ipdsfFile = files[0]; - else + string ipdsfDirectory = Path.Combine(sourceFileLocation, "ipdsf"); + if (!Directory.Exists(ipdsfDirectory)) ipdsfFile = searchPattern; + else + { + string[] files = Directory.GetFiles(ipdsfDirectory, searchPattern, SearchOption.TopDirectoryOnly); + if (files.Any()) + ipdsfFile = files[0]; + else + ipdsfFile = searchPattern; + } } + if (ipdsfFile == searchPattern) + throw new Exception(); } - if (ipdsfFile == searchPattern) - throw new Exception(); - results = new string[] { fileInfo.FullName, json, fileConnectorConfiguration.SourceFileLocation, fileConnectorConfiguration.SourceFileFilter, ipdsfFile, textFileDirectory }; + results = new string[] { fileInfo.FullName, json, fileConnectorConfiguration.SourceFileLocation, fileConnectorConfiguration.SourceFileFilter, ipdsfFile, mbn.TextFileDirectory }; if (string.IsNullOrEmpty(results[0])) throw new Exception(); if (string.IsNullOrEmpty(results[1])) @@ -1071,7 +1083,7 @@ public class AdaptationTesting : ISMTP throw new Exception(); if (string.IsNullOrEmpty(results[3])) throw new Exception(); - if (string.IsNullOrEmpty(results[4])) + if (validatePDSF && string.IsNullOrEmpty(results[4])) throw new Exception(); if (string.IsNullOrEmpty(results[5])) throw new Exception(); @@ -1232,29 +1244,33 @@ public class AdaptationTesting : ISMTP { string result; Tuple> extractResult = fileRead.ReExtract(); - Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); - Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!"); - Assert.IsNotNull(extractResult.Item4); - if (!validatePDSF) - _ = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, new(string.Empty, Array.Empty(), Array.Empty())); - else + if (!fileRead.IsDuplicator) { - Tuple pdsf = GetLogisticsColumnsAndBody(variables[2], variables[4]); - Tuple pdsfNew = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf); - CompareSave(variables[5], pdsf, pdsfNew); - Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!"); - string[] json = GetItem2(pdsf, pdsfNew); - CompareSaveJSON(variables[5], json); - Assert.IsTrue(json[0] == json[1], "Item2 check!"); - string[] join = GetItem3(pdsf, pdsfNew); - CompareSaveTSV(variables[5], join); - Assert.IsTrue(join[0] == join[1], "Item3 (Join) check!"); + Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); + Assert.IsNotNull(extractResult.Item3); + Assert.IsNotNull(extractResult.Item4); + if (!validatePDSF) + _ = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, new(string.Empty, Array.Empty(), Array.Empty())); + else + { + Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!"); + Tuple pdsf = GetLogisticsColumnsAndBody(variables[2], variables[4]); + Tuple pdsfNew = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf); + CompareSave(variables[5], pdsf, pdsfNew); + Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!"); + string[] json = GetItem2(pdsf, pdsfNew); + CompareSaveJSON(variables[5], json); + Assert.IsTrue(json[0] == json[1], "Item2 check!"); + string[] join = GetItem3(pdsf, pdsfNew); + CompareSaveTSV(variables[5], join); + Assert.IsTrue(join[0] == join[1], "Item3 (Join) check!"); + } + UpdatePassDirectory(variables[2]); } - UpdatePassDirectory(variables[2]); result = extractResult.Item1; return result; } } // namespace Adaptation._Tests.Helpers { public class AdaptationTesting { } } -// 2022-05-12 -> AdaptationTesting \ No newline at end of file +// 2022-08-05 -> AdaptationTesting \ No newline at end of file diff --git a/Adaptation/_Tests/Shared/EAFLoggingUnitTesting.cs b/Adaptation/_Tests/Shared/EAFLoggingUnitTesting.cs index 62a6cf7..bc6f20e 100644 --- a/Adaptation/_Tests/Shared/EAFLoggingUnitTesting.cs +++ b/Adaptation/_Tests/Shared/EAFLoggingUnitTesting.cs @@ -10,13 +10,13 @@ public class EAFLoggingUnitTesting : LoggingUnitTesting, IDisposable public AdaptationTesting AdaptationTesting => _AdaptationTesting; - public EAFLoggingUnitTesting(TestContext testContext, Type declaringType, bool skipEquipmentDictionary) : + public EAFLoggingUnitTesting(string dummyRoot, TestContext testContext, Type declaringType, bool skipEquipmentDictionary) : base(testContext, declaringType) { if (testContext is null || declaringType is null) _AdaptationTesting = null; else - _AdaptationTesting = new AdaptationTesting(testContext, skipEquipmentDictionary); + _AdaptationTesting = new AdaptationTesting(dummyRoot, testContext, skipEquipmentDictionary, _TestContextPropertiesAsJson, _HasWaitForProperty); } public new void Dispose() 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/MethodBaseName.cs b/Adaptation/_Tests/Shared/MethodBaseName.cs new file mode 100644 index 0000000..b14c1f5 --- /dev/null +++ b/Adaptation/_Tests/Shared/MethodBaseName.cs @@ -0,0 +1,45 @@ +namespace Adaptation._Tests.Shared; + +public class MethodBaseName +{ + + public string After { get; private set; } + public string Before { get; private set; } + public string CellInstanceConnectionName { get; private set; } + public string CellInstanceConnectionNameFromMethodBaseName { get; private set; } + public string CellInstanceName { get; private set; } + public string CellInstanceVersionName { get; private set; } + public string Comment { get; private set; } + public string DummyDirectory { get; private set; } + public string FileFullName { get; private set; } + public string RawCellInstanceName { get; private set; } + public string RawVersionName { get; private set; } + public string Separator { get; private set; } + public string TestResultsDirectory { get; private set; } + public string TextFileDirectory { get; private set; } + public string Ticks { get; private set; } + public string VersionDirectory { get; private set; } + public string WithActualCICN { get; private set; } + + public MethodBaseName(string after, string before, string cellInstanceConnectionName, string cellInstanceConnectionNameFromMethodBaseName, string cellInstanceName, string cellInstanceVersionName, string comment, string dummyDirectory, string fileFullName, string rawCellInstanceName, string rawVersionName, string separator, string testResultsDirectory, string textFileDirectory, string ticks, string versionDirectory, string withActualCICN) + { + After = after; + Before = before; + CellInstanceConnectionName = cellInstanceConnectionName; + CellInstanceConnectionNameFromMethodBaseName = cellInstanceConnectionNameFromMethodBaseName; + CellInstanceName = cellInstanceName; + CellInstanceVersionName = cellInstanceVersionName; + Comment = comment; + DummyDirectory = dummyDirectory; + FileFullName = fileFullName; + RawCellInstanceName = rawCellInstanceName; + RawVersionName = rawVersionName; + Separator = separator; + TestResultsDirectory = testResultsDirectory; + TextFileDirectory = textFileDirectory; + Ticks = ticks; + VersionDirectory = versionDirectory; + WithActualCICN = withActualCICN; + } + +} \ No newline at end of file diff --git a/Adaptation/_Tests/Shared/UnitTesting.cs b/Adaptation/_Tests/Shared/UnitTesting.cs index 3477030..1833834 100644 --- a/Adaptation/_Tests/Shared/UnitTesting.cs +++ b/Adaptation/_Tests/Shared/UnitTesting.cs @@ -13,9 +13,13 @@ namespace Adaptation._Tests.Shared; public class UnitTesting { + protected readonly bool _HasWaitForProperty; protected readonly IsEnvironment _IsEnvironment; + protected readonly string _TestContextPropertiesAsJson; public IsEnvironment IsEnvironment => _IsEnvironment; + public bool HasWaitForProperty => _HasWaitForProperty; + public string TestContextPropertiesAsJson => _TestContextPropertiesAsJson; public UnitTesting(TestContext testContext, Type declaringType) { @@ -23,38 +27,47 @@ public class UnitTesting _IsEnvironment = null; else { + string waitFor = "\"WaitFor\":"; string projectDirectory = GetProjectDirectory(testContext); - string json = JsonSerializer.Serialize(testContext.Properties); - string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode"); - if (!Directory.Exists(vsCodeDirectory)) - _ = Directory.CreateDirectory(vsCodeDirectory); - string launchText = GetLaunchText(); - File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText); - for (int i = 0; i < int.MaxValue; i++) + if (string.IsNullOrEmpty(projectDirectory)) + _IsEnvironment = null; + else { - if (!json.Contains("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) + _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) { - foreach (string testCategory in testCategoryAttribute.TestCategories) - _IsEnvironment = new IsEnvironment(testCategory); + 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) + { + 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); } } 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++) { @@ -65,8 +78,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/MET08ANLYSDIFAAST230.cs b/Adaptation/_Tests/Static/MET08ANLYSDIFAAST230.cs new file mode 100644 index 0000000..89eac85 --- /dev/null +++ b/Adaptation/_Tests/Static/MET08ANLYSDIFAAST230.cs @@ -0,0 +1,72 @@ +using Adaptation._Tests.Shared; +using Microsoft.Extensions.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Text; + +namespace Adaptation._Tests.Static; + +[TestClass] +public class MET08ANLYSDIFAAST230 : LoggingUnitTesting, IDisposable +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + internal static MET08ANLYSDIFAAST230 LoggingUnitTesting { get; private set; } + + public MET08ANLYSDIFAAST230() : base(testContext: null, declaringType: null) + { + if (LoggingUnitTesting is null) + throw new Exception(); + } + + public MET08ANLYSDIFAAST230(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType) + { + } + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) => LoggingUnitTesting ??= new MET08ANLYSDIFAAST230(testContext); + + [ClassCleanup()] + public static void ClassCleanup() + { + LoggingUnitTesting?.Logger?.LogInformation("Cleanup"); + LoggingUnitTesting?.Dispose(); + } + + [TestMethod] + public void TestDateTime() + { + DateTime dateTime = DateTime.Now; + Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString()); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging() + { + MethodBase methodBase = new StackFrame().GetMethod(); + StringBuilder results = new(); + (string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[] + { + new("MET08ANLYSDIFAAST230", "v2.47.5"), + }; + string staging = "http://mestsa07ec.ec.local:9003/CellInstanceServiceV2"; + Shared.PasteSpecialXml.EAF.XML.API.CellInstance.CellInstanceVersion cellInstanceVersion; + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); + foreach ((string cellInstanceName, string cellInstanceVersionName) in collection) + { + cellInstanceVersion = AdaptationTesting.GetCellInstanceVersion($"{staging}/{cellInstanceName}/{cellInstanceVersionName}/configuration"); + _ = results.AppendLine($"{cellInstanceName}\t{cellInstanceVersionName}\t{cellInstanceVersion.EdaConnection.PortNumber}"); + } + File.WriteAllText($"D:/Tmp/{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv", results.ToString()); + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + } + +} \ No newline at end of file diff --git a/Adaptation/_Tests/Static/SECS.cs b/Adaptation/_Tests/Static/SECS.cs new file mode 100644 index 0000000..698b9ae --- /dev/null +++ b/Adaptation/_Tests/Static/SECS.cs @@ -0,0 +1,72 @@ +using Adaptation._Tests.Shared; +using Microsoft.Extensions.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Text; + +namespace Adaptation._Tests.Static; + +[TestClass] +public class SECS : LoggingUnitTesting, IDisposable +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + internal static SECS LoggingUnitTesting { get; private set; } + + public SECS() : base(testContext: null, declaringType: null) + { + if (LoggingUnitTesting is null) + throw new Exception(); + } + + public SECS(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType) + { + } + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) => LoggingUnitTesting ??= new SECS(testContext); + + [ClassCleanup()] + public static void ClassCleanup() + { + LoggingUnitTesting?.Logger?.LogInformation("Cleanup"); + LoggingUnitTesting?.Dispose(); + } + + [TestMethod] + public void TestDateTime() + { + DateTime dateTime = DateTime.Now; + Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString()); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging() + { + MethodBase methodBase = new StackFrame().GetMethod(); + StringBuilder results = new(); + (string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[] + { + new("SPV01", "v2.43.0"), + }; + string staging = "http://mestsa07ec.ec.local:9003/CellInstanceServiceV2"; + Shared.PasteSpecialXml.EAF.XML.API.CellInstance.CellInstanceVersion cellInstanceVersion; + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); + foreach ((string cellInstanceName, string cellInstanceVersionName) in collection) + { + cellInstanceVersion = AdaptationTesting.GetCellInstanceVersion($"{staging}/{cellInstanceName}/{cellInstanceVersionName}/configuration"); + _ = results.AppendLine($"{cellInstanceName}\t{cellInstanceVersionName}\t{cellInstanceVersion.EdaConnection.PortNumber}"); + } + File.WriteAllText($"D:/Tmp/{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv", results.ToString()); + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + } + +} \ No newline at end of file diff --git a/Adaptation/appsettings.Development.json b/Adaptation/appsettings.Development.json index 923c216..f7e0b36 100644 --- a/Adaptation/appsettings.Development.json +++ b/Adaptation/appsettings.Development.json @@ -59,7 +59,7 @@ "Password": "tLIPgqM6R9hVQOteRnTHwPqIg3Zxv8CohTjFkjkFz8k=" }, { - "Use": true, + "Use": false, "Letter": "k", "Share": "\\\\messdv002.na.infineon.com\\GaN_NEC\\Characterization", "User": "INFINEON\\MESGaNEAF", @@ -80,35 +80,35 @@ "Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00=" }, { - "Use": true, + "Use": false, "Letter": "n", "Share": "\\\\10.95.154.22\\C", "User": "10.95.154.22\\Aixtron", "Password": "DYVBOr2HJdB7KOhd/IFhLA==" }, { - "Use": true, + "Use": false, "Letter": "o", "Share": "\\\\10.95.154.16\\Aixtron", "User": "10.95.154.16\\Aixtron", "Password": "DYVBOr2HJdB7KOhd/IFhLA==" }, { - "Use": true, + "Use": false, "Letter": "p", "Share": "\\\\10.95.154.15\\Aixtron", "User": "10.95.154.15\\Aixtron", "Password": "DYVBOr2HJdB7KOhd/IFhLA==" }, { - "Use": true, + "Use": false, "Letter": "q", "Share": "\\\\10.95.154.21\\Data", "User": "10.95.154.21\\XRD04Admin", "Password": "v1NOsEOCvbnhzKabspPcCQ==" }, { - "Use": true, + "Use": false, "Letter": "r", "Share": "\\\\10.95.154.23\\Data", "User": "\"10.95.154.23\\infineon us\"", diff --git a/Adaptation/appsettings.json b/Adaptation/appsettings.json index bfeb1ac..d15d437 100644 --- a/Adaptation/appsettings.json +++ b/Adaptation/appsettings.json @@ -59,7 +59,7 @@ "Password": "tLIPgqM6R9hVQOteRnTHwPqIg3Zxv8CohTjFkjkFz8k=" }, { - "Use": true, + "Use": false, "Letter": "k", "Share": "\\\\messdv002.na.infineon.com\\GaN_NEC\\Characterization", "User": "INFINEON\\MESGaNEAF", @@ -80,35 +80,35 @@ "Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00=" }, { - "Use": true, + "Use": false, "Letter": "n", "Share": "\\\\10.95.154.22\\C", "User": "10.95.154.22\\Aixtron", "Password": "DYVBOr2HJdB7KOhd/IFhLA==" }, { - "Use": true, + "Use": false, "Letter": "o", "Share": "\\\\10.95.154.16\\Aixtron", "User": "10.95.154.16\\Aixtron", "Password": "DYVBOr2HJdB7KOhd/IFhLA==" }, { - "Use": true, + "Use": false, "Letter": "p", "Share": "\\\\10.95.154.15\\Aixtron", "User": "10.95.154.15\\Aixtron", "Password": "DYVBOr2HJdB7KOhd/IFhLA==" }, { - "Use": true, + "Use": false, "Letter": "q", "Share": "\\\\10.95.154.21\\Data", "User": "10.95.154.21\\XRD04Admin", "Password": "v1NOsEOCvbnhzKabspPcCQ==" }, { - "Use": true, + "Use": false, "Letter": "r", "Share": "\\\\10.95.154.23\\Data", "User": "\"10.95.154.23\\infineon us\"", diff --git a/Adaptation/package.json b/Adaptation/package.json index 7c289a0..aa55fa0 100644 --- a/Adaptation/package.json +++ b/Adaptation/package.json @@ -10,17 +10,17 @@ "MSBuild": "\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe\" /target:Build /restore:True /p:RestoreSources=https://api.nuget.org/v3/index.json%3Bhttps://packagemanagement.eu.infineon.com:4430/api/v2/%3Bhttps://tfs.intra.infineon.com/tfs/ManufacturingIT/_packaging/eaf/nuget/v3/index.json /DetailedSummary /ConsoleLoggerParameters:PerformanceSummary;ErrorsOnly; /property:Configuration=Debug;TargetFrameworkVersion=v4.8 ../MET08ANLYSDIFAAST230.csproj", "pull": "git pull", "garbage-collect": "git gc", - "AT-CreateSelfDescription.Staging.v2_43_0-MET08ANLYSDIFAAST230": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0 & ClassName~MET08ANLYSDIFAAST230\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "AX-CreateSelfDescription.Staging.v2_43_0-SPV01_EQPT": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0 & ClassName~SPV01_EQPT\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "AY-CreateSelfDescription.Staging.v2_43_0-SPV01": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0 & ClassName~SPV01\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "AZ-CreateSelfDescription.Staging.v2_43_0": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "BA-Extract.Staging.v2_43_0-MET08ANLYSDIFAAST230-Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles637710931421087642__Normal": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~MET08ANLYSDIFAAST230 & Name~Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles637710931421087642__Normal\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "BB-Extract.Staging.v2_43_0-MET08ANLYSDIFAAST230-Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi637884771880950000__Normal": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~MET08ANLYSDIFAAST230 & Name~Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi637884771880950000__Normal\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "BC-Extract.Staging.v2_43_0-SPV01-Staging__v2_43_0__SPV01__RsM643047560320000000__Normal": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~SPV01 & Name~Staging__v2_43_0__SPV01__RsM643047560320000000__Normal\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "BT-Extract.Staging.v2_43_0-MET08ANLYSDIFAAST230": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~MET08ANLYSDIFAAST230\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "BX-Extract.Staging.v2_43_0-SPV01_EQPT": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~SPV01_EQPT\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "BY-Extract.Staging.v2_43_0-SPV01": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~SPV01\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", - "BZ-Extract.Staging.v2_43_0": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")", + "AT-CreateSelfDescription.Staging.v2_43_0-MET08ANLYSDIFAAST230": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0 & ClassName~MET08ANLYSDIFAAST230\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "AX-CreateSelfDescription.Staging.v2_43_0-SPV01_EQPT": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0 & ClassName~SPV01_EQPT\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "AY-CreateSelfDescription.Staging.v2_43_0-SPV01": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0 & ClassName~SPV01\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "AZ-CreateSelfDescription.Staging.v2_43_0": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "BA-Extract.Staging.v2_43_0-MET08ANLYSDIFAAST230-Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles637710931421087642__Normal": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~MET08ANLYSDIFAAST230 & Name~Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles637710931421087642__Normal\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "BB-Extract.Staging.v2_43_0-MET08ANLYSDIFAAST230-Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi637884771880950000__Normal": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~MET08ANLYSDIFAAST230 & Name~Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi637884771880950000__Normal\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "BC-Extract.Staging.v2_43_0-SPV01-Staging__v2_43_0__SPV01__RsM643047560320000000__Normal": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~SPV01 & Name~Staging__v2_43_0__SPV01__RsM643047560320000000__Normal\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "BT-Extract.Staging.v2_43_0-MET08ANLYSDIFAAST230": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~MET08ANLYSDIFAAST230\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "BX-Extract.Staging.v2_43_0-SPV01_EQPT": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~SPV01_EQPT\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "BY-Extract.Staging.v2_43_0-SPV01": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~SPV01\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", + "BZ-Extract.Staging.v2_43_0": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")", "EDA": "\\\\messv02ecc1.ec.local\\EC_EDA\\Staging\\PDSF\\MET08ANLYSDIFAAST230\\So~~~~~~~~~~~~~~~urce", "OpenInsightMetrologyViewer": "\\\\messv02ecc1.ec.local\\EC_EDA\\Staging\\PDSF\\MET08ANLYSDIFAAST230\\10~~~~~~~~~~~~~~~\\messv02ecc1.ec.local\\EC_Metrology_Si\\PDSF\\MET08ANLYSDIFAAST230\\Source", "IQSSi": "\\\\messv02ecc1.ec.local\\EC_EDA\\Staging\\PDSF\\MET08ANLYSDIFAAST230\\11~~~~~~~~~~~~~~~\\messv02ecc1.ec.local\\EC_SPC_Si\\PDSF\\MET08ANLYSDIFAAST230\\Source", diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 801ba2f..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env groovy -/* groovylint-disable CompileStatic, ConsecutiveStringConcatenation, DuplicateNumberLiteral, DuplicateStringLiteral, LineLength, NestedBlockDepth, NoDef, VariableTypeRequired */ -import groovy.transform.Field - -@Field String _DDrive = 'D:/' -@Field String _AssemblyName = '...' -@Field String _TargetLocation = '...' -@Field String _GitCommitSeven = '...' -@Field String _GitName = 'MET08ANLYSDIFAAST230' -@Field String _TestProjectDirectory = 'Adaptation' -@Field String _AgentStaging = 'mestsa07ec-ecmeseaf' -@Field String _DDriveNet = "${_DDrive}Framework4.8" -@Field String _AgentProduction = 'messa08ec-ecmeseaf' -@Field String _AgentDevelopment = 'mestsa003-mesedasvc' -@Field String _ProgramFilesDotnet = 'C:/Program Files/dotnet/dotnet.exe' -@Field String _ProgramFilesMSBuild = 'C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe' - -pipeline { - agent { - label env.JENKINS_ENVIRONMENT == 'Development' ? _AgentDevelopment : env.JENKINS_ENVIRONMENT == 'Staging' ? _AgentStaging : env.JENKINS_ENVIRONMENT == 'Production' ? _AgentProduction : 'Else' - } - parameters { - string(name: 'GIT_SERVER', defaultValue: env.JENKINS_ENVIRONMENT == 'Development' ? 'mestsa003.infineon.com' : 'mestsa07ec.ec.local', description: 'git server') - string(name: 'DEFAULT_FILE_SERVER', defaultValue: env.JENKINS_ENVIRONMENT == 'Development' ? 'messv02ecc1_ec_local' : 'messv02ecc1.ec.local', description: 'Default file server...') - } - stages { - // stage('Git') { - // steps { - // bat(returnStatus: true, script: 'git init') - // bat(returnStatus: true, script: 'git remote add origin \\\\' + params.GIT_SERVER + '\\Git\\' + _GitName + '.git') - // bat(returnStatus: true, script: 'git pull origin master') - // } - // } - stage('Setup') { - steps { - script { - _AssemblyName = "${env.JOB_NAME}" - // _GitCommitSeven = '1234567' - _GitCommitSeven = env.GIT_COMMIT.substring(0, 7) - def files = findFiles(glob: '*.csproj') - if (files.length != 1) { - error("Build failed because couldn't find a *.csproj file") - } - echo """ - ${files[0].name} - ${files[0].path} - ${files[0].directory} - ${files[0].length} - ${files[0].lastModified} - """ - _AssemblyName = files[0].name.split('[.]csproj')[0] - _TargetLocation = "\\\\${params.DEFAULT_FILE_SERVER}\\EC_EAFRepository\\${env.JENKINS_ENVIRONMENT}\\DeploymentStorage\\Adaptation_${_AssemblyName}" - } - } - } - stage('Info') { - steps { - echo "_AssemblyName ${_AssemblyName}" // ... - echo "BUILD_NUMBER ${env.BUILD_NUMBER}" // 11 - echo "DEFAULT_FILE_SERVER ${params.DEFAULT_FILE_SERVER}" // 11 - echo "GIT_BRANCH ${env.GIT_BRANCH}" // origin/master - echo "GIT_COMMIT ${env.GIT_COMMIT}" // 73b814069f2cf0173a62a8228815a9bc9ba93c41 - echo "GIT_SERVER ${params.GIT_SERVER}" // ... - echo "GIT_URL ${env.GIT_URL}" // D:\ProgramData\Git\....git - echo "JENKINS_ENVIRONMENT ${env.JENKINS_ENVIRONMENT}" // 11 - echo "JENKINS_URL ${env.JENKINS_URL}" // http://localhost:8080/ - echo "JOB_NAME ${env.JOB_NAME}" // ... - echo "WORKSPACE ${env.WORKSPACE}" // D:\.jenkins\_\... - } - } - // stage('Restore') { - // steps { - // bat(returnStatus: true, script: 'dotnet --info') - // } - // } - stage('Safe storage of app secrets') { - steps { - dir(_TestProjectDirectory) { - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'user-secrets init') - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'user-secrets set "BuildNumber" "' + env.BUILD_NUMBER + '"') - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'user-secrets set "GitCommitSeven" "' + _GitCommitSeven + '"') - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'user-secrets set "Server" "' + params.DEFAULT_FILE_SERVER + '"') - } - } - } - stage('Core Build') { - steps { - echo "Build number is ${currentBuild.number}" - dir(_TestProjectDirectory) { - bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + - 'build --runtime win-x64 --self-contained --verbosity quiet') - } - } - } - // stage('Test') { - // options { - // timeout(time: 10, unit: 'MINUTES') - // } - // steps { - // dir(_TestProjectDirectory) { - // bat('dotnet --info') - // } - // } - // } - stage('Framework Build') { - steps { - echo "Build number is ${currentBuild.number}" - bat(returnStatus: true, script: '"' + _ProgramFilesMSBuild + '" ' + - '/target:Restore ' + - '/detailedsummary ' + - '/consoleloggerparameters:PerformanceSummary;ErrorsOnly; ' + - '/property:Configuration=Debug;TargetFrameworkVersion=v4.8 ' + - _AssemblyName + '.csproj') - bat(returnStatus: true, script: '"' + _ProgramFilesMSBuild + '" ' + - '/target:Build ' + - '/detailedsummary ' + - '/consoleloggerparameters:PerformanceSummary;ErrorsOnly; ' + - '/property:Configuration=Debug;TargetFrameworkVersion=v4.8 ' + - _AssemblyName + '.csproj') - } - } - stage('Commit Id') { - steps { - dir('bin/Debug') { - writeFile file: "${_AssemblyName}.txt", text: "${env.GIT_COMMIT}-${env.BUILD_NUMBER}-${env.GIT_URL}" - } - } - } - stage('Package') { - steps { - fileOperations([fileZipOperation(folderPath: 'bin/Debug', outputFolderPath: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${env.JOB_NAME}-Debug")]) - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*", renameFiles: false, sourceCaptureExpression: '', targetLocation: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${env.JOB_NAME}-Debug", targetNameExpression: '')]) - } - } - // stage('Force Fail') { - // steps { - // error("Build failed because of this and that..") - // } - // } - stage('Copy Files to: file-share') { - steps { - dir('bin/Debug') { - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*.txt", renameFiles: false, sourceCaptureExpression: '', targetLocation: _TargetLocation, targetNameExpression: '')]) - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*.dll", renameFiles: false, sourceCaptureExpression: '', targetLocation: _TargetLocation, targetNameExpression: '')]) - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*.exe", renameFiles: false, sourceCaptureExpression: '', targetLocation: _TargetLocation, targetNameExpression: '')]) - fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*.pdb", renameFiles: false, sourceCaptureExpression: '', targetLocation: _TargetLocation, targetNameExpression: '')]) - } - } - } - } - post { - always { - dir('bin') { - deleteDir() - } - dir('obj') { - deleteDir() - } - dir(_TestProjectDirectory + '/bin') { - deleteDir() - } - dir(_TestProjectDirectory + '/obj') { - deleteDir() - } - cleanWs() - } - } -} diff --git a/MET08ANLYSDIFAAST230.csproj b/MET08ANLYSDIFAAST230.csproj index 9fa0e4e..4ef0bd8 100644 --- a/MET08ANLYSDIFAAST230.csproj +++ b/MET08ANLYSDIFAAST230.csproj @@ -11,7 +11,8 @@ MET08ANLYSDIFAAST230 MET08ANLYSDIFAAST230 v4.8 - win-x86 + win-x86 + win 512 @@ -105,6 +106,7 @@ + @@ -112,6 +114,12 @@ + + Component + + + + @@ -148,7 +156,7 @@ - 2.43.0 + 2.47.0 6.0.3 diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index c77f4ae..ba3126b 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.43.0.0")] -[assembly: AssemblyFileVersion("2.43.0.0")] +[assembly: AssemblyVersion("2.47.5.0")] +[assembly: AssemblyFileVersion("2.47.5.0")]