ZipPath and yml
This commit is contained in:
parent
91b162a7eb
commit
5e87407ead
13
.gitignore
vendored
13
.gitignore
vendored
@ -331,8 +331,11 @@ ASALocalRun/
|
||||
##
|
||||
## Visual Studio Code
|
||||
##
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*/!.vscode/extensions.json
|
||||
*/!.vscode/launch.json
|
||||
*/!.vscode/settings.json
|
||||
*/!.vscode/tasks.json
|
||||
*/.vscode/*
|
||||
*/.vscode/ReportGenerator/*
|
||||
|
||||
*.lnk
|
||||
|
172
.groovy
172
.groovy
@ -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 = 'DEP08SIHTRPLC'
|
||||
@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()
|
||||
}
|
||||
}
|
||||
}
|
12
Adaptation/.config/dotnet-tools.json
Normal file
12
Adaptation/.config/dotnet-tools.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-reportgenerator-globaltool": {
|
||||
"version": "5.1.15",
|
||||
"commands": [
|
||||
"reportgenerator"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -76,13 +76,18 @@ csharp_using_directive_placement = outside_namespace
|
||||
dotnet_code_quality_unused_parameters = all
|
||||
dotnet_code_quality_unused_parameters = non_public # IDE0060: Remove unused parameter
|
||||
dotnet_code_quality.CAXXXX.api_surface = private, internal
|
||||
dotnet_diagnostic.CA1816.severity = none # CA1816: Call GC.SuppressFinalize correctly
|
||||
dotnet_diagnostic.CA1825.severity = warning # CA1823: Avoid zero-length array allocations
|
||||
dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available
|
||||
dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable
|
||||
dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer AsSpan over Substring
|
||||
dotnet_diagnostic.CA1847.severity = none # CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters
|
||||
dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name
|
||||
dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2");
|
||||
dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant.
|
||||
dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary
|
||||
dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed
|
||||
dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049)
|
||||
dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter
|
||||
dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning
|
||||
dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case
|
||||
@ -215,7 +220,7 @@ dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true
|
||||
dotnet_style_predefined_type_for_member_access = true
|
||||
dotnet_style_predefined_type_for_member_access = true:warning
|
||||
dotnet_style_prefer_auto_properties = true:warning
|
||||
dotnet_style_prefer_compound_assignment = true:warning
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = false
|
||||
|
2
Adaptation/.vscode/launch.json
vendored
2
Adaptation/.vscode/launch.json
vendored
@ -4,7 +4,7 @@
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": 24076
|
||||
"processId": 13820
|
||||
}
|
||||
]
|
||||
}
|
||||
|
4
Adaptation/.vscode/settings.json
vendored
4
Adaptation/.vscode/settings.json
vendored
@ -52,6 +52,7 @@
|
||||
"XRDXRR",
|
||||
"XRDXY"
|
||||
],
|
||||
"coverage-gutters.coverageBaseDir": "../../../../DEP08SIHTRPLC/05_TestResults/TestResults/**",
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.activeBackground": "#7ea1d9",
|
||||
"activityBar.activeBorder": "#f8e6ed",
|
||||
@ -69,7 +70,8 @@
|
||||
"titleBar.activeBackground": "#5684ce",
|
||||
"titleBar.activeForeground": "#e7e7e7",
|
||||
"titleBar.inactiveBackground": "#5684ce99",
|
||||
"titleBar.inactiveForeground": "#e7e7e799"
|
||||
"titleBar.inactiveForeground": "#e7e7e799",
|
||||
"commandCenter.border": "#e7e7e799"
|
||||
},
|
||||
"peacock.color": "#5684ce",
|
||||
"cSpell.enabled": false
|
||||
|
155
Adaptation/DEP08SIHTRPLC-Development.yml
Normal file
155
Adaptation/DEP08SIHTRPLC-Development.yml
Normal file
@ -0,0 +1,155 @@
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- Development
|
||||
paths:
|
||||
include:
|
||||
- "Adaptation/*"
|
||||
|
||||
pool:
|
||||
name: Mesa-Windows-Service
|
||||
demands: DEP08SIHTRPLC-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
|
@ -15,6 +15,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VSTestLogger>trx</VSTestLogger>
|
||||
<VSTestCollect>XPlat Code Coverage</VSTestCollect>
|
||||
<VSTestResultsDirectory>../../../../DEP08SIHTRPLC/05_TestResults/TestResults</VSTestResultsDirectory>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
@ -32,50 +33,8 @@
|
||||
<DefineConstants>Linux</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="6.0.0" />
|
||||
<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="coverlet.collector" Version="3.2.0" />
|
||||
<PackageReference Include="FFMpegCore" Version="5.0.2" />
|
||||
<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.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.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="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>
|
||||
<None Include="appsettings.json">
|
||||
|
153
Adaptation/DEP08SIHTRPLC.yml
Normal file
153
Adaptation/DEP08SIHTRPLC.yml
Normal file
@ -0,0 +1,153 @@
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
paths:
|
||||
include:
|
||||
- "Adaptation/*"
|
||||
|
||||
pool:
|
||||
name: Mesa-Windows-Service
|
||||
demands: DEP08SIHTRPLC
|
||||
|
||||
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
|
@ -165,14 +165,18 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
|
||||
private void ZipFilesByDate(string sourceDirectory, SearchOption searchOption, string dayFormat)
|
||||
{
|
||||
#nullable enable
|
||||
string key;
|
||||
bool addFile;
|
||||
string? zipPath;
|
||||
string fileName;
|
||||
string[] segments;
|
||||
string[] subFiles;
|
||||
string weekOfYear;
|
||||
FileInfo fileInfo;
|
||||
string zipDirectory;
|
||||
DateTime creationTime;
|
||||
string? directoryName;
|
||||
DateTime lastWriteTime;
|
||||
DateTime nowDateTime = DateTime.Now;
|
||||
Regex regex = new("[a-zA-Z0-9]{1,}");
|
||||
@ -201,7 +205,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
foreach (string topDirectory in topDirectories)
|
||||
{
|
||||
keyValuePairs.Clear();
|
||||
directoryName = Path.GetDirectoryName(topDirectory);
|
||||
subFiles = Directory.GetFiles(topDirectory, "*", searchOption);
|
||||
zipPath = string.IsNullOrEmpty(directoryName) ? null : Path.Combine(directoryName, "ZipPath");
|
||||
zipDirectory = zipPath is not null && Directory.Exists(zipPath) ? zipPath : topDirectory;
|
||||
foreach (string subFile in subFiles)
|
||||
{
|
||||
addFile = false;
|
||||
@ -253,12 +260,12 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
}
|
||||
foreach (KeyValuePair<string, List<string>> element in keyValuePairs)
|
||||
{
|
||||
key = Path.Combine(topDirectory, $"{element.Key}.zip");
|
||||
key = Path.Combine(zipDirectory, $"{element.Key}.zip");
|
||||
if (File.Exists(key))
|
||||
{
|
||||
for (short i = 101; i < short.MaxValue; i++)
|
||||
{
|
||||
key = Path.Combine(topDirectory, $"{element.Key}_{i}.zip");
|
||||
key = Path.Combine(zipDirectory, $"{element.Key}_{i}.zip");
|
||||
if (!File.Exists(key))
|
||||
break;
|
||||
}
|
||||
@ -269,18 +276,24 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
_ = zip.CreateEntryFromFile(file, Path.GetFileName(file));
|
||||
File.Delete(file);
|
||||
}
|
||||
if (zipPath is not null && Directory.Exists(zipPath) && !string.IsNullOrEmpty(directoryName))
|
||||
{
|
||||
try
|
||||
{ Directory.SetLastWriteTime(directoryName, DateTime.Now); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
subFiles = Directory.GetFiles(topDirectory, "*.zip", SearchOption.TopDirectoryOnly);
|
||||
subFiles = Directory.GetFiles(zipDirectory, "*.zip", SearchOption.TopDirectoryOnly);
|
||||
foreach (string subFile in subFiles)
|
||||
{
|
||||
fileName = Path.GetFileNameWithoutExtension(subFile);
|
||||
segments = fileName.Split('_');
|
||||
if (segments.Length > 2)
|
||||
fileName = string.Concat(segments[0], '_', segments[1], '_', segments[2]);
|
||||
if (weeks.ContainsKey(fileName))
|
||||
if (weeks.TryGetValue(fileName, out DateTime value))
|
||||
{
|
||||
try
|
||||
{ File.SetLastWriteTime(subFile, weeks[fileName]); }
|
||||
{ File.SetLastWriteTime(subFile, value); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
@ -292,6 +305,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
}
|
||||
_Log.Info(topDirectory);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
||||
private void ZipFilesByDate()
|
||||
|
20
Adaptation/Infineon/Monitoring/MonA/ExtWebClient.cs
Normal file
20
Adaptation/Infineon/Monitoring/MonA/ExtWebClient.cs
Normal 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; }
|
||||
}
|
167
Adaptation/Infineon/Monitoring/MonA/IMonIn.cs
Normal file
167
Adaptation/Infineon/Monitoring/MonA/IMonIn.cs
Normal 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);
|
||||
}
|
292
Adaptation/Infineon/Monitoring/MonA/MonIn.cs
Normal file
292
Adaptation/Infineon/Monitoring/MonA/MonIn.cs
Normal 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();
|
||||
}
|
||||
|
||||
}
|
11
Adaptation/Infineon/Monitoring/MonA/State.cs
Normal file
11
Adaptation/Infineon/Monitoring/MonA/State.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace Infineon.Monitoring.MonA;
|
||||
|
||||
public enum State
|
||||
{
|
||||
Up,
|
||||
Ok,
|
||||
Warning,
|
||||
Critical,
|
||||
Down,
|
||||
Unknown,
|
||||
}
|
@ -12,6 +12,7 @@ public class Description : IDescription, Properties.IDescription
|
||||
public int Test { get; set; }
|
||||
public int Count { get; set; }
|
||||
public int Index { get; set; }
|
||||
public string RDS { get; set; }
|
||||
//
|
||||
public string EventName { get; set; }
|
||||
public string NullData { get; set; }
|
||||
@ -139,4 +140,6 @@ public class Description : IDescription, Properties.IDescription
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt";
|
||||
|
||||
}
|
@ -54,6 +54,7 @@ public class FileRead : Properties.IFileRead
|
||||
string Properties.IFileRead.EventName => _EventName;
|
||||
string Properties.IFileRead.MesEntity => _MesEntity;
|
||||
bool Properties.IFileRead.IsEAFHosted => _IsEAFHosted;
|
||||
bool Properties.IFileRead.IsDuplicator => _IsDuplicator;
|
||||
string Properties.IFileRead.EquipmentType => _EquipmentType;
|
||||
string Properties.IFileRead.ReportFullPath => _ReportFullPath;
|
||||
string Properties.IFileRead.CellInstanceName => _CellInstanceName;
|
||||
@ -259,24 +260,23 @@ public class FileRead : Properties.IFileRead
|
||||
return results;
|
||||
}
|
||||
|
||||
protected static string GetTupleFile(Logistics logistics, Properties.IScopeInfo scopeInfo, string duplicateDirectory)
|
||||
protected static string GetTupleFile<T>(Logistics logistics, List<T> descriptions, Properties.IScopeInfo scopeInfo, string duplicateDirectory) where T : Properties.IDescription
|
||||
{
|
||||
string result;
|
||||
string rds;
|
||||
string dateValue;
|
||||
string datePlaceholder;
|
||||
string[] segments = logistics.MID.Split('-');
|
||||
if (segments.Length < 2)
|
||||
rds = "%RDS%";
|
||||
string rdsPlaceholder = "%RDS%";
|
||||
if (!descriptions.Any() || string.IsNullOrEmpty(descriptions[0].RDS))
|
||||
rds = logistics.MID;
|
||||
else
|
||||
rds = segments[1];
|
||||
segments = scopeInfo.FileName.Split(new string[] { "DateTime:" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
rds = descriptions[0].RDS;
|
||||
string[] segments = scopeInfo.FileName.Split(new string[] { "DateTime:" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (segments.Length == 0)
|
||||
result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileNameWithoutExtension.Replace("%RDS%", rds));
|
||||
result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileNameWithoutExtension.Replace(rdsPlaceholder, rds));
|
||||
else
|
||||
{
|
||||
datePlaceholder = "%DateTime%";
|
||||
segments = segments[1].Split('%');
|
||||
string datePlaceholder = "%DateTime%";
|
||||
dateValue = logistics.DateTimeFromSequence.ToString(segments[0]);
|
||||
foreach (string segment in scopeInfo.FileName.Split('%'))
|
||||
{
|
||||
@ -284,18 +284,19 @@ public class FileRead : Properties.IFileRead
|
||||
continue;
|
||||
datePlaceholder = string.Concat('%', segment, '%');
|
||||
}
|
||||
result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileName.Replace("%RDS%", rds).Replace(datePlaceholder, dateValue));
|
||||
result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileName.Replace(rdsPlaceholder, rds).Replace(datePlaceholder, dateValue));
|
||||
}
|
||||
if (result.Contains('%'))
|
||||
throw new Exception("Placeholder exists!");
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void WaitForFileConsumption(string sourceDirectoryCloaking, Logistics logistics, DateTime dateTime, string successDirectory, string duplicateDirectory, string duplicateFile, List<(Properties.IScopeInfo, string)> tuples)
|
||||
protected void WaitForFileConsumption<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;
|
||||
long preWait;
|
||||
string tupleFile;
|
||||
string tupleFileName = string.Empty;
|
||||
List<string> duplicateFiles = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
List<int> consumedFileIndices = new();
|
||||
@ -305,26 +306,28 @@ public class FileRead : Properties.IFileRead
|
||||
preWait = dateTime.AddMilliseconds(1234).Ticks;
|
||||
else
|
||||
preWait = dateTime.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks;
|
||||
if (!tuples.Any())
|
||||
if (!collection.Any())
|
||||
duplicateFiles.Add(duplicateFile);
|
||||
string fileName = Path.GetFileNameWithoutExtension(logistics.ReportFullPath);
|
||||
string successFile = string.Concat(successDirectory, @"\", Path.GetFileName(logistics.ReportFullPath));
|
||||
foreach ((Properties.IScopeInfo scopeInfo, string text) in tuples)
|
||||
foreach ((Properties.IScopeInfo scopeInfo, string text) in collection)
|
||||
{
|
||||
if (scopeInfo.FileName.StartsWith(@"\"))
|
||||
tupleFile = scopeInfo.FileName;
|
||||
else if (!scopeInfo.FileName.Contains('%'))
|
||||
tupleFile = string.Concat(duplicateDirectory, @"\", fileName, "_", scopeInfo.FileNameWithoutExtension, ".pdsfc");
|
||||
else
|
||||
tupleFile = GetTupleFile(logistics, scopeInfo, duplicateDirectory);
|
||||
tupleFile = GetTupleFile(logistics, descriptions, scopeInfo, duplicateDirectory);
|
||||
tupleFileName = Path.GetFileNameWithoutExtension(tupleFile).Split('.')[0];
|
||||
duplicateFiles.Add(tupleFile);
|
||||
File.WriteAllText(tupleFile, text);
|
||||
if (_IsEAFHosted)
|
||||
File.WriteAllText(tupleFile, text);
|
||||
}
|
||||
for (short i = 0; i < short.MaxValue; i++)
|
||||
{
|
||||
if (DateTime.Now.Ticks > preWait)
|
||||
break;
|
||||
Thread.Sleep(500);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
if (!moreThanAnHour)
|
||||
{
|
||||
@ -339,7 +342,17 @@ public class FileRead : Properties.IFileRead
|
||||
for (int i = 0; i < duplicateFiles.Count; i++)
|
||||
{
|
||||
if (!File.Exists(duplicateFiles[i]))
|
||||
consumedFileIndices.Add(i);
|
||||
{
|
||||
if (string.IsNullOrEmpty(tupleFileName))
|
||||
consumedFileIndices.Add(i);
|
||||
else if (duplicateFiles.All(l => Path.GetFileNameWithoutExtension(l).Split('.')[0] == tupleFileName))
|
||||
{
|
||||
for (int j = 0; j < duplicateFiles.Count; j++)
|
||||
consumedFileIndices.Add(j);
|
||||
}
|
||||
else
|
||||
consumedFileIndices.Add(i);
|
||||
}
|
||||
}
|
||||
if (consumedFileIndices.Count == duplicateFiles.Count)
|
||||
break;
|
||||
@ -360,7 +373,7 @@ public class FileRead : Properties.IFileRead
|
||||
}
|
||||
throw new Exception(string.Concat("After {", _BreakAfterSeconds, "} seconds, right side of {", sourceDirectoryCloaking, "} didn't consume file(s) ", stringBuilder));
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -598,10 +611,10 @@ public class FileRead : Properties.IFileRead
|
||||
}
|
||||
}
|
||||
|
||||
protected void WaitForFileConsumption(DateTime dateTime, bool isDummyRun, string successDirectory, string duplicateDirectory, List<(Properties.IScopeInfo, string)> tuples, string duplicateFile)
|
||||
protected void WaitForFileConsumption<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)
|
||||
WaitForFileConsumption(_FileConnectorConfiguration.SourceDirectoryCloaking, _Logistics, dateTime, successDirectory, duplicateDirectory, duplicateFile, tuples);
|
||||
WaitForFileConsumption(_FileConnectorConfiguration.SourceDirectoryCloaking, _Logistics, dateTime, descriptions, successDirectory, duplicateDirectory, duplicateFile, collection);
|
||||
else
|
||||
{
|
||||
long breakAfter = DateTime.Now.AddSeconds(_FileConnectorConfiguration.ConnectionRetryInterval.Value).Ticks;
|
||||
|
@ -51,7 +51,7 @@ public class Logistics : ILogistics
|
||||
_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))
|
||||
throw new Exception();
|
||||
@ -59,7 +59,7 @@ public class Logistics : ILogistics
|
||||
throw new Exception();
|
||||
_NullData = fileRead.NullData;
|
||||
_FileInfo = new(reportFullPath);
|
||||
DateTime dateTime = _FileInfo.LastWriteTime;
|
||||
DateTime dateTime = new(_FileInfo.LastWriteTime.Ticks + tickOffset);
|
||||
if (fileInfoLength.HasValue && _FileInfo.Length < fileInfoLength.Value)
|
||||
dateTime = dateTime.AddTicks(-1);
|
||||
_JobID = fileRead.CellInstanceName;
|
||||
|
@ -16,7 +16,7 @@ public class ScopeInfo : Properties.IScopeInfo
|
||||
public string QueryFilter { get; private set; }
|
||||
public string FileNameWithoutExtension { get; private set; }
|
||||
|
||||
public ScopeInfo(Test test, string fileName, string queryFilter = "", string title = "", string html = "")
|
||||
public ScopeInfo(Test test, string fileName, string queryFilter = "", string title = "", string html = "", string extraExtension = "")
|
||||
{
|
||||
Enum = test;
|
||||
Test = test;
|
||||
|
@ -30,7 +30,7 @@ public partial class WS
|
||||
};
|
||||
HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead).Result;
|
||||
resultsJson = httpResponseMessage.Content.ReadAsStringAsync().Result;
|
||||
results = JsonSerializer.Deserialize<Results>(resultsJson);
|
||||
results = JsonSerializer.Deserialize<Results>(resultsJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
}
|
||||
if (!results.Success)
|
||||
results.Errors.Add(results.ToString());
|
||||
@ -44,8 +44,7 @@ public partial class WS
|
||||
_ = stringBuilder.AppendLine(exception.Message);
|
||||
exception = exception.InnerException;
|
||||
}
|
||||
if (results.Errors is null)
|
||||
results.Errors = new List<string>();
|
||||
results.Errors ??= new List<string>();
|
||||
results.Errors.Add(stringBuilder.ToString());
|
||||
}
|
||||
return new(resultsJson, results);
|
||||
|
@ -91,8 +91,7 @@ public class ProcessDataStandardFormat
|
||||
string segment;
|
||||
List<string> body = new();
|
||||
StringBuilder logistics = new();
|
||||
if (lines is null)
|
||||
lines = File.ReadAllLines(reportFullPath);
|
||||
lines ??= File.ReadAllLines(reportFullPath);
|
||||
string[] segments;
|
||||
if (lines.Length < 7)
|
||||
segments = Array.Empty<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)
|
||||
{
|
||||
StringBuilder result = new();
|
||||
if (ignoreParameterNames is null)
|
||||
ignoreParameterNames = new List<string>();
|
||||
ignoreParameterNames ??= new List<string>();
|
||||
if (useDateTimeFromSequence && !string.IsNullOrEmpty(format))
|
||||
throw new Exception();
|
||||
else if (!useDateTimeFromSequence && string.IsNullOrEmpty(format))
|
||||
@ -357,8 +355,7 @@ public class ProcessDataStandardFormat
|
||||
if (string.IsNullOrEmpty(lines[i]))
|
||||
continue;
|
||||
segments = lines[i].Split(inputSeparator);
|
||||
if (currentGroup is null)
|
||||
currentGroup = segments.Length;
|
||||
currentGroup ??= segments.Length;
|
||||
if (segments.Length != currentGroup)
|
||||
{
|
||||
currentGroup = segments.Length;
|
||||
|
@ -6,5 +6,6 @@ public interface IDescription
|
||||
int Test { get; }
|
||||
int Count { get; }
|
||||
int Index { get; }
|
||||
string RDS { get; }
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ public interface IFileRead
|
||||
string MesEntity { get; }
|
||||
bool IsEAFHosted { get; }
|
||||
string EventName { get; }
|
||||
bool IsDuplicator { get; }
|
||||
string EquipmentType { get; }
|
||||
string ReportFullPath { get; }
|
||||
string CellInstanceName { get; }
|
||||
|
@ -15,23 +15,23 @@ public class DEP08SIHTRPLC : EAFLoggingUnitTesting
|
||||
#pragma warning disable CA2254
|
||||
#pragma warning disable IDE0060
|
||||
|
||||
internal static string DummyRoot { get; private set; }
|
||||
internal static DEP08SIHTRPLC EAFLoggingUnitTesting { get; private set; }
|
||||
|
||||
public DEP08SIHTRPLC() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
|
||||
public DEP08SIHTRPLC() : base(DummyRoot, testContext: null, declaringType: null, skipEquipmentDictionary: false)
|
||||
{
|
||||
if (EAFLoggingUnitTesting is null)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public DEP08SIHTRPLC(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)
|
||||
public DEP08SIHTRPLC(TestContext testContext) : base(DummyRoot, testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)
|
||||
{
|
||||
}
|
||||
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext testContext)
|
||||
{
|
||||
if (EAFLoggingUnitTesting is null)
|
||||
EAFLoggingUnitTesting = new DEP08SIHTRPLC(testContext);
|
||||
EAFLoggingUnitTesting ??= new DEP08SIHTRPLC(testContext);
|
||||
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
|
||||
string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
|
||||
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
|
||||
@ -41,12 +41,13 @@ public class DEP08SIHTRPLC : EAFLoggingUnitTesting
|
||||
[ClassCleanup()]
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
if (EAFLoggingUnitTesting.Logger is not null)
|
||||
EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
|
||||
if (EAFLoggingUnitTesting is not null)
|
||||
EAFLoggingUnitTesting.Dispose();
|
||||
EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup");
|
||||
EAFLoggingUnitTesting?.Dispose();
|
||||
}
|
||||
|
||||
#if true
|
||||
[Ignore]
|
||||
#endif
|
||||
[TestMethod]
|
||||
public void Staging__v2_43_0__DEP08SIHTRPLC__ZipFilesByDate()
|
||||
{
|
||||
|
@ -18,6 +18,9 @@ public class DEP08SIHTRPLC
|
||||
_DEP08SIHTRPLC = CreateSelfDescription.Staging.v2_43_0.DEP08SIHTRPLC.EAFLoggingUnitTesting;
|
||||
}
|
||||
|
||||
#if true
|
||||
[Ignore]
|
||||
#endif
|
||||
[TestMethod]
|
||||
public void Staging__v2_43_0__DEP08SIHTRPLC__ZipFilesByDate() => _DEP08SIHTRPLC.Staging__v2_43_0__DEP08SIHTRPLC__ZipFilesByDate();
|
||||
|
||||
|
@ -26,10 +26,13 @@ namespace Adaptation._Tests.Shared;
|
||||
public class AdaptationTesting : ISMTP
|
||||
{
|
||||
|
||||
protected readonly string _DummyRoot;
|
||||
protected readonly string _Environment;
|
||||
protected readonly string _HostNameAndPort;
|
||||
protected readonly bool _HasWaitForProperty;
|
||||
protected readonly TestContext _TestContext;
|
||||
protected readonly bool _SkipEquipmentDictionary;
|
||||
protected readonly string _TestContextPropertiesAsJson;
|
||||
protected readonly Dictionary<string, CellInstanceVersion> _CellInstanceVersions;
|
||||
protected readonly Dictionary<string, EquipmentTypeVersion> _EquipmentTypeVersions;
|
||||
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, List<Tuple<string, string>>> _EquipmentDictionaryEventDescriptions;
|
||||
|
||||
public string DummyRoot => _DummyRoot;
|
||||
public string Environment => _Environment;
|
||||
public TestContext TestContext => _TestContext;
|
||||
public string HostNameAndPort => _HostNameAndPort;
|
||||
public bool HasWaitForProperty => _HasWaitForProperty;
|
||||
public bool SkipEquipmentDictionary => _SkipEquipmentDictionary;
|
||||
public string TestContextPropertiesAsJson => _TestContextPropertiesAsJson;
|
||||
public Dictionary<string, CellInstanceVersion> CellInstanceVersions => _CellInstanceVersions;
|
||||
public Dictionary<string, EquipmentTypeVersion> EquipmentTypeVersions => _EquipmentTypeVersions;
|
||||
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();
|
||||
|
||||
public AdaptationTesting(TestContext testContext, bool skipEquipmentDictionary)
|
||||
public AdaptationTesting(string dummyRoot, TestContext testContext, bool skipEquipmentDictionary, string testContextPropertiesAsJson, bool hasWaitForProperty)
|
||||
{
|
||||
|
||||
string environment = GetEnvironment(testContext);
|
||||
string hostNameAndPort = GetHostNameAndPort(environment);
|
||||
_DummyRoot = dummyRoot;
|
||||
_TestContext = testContext;
|
||||
_Environment = environment;
|
||||
_HostNameAndPort = hostNameAndPort;
|
||||
_HasWaitForProperty = hasWaitForProperty;
|
||||
_SkipEquipmentDictionary = skipEquipmentDictionary;
|
||||
_TestContextPropertiesAsJson = testContextPropertiesAsJson;
|
||||
_CellInstanceVersions = new Dictionary<string, CellInstanceVersion>();
|
||||
_EquipmentTypeVersions = new Dictionary<string, EquipmentTypeVersion>();
|
||||
_EquipmentTypeVersions = new Dictionary<string, EquipmentTypeVersion>();
|
||||
_ParameterizedModelObjectDefinitionTypes = new Dictionary<string, string>();
|
||||
_ParameterizedModelObjectDefinitionTypes = new Dictionary<string, string>();
|
||||
_EquipmentDictionaryVersions = new Dictionary<string, EquipmentDictionaryVersion>();
|
||||
_FileConnectorConfigurations = new Dictionary<string, FileConnectorConfiguration>();
|
||||
@ -94,23 +105,28 @@ public class AdaptationTesting : ISMTP
|
||||
return result;
|
||||
}
|
||||
|
||||
protected string GetTestResultsDirectory()
|
||||
public static string GetTestResultsDirectory(string testContextTestResultsDirectory, bool hasWaitForProperty)
|
||||
{
|
||||
string result = string.Empty;
|
||||
string testResults = "05_TestResults";
|
||||
string checkDirectory = _TestContext.TestResultsDirectory;
|
||||
if (string.IsNullOrEmpty(checkDirectory) || !checkDirectory.Contains(testResults))
|
||||
throw new Exception();
|
||||
string rootDirectory = Path.GetPathRoot(checkDirectory);
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
string checkDirectory = testContextTestResultsDirectory;
|
||||
if (hasWaitForProperty && (string.IsNullOrEmpty(checkDirectory) || !checkDirectory.Contains(testResults)))
|
||||
throw new Exception($"A:{checkDirectory}; B:{testResults};");
|
||||
else if (!hasWaitForProperty && (string.IsNullOrEmpty(checkDirectory) || !checkDirectory.Contains(testResults)))
|
||||
result = testContextTestResultsDirectory;
|
||||
else
|
||||
{
|
||||
checkDirectory = Path.GetDirectoryName(checkDirectory);
|
||||
if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == rootDirectory)
|
||||
break;
|
||||
if (checkDirectory.EndsWith(testResults) && Directory.Exists(checkDirectory))
|
||||
string rootDirectory = Path.GetPathRoot(checkDirectory);
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
result = checkDirectory;
|
||||
break;
|
||||
checkDirectory = Path.GetDirectoryName(checkDirectory);
|
||||
if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == rootDirectory)
|
||||
break;
|
||||
if (checkDirectory.EndsWith(testResults) && Directory.Exists(checkDirectory))
|
||||
{
|
||||
result = checkDirectory;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(result))
|
||||
@ -118,6 +134,12 @@ public class AdaptationTesting : ISMTP
|
||||
return result;
|
||||
}
|
||||
|
||||
private string GetTestResultsDirectory(bool hasWaitForProperty)
|
||||
{
|
||||
string result = GetTestResultsDirectory(_TestContext.TestResultsDirectory, hasWaitForProperty);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected static string GetCellInstanceConnectionName(string cellInstanceConnectionName)
|
||||
{
|
||||
string result;
|
||||
@ -170,28 +192,29 @@ public class AdaptationTesting : ISMTP
|
||||
return results;
|
||||
}
|
||||
|
||||
internal string[] GetSegments(string methodBaseName)
|
||||
public static MethodBaseName GetMethodBaseName(string dummyRoot, string environment, bool hasWaitForProperty, string methodBaseName, string testResultsDirectory)
|
||||
{
|
||||
List<string> results;
|
||||
string fileFullName;
|
||||
MethodBaseName result;
|
||||
string comment;
|
||||
string[] textFiles;
|
||||
string fileFullName;
|
||||
string dummyDirectory;
|
||||
string withActualCICN;
|
||||
string separator = "__";
|
||||
string textFileDirectory;
|
||||
string connectionNameAndTicks;
|
||||
string cellInstanceConnectionName;
|
||||
string ticks = DateTime.Now.Ticks.ToString();
|
||||
string cellInstanceConnectionNameFromMethodBaseName;
|
||||
string testResultsDirectory = GetTestResultsDirectory();
|
||||
string[] segments = methodBaseName.Split(new string[] { separator }, StringSplitOptions.None);
|
||||
if (segments[0] != _Environment)
|
||||
if (segments[0] != environment)
|
||||
throw new Exception();
|
||||
string rawVersionName = segments[1];
|
||||
string rawCellInstanceName = segments[2];
|
||||
string cellInstanceVersionName = segments[1].Replace('_', '.');
|
||||
string cellInstanceName = segments[2].Replace('_', '-').Replace("_EQPT", "-EQPT");
|
||||
string before = string.Concat(_Environment, separator, rawVersionName, separator, cellInstanceName, separator);
|
||||
string before = string.Concat(environment, separator, rawVersionName, separator, cellInstanceName, separator);
|
||||
string after = methodBaseName.Substring(before.Length);
|
||||
string versionDirectory = Path.Combine(testResultsDirectory, _Environment, cellInstanceName, cellInstanceVersionName);
|
||||
string versionDirectory = Path.Combine(testResultsDirectory, environment, cellInstanceName, cellInstanceVersionName);
|
||||
if (!Directory.Exists(versionDirectory))
|
||||
_ = Directory.CreateDirectory(versionDirectory);
|
||||
comment = segments[segments.Length - 1];
|
||||
@ -221,87 +244,76 @@ public class AdaptationTesting : ISMTP
|
||||
cellInstanceConnectionNameFromMethodBaseName = after;
|
||||
}
|
||||
cellInstanceConnectionName = GetCellInstanceConnectionName(cellInstanceConnectionNameFromMethodBaseName);
|
||||
string methodBaseNameWithActualCICN = GetMethodBaseNameWithActualCICN(methodBaseName, rawCellInstanceName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceConnectionName, ticks);
|
||||
withActualCICN = GetMethodBaseNameWithActualCICN(methodBaseName, rawCellInstanceName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceConnectionName, ticks);
|
||||
if (hasWaitForProperty)
|
||||
dummyDirectory = string.Empty;
|
||||
else if (string.IsNullOrEmpty(ticks))
|
||||
dummyDirectory = string.Empty;
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(dummyRoot))
|
||||
throw new Exception($"{nameof(dummyRoot)} is empty!");
|
||||
if (!withActualCICN.Contains(ticks))
|
||||
throw new Exception($"{withActualCICN} doesn't contain {ticks}!");
|
||||
segments = withActualCICN.Split(new string[] { ticks }, StringSplitOptions.None);
|
||||
dummyDirectory = Path.Combine(dummyRoot, cellInstanceName, ticks, string.Join(null, segments));
|
||||
if (!Directory.Exists(dummyDirectory))
|
||||
_ = Directory.CreateDirectory(dummyDirectory);
|
||||
}
|
||||
if (string.IsNullOrEmpty(ticks))
|
||||
{
|
||||
textFiles = Array.Empty<string>();
|
||||
fileFullName = Path.Combine(versionDirectory, methodBaseNameWithActualCICN, $"{cellInstanceConnectionNameFromMethodBaseName}.json");
|
||||
textFileDirectory = string.Empty;
|
||||
fileFullName = Path.Combine(versionDirectory, withActualCICN, $"{cellInstanceConnectionNameFromMethodBaseName}.json");
|
||||
}
|
||||
else
|
||||
{
|
||||
segments = methodBaseNameWithActualCICN.Split(new string[] { ticks }, StringSplitOptions.None);
|
||||
string textDirectory = Path.Combine(versionDirectory, segments[0], string.Concat(ticks, segments[1]));
|
||||
segments = withActualCICN.Split(new string[] { ticks }, StringSplitOptions.None);
|
||||
textFileDirectory = Path.Combine(versionDirectory, segments[0], string.Concat(ticks, segments[1]));
|
||||
fileFullName = Path.Combine(versionDirectory, segments[0], $"{cellInstanceConnectionNameFromMethodBaseName}.json");
|
||||
if (!Directory.Exists(textDirectory))
|
||||
}
|
||||
result = new(after, before, cellInstanceConnectionName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceName, cellInstanceVersionName, comment, dummyDirectory, fileFullName, rawCellInstanceName, rawVersionName, separator, testResultsDirectory, textFileDirectory, ticks, versionDirectory, withActualCICN);
|
||||
return result;
|
||||
}
|
||||
|
||||
private MethodBaseName GetMethodBaseName(MethodBase methodBase)
|
||||
{
|
||||
MethodBaseName result;
|
||||
string testResultsDirectory = GetTestResultsDirectory(_HasWaitForProperty);
|
||||
result = GetMethodBaseName(_DummyRoot, _Environment, _HasWaitForProperty, methodBase.Name, testResultsDirectory);
|
||||
return result;
|
||||
}
|
||||
|
||||
private string[] GetTextFiles(MethodBaseName mbn)
|
||||
{
|
||||
string[] results;
|
||||
if (string.IsNullOrEmpty(mbn.TextFileDirectory))
|
||||
results = Array.Empty<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(textDirectory), $"_Rename - {Path.GetFileName(textDirectory)}");
|
||||
string renameDirectory = Path.Combine(Path.GetDirectoryName(mbn.TextFileDirectory), $"_Rename - {Path.GetFileName(mbn.TextFileDirectory)}");
|
||||
_ = Directory.CreateDirectory(renameDirectory);
|
||||
_ = Process.Start("explorer.exe", renameDirectory);
|
||||
File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileFilter)}.txt"), string.Empty);
|
||||
File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileLocation)}.txt"), string.Empty);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
results = Directory.GetFiles(mbn.TextFileDirectory, "*.txt", SearchOption.TopDirectoryOnly);
|
||||
if (!string.IsNullOrEmpty(mbn.Ticks) && _HasWaitForProperty && !results.Any())
|
||||
{
|
||||
textFiles = Directory.GetFiles(textDirectory, "*.txt", SearchOption.TopDirectoryOnly);
|
||||
if (!textFiles.Any())
|
||||
{
|
||||
_ = Process.Start("explorer.exe", textDirectory);
|
||||
File.WriteAllText(Path.Combine(textDirectory, "_ Why.why"), string.Empty);
|
||||
}
|
||||
_ = Process.Start("explorer.exe", mbn.TextFileDirectory);
|
||||
File.WriteAllText(Path.Combine(mbn.TextFileDirectory, "_ Why.why"), string.Empty);
|
||||
}
|
||||
}
|
||||
results = new List<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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
MemoryStream memoryStream = new();
|
||||
@ -331,7 +343,7 @@ public class AdaptationTesting : ISMTP
|
||||
return result as T;
|
||||
}
|
||||
|
||||
protected static CellInstanceVersion GetCellInstanceVersion(string url)
|
||||
public static CellInstanceVersion GetCellInstanceVersion(string url)
|
||||
{
|
||||
CellInstanceVersion result;
|
||||
byte[] byteArray;
|
||||
@ -466,6 +478,7 @@ public class AdaptationTesting : ISMTP
|
||||
AppendLine("#pragma warning disable CA2254").
|
||||
AppendLine("#pragma warning disable IDE0060").
|
||||
AppendLine().
|
||||
AppendLine("internal static string DummyRoot { get; private set; }").
|
||||
Append("internal static ").Append(cellInstanceNameWithoutHyphen).AppendLine(" EAFLoggingUnitTesting { get; private set; }");
|
||||
else
|
||||
throw new Exception();
|
||||
@ -474,13 +487,15 @@ public class AdaptationTesting : ISMTP
|
||||
else if (i == 1)
|
||||
_ = stringBuilder.
|
||||
AppendLine().
|
||||
Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)").
|
||||
Append("static ").Append(cellInstanceNameWithoutHyphen).AppendLine("() => DummyRoot = @\"\\\\messv02ecc1.ec.local\\EC_Characterization_Si\\Dummy\";").
|
||||
AppendLine().
|
||||
Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("() : base(DummyRoot, testContext: null, declaringType: null, skipEquipmentDictionary: false)").
|
||||
AppendLine("{").
|
||||
AppendLine("if (EAFLoggingUnitTesting is null)").
|
||||
AppendLine("throw new Exception();").
|
||||
AppendLine("}").
|
||||
AppendLine().
|
||||
Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)").
|
||||
Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("(TestContext testContext) : base(DummyRoot, testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)").
|
||||
AppendLine("{").
|
||||
AppendLine("}").
|
||||
AppendLine();
|
||||
@ -541,6 +556,9 @@ public class AdaptationTesting : ISMTP
|
||||
if (i == 2)
|
||||
{
|
||||
_ = stringBuilder.
|
||||
AppendLine("#if true").
|
||||
AppendLine("[Ignore]").
|
||||
AppendLine("#endif").
|
||||
AppendLine("[TestMethod]").
|
||||
Append("public void ").Append(methodName).Append("() => ").Append('_').Append(cellInstanceNameWithoutHyphen).Append('.').Append(methodName).AppendLine("();").AppendLine();
|
||||
}
|
||||
@ -550,13 +568,16 @@ public class AdaptationTesting : ISMTP
|
||||
throw new Exception("Versions should match!");
|
||||
equipmentTypeName = componentsCellComponentCellComponent.Equipment.EquipmentType.Name;
|
||||
_ = stringBuilder.
|
||||
AppendLine("#if true").
|
||||
AppendLine("[Ignore]").
|
||||
AppendLine("#endif").
|
||||
AppendLine("[TestMethod]").
|
||||
Append("public void ").Append(methodName).AppendLine("()").
|
||||
AppendLine("{").
|
||||
Append("string check = \"").Append(check.Split('\\').Last()).AppendLine("\";").
|
||||
AppendLine("MethodBase methodBase = new StackFrame().GetMethod();").
|
||||
AppendLine("EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Getting configuration\"));").
|
||||
AppendLine("_ = Shared.AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);").
|
||||
AppendLine("_ = AdaptationTesting.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);").
|
||||
AppendLine("EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Exit\"));").
|
||||
AppendLine("}").
|
||||
AppendLine();
|
||||
@ -600,14 +621,10 @@ public class AdaptationTesting : ISMTP
|
||||
result = JsonSerializer.Deserialize<FileConnectorConfiguration>(json, jsonSerializerOptions);
|
||||
if (string.IsNullOrEmpty(result.SourceFileFilter))
|
||||
result.SourceFileFilter = string.Empty;
|
||||
if (result.ErrorTargetFileLocation is null)
|
||||
result.ErrorTargetFileLocation = string.Empty;
|
||||
if (result.SourceFileLocation is null)
|
||||
result.SourceFileLocation = string.Empty;
|
||||
if (result.TargetFileLocation is null)
|
||||
result.TargetFileLocation = string.Empty;
|
||||
if (result.FolderAgeCheckIndividualSubFolders is null)
|
||||
result.FolderAgeCheckIndividualSubFolders = false;
|
||||
result.ErrorTargetFileLocation ??= string.Empty;
|
||||
result.SourceFileLocation ??= string.Empty;
|
||||
result.TargetFileLocation ??= string.Empty;
|
||||
result.FolderAgeCheckIndividualSubFolders ??= false;
|
||||
result.ConnectionSettings = new List<ConnectionSetting>();
|
||||
result.SourceFileFilters = result.SourceFileFilter.Split('|').ToList();
|
||||
if (componentsCellComponentCellComponent.Equipment?.ConnectionSettings is not null)
|
||||
@ -857,7 +874,7 @@ public class AdaptationTesting : ISMTP
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Dictionary<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()
|
||||
{
|
||||
@ -866,6 +883,7 @@ public class AdaptationTesting : ISMTP
|
||||
{ nameof(cellInstanceName), cellInstanceName },
|
||||
{ nameof(equipmentTypeName), equipmentTypeName },
|
||||
{ nameof(cellInstanceVersionName), cellInstanceVersionName },
|
||||
{ nameof(edaConnectionPortNumber), edaConnectionPortNumber },
|
||||
{ nameof(equipmentDictionaryName), equipmentDictionaryName },
|
||||
{ nameof(cellInstanceConnectionName), cellInstanceConnectionName },
|
||||
{ nameof(FileConnectorConfiguration), fileConnectorConfiguration },
|
||||
@ -879,32 +897,26 @@ public class AdaptationTesting : ISMTP
|
||||
public string[] GetCSharpText(string testName)
|
||||
{
|
||||
string[] results;
|
||||
string[] segments = GetSegments(testName);
|
||||
FileInfo fileInfo = GetFileName(segments);
|
||||
string cellInstanceName = GetCellInstanceName(segments);
|
||||
string cellInstanceVersionName = GetCellInstanceVersionName(segments);
|
||||
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments);
|
||||
if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
|
||||
string testResultsDirectory = GetTestResultsDirectory(_HasWaitForProperty);
|
||||
MethodBaseName mbn = GetMethodBaseName(_DummyRoot, _Environment, _HasWaitForProperty, testName, testResultsDirectory);
|
||||
FileInfo fileInfo = new(mbn.FileFullName);
|
||||
if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
|
||||
_ = Directory.CreateDirectory(fileInfo.Directory.FullName);
|
||||
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName);
|
||||
results = GetCSharpTextB(fileInfo, cellInstanceName, cellInstanceVersionName, cellInstanceVersionTuple.Item2);
|
||||
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName);
|
||||
results = GetCSharpTextB(fileInfo, mbn.CellInstanceName, mbn.CellInstanceVersionName, cellInstanceVersionTuple.Item2);
|
||||
return results;
|
||||
}
|
||||
|
||||
public string[] GetConfiguration(MethodBase methodBase)
|
||||
{
|
||||
string[] results;
|
||||
string[] segments = GetSegments(methodBase.Name);
|
||||
string ticks = GetTicks(segments);
|
||||
FileInfo fileInfo = GetFileName(segments);
|
||||
string cellInstanceName = GetCellInstanceName(segments);
|
||||
string cellInstanceVersionName = GetCellInstanceVersionName(segments);
|
||||
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments);
|
||||
if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
|
||||
MethodBaseName mbn = GetMethodBaseName(methodBase);
|
||||
FileInfo fileInfo = new(mbn.FileFullName);
|
||||
if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
|
||||
_ = Directory.CreateDirectory(fileInfo.Directory.FullName);
|
||||
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName);
|
||||
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName);
|
||||
if (string.IsNullOrEmpty(ticks) && fileConnectorConfigurationTuple.Item2?.FileScanningIntervalInSeconds is not null)
|
||||
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName);
|
||||
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, mbn.CellInstanceConnectionName);
|
||||
if (string.IsNullOrEmpty(mbn.Ticks) && fileConnectorConfigurationTuple.Item2?.FileScanningIntervalInSeconds is not null)
|
||||
{
|
||||
string fileScanningIntervalInSecondsLine;
|
||||
string versionDirectory = Path.GetDirectoryName(fileInfo.DirectoryName);
|
||||
@ -914,12 +926,12 @@ public class AdaptationTesting : ISMTP
|
||||
fileScanningIntervalInSecondsLine = $"+\t{fileConnectorConfigurationTuple.Item2.FileScanningIntervalInSeconds.Value:+0000}\t{Path.GetFileName(fileInfo.DirectoryName)}";
|
||||
File.AppendAllLines(Path.Combine(versionDirectory, "FileScanningIntervalInSeconds.txt"), new string[] { fileScanningIntervalInSecondsLine });
|
||||
}
|
||||
Tuple<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, 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);
|
||||
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 });
|
||||
results = new string[] { fileInfo.FullName, json };
|
||||
return results;
|
||||
@ -928,22 +940,19 @@ public class AdaptationTesting : ISMTP
|
||||
public IFileRead Get(MethodBase methodBase, string sourceFileLocation, string sourceFileFilter, bool useCyclicalForDescription)
|
||||
{
|
||||
IFileRead result;
|
||||
string[] segments = GetSegments(methodBase.Name);
|
||||
FileInfo fileInfo = GetFileName(segments);
|
||||
string cellInstanceName = GetCellInstanceName(segments);
|
||||
string cellInstanceVersionName = GetCellInstanceVersionName(segments);
|
||||
MethodBaseName mbn = GetMethodBaseName(methodBase);
|
||||
FileInfo fileInfo = new(mbn.FileFullName);
|
||||
Dictionary<string, string> fileParameter = new();
|
||||
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments);
|
||||
if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
|
||||
if (!string.IsNullOrEmpty(mbn.CellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
|
||||
_ = Directory.CreateDirectory(fileInfo.Directory.FullName);
|
||||
Dictionary<string, List<long>> dummyRuns = new();
|
||||
Dictionary<long, List<string>> staticRuns = new();
|
||||
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName);
|
||||
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName);
|
||||
Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName);
|
||||
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName);
|
||||
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, mbn.CellInstanceConnectionName);
|
||||
Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, mbn.CellInstanceConnectionName);
|
||||
Tuple<string, string> parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(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);
|
||||
if (!string.IsNullOrEmpty(sourceFileLocation) && sourceFileLocation != fileConnectorConfigurationTuple.Item2.SourceFileLocation)
|
||||
fileConnectorConfigurationTuple.Item2.SourceFileLocation = sourceFileLocation;
|
||||
@ -975,33 +984,29 @@ public class AdaptationTesting : ISMTP
|
||||
_ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder);
|
||||
}
|
||||
}
|
||||
result = FileHandlers.CellInstanceConnectionName.Get(this, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryVersionTuple.Item2, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: false);
|
||||
result = FileHandlers.CellInstanceConnectionName.Get(this, fileParameter, mbn.CellInstanceName, mbn.CellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryVersionTuple.Item2, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: false);
|
||||
return result;
|
||||
}
|
||||
|
||||
public string[] GetVariables(MethodBase methodBase, string check)
|
||||
public string[] GetVariables(MethodBase methodBase, string check, bool validatePDSF = true)
|
||||
{
|
||||
string[] results;
|
||||
string[] lines;
|
||||
string ipdsfFile;
|
||||
string textFileDirectory;
|
||||
string[] segments;
|
||||
string fileNameWithoutExtension;
|
||||
string searchPattern = "*.ipdsf";
|
||||
string methodBaseNameWithActualCICN;
|
||||
string sourceFileFilter = string.Empty;
|
||||
string sourceFileLocation = string.Empty;
|
||||
string[] segments = GetSegments(methodBase);
|
||||
string ticks = GetTicks(segments);
|
||||
FileInfo fileInfo = GetFileName(segments);
|
||||
string[] textFiles = GetTextFiles(segments);
|
||||
string cellInstanceName = GetCellInstanceName(segments);
|
||||
string rawCellInstanceName = GetRawCellInstanceName(segments);
|
||||
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments);
|
||||
string cellInstanceConnectionNameFromMethodBaseName = GetCellInstanceConnectionNameFromMethodBaseName(segments);
|
||||
string methodBaseNameWithActualCICN = GetMethodBaseNameWithActualCICN(methodBase.Name, rawCellInstanceName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceConnectionName, ticks);
|
||||
MethodBaseName mbn = GetMethodBaseName(methodBase);
|
||||
string[] textFiles = GetTextFiles(mbn);
|
||||
if (!textFiles.Any())
|
||||
textFileDirectory = string.Empty;
|
||||
else
|
||||
textFileDirectory = Path.GetDirectoryName(textFiles[0]);
|
||||
{
|
||||
if (_HasWaitForProperty)
|
||||
throw new Exception("Set text file!");
|
||||
sourceFileLocation = mbn.DummyDirectory;
|
||||
}
|
||||
foreach (string textFile in textFiles)
|
||||
{
|
||||
lines = File.ReadAllLines(textFile);
|
||||
@ -1012,18 +1017,20 @@ public class AdaptationTesting : ISMTP
|
||||
sourceFileFilter = lines[0];
|
||||
else if (fileNameWithoutExtension == nameof(FileConnectorConfiguration.SourceFileLocation))
|
||||
{
|
||||
segments = lines[0].Split(new string[] { ticks }, StringSplitOptions.None);
|
||||
methodBaseNameWithActualCICN = GetMethodBaseNameWithActualCICN(methodBase.Name, mbn.RawCellInstanceName, mbn.CellInstanceConnectionNameFromMethodBaseName, mbn.CellInstanceConnectionName, mbn.Ticks);
|
||||
segments = lines[0].Split(new string[] { mbn.Ticks }, StringSplitOptions.None);
|
||||
if (segments.Length > 2)
|
||||
throw new Exception("Ticks should only appear once in source file location!");
|
||||
if (segments.Length != 2)
|
||||
throw new Exception("Ticks missing from source file location!");
|
||||
if (segments[1].Contains(ticks))
|
||||
if (segments[1].Contains(mbn.Ticks))
|
||||
throw new Exception("From source file location path should not contain ticks!");
|
||||
if (!segments[1].EndsWith(methodBaseNameWithActualCICN.Replace(ticks, string.Empty)))
|
||||
if (!segments[1].EndsWith(methodBaseNameWithActualCICN.Replace(mbn.Ticks, string.Empty)))
|
||||
throw new Exception("Method name missing from source file location!");
|
||||
sourceFileLocation = lines[0];
|
||||
}
|
||||
}
|
||||
FileInfo fileInfo = new(mbn.FileFullName);
|
||||
if (!Directory.Exists(fileInfo.Directory.FullName))
|
||||
_ = Directory.CreateDirectory(fileInfo.Directory.FullName);
|
||||
if (!fileInfo.Exists)
|
||||
@ -1044,25 +1051,30 @@ public class AdaptationTesting : ISMTP
|
||||
fileConnectorConfiguration.SourceFileFilter = sourceFileFilter;
|
||||
if (!string.IsNullOrEmpty(sourceFileLocation))
|
||||
fileConnectorConfiguration.SourceFileLocation = sourceFileLocation;
|
||||
if (string.IsNullOrEmpty(sourceFileLocation))
|
||||
ipdsfFile = searchPattern;
|
||||
if (!validatePDSF)
|
||||
ipdsfFile = string.Empty;
|
||||
else
|
||||
{
|
||||
string ipdsfDirectory = Path.Combine(sourceFileLocation, "ipdsf");
|
||||
if (!Directory.Exists(ipdsfDirectory))
|
||||
if (string.IsNullOrEmpty(sourceFileLocation))
|
||||
ipdsfFile = searchPattern;
|
||||
else
|
||||
{
|
||||
string[] files = Directory.GetFiles(ipdsfDirectory, searchPattern, SearchOption.TopDirectoryOnly);
|
||||
if (files.Any())
|
||||
ipdsfFile = files[0];
|
||||
else
|
||||
string ipdsfDirectory = Path.Combine(sourceFileLocation, "ipdsf");
|
||||
if (!Directory.Exists(ipdsfDirectory))
|
||||
ipdsfFile = searchPattern;
|
||||
else
|
||||
{
|
||||
string[] files = Directory.GetFiles(ipdsfDirectory, searchPattern, SearchOption.TopDirectoryOnly);
|
||||
if (files.Any())
|
||||
ipdsfFile = files[0];
|
||||
else
|
||||
ipdsfFile = searchPattern;
|
||||
}
|
||||
}
|
||||
if (ipdsfFile == searchPattern)
|
||||
throw new Exception();
|
||||
}
|
||||
if (ipdsfFile == searchPattern)
|
||||
throw new Exception();
|
||||
results = new string[] { fileInfo.FullName, json, fileConnectorConfiguration.SourceFileLocation, fileConnectorConfiguration.SourceFileFilter, ipdsfFile, textFileDirectory };
|
||||
results = new string[] { fileInfo.FullName, json, fileConnectorConfiguration.SourceFileLocation, fileConnectorConfiguration.SourceFileFilter, ipdsfFile, mbn.TextFileDirectory };
|
||||
if (string.IsNullOrEmpty(results[0]))
|
||||
throw new Exception();
|
||||
if (string.IsNullOrEmpty(results[1]))
|
||||
@ -1071,7 +1083,7 @@ public class AdaptationTesting : ISMTP
|
||||
throw new Exception();
|
||||
if (string.IsNullOrEmpty(results[3]))
|
||||
throw new Exception();
|
||||
if (string.IsNullOrEmpty(results[4]))
|
||||
if (validatePDSF && string.IsNullOrEmpty(results[4]))
|
||||
throw new Exception();
|
||||
if (string.IsNullOrEmpty(results[5]))
|
||||
throw new Exception();
|
||||
@ -1232,29 +1244,33 @@ public class AdaptationTesting : ISMTP
|
||||
{
|
||||
string result;
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult = fileRead.ReExtract();
|
||||
Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
|
||||
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
|
||||
Assert.IsNotNull(extractResult.Item4);
|
||||
if (!validatePDSF)
|
||||
_ = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, new(string.Empty, Array.Empty<string>(), Array.Empty<string>()));
|
||||
else
|
||||
if (!fileRead.IsDuplicator)
|
||||
{
|
||||
Tuple<string, string[], string[]> pdsf = GetLogisticsColumnsAndBody(variables[2], variables[4]);
|
||||
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!");
|
||||
Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
|
||||
Assert.IsNotNull(extractResult.Item3);
|
||||
Assert.IsNotNull(extractResult.Item4);
|
||||
if (!validatePDSF)
|
||||
_ = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, new(string.Empty, Array.Empty<string>(), Array.Empty<string>()));
|
||||
else
|
||||
{
|
||||
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
|
||||
Tuple<string, string[], string[]> pdsf = GetLogisticsColumnsAndBody(variables[2], variables[4]);
|
||||
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;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
// namespace Adaptation._Tests.Helpers { public class AdaptationTesting { } }
|
||||
// 2022-05-12 -> AdaptationTesting
|
||||
// 2022-08-05 -> AdaptationTesting
|
@ -10,13 +10,13 @@ public class EAFLoggingUnitTesting : LoggingUnitTesting, IDisposable
|
||||
|
||||
public AdaptationTesting AdaptationTesting => _AdaptationTesting;
|
||||
|
||||
public EAFLoggingUnitTesting(TestContext testContext, Type declaringType, bool skipEquipmentDictionary) :
|
||||
public EAFLoggingUnitTesting(string dummyRoot, TestContext testContext, Type declaringType, bool skipEquipmentDictionary) :
|
||||
base(testContext, declaringType)
|
||||
{
|
||||
if (testContext is null || declaringType is null)
|
||||
_AdaptationTesting = null;
|
||||
else
|
||||
_AdaptationTesting = new AdaptationTesting(testContext, skipEquipmentDictionary);
|
||||
_AdaptationTesting = new AdaptationTesting(dummyRoot, testContext, skipEquipmentDictionary, _TestContextPropertiesAsJson, _HasWaitForProperty);
|
||||
}
|
||||
|
||||
public new void Dispose()
|
||||
|
@ -26,7 +26,7 @@ public class LoggingUnitTesting : UnitTesting, IDisposable
|
||||
base(testContext, declaringType)
|
||||
{
|
||||
_LoggerFactory = new LoggerFactory();
|
||||
if (testContext is null || declaringType is null)
|
||||
if (testContext is null || declaringType is null || _IsEnvironment is null)
|
||||
{
|
||||
_ConfigurationRoot = null;
|
||||
_DefaultLogLevel = null;
|
||||
|
45
Adaptation/_Tests/Shared/MethodBaseName.cs
Normal file
45
Adaptation/_Tests/Shared/MethodBaseName.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -13,9 +13,13 @@ namespace Adaptation._Tests.Shared;
|
||||
public class UnitTesting
|
||||
{
|
||||
|
||||
protected readonly bool _HasWaitForProperty;
|
||||
protected readonly IsEnvironment _IsEnvironment;
|
||||
protected readonly string _TestContextPropertiesAsJson;
|
||||
|
||||
public IsEnvironment IsEnvironment => _IsEnvironment;
|
||||
public bool HasWaitForProperty => _HasWaitForProperty;
|
||||
public string TestContextPropertiesAsJson => _TestContextPropertiesAsJson;
|
||||
|
||||
public UnitTesting(TestContext testContext, Type declaringType)
|
||||
{
|
||||
@ -23,38 +27,47 @@ public class UnitTesting
|
||||
_IsEnvironment = null;
|
||||
else
|
||||
{
|
||||
string waitFor = "\"WaitFor\":";
|
||||
string projectDirectory = GetProjectDirectory(testContext);
|
||||
string json = JsonSerializer.Serialize(testContext.Properties);
|
||||
string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode");
|
||||
if (!Directory.Exists(vsCodeDirectory))
|
||||
_ = Directory.CreateDirectory(vsCodeDirectory);
|
||||
string launchText = GetLaunchText();
|
||||
File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText);
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
if (string.IsNullOrEmpty(projectDirectory))
|
||||
_IsEnvironment = null;
|
||||
else
|
||||
{
|
||||
if (!json.Contains("Debugger.IsAttached") || Debugger.IsAttached)
|
||||
break;
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
MethodBase methodBase = declaringType.GetMethod(testContext.TestName);
|
||||
if (methodBase is not null)
|
||||
{
|
||||
TestCategoryAttribute testCategoryAttribute = methodBase.GetCustomAttribute<TestCategoryAttribute>();
|
||||
if (testCategoryAttribute is not null)
|
||||
_TestContextPropertiesAsJson = JsonSerializer.Serialize(testContext.Properties, new JsonSerializerOptions { WriteIndented = true });
|
||||
_HasWaitForProperty = _TestContextPropertiesAsJson.Contains(waitFor);
|
||||
string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode");
|
||||
if (!Directory.Exists(vsCodeDirectory))
|
||||
_ = Directory.CreateDirectory(vsCodeDirectory);
|
||||
string launchText = GetLaunchText();
|
||||
File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText);
|
||||
if (_HasWaitForProperty)
|
||||
{
|
||||
foreach (string testCategory in testCategoryAttribute.TestCategories)
|
||||
_IsEnvironment = new IsEnvironment(testCategory);
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
if (!_TestContextPropertiesAsJson.Contains($"{waitFor} \"Debugger.IsAttached\"") || Debugger.IsAttached)
|
||||
break;
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
MethodBase methodBase = declaringType.GetMethod(testContext.TestName);
|
||||
if (methodBase is not null)
|
||||
{
|
||||
TestCategoryAttribute testCategoryAttribute = methodBase.GetCustomAttribute<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)
|
||||
{
|
||||
string result;
|
||||
string[] checkFiles = null;
|
||||
string[] checkFiles;
|
||||
result = Path.GetDirectoryName(testContext.DeploymentDirectory);
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
@ -65,8 +78,6 @@ public class UnitTesting
|
||||
break;
|
||||
result = Path.GetDirectoryName(result);
|
||||
}
|
||||
if (string.IsNullOrEmpty(result) || checkFiles is null || !checkFiles.Any())
|
||||
throw new Exception(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
72
Adaptation/_Tests/Static/DEP08SIHTRPLC.cs
Normal file
72
Adaptation/_Tests/Static/DEP08SIHTRPLC.cs
Normal 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 DEP08SIHTRPLC : LoggingUnitTesting, IDisposable
|
||||
{
|
||||
|
||||
#pragma warning disable CA2254
|
||||
#pragma warning disable IDE0060
|
||||
|
||||
internal static DEP08SIHTRPLC LoggingUnitTesting { get; private set; }
|
||||
|
||||
public DEP08SIHTRPLC() : base(testContext: null, declaringType: null)
|
||||
{
|
||||
if (LoggingUnitTesting is null)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public DEP08SIHTRPLC(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType)
|
||||
{
|
||||
}
|
||||
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext testContext) => LoggingUnitTesting ??= new DEP08SIHTRPLC(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("DEP08SIHTRPLC", "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"));
|
||||
}
|
||||
|
||||
}
|
76
Adaptation/_Tests/Static/PLC.cs
Normal file
76
Adaptation/_Tests/Static/PLC.cs
Normal file
@ -0,0 +1,76 @@
|
||||
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 PLC : LoggingUnitTesting, IDisposable
|
||||
{
|
||||
|
||||
#pragma warning disable CA2254
|
||||
#pragma warning disable IDE0060
|
||||
|
||||
internal static PLC LoggingUnitTesting { get; private set; }
|
||||
|
||||
public PLC() : base(testContext: null, declaringType: null)
|
||||
{
|
||||
if (LoggingUnitTesting is null)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public PLC(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType)
|
||||
{
|
||||
}
|
||||
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext testContext) => LoggingUnitTesting ??= new PLC(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("R47-PLC", "v2.19.0"),
|
||||
new("R70-PLC", "v2.19.0"),
|
||||
new("R72-PLC", "v2.19.0"),
|
||||
new("R73-PLC", "v2.19.0"),
|
||||
new("R74-PLC", "v2.19.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"));
|
||||
}
|
||||
|
||||
}
|
@ -59,7 +59,7 @@
|
||||
"Password": "tLIPgqM6R9hVQOteRnTHwPqIg3Zxv8CohTjFkjkFz8k="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "k",
|
||||
"Share": "\\\\messdv002.na.infineon.com\\GaN_NEC\\Characterization",
|
||||
"User": "INFINEON\\MESGaNEAF",
|
||||
@ -80,35 +80,35 @@
|
||||
"Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "n",
|
||||
"Share": "\\\\10.95.154.22\\C",
|
||||
"User": "10.95.154.22\\Aixtron",
|
||||
"Password": "DYVBOr2HJdB7KOhd/IFhLA=="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "o",
|
||||
"Share": "\\\\10.95.154.16\\Aixtron",
|
||||
"User": "10.95.154.16\\Aixtron",
|
||||
"Password": "DYVBOr2HJdB7KOhd/IFhLA=="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "p",
|
||||
"Share": "\\\\10.95.154.15\\Aixtron",
|
||||
"User": "10.95.154.15\\Aixtron",
|
||||
"Password": "DYVBOr2HJdB7KOhd/IFhLA=="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "q",
|
||||
"Share": "\\\\10.95.154.21\\Data",
|
||||
"User": "10.95.154.21\\XRD04Admin",
|
||||
"Password": "v1NOsEOCvbnhzKabspPcCQ=="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "r",
|
||||
"Share": "\\\\10.95.154.23\\Data",
|
||||
"User": "\"10.95.154.23\\infineon us\"",
|
||||
|
@ -59,7 +59,7 @@
|
||||
"Password": "tLIPgqM6R9hVQOteRnTHwPqIg3Zxv8CohTjFkjkFz8k="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "k",
|
||||
"Share": "\\\\messdv002.na.infineon.com\\GaN_NEC\\Characterization",
|
||||
"User": "INFINEON\\MESGaNEAF",
|
||||
@ -80,35 +80,35 @@
|
||||
"Password": "CUGygiPwahy4U3j+6KqqoMZ08STyVDR1rKm6MwPpt00="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "n",
|
||||
"Share": "\\\\10.95.154.22\\C",
|
||||
"User": "10.95.154.22\\Aixtron",
|
||||
"Password": "DYVBOr2HJdB7KOhd/IFhLA=="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "o",
|
||||
"Share": "\\\\10.95.154.16\\Aixtron",
|
||||
"User": "10.95.154.16\\Aixtron",
|
||||
"Password": "DYVBOr2HJdB7KOhd/IFhLA=="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "p",
|
||||
"Share": "\\\\10.95.154.15\\Aixtron",
|
||||
"User": "10.95.154.15\\Aixtron",
|
||||
"Password": "DYVBOr2HJdB7KOhd/IFhLA=="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "q",
|
||||
"Share": "\\\\10.95.154.21\\Data",
|
||||
"User": "10.95.154.21\\XRD04Admin",
|
||||
"Password": "v1NOsEOCvbnhzKabspPcCQ=="
|
||||
},
|
||||
{
|
||||
"Use": true,
|
||||
"Use": false,
|
||||
"Letter": "r",
|
||||
"Share": "\\\\10.95.154.23\\Data",
|
||||
"User": "\"10.95.154.23\\infineon us\"",
|
||||
|
@ -1,5 +1,8 @@
|
||||
{
|
||||
"scripts": {
|
||||
"AT-CreateSelfDescription.Staging.v2_43_0-DEP08SIHTRPLC": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0 & ClassName~DEP08SIHTRPLC\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")",
|
||||
"BA-Extract.Staging.v2_43_0-DEP08SIHTRPLC": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~DEP08SIHTRPLC\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")",
|
||||
"BB-Extract.Staging.v2_43_0-DEP08SIHTRPLC-Staging__v2_43_0__DEP08SIHTRPLC__ZipFilesByDate": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~DEP08SIHTRPLC & Name~Staging__v2_43_0__DEP08SIHTRPLC__ZipFilesByDate\" -- TestRunParameters.Parameter(name=\\\"WaitFor\\\", value=\\\"Debugger.IsAttached\\\")",
|
||||
"Alpha": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
"nuget-clear": "dotnet nuget locals all --clear",
|
||||
"build": "dotnet build --runtime win-x64 --self-contained",
|
||||
@ -9,9 +12,6 @@
|
||||
"dotnet-format": "dotnet format --report .vscode --verbosity detailed --severity warn",
|
||||
"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 ../DEP08SIHTRPLC.csproj",
|
||||
"pull": "git pull",
|
||||
"garbage-collect": "git gc",
|
||||
"AT-CreateSelfDescription.Staging.v2_43_0-DEP08SIHTRPLC": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.CreateSelfDescription.Staging.v2_43_0 & ClassName~DEP08SIHTRPLC\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")",
|
||||
"BA-Extract.Staging.v2_43_0-DEP08SIHTRPLC": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~DEP08SIHTRPLC\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")",
|
||||
"BB-Extract.Staging.v2_43_0-DEP08SIHTRPLC-Staging__v2_43_0__DEP08SIHTRPLC__ZipFilesByDate": "dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~Adaptation._Tests.Extract.Staging.v2_43_0 & ClassName~DEP08SIHTRPLC & Name~Staging__v2_43_0__DEP08SIHTRPLC__ZipFilesByDate\" -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")"
|
||||
"garbage-collect": "git gc"
|
||||
}
|
||||
}
|
@ -11,7 +11,8 @@
|
||||
<RootNamespace>DEP08SIHTRPLC</RootNamespace>
|
||||
<AssemblyName>DEP08SIHTRPLC</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
|
||||
<RuntimeIdentifier Condition="'$(Configuration)' == 'Debug'">win-x86</RuntimeIdentifier>
|
||||
<RuntimeIdentifier Condition="'$(Configuration)' == 'Release'">win</RuntimeIdentifier>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
@ -95,6 +96,12 @@
|
||||
<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\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\SecsDriver\HsmsConnectionMode.cs" />
|
||||
<Compile Include="Adaptation\PeerGroup\GCL\SecsDriver\HsmsSessionMode.cs" />
|
||||
@ -137,7 +144,7 @@
|
||||
<Version>4.7.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Infineon.EAF.Runtime">
|
||||
<Version>2.43.0</Version>
|
||||
<Version>2.47.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Instances">
|
||||
<Version>1.6.1</Version>
|
||||
|
172
Jenkinsfile
vendored
172
Jenkinsfile
vendored
@ -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 = 'DEP08SIHTRPLC'
|
||||
@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()
|
||||
}
|
||||
}
|
||||
}
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.43.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.43.0.0")]
|
||||
[assembly: AssemblyVersion("2.47.5.0")]
|
||||
[assembly: AssemblyFileVersion("2.47.5.0")]
|
||||
|
@ -1,20 +0,0 @@
|
||||
# Introduction
|
||||
DEP08SIHTRPLC EAF adaptation
|
||||
|
||||
# Getting Started
|
||||
1. Framework - DEP08SIHTRPLC.csproj
|
||||
2. dotnet core - Adaptation\DEP08SIHTRPLC.Tests.csproj
|
||||
3. https://tfs.intra.infineon.com/tfs/ManufacturingIT/_packaging/eaf/nuget/v3/index.json
|
||||
4. https://packagemanagement.eu.infineon.com:4430/packages
|
||||
|
||||
# Build and Test
|
||||
See Adaptation\_Tests for dotnet core tests
|
||||
|
||||
# TFS
|
||||
$/MIT_EAF_Adaptations/Trunk/DEP08SIHTRPLC/06_SourceCode
|
||||
|
||||
# Last TFS Changeset
|
||||
N/A
|
||||
|
||||
# Git
|
||||
git@tfs.intra.infineon.com:22/tfs/ManufacturingIT/Mesa_FI/_git/DEP08SIHTRPLC
|
Loading…
x
Reference in New Issue
Block a user