Fixed Archive and Added OpenInsight

This commit is contained in:
Mike Phares 2023-03-15 16:31:04 -07:00
parent 8a4c91014c
commit 3675677d78
46 changed files with 2154 additions and 799 deletions

13
.gitignore vendored
View File

@ -331,8 +331,11 @@ ASALocalRun/
## ##
## Visual Studio Code ## Visual Studio Code
## ##
.vscode/* */!.vscode/extensions.json
!.vscode/settings.json */!.vscode/launch.json
!.vscode/tasks.json */!.vscode/settings.json
!.vscode/launch.json */!.vscode/tasks.json
!.vscode/extensions.json */.vscode/*
*/.vscode/ReportGenerator/*
*.lnk

172
.groovy
View File

@ -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()
}
}
}

View File

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "5.1.15",
"commands": [
"reportgenerator"
]
}
}
}

View File

@ -76,13 +76,18 @@ csharp_using_directive_placement = outside_namespace
dotnet_code_quality_unused_parameters = all dotnet_code_quality_unused_parameters = all
dotnet_code_quality_unused_parameters = non_public # IDE0060: Remove unused parameter dotnet_code_quality_unused_parameters = non_public # IDE0060: Remove unused parameter
dotnet_code_quality.CAXXXX.api_surface = private, internal 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.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.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.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.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.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.IDE0005.severity = warning # Using directive is unnecessary
dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed
dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049)
dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter dotnet_diagnostic.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.severity = warning
dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case 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_other_operators = never_if_unnecessary
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
dotnet_style_predefined_type_for_locals_parameters_members = true 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_auto_properties = true:warning
dotnet_style_prefer_compound_assignment = true:warning dotnet_style_prefer_compound_assignment = true:warning
dotnet_style_prefer_conditional_expression_over_assignment = false dotnet_style_prefer_conditional_expression_over_assignment = false

View File

@ -4,7 +4,7 @@
"name": ".NET Core Attach", "name": ".NET Core Attach",
"type": "coreclr", "type": "coreclr",
"request": "attach", "request": "attach",
"processId": 20196 "processId": 25008
} }
] ]
} }

View File

@ -22,6 +22,7 @@
"Villach", "Villach",
"Vrng" "Vrng"
], ],
"coverage-gutters.coverageBaseDir": "../../../../MET08ANLYSDIFAAST230/05_TestResults/TestResults/**",
"workbench.colorCustomizations": { "workbench.colorCustomizations": {
"activityBar.activeBackground": "#0fc5f0", "activityBar.activeBackground": "#0fc5f0",
"activityBar.activeBorder": "#d20dac", "activityBar.activeBorder": "#d20dac",
@ -39,7 +40,8 @@
"titleBar.activeBackground": "#0c9ec0", "titleBar.activeBackground": "#0c9ec0",
"titleBar.activeForeground": "#e7e7e7", "titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#0c9ec099", "titleBar.inactiveBackground": "#0c9ec099",
"titleBar.inactiveForeground": "#e7e7e799" "titleBar.inactiveForeground": "#e7e7e799",
"commandCenter.border": "#e7e7e799"
}, },
"peacock.color": "#0c9ec0" "peacock.color": "#0c9ec0"
} }

View File

@ -103,10 +103,10 @@ public class FileRead : Shared.FileRead, IFileRead
return results; return results;
} }
private void FileCopy(string reportFullPath, DateTime dateTime) private void FileCopy<T>(string reportFullPath, DateTime dateTime, List<T> descriptions) where T : Shared.Properties.IDescription
{ {
bool isDummyRun = false; bool isDummyRun = false;
List<(Shared.Properties.IScopeInfo, string)> tuples = new(); List<(Shared.Properties.IScopeInfo, string)> collection = new();
string successDirectory = _FileConnectorConfiguration.AlternateTargetFolder; string successDirectory = _FileConnectorConfiguration.AlternateTargetFolder;
string fileNameAfterUnderscoreSplit = GetFileNameAfterUnderscoreSplit(reportFullPath); string fileNameAfterUnderscoreSplit = GetFileNameAfterUnderscoreSplit(reportFullPath);
string duplicateDirectory = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, fileNameAfterUnderscoreSplit); string duplicateDirectory = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, fileNameAfterUnderscoreSplit);
@ -114,7 +114,7 @@ public class FileRead : Shared.FileRead, IFileRead
_ = Directory.CreateDirectory(duplicateDirectory); _ = Directory.CreateDirectory(duplicateDirectory);
string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath)); string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath));
File.Copy(reportFullPath, duplicateFile, overwrite: true); File.Copy(reportFullPath, duplicateFile, overwrite: true);
WaitForFileConsumption(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile); WaitForFileConsumption(dateTime, descriptions, isDummyRun, successDirectory, duplicateDirectory, collection, duplicateFile);
} }
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
@ -127,7 +127,7 @@ public class FileRead : Shared.FileRead, IFileRead
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements); List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
FileCopy(reportFullPath, dateTime); FileCopy(reportFullPath, dateTime, descriptions);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>()); results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
return results; return results;
} }

View File

@ -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) if (dateTime == DateTime.MinValue)
{ } { }
@ -128,12 +128,17 @@ public class FileRead : Shared.FileRead, IFileRead
string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID); string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID);
if (!Directory.Exists(jobIdDirectory)) if (!Directory.Exists(jobIdDirectory))
_ = Directory.CreateDirectory(jobIdDirectory); _ = Directory.CreateDirectory(jobIdDirectory);
string[] matchDirectories = new string[] { GetDirectoriesRecursively(jobIdDirectory, logisticsSequence).FirstOrDefault() }; if (!Directory.GetDirectories(jobIdDirectory).Any())
if ((matchDirectories is null) || matchDirectories.Length != 1) File.Copy(reportFullPath, Path.Combine(destinationArchiveDirectory, Path.GetFileName(reportFullPath)));
throw new Exception("Didn't find directory by logistics sequence"); else
string sourceDirectory = Path.GetDirectoryName(matchDirectories[0]); {
destinationArchiveDirectory = Path.Combine(destinationArchiveDirectory, Path.GetFileName(sourceDirectory)); string[] matchDirectories = GetDirectoriesRecursively(jobIdDirectory, logisticsSequence).ToArray();
Directory.Move(sourceDirectory, destinationArchiveDirectory); 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<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
@ -146,7 +151,7 @@ public class FileRead : Shared.FileRead, IFileRead
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements); List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
MoveArchive(dateTime); MoveArchive(reportFullPath, dateTime);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>()); results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
return results; return results;
} }

View File

@ -103,17 +103,17 @@ public class FileRead : Shared.FileRead, IFileRead
return results; return results;
} }
private void FileCopy(string reportFullPath, DateTime dateTime) private void FileCopy<T>(string reportFullPath, DateTime dateTime, List<T> descriptions) where T : Shared.Properties.IDescription
{ {
bool isDummyRun = false; bool isDummyRun = false;
string successDirectory = string.Empty; 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); string duplicateDirectory = Path.Combine(_FileConnectorConfiguration.SourceFileLocation, _CellInstanceName);
if (!Directory.Exists(duplicateDirectory)) if (!Directory.Exists(duplicateDirectory))
_ = Directory.CreateDirectory(duplicateDirectory); _ = Directory.CreateDirectory(duplicateDirectory);
string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath)); string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath));
File.Copy(reportFullPath, duplicateFile, overwrite: true); File.Copy(reportFullPath, duplicateFile, overwrite: true);
WaitForFileConsumption(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile); WaitForFileConsumption(dateTime, descriptions, isDummyRun, successDirectory, duplicateDirectory, collection, duplicateFile);
} }
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
@ -128,7 +128,7 @@ public class FileRead : Shared.FileRead, IFileRead
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements); List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
FileCopy(reportFullPath, dateTime); FileCopy(reportFullPath, dateTime, descriptions);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>()); results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
return results; return results;
} }

View File

@ -158,6 +158,7 @@ public class FileRead : Shared.FileRead, IFileRead
long preWait; long preWait;
string errFile; string errFile;
string checkDirectory; string checkDirectory;
string noWaitDirectory;
foreach ((string matchingFile, string checkFile) in collection) foreach ((string matchingFile, string checkFile) in collection)
{ {
errFile = string.Concat(checkFile, ".err"); errFile = string.Concat(checkFile, ".err");
@ -165,6 +166,9 @@ public class FileRead : Shared.FileRead, IFileRead
if (!Directory.Exists(checkDirectory)) if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory); _ = Directory.CreateDirectory(checkDirectory);
File.Move(matchingFile, checkFile); File.Move(matchingFile, checkFile);
noWaitDirectory = Path.Combine(checkDirectory, "NoWaitDirectory");
if (Directory.Exists(noWaitDirectory))
continue;
if (_FileConnectorConfiguration?.FileHandleWaitTime is null) if (_FileConnectorConfiguration?.FileHandleWaitTime is null)
preWait = DateTime.Now.AddMilliseconds(1234).Ticks; preWait = DateTime.Now.AddMilliseconds(1234).Ticks;
else else

View File

@ -3,10 +3,13 @@ using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
using Adaptation.Shared; using Adaptation.Shared;
using Adaptation.Shared.Duplicator; using Adaptation.Shared.Duplicator;
using Adaptation.Shared.Methods; using Adaptation.Shared.Methods;
using Adaptation.Shared.Metrology;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.FileHandlers.OpenInsight; namespace Adaptation.FileHandlers.OpenInsight;
@ -14,6 +17,11 @@ namespace Adaptation.FileHandlers.OpenInsight;
public class FileRead : Shared.FileRead, IFileRead 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<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, 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); throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator) if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName); 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<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
@ -103,16 +115,53 @@ public class FileRead : Shared.FileRead, IFileRead
return results; return results;
} }
private static void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, List<Shared.Properties.IDescription> descriptions, Test[] tests) internal static string GetLines(Logistics logistics, List<Shared.Properties.IDescription> descriptions)
{ {
if (reportFullPath is null) StringBuilder results = new();
{ } Shared.Properties.IDescription x = descriptions[0];
if (dateTime == DateTime.MinValue) char del = x.MesEntity == x.Reactor ? '\t' : '~';
{ } _ = results.Append(logistics.MesEntity).Append(del)
if (descriptions is null) .Append(x.MesEntity).Append(del);
{ } return results.ToString();
if (tests is null) }
{ }
private void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, string logistics, List<Shared.Properties.IDescription> 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<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
@ -125,7 +174,7 @@ public class FileRead : Shared.FileRead, IFileRead
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements); List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
SaveOpenInsightFile(reportFullPath, dateTime, descriptions, tests); SaveOpenInsightFile(reportFullPath, dateTime, pdsf.Item1, descriptions, tests);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>()); results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
return results; return results;
} }

View File

@ -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<JsonElement[]>(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<JsonElement>(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
}

View File

@ -103,15 +103,15 @@ public class FileRead : Shared.FileRead, IFileRead
return results; return results;
} }
private void FileCopy(string reportFullPath, DateTime dateTime) private void FileCopy<T>(string reportFullPath, DateTime dateTime, List<T> descriptions) where T : Shared.Properties.IDescription
{ {
bool isDummyRun = false; bool isDummyRun = false;
string successDirectory = string.Empty; string successDirectory = string.Empty;
List<(Shared.Properties.IScopeInfo, string)> tuples = new(); List<(Shared.Properties.IScopeInfo, string)> collection = new();
string duplicateDirectory = _FileConnectorConfiguration.TargetFileLocation; string duplicateDirectory = _FileConnectorConfiguration.TargetFileLocation;
string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath)); string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath));
File.Copy(reportFullPath, duplicateFile, overwrite: true); File.Copy(reportFullPath, duplicateFile, overwrite: true);
WaitForFileConsumption(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile); WaitForFileConsumption(dateTime, descriptions, isDummyRun, successDirectory, duplicateDirectory, collection, duplicateFile);
} }
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
@ -126,7 +126,7 @@ public class FileRead : Shared.FileRead, IFileRead
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements); List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
FileCopy(reportFullPath, dateTime); FileCopy(reportFullPath, dateTime, descriptions);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>()); results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tests, jsonElements, new List<FileInfo>());
return results; return results;
} }

View File

@ -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; }
}

View File

@ -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);
}

View File

@ -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<string, MonIn> _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<string, MonIn> keyValuePair = new();
foreach (KeyValuePair<string, MonIn> instance in _Instances)
{
if (instance.Value == this)
{
keyValuePair = instance;
break;
}
}
_ = _Instances.Remove(keyValuePair.Key);
_WebClient?.Dispose();
}
}

View File

@ -0,0 +1,11 @@
namespace Infineon.Monitoring.MonA;
public enum State
{
Up,
Ok,
Warning,
Critical,
Down,
Unknown,
}

View File

@ -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

View File

@ -15,6 +15,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<VSTestLogger>trx</VSTestLogger> <VSTestLogger>trx</VSTestLogger>
<VSTestCollect>XPlat Code Coverage</VSTestCollect>
<VSTestResultsDirectory>../../../../MET08ANLYSDIFAAST230/05_TestResults/TestResults</VSTestResultsDirectory> <VSTestResultsDirectory>../../../../MET08ANLYSDIFAAST230/05_TestResults/TestResults</VSTestResultsDirectory>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@ -32,50 +33,8 @@
<DefineConstants>Linux</DefineConstants> <DefineConstants>Linux</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" /> <PackageReference Include="coverlet.collector" Version="3.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="6.0.0" /> <PackageReference Include="FFMpegCore" Version="5.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="System.Data.OleDb" Version="6.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FFMpegCore" Version="4.8.0" />
<PackageReference Include="Infineon.Monitoring.MonA" Version="3.0.0" />
<PackageReference Include="Infineon.Yoda" Version="5.4.1" />
<PackageReference Include="Instances" Version="2.0.0" />
<PackageReference Include="RoboSharp" Version="1.2.7" />
<PackageReference Include="Tesseract" Version="4.1.1" />
<PackageReference Include="Tibco.Rendezvous" Version="8.5.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="External.Common.Logging.Core" Version="3.3.1"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="External.Common.Logging" Version="3.3.1"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="External.log4net" Version="2.0.8"><NoWarn>NU1701</NoWarn></PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Pdfbox" Version="1.1.1"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="IKVM.AWT.WinForms" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference> <PackageReference Include="IKVM.AWT.WinForms" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="IKVM.OpenJDK.Core" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference> <PackageReference Include="IKVM.OpenJDK.Core" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="IKVM.OpenJDK.Media" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference> <PackageReference Include="IKVM.OpenJDK.Media" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference>
@ -83,6 +42,41 @@
<PackageReference Include="IKVM.OpenJDK.Util" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference> <PackageReference Include="IKVM.OpenJDK.Util" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="IKVM.OpenJDK.XML.API" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference> <PackageReference Include="IKVM.OpenJDK.XML.API" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="IKVM.Runtime" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference> <PackageReference Include="IKVM.Runtime" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="Instances" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="7.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="Pdfbox" Version="1.1.1"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="RoboSharp" Version="1.2.8" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageReference Include="System.Data.OleDb" Version="7.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
<PackageReference Include="Tesseract" Version="5.2.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Tibco.Rendezvous" Version="8.5.0" />
<PackageReference Include="Infineon.Yoda" Version="5.4.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Infineon.Mesa.PDF.Text.Stripper" Version="4.8.0.1"><NoWarn>NU1701</NoWarn></PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="External.Common.Logging.Core" Version="3.3.1"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="External.Common.Logging" Version="3.3.1"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="External.log4net" Version="2.0.8"><NoWarn>NU1701</NoWarn></PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="appsettings.json"> <None Include="appsettings.json">

View File

@ -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

View File

@ -21,7 +21,13 @@ public class Description : IDescription, Properties.IDescription
public string ReportFullPath { get; set; } public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; } public string ProcessJobID { get; set; }
public string MID { 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"; string IDescription.GetEventDescription() => "File Has been read and parsed";
@ -139,4 +145,6 @@ public class Description : IDescription, Properties.IDescription
return result; return result;
} }
internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt";
} }

View File

@ -54,6 +54,7 @@ public class FileRead : Properties.IFileRead
string Properties.IFileRead.EventName => _EventName; string Properties.IFileRead.EventName => _EventName;
string Properties.IFileRead.MesEntity => _MesEntity; string Properties.IFileRead.MesEntity => _MesEntity;
bool Properties.IFileRead.IsEAFHosted => _IsEAFHosted; bool Properties.IFileRead.IsEAFHosted => _IsEAFHosted;
bool Properties.IFileRead.IsDuplicator => _IsDuplicator;
string Properties.IFileRead.EquipmentType => _EquipmentType; string Properties.IFileRead.EquipmentType => _EquipmentType;
string Properties.IFileRead.ReportFullPath => _ReportFullPath; string Properties.IFileRead.ReportFullPath => _ReportFullPath;
string Properties.IFileRead.CellInstanceName => _CellInstanceName; string Properties.IFileRead.CellInstanceName => _CellInstanceName;
@ -259,24 +260,23 @@ public class FileRead : Properties.IFileRead
return results; return results;
} }
protected static string GetTupleFile(Logistics logistics, Properties.IScopeInfo scopeInfo, string duplicateDirectory) protected static string GetTupleFile<T>(Logistics logistics, List<T> descriptions, Properties.IScopeInfo scopeInfo, string duplicateDirectory) where T : Properties.IDescription
{ {
string result; string result;
string rds; string rds;
string dateValue; string dateValue;
string datePlaceholder; string rdsPlaceholder = "%RDS%";
string[] segments = logistics.MID.Split('-'); if (!descriptions.Any() || string.IsNullOrEmpty(descriptions[0].RDS))
if (segments.Length < 2) rds = logistics.MID;
rds = "%RDS%";
else else
rds = segments[1]; rds = descriptions[0].RDS;
segments = scopeInfo.FileName.Split(new string[] { "DateTime:" }, StringSplitOptions.RemoveEmptyEntries); string[] segments = scopeInfo.FileName.Split(new string[] { "DateTime:" }, StringSplitOptions.RemoveEmptyEntries);
if (segments.Length == 0) if (segments.Length == 0)
result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileNameWithoutExtension.Replace("%RDS%", rds)); result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileNameWithoutExtension.Replace(rdsPlaceholder, rds));
else else
{ {
datePlaceholder = "%DateTime%";
segments = segments[1].Split('%'); segments = segments[1].Split('%');
string datePlaceholder = "%DateTime%";
dateValue = logistics.DateTimeFromSequence.ToString(segments[0]); dateValue = logistics.DateTimeFromSequence.ToString(segments[0]);
foreach (string segment in scopeInfo.FileName.Split('%')) foreach (string segment in scopeInfo.FileName.Split('%'))
{ {
@ -284,18 +284,19 @@ public class FileRead : Properties.IFileRead
continue; continue;
datePlaceholder = string.Concat('%', segment, '%'); 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('%')) if (result.Contains('%'))
throw new Exception("Placeholder exists!"); throw new Exception("Placeholder exists!");
return result; 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<T>(string sourceDirectoryCloaking, Logistics logistics, DateTime dateTime, List<T> descriptions, string successDirectory, string duplicateDirectory, string duplicateFile, List<(Properties.IScopeInfo, string)> collection) where T : Properties.IDescription
{ {
bool check; bool check;
long preWait; long preWait;
string tupleFile; string tupleFile;
string tupleFileName = string.Empty;
List<string> duplicateFiles = new(); List<string> duplicateFiles = new();
StringBuilder stringBuilder = new(); StringBuilder stringBuilder = new();
List<int> consumedFileIndices = new(); List<int> consumedFileIndices = new();
@ -305,26 +306,28 @@ public class FileRead : Properties.IFileRead
preWait = dateTime.AddMilliseconds(1234).Ticks; preWait = dateTime.AddMilliseconds(1234).Ticks;
else else
preWait = dateTime.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks; preWait = dateTime.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks;
if (!tuples.Any()) if (!collection.Any())
duplicateFiles.Add(duplicateFile); duplicateFiles.Add(duplicateFile);
string fileName = Path.GetFileNameWithoutExtension(logistics.ReportFullPath); string fileName = Path.GetFileNameWithoutExtension(logistics.ReportFullPath);
string successFile = string.Concat(successDirectory, @"\", Path.GetFileName(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(@"\")) if (scopeInfo.FileName.StartsWith(@"\"))
tupleFile = scopeInfo.FileName; tupleFile = scopeInfo.FileName;
else if (!scopeInfo.FileName.Contains('%')) else if (!scopeInfo.FileName.Contains('%'))
tupleFile = string.Concat(duplicateDirectory, @"\", fileName, "_", scopeInfo.FileNameWithoutExtension, ".pdsfc"); tupleFile = string.Concat(duplicateDirectory, @"\", fileName, "_", scopeInfo.FileNameWithoutExtension, ".pdsfc");
else else
tupleFile = GetTupleFile(logistics, scopeInfo, duplicateDirectory); tupleFile = GetTupleFile(logistics, descriptions, scopeInfo, duplicateDirectory);
tupleFileName = Path.GetFileNameWithoutExtension(tupleFile).Split('.')[0];
duplicateFiles.Add(tupleFile); duplicateFiles.Add(tupleFile);
File.WriteAllText(tupleFile, text); if (_IsEAFHosted)
File.WriteAllText(tupleFile, text);
} }
for (short i = 0; i < short.MaxValue; i++) for (short i = 0; i < short.MaxValue; i++)
{ {
if (DateTime.Now.Ticks > preWait) if (DateTime.Now.Ticks > preWait)
break; break;
Thread.Sleep(500); Thread.Sleep(100);
} }
if (!moreThanAnHour) if (!moreThanAnHour)
{ {
@ -339,7 +342,17 @@ public class FileRead : Properties.IFileRead
for (int i = 0; i < duplicateFiles.Count; i++) for (int i = 0; i < duplicateFiles.Count; i++)
{ {
if (!File.Exists(duplicateFiles[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) if (consumedFileIndices.Count == duplicateFiles.Count)
break; 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)); 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<T>(DateTime dateTime, List<T> descriptions, bool isDummyRun, string successDirectory, string duplicateDirectory, List<(Properties.IScopeInfo, string)> collection, string duplicateFile) where T : Properties.IDescription
{ {
if (!isDummyRun && _IsEAFHosted) if (!isDummyRun && _IsEAFHosted)
WaitForFileConsumption(_FileConnectorConfiguration.SourceDirectoryCloaking, _Logistics, dateTime, successDirectory, duplicateDirectory, duplicateFile, tuples); WaitForFileConsumption(_FileConnectorConfiguration.SourceDirectoryCloaking, _Logistics, dateTime, descriptions, successDirectory, duplicateDirectory, duplicateFile, collection);
else else
{ {
long breakAfter = DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks; long breakAfter = DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks;

View File

@ -9,55 +9,67 @@ namespace Adaptation.Shared;
public class Logistics : ILogistics public class Logistics : ILogistics
{ {
public object NullData { get; private set; } protected readonly DateTime _DateTimeFromSequence;
public string JobID { get; private set; } //CellName protected readonly FileInfo _FileInfo;
public long Sequence { get; private set; } //Ticks protected readonly string _JobID;
public DateTime DateTimeFromSequence { get; private set; } protected readonly List<string> _Logistics1;
public double TotalSecondsSinceLastWriteTimeFromSequence { get; private set; } protected readonly List<Logistics2> _Logistics2;
public string MesEntity { get; private set; } //SPC protected string _MID;
public string ReportFullPath { get; private set; } //Extract file protected readonly string _MesEntity;
public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics) protected readonly object _NullData;
public string MID { get; set; } //Lot & Pocket || Lot protected string _ProcessJobID;
public List<string> Tags { get; set; } protected readonly string _ReportFullPath;
public List<string> Logistics1 { get; set; } protected readonly long _Sequence;
public List<Logistics2> Logistics2 { get; set; } protected readonly double _TotalSecondsSinceLastWriteTimeFromSequence;
public DateTime DateTimeFromSequence => _DateTimeFromSequence;
public FileInfo FileInfo => _FileInfo;
public string JobID => _JobID;
public List<string> Logistics1 => _Logistics1;
public List<Logistics2> 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) public Logistics(IFileRead fileRead)
{ {
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now;
NullData = null; _NullData = null;
Sequence = dateTime.Ticks; _Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; _DateTimeFromSequence = dateTime;
JobID = fileRead.CellInstanceName; _JobID = fileRead.CellInstanceName;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime); _MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = string.Empty; _ReportFullPath = string.Empty;
ProcessJobID = nameof(ProcessJobID); _ProcessJobID = nameof(ProcessJobID);
MID = nameof(MID); _MID = nameof(MID);
Tags = new List<string>(); _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); _Logistics2 = new List<Logistics2>();
Logistics2 = new List<Logistics2>();
} }
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)) if (string.IsNullOrEmpty(fileRead.CellInstanceName))
throw new Exception(); throw new Exception();
if (string.IsNullOrEmpty(fileRead.MesEntity)) if (string.IsNullOrEmpty(fileRead.MesEntity))
throw new Exception(); throw new Exception();
NullData = fileRead.NullData; _NullData = fileRead.NullData;
FileInfo fileInfo = new(reportFullPath); _FileInfo = new(reportFullPath);
DateTime dateTime = fileInfo.LastWriteTime; DateTime dateTime = new(_FileInfo.LastWriteTime.Ticks + tickOffset);
if (fileInfoLength.HasValue && fileInfo.Length < fileInfoLength.Value) if (fileInfoLength.HasValue && _FileInfo.Length < fileInfoLength.Value)
dateTime = dateTime.AddTicks(-1); dateTime = dateTime.AddTicks(-1);
JobID = fileRead.CellInstanceName; _JobID = fileRead.CellInstanceName;
Sequence = dateTime.Ticks; _Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; _DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = fileRead.MesEntity; _MesEntity = fileRead.MesEntity;
ReportFullPath = fileInfo.FullName; _ReportFullPath = _FileInfo.FullName;
ProcessJobID = nameof(ProcessJobID); _ProcessJobID = nameof(ProcessJobID);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(_FileInfo.FullName);
if (useSplitForMID) if (useSplitForMID)
{ {
if (fileNameWithoutExtension.IndexOf(".") > -1) if (fileNameWithoutExtension.IndexOf(".") > -1)
@ -67,10 +79,9 @@ public class Logistics : ILogistics
if (fileNameWithoutExtension.IndexOf("-") > -1) if (fileNameWithoutExtension.IndexOf("-") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim(); fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
} }
MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower()); _MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
Tags = new List<string>(); _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); _Logistics2 = new List<Logistics2>();
Logistics2 = new List<Logistics2>();
} }
public Logistics(string reportFullPath, string logistics) public Logistics(string reportFullPath, string logistics)
@ -78,57 +89,57 @@ public class Logistics : ILogistics
string key; string key;
DateTime dateTime; DateTime dateTime;
string[] segments; 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")) if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
{ {
NullData = null; _NullData = null;
JobID = "null"; _JobID = "null";
dateTime = new FileInfo(reportFullPath).LastWriteTime; dateTime = _FileInfo.LastWriteTime;
Sequence = dateTime.Ticks; _Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; _DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime); _MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = reportFullPath; _ReportFullPath = reportFullPath;
ProcessJobID = "R##"; _ProcessJobID = "R##";
MID = "null"; _MID = "null";
Tags = new List<string>(); _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); _Logistics2 = new List<Logistics2>();
Logistics2 = new List<Logistics2>();
} }
else else
{ {
string logistics1Line1 = Logistics1[0]; string logistics1Line1 = Logistics1[0];
key = "NULL_DATA="; key = "NULL_DATA=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
NullData = null; _NullData = null;
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
NullData = segments[1].Split(';')[0]; _NullData = segments[1].Split(';')[0];
} }
key = "JOBID="; key = "JOBID=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
JobID = "null"; _JobID = "null";
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
JobID = segments[1].Split(';')[0]; _JobID = segments[1].Split(';')[0];
} }
key = "SEQUENCE="; key = "SEQUENCE=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
dateTime = new FileInfo(reportFullPath).LastWriteTime; dateTime = _FileInfo.LastWriteTime;
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); 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) 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 else
dateTime = new DateTime(sequence); dateTime = new DateTime(sequence);
} }
Sequence = dateTime.Ticks; _Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; _DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
DateTime lastWriteTime = new FileInfo(reportFullPath).LastWriteTime; DateTime lastWriteTime = _FileInfo.LastWriteTime;
if (TotalSecondsSinceLastWriteTimeFromSequence > 600) if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
{ {
if (lastWriteTime != dateTime) if (lastWriteTime != dateTime)
@ -138,33 +149,32 @@ public class Logistics : ILogistics
} }
key = "MES_ENTITY="; key = "MES_ENTITY=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
MesEntity = DefaultMesEntity(dateTime); _MesEntity = DefaultMesEntity(dateTime);
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); 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="; key = "PROCESS_JOBID=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
ProcessJobID = "R##"; _ProcessJobID = "R##";
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
ProcessJobID = segments[1].Split(';')[0]; _ProcessJobID = segments[1].Split(';')[0];
} }
key = "MID="; key = "MID=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
MID = "null"; _MID = "null";
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MID = segments[1].Split(';')[0]; _MID = segments[1].Split(';')[0];
} }
} }
Logistics2 logistics2; Logistics2 logistics2;
Tags = new List<string>(); _Logistics2 = new List<Logistics2>();
Logistics2 = new List<Logistics2>();
for (int i = 1; i < Logistics1.Count; i++) for (int i = 1; i < Logistics1.Count; i++)
{ {
if (Logistics1[i].StartsWith("LOGISTICS_2")) 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"); private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
internal string GetLotViaMostCommonMethod() => MID.Substring(0, MID.Length - 2); internal void Update(string mid, string processJobID)
internal string GetPocketNumberViaMostCommonMethod() => MID.Substring(MID.Length - 2);
internal void Update(string dateTime, string processJobID, string mid)
{ {
if (!DateTime.TryParse(dateTime, out DateTime dateTimeCasted)) _MID = mid;
dateTimeCasted = DateTime.Now; _ProcessJobID = processJobID;
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<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
} }
} }

View File

@ -16,7 +16,7 @@ public class ScopeInfo : Properties.IScopeInfo
public string QueryFilter { get; private set; } public string QueryFilter { get; private set; }
public string FileNameWithoutExtension { 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; Enum = test;
Test = test; Test = test;

View File

@ -30,7 +30,7 @@ public partial class WS
}; };
HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead).Result; HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead).Result;
resultsJson = httpResponseMessage.Content.ReadAsStringAsync().Result; resultsJson = httpResponseMessage.Content.ReadAsStringAsync().Result;
results = JsonSerializer.Deserialize<Results>(resultsJson); results = JsonSerializer.Deserialize<Results>(resultsJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
} }
if (!results.Success) if (!results.Success)
results.Errors.Add(results.ToString()); results.Errors.Add(results.ToString());
@ -44,8 +44,8 @@ public partial class WS
_ = stringBuilder.AppendLine(exception.Message); _ = stringBuilder.AppendLine(exception.Message);
exception = exception.InnerException; exception = exception.InnerException;
} }
if (results.Errors is null) results.Errors ??= new List<string>();
results.Errors = new List<string>(); results.Errors.Add(resultsJson);
results.Errors.Add(stringBuilder.ToString()); results.Errors.Add(stringBuilder.ToString());
} }
return new(resultsJson, results); return new(resultsJson, results);

View File

@ -91,8 +91,7 @@ public class ProcessDataStandardFormat
string segment; string segment;
List<string> body = new(); List<string> body = new();
StringBuilder logistics = new(); StringBuilder logistics = new();
if (lines is null) lines ??= File.ReadAllLines(reportFullPath);
lines = File.ReadAllLines(reportFullPath);
string[] segments; string[] segments;
if (lines.Length < 7) if (lines.Length < 7)
segments = Array.Empty<string>(); segments = Array.Empty<string>();
@ -276,8 +275,7 @@ public class ProcessDataStandardFormat
public static string GetLines(Logistics logistics, Properties.IScopeInfo scopeInfo, List<string> names, Dictionary<string, List<string>> keyValuePairs, string dateFormat, string timeFormat, List<string> pairedParameterNames, bool useDateTimeFromSequence = true, string format = "", List<string> ignoreParameterNames = null) public static string GetLines(Logistics logistics, Properties.IScopeInfo scopeInfo, List<string> names, Dictionary<string, List<string>> keyValuePairs, string dateFormat, string timeFormat, List<string> pairedParameterNames, bool useDateTimeFromSequence = true, string format = "", List<string> ignoreParameterNames = null)
{ {
StringBuilder result = new(); StringBuilder result = new();
if (ignoreParameterNames is null) ignoreParameterNames ??= new List<string>();
ignoreParameterNames = new List<string>();
if (useDateTimeFromSequence && !string.IsNullOrEmpty(format)) if (useDateTimeFromSequence && !string.IsNullOrEmpty(format))
throw new Exception(); throw new Exception();
else if (!useDateTimeFromSequence && string.IsNullOrEmpty(format)) else if (!useDateTimeFromSequence && string.IsNullOrEmpty(format))
@ -357,8 +355,7 @@ public class ProcessDataStandardFormat
if (string.IsNullOrEmpty(lines[i])) if (string.IsNullOrEmpty(lines[i]))
continue; continue;
segments = lines[i].Split(inputSeparator); segments = lines[i].Split(inputSeparator);
if (currentGroup is null) currentGroup ??= segments.Length;
currentGroup = segments.Length;
if (segments.Length != currentGroup) if (segments.Length != currentGroup)
{ {
currentGroup = segments.Length; currentGroup = segments.Length;

View File

@ -7,4 +7,13 @@ public interface IDescription
int Count { get; } int Count { get; }
int Index { 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; }
} }

View File

@ -7,6 +7,7 @@ public interface IFileRead
string MesEntity { get; } string MesEntity { get; }
bool IsEAFHosted { get; } bool IsEAFHosted { get; }
string EventName { get; } string EventName { get; }
bool IsDuplicator { get; }
string EquipmentType { get; } string EquipmentType { get; }
string ReportFullPath { get; } string ReportFullPath { get; }
string CellInstanceName { get; } string CellInstanceName { get; }

View File

@ -1,22 +1,23 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
namespace Adaptation.Shared.Properties; namespace Adaptation.Shared.Properties;
public interface ILogistics public interface ILogistics
{ {
public object NullData { get; }
public string JobID { get; } //CellName
public long Sequence { get; } //Ticks
public DateTime DateTimeFromSequence { get; } public DateTime DateTimeFromSequence { get; }
public FileInfo FileInfo { get; }
public string JobID { get; }
public List<string> Logistics1 { get; }
public List<Logistics2> 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 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<string> Tags { get; set; }
public List<string> Logistics1 { get; set; }
public List<Logistics2> Logistics2 { get; set; }
} }

View File

@ -15,23 +15,23 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
#pragma warning disable CA2254 #pragma warning disable CA2254
#pragma warning disable IDE0060 #pragma warning disable IDE0060
internal static string DummyRoot { get; private set; }
internal static MET08ANLYSDIFAAST230 EAFLoggingUnitTesting { 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) if (EAFLoggingUnitTesting is null)
throw new Exception(); 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] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) 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")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
@ -41,12 +41,13 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
[ClassCleanup()] [ClassCleanup()]
public static void ClassCleanup() public static void ClassCleanup()
{ {
if (EAFLoggingUnitTesting.Logger is not null) EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup");
EAFLoggingUnitTesting.Logger.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose();
if (EAFLoggingUnitTesting is not null)
EAFLoggingUnitTesting.Dispose();
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles()
{ {
@ -57,6 +58,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer()
{ {
@ -67,6 +71,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi()
{ {
@ -77,6 +84,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsight() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsight()
{ {
@ -87,6 +97,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments()
{ {
@ -97,6 +110,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__APC() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__APC()
{ {
@ -107,6 +123,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__SPaCe() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__SPaCe()
{ {
@ -117,6 +136,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Processed() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Processed()
{ {
@ -127,6 +149,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Archive() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Archive()
{ {
@ -137,6 +162,9 @@ public class MET08ANLYSDIFAAST230 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Dummy() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Dummy()
{ {

View File

@ -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"));
}
}

View File

@ -22,9 +22,15 @@ public class MET08ANLYSDIFAAST230
_MET08ANLYSDIFAAST230 = CreateSelfDescription.Staging.v2_43_0.MET08ANLYSDIFAAST230.EAFLoggingUnitTesting; _MET08ANLYSDIFAAST230 = CreateSelfDescription.Staging.v2_43_0.MET08ANLYSDIFAAST230.EAFLoggingUnitTesting;
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles();
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles637710931421087642__Normal() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__MoveMatchingFiles637710931421087642__Normal()
{ {
@ -37,12 +43,21 @@ public class MET08ANLYSDIFAAST230
_ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics, validatePDSF: false); _ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics, validatePDSF: false);
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewer();
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi();
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi637884771880950000__Normal() public void Staging__v2_43_0__MET08ANLYSDIFAAST230__IQSSi637884771880950000__Normal()
{ {
@ -55,24 +70,45 @@ public class MET08ANLYSDIFAAST230
_ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics, validatePDSF: false); _ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics, validatePDSF: false);
} }
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsight() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsight(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsight() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsight();
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__OpenInsightMetrologyViewerAttachments();
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__APC() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__APC(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__APC() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__APC();
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__SPaCe() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__SPaCe(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__SPaCe() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__SPaCe();
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Processed() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__Processed(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Processed() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__Processed();
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Archive() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__Archive(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Archive() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__Archive();
#if true
[Ignore]
#endif
[TestMethod] [TestMethod]
public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Dummy() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__Dummy(); public void Staging__v2_43_0__MET08ANLYSDIFAAST230__Dummy() => _MET08ANLYSDIFAAST230.Staging__v2_43_0__MET08ANLYSDIFAAST230__Dummy();

View File

@ -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();
}

View File

@ -26,10 +26,13 @@ namespace Adaptation._Tests.Shared;
public class AdaptationTesting : ISMTP public class AdaptationTesting : ISMTP
{ {
protected readonly string _DummyRoot;
protected readonly string _Environment; protected readonly string _Environment;
protected readonly string _HostNameAndPort; protected readonly string _HostNameAndPort;
protected readonly bool _HasWaitForProperty;
protected readonly TestContext _TestContext; protected readonly TestContext _TestContext;
protected readonly bool _SkipEquipmentDictionary; protected readonly bool _SkipEquipmentDictionary;
protected readonly string _TestContextPropertiesAsJson;
protected readonly Dictionary<string, CellInstanceVersion> _CellInstanceVersions; protected readonly Dictionary<string, CellInstanceVersion> _CellInstanceVersions;
protected readonly Dictionary<string, EquipmentTypeVersion> _EquipmentTypeVersions; protected readonly Dictionary<string, EquipmentTypeVersion> _EquipmentTypeVersions;
protected readonly Dictionary<string, string> _ParameterizedModelObjectDefinitionTypes; protected readonly Dictionary<string, string> _ParameterizedModelObjectDefinitionTypes;
@ -38,10 +41,13 @@ public class AdaptationTesting : ISMTP
protected readonly Dictionary<string, IList<ModelObjectParameterDefinition>> _ModelObjectParameters; protected readonly Dictionary<string, IList<ModelObjectParameterDefinition>> _ModelObjectParameters;
protected readonly Dictionary<string, List<Tuple<string, string>>> _EquipmentDictionaryEventDescriptions; protected readonly Dictionary<string, List<Tuple<string, string>>> _EquipmentDictionaryEventDescriptions;
public string DummyRoot => _DummyRoot;
public string Environment => _Environment; public string Environment => _Environment;
public TestContext TestContext => _TestContext; public TestContext TestContext => _TestContext;
public string HostNameAndPort => _HostNameAndPort; public string HostNameAndPort => _HostNameAndPort;
public bool HasWaitForProperty => _HasWaitForProperty;
public bool SkipEquipmentDictionary => _SkipEquipmentDictionary; public bool SkipEquipmentDictionary => _SkipEquipmentDictionary;
public string TestContextPropertiesAsJson => _TestContextPropertiesAsJson;
public Dictionary<string, CellInstanceVersion> CellInstanceVersions => _CellInstanceVersions; public Dictionary<string, CellInstanceVersion> CellInstanceVersions => _CellInstanceVersions;
public Dictionary<string, EquipmentTypeVersion> EquipmentTypeVersions => _EquipmentTypeVersions; public Dictionary<string, EquipmentTypeVersion> EquipmentTypeVersions => _EquipmentTypeVersions;
public Dictionary<string, IList<ModelObjectParameterDefinition>> ModelObjectParameters => _ModelObjectParameters; public Dictionary<string, IList<ModelObjectParameterDefinition>> ModelObjectParameters => _ModelObjectParameters;
@ -56,17 +62,22 @@ public class AdaptationTesting : ISMTP
void ISMTP.SendNormalPriorityEmailMessage(string subject, string body) => throw new NotImplementedException(); 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 environment = GetEnvironment(testContext);
string hostNameAndPort = GetHostNameAndPort(environment); string hostNameAndPort = GetHostNameAndPort(environment);
_DummyRoot = dummyRoot;
_TestContext = testContext; _TestContext = testContext;
_Environment = environment; _Environment = environment;
_HostNameAndPort = hostNameAndPort; _HostNameAndPort = hostNameAndPort;
_HasWaitForProperty = hasWaitForProperty;
_SkipEquipmentDictionary = skipEquipmentDictionary; _SkipEquipmentDictionary = skipEquipmentDictionary;
_TestContextPropertiesAsJson = testContextPropertiesAsJson;
_CellInstanceVersions = new Dictionary<string, CellInstanceVersion>(); _CellInstanceVersions = new Dictionary<string, CellInstanceVersion>();
_EquipmentTypeVersions = new Dictionary<string, EquipmentTypeVersion>(); _EquipmentTypeVersions = new Dictionary<string, EquipmentTypeVersion>();
_EquipmentTypeVersions = new Dictionary<string, EquipmentTypeVersion>();
_ParameterizedModelObjectDefinitionTypes = new Dictionary<string, string>();
_ParameterizedModelObjectDefinitionTypes = new Dictionary<string, string>(); _ParameterizedModelObjectDefinitionTypes = new Dictionary<string, string>();
_EquipmentDictionaryVersions = new Dictionary<string, EquipmentDictionaryVersion>(); _EquipmentDictionaryVersions = new Dictionary<string, EquipmentDictionaryVersion>();
_FileConnectorConfigurations = new Dictionary<string, FileConnectorConfiguration>(); _FileConnectorConfigurations = new Dictionary<string, FileConnectorConfiguration>();
@ -94,23 +105,28 @@ public class AdaptationTesting : ISMTP
return result; return result;
} }
protected string GetTestResultsDirectory() public static string GetTestResultsDirectory(string testContextTestResultsDirectory, bool hasWaitForProperty)
{ {
string result = string.Empty; string result = string.Empty;
string testResults = "05_TestResults"; string testResults = "05_TestResults";
string checkDirectory = _TestContext.TestResultsDirectory; string checkDirectory = testContextTestResultsDirectory;
if (string.IsNullOrEmpty(checkDirectory) || !checkDirectory.Contains(testResults)) if (hasWaitForProperty && (string.IsNullOrEmpty(checkDirectory) || !checkDirectory.Contains(testResults)))
throw new Exception(); throw new Exception($"A:{checkDirectory}; B:{testResults};");
string rootDirectory = Path.GetPathRoot(checkDirectory); else if (!hasWaitForProperty && (string.IsNullOrEmpty(checkDirectory) || !checkDirectory.Contains(testResults)))
for (int i = 0; i < int.MaxValue; i++) result = testContextTestResultsDirectory;
else
{ {
checkDirectory = Path.GetDirectoryName(checkDirectory); string rootDirectory = Path.GetPathRoot(checkDirectory);
if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == rootDirectory) for (int i = 0; i < int.MaxValue; i++)
break;
if (checkDirectory.EndsWith(testResults) && Directory.Exists(checkDirectory))
{ {
result = checkDirectory; checkDirectory = Path.GetDirectoryName(checkDirectory);
break; if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == rootDirectory)
break;
if (checkDirectory.EndsWith(testResults) && Directory.Exists(checkDirectory))
{
result = checkDirectory;
break;
}
} }
} }
if (string.IsNullOrEmpty(result)) if (string.IsNullOrEmpty(result))
@ -118,6 +134,12 @@ public class AdaptationTesting : ISMTP
return result; return result;
} }
private string GetTestResultsDirectory(bool hasWaitForProperty)
{
string result = GetTestResultsDirectory(_TestContext.TestResultsDirectory, hasWaitForProperty);
return result;
}
protected static string GetCellInstanceConnectionName(string cellInstanceConnectionName) protected static string GetCellInstanceConnectionName(string cellInstanceConnectionName)
{ {
string result; string result;
@ -170,28 +192,29 @@ public class AdaptationTesting : ISMTP
return results; return results;
} }
internal string[] GetSegments(string methodBaseName) public static MethodBaseName GetMethodBaseName(string dummyRoot, string environment, bool hasWaitForProperty, string methodBaseName, string testResultsDirectory)
{ {
List<string> results; MethodBaseName result;
string fileFullName;
string comment; string comment;
string[] textFiles; string fileFullName;
string dummyDirectory;
string withActualCICN;
string separator = "__"; string separator = "__";
string textFileDirectory;
string connectionNameAndTicks; string connectionNameAndTicks;
string cellInstanceConnectionName; string cellInstanceConnectionName;
string ticks = DateTime.Now.Ticks.ToString(); string ticks = DateTime.Now.Ticks.ToString();
string cellInstanceConnectionNameFromMethodBaseName; string cellInstanceConnectionNameFromMethodBaseName;
string testResultsDirectory = GetTestResultsDirectory();
string[] segments = methodBaseName.Split(new string[] { separator }, StringSplitOptions.None); string[] segments = methodBaseName.Split(new string[] { separator }, StringSplitOptions.None);
if (segments[0] != _Environment) if (segments[0] != environment)
throw new Exception(); throw new Exception();
string rawVersionName = segments[1]; string rawVersionName = segments[1];
string rawCellInstanceName = segments[2]; string rawCellInstanceName = segments[2];
string cellInstanceVersionName = segments[1].Replace('_', '.'); string cellInstanceVersionName = segments[1].Replace('_', '.');
string cellInstanceName = segments[2].Replace('_', '-').Replace("_EQPT", "-EQPT"); 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 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)) if (!Directory.Exists(versionDirectory))
_ = Directory.CreateDirectory(versionDirectory); _ = Directory.CreateDirectory(versionDirectory);
comment = segments[segments.Length - 1]; comment = segments[segments.Length - 1];
@ -221,87 +244,76 @@ public class AdaptationTesting : ISMTP
cellInstanceConnectionNameFromMethodBaseName = after; cellInstanceConnectionNameFromMethodBaseName = after;
} }
cellInstanceConnectionName = GetCellInstanceConnectionName(cellInstanceConnectionNameFromMethodBaseName); 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)) if (string.IsNullOrEmpty(ticks))
{ {
textFiles = Array.Empty<string>(); textFileDirectory = string.Empty;
fileFullName = Path.Combine(versionDirectory, methodBaseNameWithActualCICN, $"{cellInstanceConnectionNameFromMethodBaseName}.json"); fileFullName = Path.Combine(versionDirectory, withActualCICN, $"{cellInstanceConnectionNameFromMethodBaseName}.json");
} }
else else
{ {
segments = methodBaseNameWithActualCICN.Split(new string[] { ticks }, StringSplitOptions.None); segments = withActualCICN.Split(new string[] { ticks }, StringSplitOptions.None);
string textDirectory = Path.Combine(versionDirectory, segments[0], string.Concat(ticks, segments[1])); textFileDirectory = Path.Combine(versionDirectory, segments[0], string.Concat(ticks, segments[1]));
fileFullName = Path.Combine(versionDirectory, segments[0], $"{cellInstanceConnectionNameFromMethodBaseName}.json"); 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<string>();
else if (!Directory.Exists(mbn.TextFileDirectory))
{
results = Array.Empty<string>();
if (!_HasWaitForProperty)
_ = Directory.CreateDirectory(mbn.TextFileDirectory);
else
{ {
textFiles = Array.Empty<string>(); string renameDirectory = Path.Combine(Path.GetDirectoryName(mbn.TextFileDirectory), $"_Rename - {Path.GetFileName(mbn.TextFileDirectory)}");
string renameDirectory = Path.Combine(Path.GetDirectoryName(textDirectory), $"_Rename - {Path.GetFileName(textDirectory)}");
_ = Directory.CreateDirectory(renameDirectory); _ = Directory.CreateDirectory(renameDirectory);
_ = Process.Start("explorer.exe", renameDirectory); _ = Process.Start("explorer.exe", renameDirectory);
File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileFilter)}.txt"), string.Empty); File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileFilter)}.txt"), string.Empty);
File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileLocation)}.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); _ = Process.Start("explorer.exe", mbn.TextFileDirectory);
if (!textFiles.Any()) File.WriteAllText(Path.Combine(mbn.TextFileDirectory, "_ Why.why"), string.Empty);
{
_ = Process.Start("explorer.exe", textDirectory);
File.WriteAllText(Path.Combine(textDirectory, "_ Why.why"), string.Empty);
}
} }
} }
results = new List<string>
{
_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; 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<string> 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) protected static Stream ToStream(string @this)
{ {
MemoryStream memoryStream = new(); MemoryStream memoryStream = new();
@ -331,7 +343,7 @@ public class AdaptationTesting : ISMTP
return result as T; return result as T;
} }
protected static CellInstanceVersion GetCellInstanceVersion(string url) public static CellInstanceVersion GetCellInstanceVersion(string url)
{ {
CellInstanceVersion result; CellInstanceVersion result;
byte[] byteArray; byte[] byteArray;
@ -466,6 +478,7 @@ public class AdaptationTesting : ISMTP
AppendLine("#pragma warning disable CA2254"). AppendLine("#pragma warning disable CA2254").
AppendLine("#pragma warning disable IDE0060"). AppendLine("#pragma warning disable IDE0060").
AppendLine(). AppendLine().
AppendLine("internal static string DummyRoot { get; private set; }").
Append("internal static ").Append(cellInstanceNameWithoutHyphen).AppendLine(" EAFLoggingUnitTesting { get; private set; }"); Append("internal static ").Append(cellInstanceNameWithoutHyphen).AppendLine(" EAFLoggingUnitTesting { get; private set; }");
else else
throw new Exception(); throw new Exception();
@ -474,13 +487,15 @@ public class AdaptationTesting : ISMTP
else if (i == 1) else if (i == 1)
_ = stringBuilder. _ = stringBuilder.
AppendLine(). 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("{").
AppendLine("if (EAFLoggingUnitTesting is null)"). AppendLine("if (EAFLoggingUnitTesting is null)").
AppendLine("throw new Exception();"). AppendLine("throw new Exception();").
AppendLine("}"). AppendLine("}").
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("}"). AppendLine("}").
AppendLine(); AppendLine();
@ -541,6 +556,9 @@ public class AdaptationTesting : ISMTP
if (i == 2) if (i == 2)
{ {
_ = stringBuilder. _ = stringBuilder.
AppendLine("#if true").
AppendLine("[Ignore]").
AppendLine("#endif").
AppendLine("[TestMethod]"). AppendLine("[TestMethod]").
Append("public void ").Append(methodName).Append("() => ").Append('_').Append(cellInstanceNameWithoutHyphen).Append('.').Append(methodName).AppendLine("();").AppendLine(); 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!"); throw new Exception("Versions should match!");
equipmentTypeName = componentsCellComponentCellComponent.Equipment.EquipmentType.Name; equipmentTypeName = componentsCellComponentCellComponent.Equipment.EquipmentType.Name;
_ = stringBuilder. _ = stringBuilder.
AppendLine("#if true").
AppendLine("[Ignore]").
AppendLine("#endif").
AppendLine("[TestMethod]"). AppendLine("[TestMethod]").
Append("public void ").Append(methodName).AppendLine("()"). Append("public void ").Append(methodName).AppendLine("()").
AppendLine("{"). AppendLine("{").
Append("string check = \"").Append(check.Split('\\').Last()).AppendLine("\";"). Append("string check = \"").Append(check.Split('\\').Last()).AppendLine("\";").
AppendLine("MethodBase methodBase = new StackFrame().GetMethod();"). AppendLine("MethodBase methodBase = new StackFrame().GetMethod();").
AppendLine("EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Getting configuration\"));"). 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("EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Exit\"));").
AppendLine("}"). AppendLine("}").
AppendLine(); AppendLine();
@ -600,14 +621,10 @@ public class AdaptationTesting : ISMTP
result = JsonSerializer.Deserialize<FileConnectorConfiguration>(json, jsonSerializerOptions); result = JsonSerializer.Deserialize<FileConnectorConfiguration>(json, jsonSerializerOptions);
if (string.IsNullOrEmpty(result.SourceFileFilter)) if (string.IsNullOrEmpty(result.SourceFileFilter))
result.SourceFileFilter = string.Empty; result.SourceFileFilter = string.Empty;
if (result.ErrorTargetFileLocation is null) result.ErrorTargetFileLocation ??= string.Empty;
result.ErrorTargetFileLocation = string.Empty; result.SourceFileLocation ??= string.Empty;
if (result.SourceFileLocation is null) result.TargetFileLocation ??= string.Empty;
result.SourceFileLocation = string.Empty; result.FolderAgeCheckIndividualSubFolders ??= false;
if (result.TargetFileLocation is null)
result.TargetFileLocation = string.Empty;
if (result.FolderAgeCheckIndividualSubFolders is null)
result.FolderAgeCheckIndividualSubFolders = false;
result.ConnectionSettings = new List<ConnectionSetting>(); result.ConnectionSettings = new List<ConnectionSetting>();
result.SourceFileFilters = result.SourceFileFilter.Split('|').ToList(); result.SourceFileFilters = result.SourceFileFilter.Split('|').ToList();
if (componentsCellComponentCellComponent.Equipment?.ConnectionSettings is not null) if (componentsCellComponentCellComponent.Equipment?.ConnectionSettings is not null)
@ -857,7 +874,7 @@ public class AdaptationTesting : ISMTP
return result; return result;
} }
protected Dictionary<string, object> GetKeyValuePairs(string cellInstanceName, string cellInstanceVersionName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, List<Tuple<string, string>> equipmentDictionaryIsAlwaysEnabledEvents) protected Dictionary<string, object> GetKeyValuePairs(string cellInstanceName, string cellInstanceVersionName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, List<Tuple<string, string>> equipmentDictionaryIsAlwaysEnabledEvents, int edaConnectionPortNumber)
{ {
Dictionary<string, object> results = new() Dictionary<string, object> results = new()
{ {
@ -866,6 +883,7 @@ public class AdaptationTesting : ISMTP
{ nameof(cellInstanceName), cellInstanceName }, { nameof(cellInstanceName), cellInstanceName },
{ nameof(equipmentTypeName), equipmentTypeName }, { nameof(equipmentTypeName), equipmentTypeName },
{ nameof(cellInstanceVersionName), cellInstanceVersionName }, { nameof(cellInstanceVersionName), cellInstanceVersionName },
{ nameof(edaConnectionPortNumber), edaConnectionPortNumber },
{ nameof(equipmentDictionaryName), equipmentDictionaryName }, { nameof(equipmentDictionaryName), equipmentDictionaryName },
{ nameof(cellInstanceConnectionName), cellInstanceConnectionName }, { nameof(cellInstanceConnectionName), cellInstanceConnectionName },
{ nameof(FileConnectorConfiguration), fileConnectorConfiguration }, { nameof(FileConnectorConfiguration), fileConnectorConfiguration },
@ -879,32 +897,26 @@ public class AdaptationTesting : ISMTP
public string[] GetCSharpText(string testName) public string[] GetCSharpText(string testName)
{ {
string[] results; string[] results;
string[] segments = GetSegments(testName); string testResultsDirectory = GetTestResultsDirectory(_HasWaitForProperty);
FileInfo fileInfo = GetFileName(segments); MethodBaseName mbn = GetMethodBaseName(_DummyRoot, _Environment, _HasWaitForProperty, testName, testResultsDirectory);
string cellInstanceName = GetCellInstanceName(segments); FileInfo fileInfo = new(mbn.FileFullName);
string cellInstanceVersionName = GetCellInstanceVersionName(segments); if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments);
if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
_ = Directory.CreateDirectory(fileInfo.Directory.FullName); _ = Directory.CreateDirectory(fileInfo.Directory.FullName);
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName); Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName);
results = GetCSharpTextB(fileInfo, cellInstanceName, cellInstanceVersionName, cellInstanceVersionTuple.Item2); results = GetCSharpTextB(fileInfo, mbn.CellInstanceName, mbn.CellInstanceVersionName, cellInstanceVersionTuple.Item2);
return results; return results;
} }
public string[] GetConfiguration(MethodBase methodBase) public string[] GetConfiguration(MethodBase methodBase)
{ {
string[] results; string[] results;
string[] segments = GetSegments(methodBase.Name); MethodBaseName mbn = GetMethodBaseName(methodBase);
string ticks = GetTicks(segments); FileInfo fileInfo = new(mbn.FileFullName);
FileInfo fileInfo = GetFileName(segments); if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
string cellInstanceName = GetCellInstanceName(segments);
string cellInstanceVersionName = GetCellInstanceVersionName(segments);
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments);
if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
_ = Directory.CreateDirectory(fileInfo.Directory.FullName); _ = Directory.CreateDirectory(fileInfo.Directory.FullName);
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName); Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName);
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName); Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, mbn.CellInstanceConnectionName);
if (string.IsNullOrEmpty(ticks) && fileConnectorConfigurationTuple.Item2?.FileScanningIntervalInSeconds is not null) if (string.IsNullOrEmpty(mbn.Ticks) && fileConnectorConfigurationTuple.Item2?.FileScanningIntervalInSeconds is not null)
{ {
string fileScanningIntervalInSecondsLine; string fileScanningIntervalInSecondsLine;
string versionDirectory = Path.GetDirectoryName(fileInfo.DirectoryName); 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)}"; fileScanningIntervalInSecondsLine = $"+\t{fileConnectorConfigurationTuple.Item2.FileScanningIntervalInSeconds.Value:+0000}\t{Path.GetFileName(fileInfo.DirectoryName)}";
File.AppendAllLines(Path.Combine(versionDirectory, "FileScanningIntervalInSeconds.txt"), new string[] { fileScanningIntervalInSecondsLine }); File.AppendAllLines(Path.Combine(versionDirectory, "FileScanningIntervalInSeconds.txt"), new string[] { fileScanningIntervalInSecondsLine });
} }
Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName); Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName);
Tuple<string, string> parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple); Tuple<string, string> parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple);
Tuple<string, IList<ModelObjectParameterDefinition>> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple); Tuple<string, IList<ModelObjectParameterDefinition>> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple);
Tuple<string, string, string, EquipmentDictionaryVersion> equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName, equipmentTypeVersionTuple.Item4); Tuple<string, string, string, EquipmentDictionaryVersion> equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName, equipmentTypeVersionTuple.Item4);
Tuple<string, List<Tuple<string, string>>> equipmentDictionaryIsAlwaysEnabledEventsTuple = GetEquipmentDictionaryIsAlwaysEnabledEventsTuple(equipmentDictionaryVersionTuple); Tuple<string, List<Tuple<string, string>>> equipmentDictionaryIsAlwaysEnabledEventsTuple = GetEquipmentDictionaryIsAlwaysEnabledEventsTuple(equipmentDictionaryVersionTuple);
Dictionary<string, object> objects = GetKeyValuePairs(cellInstanceName, cellInstanceVersionName, cellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryVersionTuple.Item2, equipmentDictionaryIsAlwaysEnabledEventsTuple.Item2); Dictionary<string, object> 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 }); string json = JsonSerializer.Serialize(objects, new JsonSerializerOptions { WriteIndented = true });
results = new string[] { fileInfo.FullName, json }; results = new string[] { fileInfo.FullName, json };
return results; return results;
@ -928,22 +940,19 @@ public class AdaptationTesting : ISMTP
public IFileRead Get(MethodBase methodBase, string sourceFileLocation, string sourceFileFilter, bool useCyclicalForDescription) public IFileRead Get(MethodBase methodBase, string sourceFileLocation, string sourceFileFilter, bool useCyclicalForDescription)
{ {
IFileRead result; IFileRead result;
string[] segments = GetSegments(methodBase.Name); MethodBaseName mbn = GetMethodBaseName(methodBase);
FileInfo fileInfo = GetFileName(segments); FileInfo fileInfo = new(mbn.FileFullName);
string cellInstanceName = GetCellInstanceName(segments);
string cellInstanceVersionName = GetCellInstanceVersionName(segments);
Dictionary<string, string> fileParameter = new(); Dictionary<string, string> fileParameter = new();
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments); if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
_ = Directory.CreateDirectory(fileInfo.Directory.FullName); _ = Directory.CreateDirectory(fileInfo.Directory.FullName);
Dictionary<string, List<long>> dummyRuns = new(); Dictionary<string, List<long>> dummyRuns = new();
Dictionary<long, List<string>> staticRuns = new(); Dictionary<long, List<string>> staticRuns = new();
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName); Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName);
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName); Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, mbn.CellInstanceConnectionName);
Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName); Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName);
Tuple<string, string> parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple); Tuple<string, string> parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple);
Tuple<string, IList<ModelObjectParameterDefinition>> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple); Tuple<string, IList<ModelObjectParameterDefinition>> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple);
Tuple<string, string, string, EquipmentDictionaryVersion> equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName, equipmentTypeVersionTuple.Item4); Tuple<string, string, string, EquipmentDictionaryVersion> equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName, equipmentTypeVersionTuple.Item4);
_ = GetEquipmentDictionaryIsAlwaysEnabledEventsTuple(equipmentDictionaryVersionTuple); _ = GetEquipmentDictionaryIsAlwaysEnabledEventsTuple(equipmentDictionaryVersionTuple);
if (!string.IsNullOrEmpty(sourceFileLocation) && sourceFileLocation != fileConnectorConfigurationTuple.Item2.SourceFileLocation) if (!string.IsNullOrEmpty(sourceFileLocation) && sourceFileLocation != fileConnectorConfigurationTuple.Item2.SourceFileLocation)
fileConnectorConfigurationTuple.Item2.SourceFileLocation = sourceFileLocation; fileConnectorConfigurationTuple.Item2.SourceFileLocation = sourceFileLocation;
@ -975,33 +984,29 @@ public class AdaptationTesting : ISMTP
_ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder); _ = 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; return result;
} }
public string[] GetVariables(MethodBase methodBase, string check) public string[] GetVariables(MethodBase methodBase, string check, bool validatePDSF = true)
{ {
string[] results; string[] results;
string[] lines; string[] lines;
string ipdsfFile; string ipdsfFile;
string textFileDirectory; string[] segments;
string fileNameWithoutExtension; string fileNameWithoutExtension;
string searchPattern = "*.ipdsf"; string searchPattern = "*.ipdsf";
string methodBaseNameWithActualCICN;
string sourceFileFilter = string.Empty; string sourceFileFilter = string.Empty;
string sourceFileLocation = string.Empty; string sourceFileLocation = string.Empty;
string[] segments = GetSegments(methodBase); MethodBaseName mbn = GetMethodBaseName(methodBase);
string ticks = GetTicks(segments); string[] textFiles = GetTextFiles(mbn);
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);
if (!textFiles.Any()) if (!textFiles.Any())
textFileDirectory = string.Empty; {
else if (_HasWaitForProperty)
textFileDirectory = Path.GetDirectoryName(textFiles[0]); throw new Exception("Set text file!");
sourceFileLocation = mbn.DummyDirectory;
}
foreach (string textFile in textFiles) foreach (string textFile in textFiles)
{ {
lines = File.ReadAllLines(textFile); lines = File.ReadAllLines(textFile);
@ -1012,18 +1017,20 @@ public class AdaptationTesting : ISMTP
sourceFileFilter = lines[0]; sourceFileFilter = lines[0];
else if (fileNameWithoutExtension == nameof(FileConnectorConfiguration.SourceFileLocation)) 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) if (segments.Length > 2)
throw new Exception("Ticks should only appear once in source file location!"); throw new Exception("Ticks should only appear once in source file location!");
if (segments.Length != 2) if (segments.Length != 2)
throw new Exception("Ticks missing from source file location!"); 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!"); 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!"); throw new Exception("Method name missing from source file location!");
sourceFileLocation = lines[0]; sourceFileLocation = lines[0];
} }
} }
FileInfo fileInfo = new(mbn.FileFullName);
if (!Directory.Exists(fileInfo.Directory.FullName)) if (!Directory.Exists(fileInfo.Directory.FullName))
_ = Directory.CreateDirectory(fileInfo.Directory.FullName); _ = Directory.CreateDirectory(fileInfo.Directory.FullName);
if (!fileInfo.Exists) if (!fileInfo.Exists)
@ -1044,25 +1051,30 @@ public class AdaptationTesting : ISMTP
fileConnectorConfiguration.SourceFileFilter = sourceFileFilter; fileConnectorConfiguration.SourceFileFilter = sourceFileFilter;
if (!string.IsNullOrEmpty(sourceFileLocation)) if (!string.IsNullOrEmpty(sourceFileLocation))
fileConnectorConfiguration.SourceFileLocation = sourceFileLocation; fileConnectorConfiguration.SourceFileLocation = sourceFileLocation;
if (string.IsNullOrEmpty(sourceFileLocation)) if (!validatePDSF)
ipdsfFile = searchPattern; ipdsfFile = string.Empty;
else else
{ {
string ipdsfDirectory = Path.Combine(sourceFileLocation, "ipdsf"); if (string.IsNullOrEmpty(sourceFileLocation))
if (!Directory.Exists(ipdsfDirectory))
ipdsfFile = searchPattern; ipdsfFile = searchPattern;
else else
{ {
string[] files = Directory.GetFiles(ipdsfDirectory, searchPattern, SearchOption.TopDirectoryOnly); string ipdsfDirectory = Path.Combine(sourceFileLocation, "ipdsf");
if (files.Any()) if (!Directory.Exists(ipdsfDirectory))
ipdsfFile = files[0];
else
ipdsfFile = searchPattern; 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) results = new string[] { fileInfo.FullName, json, fileConnectorConfiguration.SourceFileLocation, fileConnectorConfiguration.SourceFileFilter, ipdsfFile, mbn.TextFileDirectory };
throw new Exception();
results = new string[] { fileInfo.FullName, json, fileConnectorConfiguration.SourceFileLocation, fileConnectorConfiguration.SourceFileFilter, ipdsfFile, textFileDirectory };
if (string.IsNullOrEmpty(results[0])) if (string.IsNullOrEmpty(results[0]))
throw new Exception(); throw new Exception();
if (string.IsNullOrEmpty(results[1])) if (string.IsNullOrEmpty(results[1]))
@ -1071,7 +1083,7 @@ public class AdaptationTesting : ISMTP
throw new Exception(); throw new Exception();
if (string.IsNullOrEmpty(results[3])) if (string.IsNullOrEmpty(results[3]))
throw new Exception(); throw new Exception();
if (string.IsNullOrEmpty(results[4])) if (validatePDSF && string.IsNullOrEmpty(results[4]))
throw new Exception(); throw new Exception();
if (string.IsNullOrEmpty(results[5])) if (string.IsNullOrEmpty(results[5]))
throw new Exception(); throw new Exception();
@ -1232,29 +1244,33 @@ public class AdaptationTesting : ISMTP
{ {
string result; string result;
Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult = fileRead.ReExtract(); Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult = fileRead.ReExtract();
Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); if (!fileRead.IsDuplicator)
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<string>(), Array.Empty<string>()));
else
{ {
Tuple<string, string[], string[]> pdsf = GetLogisticsColumnsAndBody(variables[2], variables[4]); Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
Tuple<string, string[], string[]> pdsfNew = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf); Assert.IsNotNull(extractResult.Item3);
CompareSave(variables[5], pdsf, pdsfNew); Assert.IsNotNull(extractResult.Item4);
Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!"); if (!validatePDSF)
string[] json = GetItem2(pdsf, pdsfNew); _ = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, new(string.Empty, Array.Empty<string>(), Array.Empty<string>()));
CompareSaveJSON(variables[5], json); else
Assert.IsTrue(json[0] == json[1], "Item2 check!"); {
string[] join = GetItem3(pdsf, pdsfNew); Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
CompareSaveTSV(variables[5], join); Tuple<string, string[], string[]> pdsf = GetLogisticsColumnsAndBody(variables[2], variables[4]);
Assert.IsTrue(join[0] == join[1], "Item3 (Join) check!"); Tuple<string, string[], string[]> 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; result = extractResult.Item1;
return result; return result;
} }
} }
// namespace Adaptation._Tests.Helpers { public class AdaptationTesting { } } // namespace Adaptation._Tests.Helpers { public class AdaptationTesting { } }
// 2022-05-12 -> AdaptationTesting // 2022-08-05 -> AdaptationTesting

View File

@ -10,13 +10,13 @@ public class EAFLoggingUnitTesting : LoggingUnitTesting, IDisposable
public AdaptationTesting AdaptationTesting => _AdaptationTesting; 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) base(testContext, declaringType)
{ {
if (testContext is null || declaringType is null) if (testContext is null || declaringType is null)
_AdaptationTesting = null; _AdaptationTesting = null;
else else
_AdaptationTesting = new AdaptationTesting(testContext, skipEquipmentDictionary); _AdaptationTesting = new AdaptationTesting(dummyRoot, testContext, skipEquipmentDictionary, _TestContextPropertiesAsJson, _HasWaitForProperty);
} }
public new void Dispose() public new void Dispose()

View File

@ -26,7 +26,7 @@ public class LoggingUnitTesting : UnitTesting, IDisposable
base(testContext, declaringType) base(testContext, declaringType)
{ {
_LoggerFactory = new LoggerFactory(); _LoggerFactory = new LoggerFactory();
if (testContext is null || declaringType is null) if (testContext is null || declaringType is null || _IsEnvironment is null)
{ {
_ConfigurationRoot = null; _ConfigurationRoot = null;
_DefaultLogLevel = null; _DefaultLogLevel = null;

View File

@ -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;
}
}

View File

@ -13,9 +13,13 @@ namespace Adaptation._Tests.Shared;
public class UnitTesting public class UnitTesting
{ {
protected readonly bool _HasWaitForProperty;
protected readonly IsEnvironment _IsEnvironment; protected readonly IsEnvironment _IsEnvironment;
protected readonly string _TestContextPropertiesAsJson;
public IsEnvironment IsEnvironment => _IsEnvironment; public IsEnvironment IsEnvironment => _IsEnvironment;
public bool HasWaitForProperty => _HasWaitForProperty;
public string TestContextPropertiesAsJson => _TestContextPropertiesAsJson;
public UnitTesting(TestContext testContext, Type declaringType) public UnitTesting(TestContext testContext, Type declaringType)
{ {
@ -23,38 +27,47 @@ public class UnitTesting
_IsEnvironment = null; _IsEnvironment = null;
else else
{ {
string waitFor = "\"WaitFor\":";
string projectDirectory = GetProjectDirectory(testContext); string projectDirectory = GetProjectDirectory(testContext);
string json = JsonSerializer.Serialize(testContext.Properties); if (string.IsNullOrEmpty(projectDirectory))
string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode"); _IsEnvironment = null;
if (!Directory.Exists(vsCodeDirectory)) else
_ = Directory.CreateDirectory(vsCodeDirectory);
string launchText = GetLaunchText();
File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText);
for (int i = 0; i < int.MaxValue; i++)
{ {
if (!json.Contains("Debugger.IsAttached") || Debugger.IsAttached) _TestContextPropertiesAsJson = JsonSerializer.Serialize(testContext.Properties, new JsonSerializerOptions { WriteIndented = true });
break; _HasWaitForProperty = _TestContextPropertiesAsJson.Contains(waitFor);
Thread.Sleep(500); string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode");
} if (!Directory.Exists(vsCodeDirectory))
MethodBase methodBase = declaringType.GetMethod(testContext.TestName); _ = Directory.CreateDirectory(vsCodeDirectory);
if (methodBase is not null) string launchText = GetLaunchText();
{ File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText);
TestCategoryAttribute testCategoryAttribute = methodBase.GetCustomAttribute<TestCategoryAttribute>(); if (_HasWaitForProperty)
if (testCategoryAttribute is not null)
{ {
foreach (string testCategory in testCategoryAttribute.TestCategories) for (int i = 0; i < int.MaxValue; i++)
_IsEnvironment = new IsEnvironment(testCategory); {
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<TestCategoryAttribute>();
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) internal static string GetProjectDirectory(TestContext testContext)
{ {
string result; string result;
string[] checkFiles = null; string[] checkFiles;
result = Path.GetDirectoryName(testContext.DeploymentDirectory); result = Path.GetDirectoryName(testContext.DeploymentDirectory);
for (int i = 0; i < int.MaxValue; i++) for (int i = 0; i < int.MaxValue; i++)
{ {
@ -65,8 +78,6 @@ public class UnitTesting
break; break;
result = Path.GetDirectoryName(result); result = Path.GetDirectoryName(result);
} }
if (string.IsNullOrEmpty(result) || checkFiles is null || !checkFiles.Any())
throw new Exception(result);
return result; return result;
} }

View File

@ -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"));
}
}

View File

@ -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"));
}
}

View File

@ -59,7 +59,7 @@
"Password": "tLIPgqM6R9hVQOteRnTHwPqIg3Zxv8CohTjFkjkFz8k=" "Password": "tLIPgqM6R9hVQOteRnTHwPqIg3Zxv8CohTjFkjkFz8k="
}, },
{ {
"Use": true, "Use": false,
"Letter": "k", "Letter": "k",
"Share": "\\\\messdv002.na.infineon.com\\GaN_NEC\\Characterization", "Share": "\\\\messdv002.na.infineon.com\\GaN_NEC\\Characterization",
"User": "INFINEON\\MESGaNEAF", "User": "INFINEON\\MESGaNEAF",
@ -80,35 +80,35 @@
"Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00=" "Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00="
}, },
{ {
"Use": true, "Use": false,
"Letter": "n", "Letter": "n",
"Share": "\\\\10.95.154.22\\C", "Share": "\\\\10.95.154.22\\C",
"User": "10.95.154.22\\Aixtron", "User": "10.95.154.22\\Aixtron",
"Password": "DYVBOr2HJdB7KOhd/IFhLA==" "Password": "DYVBOr2HJdB7KOhd/IFhLA=="
}, },
{ {
"Use": true, "Use": false,
"Letter": "o", "Letter": "o",
"Share": "\\\\10.95.154.16\\Aixtron", "Share": "\\\\10.95.154.16\\Aixtron",
"User": "10.95.154.16\\Aixtron", "User": "10.95.154.16\\Aixtron",
"Password": "DYVBOr2HJdB7KOhd/IFhLA==" "Password": "DYVBOr2HJdB7KOhd/IFhLA=="
}, },
{ {
"Use": true, "Use": false,
"Letter": "p", "Letter": "p",
"Share": "\\\\10.95.154.15\\Aixtron", "Share": "\\\\10.95.154.15\\Aixtron",
"User": "10.95.154.15\\Aixtron", "User": "10.95.154.15\\Aixtron",
"Password": "DYVBOr2HJdB7KOhd/IFhLA==" "Password": "DYVBOr2HJdB7KOhd/IFhLA=="
}, },
{ {
"Use": true, "Use": false,
"Letter": "q", "Letter": "q",
"Share": "\\\\10.95.154.21\\Data", "Share": "\\\\10.95.154.21\\Data",
"User": "10.95.154.21\\XRD04Admin", "User": "10.95.154.21\\XRD04Admin",
"Password": "v1NOsEOCvbnhzKabspPcCQ==" "Password": "v1NOsEOCvbnhzKabspPcCQ=="
}, },
{ {
"Use": true, "Use": false,
"Letter": "r", "Letter": "r",
"Share": "\\\\10.95.154.23\\Data", "Share": "\\\\10.95.154.23\\Data",
"User": "\"10.95.154.23\\infineon us\"", "User": "\"10.95.154.23\\infineon us\"",

View File

@ -59,7 +59,7 @@
"Password": "tLIPgqM6R9hVQOteRnTHwPqIg3Zxv8CohTjFkjkFz8k=" "Password": "tLIPgqM6R9hVQOteRnTHwPqIg3Zxv8CohTjFkjkFz8k="
}, },
{ {
"Use": true, "Use": false,
"Letter": "k", "Letter": "k",
"Share": "\\\\messdv002.na.infineon.com\\GaN_NEC\\Characterization", "Share": "\\\\messdv002.na.infineon.com\\GaN_NEC\\Characterization",
"User": "INFINEON\\MESGaNEAF", "User": "INFINEON\\MESGaNEAF",
@ -80,35 +80,35 @@
"Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00=" "Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00="
}, },
{ {
"Use": true, "Use": false,
"Letter": "n", "Letter": "n",
"Share": "\\\\10.95.154.22\\C", "Share": "\\\\10.95.154.22\\C",
"User": "10.95.154.22\\Aixtron", "User": "10.95.154.22\\Aixtron",
"Password": "DYVBOr2HJdB7KOhd/IFhLA==" "Password": "DYVBOr2HJdB7KOhd/IFhLA=="
}, },
{ {
"Use": true, "Use": false,
"Letter": "o", "Letter": "o",
"Share": "\\\\10.95.154.16\\Aixtron", "Share": "\\\\10.95.154.16\\Aixtron",
"User": "10.95.154.16\\Aixtron", "User": "10.95.154.16\\Aixtron",
"Password": "DYVBOr2HJdB7KOhd/IFhLA==" "Password": "DYVBOr2HJdB7KOhd/IFhLA=="
}, },
{ {
"Use": true, "Use": false,
"Letter": "p", "Letter": "p",
"Share": "\\\\10.95.154.15\\Aixtron", "Share": "\\\\10.95.154.15\\Aixtron",
"User": "10.95.154.15\\Aixtron", "User": "10.95.154.15\\Aixtron",
"Password": "DYVBOr2HJdB7KOhd/IFhLA==" "Password": "DYVBOr2HJdB7KOhd/IFhLA=="
}, },
{ {
"Use": true, "Use": false,
"Letter": "q", "Letter": "q",
"Share": "\\\\10.95.154.21\\Data", "Share": "\\\\10.95.154.21\\Data",
"User": "10.95.154.21\\XRD04Admin", "User": "10.95.154.21\\XRD04Admin",
"Password": "v1NOsEOCvbnhzKabspPcCQ==" "Password": "v1NOsEOCvbnhzKabspPcCQ=="
}, },
{ {
"Use": true, "Use": false,
"Letter": "r", "Letter": "r",
"Share": "\\\\10.95.154.23\\Data", "Share": "\\\\10.95.154.23\\Data",
"User": "\"10.95.154.23\\infineon us\"", "User": "\"10.95.154.23\\infineon us\"",

View File

@ -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", "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", "pull": "git pull",
"garbage-collect": "git gc", "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\\\")", "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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"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=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")",
"EDA": "\\\\messv02ecc1.ec.local\\EC_EDA\\Staging\\PDSF\\MET08ANLYSDIFAAST230\\So~~~~~~~~~~~~~~~urce", "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", "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", "IQSSi": "\\\\messv02ecc1.ec.local\\EC_EDA\\Staging\\PDSF\\MET08ANLYSDIFAAST230\\11~~~~~~~~~~~~~~~\\messv02ecc1.ec.local\\EC_SPC_Si\\PDSF\\MET08ANLYSDIFAAST230\\Source",

172
Jenkinsfile vendored
View File

@ -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()
}
}
}

View File

@ -11,7 +11,8 @@
<RootNamespace>MET08ANLYSDIFAAST230</RootNamespace> <RootNamespace>MET08ANLYSDIFAAST230</RootNamespace>
<AssemblyName>MET08ANLYSDIFAAST230</AssemblyName> <AssemblyName>MET08ANLYSDIFAAST230</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<RuntimeIdentifier>win-x86</RuntimeIdentifier> <RuntimeIdentifier Condition="'$(Configuration)' == 'Debug'">win-x86</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(Configuration)' == 'Release'">win</RuntimeIdentifier>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@ -105,6 +106,7 @@
<Compile Include="Adaptation\FileHandlers\OpenInsightMetrologyViewerAttachments\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\OpenInsightMetrologyViewerAttachments\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\OpenInsightMetrologyViewer\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\OpenInsightMetrologyViewer\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\OpenInsight\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\OpenInsight\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\OpenInsight\FromIQS.cs" />
<Compile Include="Adaptation\FileHandlers\Processed\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\Processed\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\SPaCe\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\SPaCe\FileRead.cs" />
<Compile Include="Adaptation\Ifx\Eaf\Common\Configuration\ConnectionSetting.cs" /> <Compile Include="Adaptation\Ifx\Eaf\Common\Configuration\ConnectionSetting.cs" />
@ -112,6 +114,12 @@
<Compile Include="Adaptation\Ifx\Eaf\EquipmentConnector\File\Component\FilePathGenerator.cs" /> <Compile Include="Adaptation\Ifx\Eaf\EquipmentConnector\File\Component\FilePathGenerator.cs" />
<Compile Include="Adaptation\Ifx\Eaf\EquipmentConnector\File\Configuration\FileConnectorConfiguration.cs" /> <Compile Include="Adaptation\Ifx\Eaf\EquipmentConnector\File\Configuration\FileConnectorConfiguration.cs" />
<Compile Include="Adaptation\Ifx\Eaf\EquipmentConnector\File\SelfDescription\FileConnectorParameterTypeDefinitionProvider.cs" /> <Compile Include="Adaptation\Ifx\Eaf\EquipmentConnector\File\SelfDescription\FileConnectorParameterTypeDefinitionProvider.cs" />
<Compile Include="Adaptation\Infineon\Monitoring\MonA\ExtWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Adaptation\Infineon\Monitoring\MonA\IMonIn.cs" />
<Compile Include="Adaptation\Infineon\Monitoring\MonA\MonIn.cs" />
<Compile Include="Adaptation\Infineon\Monitoring\MonA\State.cs" />
<Compile Include="Adaptation\PeerGroup\GCL\Annotations\NotNullAttribute.cs" /> <Compile Include="Adaptation\PeerGroup\GCL\Annotations\NotNullAttribute.cs" />
<Compile Include="Adaptation\PeerGroup\GCL\SecsDriver\HsmsConnectionMode.cs" /> <Compile Include="Adaptation\PeerGroup\GCL\SecsDriver\HsmsConnectionMode.cs" />
<Compile Include="Adaptation\PeerGroup\GCL\SecsDriver\HsmsSessionMode.cs" /> <Compile Include="Adaptation\PeerGroup\GCL\SecsDriver\HsmsSessionMode.cs" />
@ -148,7 +156,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Infineon.EAF.Runtime"> <PackageReference Include="Infineon.EAF.Runtime">
<Version>2.43.0</Version> <Version>2.47.0</Version>
</PackageReference> </PackageReference>
<PackageReference Include="System.Text.Json"> <PackageReference Include="System.Text.Json">
<Version>6.0.3</Version> <Version>6.0.3</Version>

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.43.0.0")] [assembly: AssemblyVersion("2.47.5.0")]
[assembly: AssemblyFileVersion("2.43.0.0")] [assembly: AssemblyFileVersion("2.47.5.0")]