Viewer to Server
| @ -83,6 +83,7 @@ dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name | |||||||
| dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. | dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. | ||||||
| dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2"); | dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2"); | ||||||
| dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary | dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary | ||||||
|  | dotnet_diagnostic.IDE0031.severity = warning # Use null propagation (IDE0031) | ||||||
| dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed | dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed | ||||||
| dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049) | dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049) | ||||||
| dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter | dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @ -52,7 +52,7 @@ BenchmarkDotNet.Artifacts/ | |||||||
| project.lock.json | project.lock.json | ||||||
| project.fragment.lock.json | project.fragment.lock.json | ||||||
| artifacts/ | artifacts/ | ||||||
| **/Properties/launchSettings.json | # **/Properties/launchSettings.json | ||||||
|  |  | ||||||
| # StyleCop | # StyleCop | ||||||
| StyleCopReport.xml | StyleCopReport.xml | ||||||
|  | |||||||
							
								
								
									
										266
									
								
								.groovy
									
									
									
									
									
								
							
							
						
						| @ -1,266 +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 _ExePath = '...' |  | ||||||
| @Field String _NGINXFile = '...' |  | ||||||
| @Field String _PortNumber = '...' |  | ||||||
| @Field String _AssemblyName = '...' |  | ||||||
| @Field String _AgentDevelopment = '' |  | ||||||
| @Field String _NetVersion = 'net6.0' |  | ||||||
| @Field String _GitCommitSeven = '...' |  | ||||||
| @Field String _TargetLocation = '...' |  | ||||||
| @Field String _FirstBeforePlus = '5000' |  | ||||||
| @Field String _GitName = 'OI-Metrology' |  | ||||||
| @Field String _MonARessource = 'OI_Metrology' |  | ||||||
| @Field String _WorkingDirectoryName = 'IFXApps' |  | ||||||
| @Field String _DDriveNet = "${_DDrive}${_NetVersion}" |  | ||||||
| @Field String _AgentStaging = 'messa010ec-ecfisysadmin' |  | ||||||
| @Field String _AgentProduction = 'messa010ec-ecfisysadmin' |  | ||||||
| @Field String _CredentialsId = 'Metrology-Username-Password' |  | ||||||
| @Field String _Company = 'Infineon Technologies Americas Corp.' |  | ||||||
| @Field String _ProgramFilesDotnet = 'C:/program files/dotnet/dotnet.exe' |  | ||||||
|  |  | ||||||
| pipeline { |  | ||||||
|     agent { |  | ||||||
|         label env.JENKINS_ENVIRONMENT == 'Development' ? _AgentDevelopment : env.JENKINS_ENVIRONMENT == 'Staging' ? _AgentStaging : env.JENKINS_ENVIRONMENT == 'Production' ? _AgentProduction : 'Else' |  | ||||||
|     } |  | ||||||
|     parameters { |  | ||||||
|         string(name: 'MONA_SUFFIX', defaultValue: env.JENKINS_ENVIRONMENT == 'Development' ? '_IFX' : '_EC', description: 'MonA Suffix') |  | ||||||
|         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...') |  | ||||||
|         string(name: 'PROJECT_DIRECTORY', defaultValue: 'Archive', description: 'Archive|Viewer') |  | ||||||
|     } |  | ||||||
|     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}-${env.PROJECT_DIRECTORY}" |  | ||||||
|                     _GitCommitSeven = '1234567' |  | ||||||
|                     // _GitCommitSeven = env.GIT_COMMIT.substring(0, 7) |  | ||||||
|                     dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                         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}" |  | ||||||
|                     withCredentials([usernamePassword(credentialsId: _CredentialsId, passwordVariable: 'password', usernameVariable: 'username')]) { |  | ||||||
|                         dir("C:/Users/${username}/AppData/Local/IFXApps/nginx-1.20.1/conf/includes") { |  | ||||||
|                             _NGINXFile = "C:/Users/${username}/AppData/Local/IFXApps/nginx-1.20.1/conf/includes/${_AssemblyName}.conf" |  | ||||||
|                             def files = findFiles(glob: "${_AssemblyName}.conf") |  | ||||||
|                             if (files.length != 1) { |  | ||||||
|                                 writeFile(file: _NGINXFile, text: "location / { proxy_pass http://localhost:${_FirstBeforePlus}; }") |  | ||||||
|                             } |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Read NGINX') { |  | ||||||
|             steps { |  | ||||||
|                 script { |  | ||||||
|                     String text = readFile(file: _NGINXFile) |  | ||||||
|                     String check = text == null ? _FirstBeforePlus : text.split(';')[0] |  | ||||||
|                     String[] segments = check.split(':') |  | ||||||
|                     if (segments.length != 3) { |  | ||||||
|                         _PortNumber = check |  | ||||||
|                     } |  | ||||||
|                     else { |  | ||||||
|                         _PortNumber = (segments[2].toInteger() + 2).toString() |  | ||||||
|                     } |  | ||||||
|                     _ExePath = "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-${env.PROJECT_DIRECTORY}/${_AssemblyName}.exe" |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Info') { |  | ||||||
|             steps { |  | ||||||
|                 // echo "GIT_URL_N - ${env.GIT_URL_N}" |  | ||||||
|                 // echo "BRANCH_NAME ${env.BRANCH_NAME}" |  | ||||||
|                 // echo "DEPLOY_VERSION ${env.DEPLOY_VERSION}" |  | ||||||
|                 // echo "GIT_AUTHOR_NAME ${env.GIT_AUTHOR_NAME}" |  | ||||||
|                 // echo "GIT_LOCAL_BRANCH ${env.GIT_LOCAL_BRANCH}" |  | ||||||
|                 // echo "GIT_COMMITTER_EMAIL ${env.GIT_COMMITTER_EMAIL}" |  | ||||||
|                 // echo "GIT_PREVIOUS_COMMIT ${env.GIT_PREVIOUS_COMMIT}" |  | ||||||
|                 // echo "GIT_PREVIOUS_SUCCESSFUL_COMMIT ${env.GIT_PREVIOUS_SUCCESSFUL_COMMIT}" |  | ||||||
|                 echo "_AssemblyName ${_AssemblyName}" // ... |  | ||||||
|                 echo "_ExePath ${_ExePath}" // ... |  | ||||||
|                 echo "_PortNumber ${_PortNumber}" // ... |  | ||||||
|                 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 "PROJECT_DIRECTORY ${env.PROJECT_DIRECTORY}" // ... |  | ||||||
|                 echo "WORKSPACE ${env.WORKSPACE}" // D:\.jenkins\_\... |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         // stage('Restore') { |  | ||||||
|         //     steps { |  | ||||||
|         //         bat(returnStatus: true, script: 'dotnet --info') |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         stage('Safe storage of app secrets') { |  | ||||||
|             steps { |  | ||||||
|                 withCredentials([usernamePassword(credentialsId: _CredentialsId, passwordVariable: 'password', usernameVariable: 'username')]) { |  | ||||||
|                     dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets init') |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "Company" "' + _Company + '"') |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "ServiceUser" "' + username + '"') |  | ||||||
|                         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 + '"') |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "URLs" "' + 'http://localhost:' + _PortNumber) |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "WorkingDirectoryName" "' + _WorkingDirectoryName + '"') |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "MonARessource" "' + _MonARessource + '_' + env.PROJECT_DIRECTORY + env.MONA_SUFFIX + '"') |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         // stage('Core Build (packagemanagement.eu.infineon.com)') { |  | ||||||
|         //     steps { |  | ||||||
|         //         echo "Build number is ${currentBuild.number}" |  | ||||||
|         //         dir(env.PROJECT_DIRECTORY) { |  | ||||||
|         //             bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|         //                 'build --runtime win-x64 --self-contained --verbosity quiet --source ' + |  | ||||||
|         //                 'https://packagemanagement.eu.infineon.com:4430/api/v2/') |  | ||||||
|         //         } |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         stage('Core Build') { |  | ||||||
|             steps { |  | ||||||
|                 echo "Build number is ${currentBuild.number}" |  | ||||||
|                 dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                     bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                         'build --runtime win-x64 --self-contained --verbosity quiet') |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Commit Id') { |  | ||||||
|             steps { |  | ||||||
|                 dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                     writeFile(file: 'bin/Debug/' + _NetVersion + "/win-x64/${env.GIT_COMMIT}-${env.BUILD_NUMBER}.txt", text: "${env.GIT_URL}") |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         // stage('Test') { |  | ||||||
|         //     options { |  | ||||||
|         //         timeout(time: 10, unit: 'MINUTES') |  | ||||||
|         //     } |  | ||||||
|         //     steps { |  | ||||||
|         //         dir(env.PROJECT_DIRECTORY) { |  | ||||||
|         //             bat('dotnet --info') |  | ||||||
|         //         } |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         // stage('Version') { |  | ||||||
|         //     steps { |  | ||||||
|         //         bat('dotnet --info') |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         stage('Package') { |  | ||||||
|             steps { |  | ||||||
|                 dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                     fileOperations([fileZipOperation(folderPath: 'bin/Debug/' + _NetVersion + '/win-x64', outputFolderPath: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-Debug")]) |  | ||||||
|                     fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*", renameFiles: false, sourceCaptureExpression: '', targetLocation: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-Debug", targetNameExpression: '')]) |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Publish') { |  | ||||||
|             steps { |  | ||||||
|                 dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                     bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                         'publish --configuration Release --runtime win-x64 --verbosity quiet ' + |  | ||||||
|                         "--self-contained true --p:Version=6.0.202-${_GitCommitSeven}-${env.BUILD_NUMBER} -o " + |  | ||||||
|                         '"' + "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-${env.PROJECT_DIRECTORY}" + '"') |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Service') { |  | ||||||
|             steps { |  | ||||||
|                 withCredentials([usernamePassword(credentialsId: _CredentialsId, passwordVariable: 'password', usernameVariable: 'username')]) { |  | ||||||
|                     bat(returnStatus: true, script: 'sc create "' + "${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-${_PortNumber}" + '" ' + |  | ||||||
|                         'start= delayed-auto DisplayName="' + "${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-${_PortNumber}" + '" ' + |  | ||||||
|                         'binPath= "' + _ExePath + '" ' + |  | ||||||
|                         'obj= "' + "${env.USERDOMAIN}\\${username}" + '" password= "' + password + '"') |  | ||||||
|                     bat(returnStatus: true, script: 'sc start "' + "${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-${_PortNumber}" + '"') |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Upadate NGINX') { |  | ||||||
|             steps { |  | ||||||
|                 writeFile(file: _NGINXFile, text: "location / { proxy_pass http://localhost:${_PortNumber}; }") |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('NGINX Test and Reload') { |  | ||||||
|             steps { |  | ||||||
|                 withCredentials([usernamePassword(credentialsId: _CredentialsId, passwordVariable: 'password', usernameVariable: 'username')]) { |  | ||||||
|                     dir("C:/Users/${username}/AppData/Local/IFXApps/nginx-1.20.1") { |  | ||||||
|                         script { |  | ||||||
|                             int returnStatus = bat(returnStatus: true, script: 'nginx.exe -t') |  | ||||||
|                             println("returnStatus ################ ${returnStatus} ####################") |  | ||||||
|                             if (returnStatus == 0) { |  | ||||||
|                                 bat(returnStatus: true, script: 'nginx.exe -s reload') |  | ||||||
|                             } |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         // stage('Force Fail') { |  | ||||||
|         //     steps { |  | ||||||
|         //         error("Build failed because of this and that..") |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         // stage('Copy Files to: file-share') { |  | ||||||
|         //     steps { |  | ||||||
|         //         dir(env.PROJECT_DIRECTORY + '/bin/Debug/' + _NetVersion + '/win-x64') { |  | ||||||
|         //             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(env.PROJECT_DIRECTORY + '/bin') { |  | ||||||
|                 deleteDir() |  | ||||||
|             } |  | ||||||
|             dir(env.PROJECT_DIRECTORY + '/obj') { |  | ||||||
|                 deleteDir() |  | ||||||
|             } |  | ||||||
|             // cleanWs() |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
							
								
								
									
										53
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						| @ -5,27 +5,68 @@ | |||||||
|             // Use IntelliSense to find out which attributes exist for C# debugging |             // Use IntelliSense to find out which attributes exist for C# debugging | ||||||
|             // Use hover for the description of the existing attributes |             // Use hover for the description of the existing attributes | ||||||
|             // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md |             // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md | ||||||
|             "name": ".NET Core Launch (web)", |             "name": ".NET Core Launch (web) - Server", | ||||||
|             "type": "coreclr", |             "type": "coreclr", | ||||||
|             "request": "launch", |             "request": "launch", | ||||||
|             "preLaunchTask": "build", |             "preLaunchTask": "buildServer", | ||||||
|             // If you have changed target frameworks, make sure to update the program path. |             // If you have changed target frameworks, make sure to update the program path. | ||||||
|             "program": "${workspaceFolder}/Archive/bin/Debug/net6.0/win-x64/Archive.dll", |             "program": "${workspaceFolder}/Server/bin/Debug/net7.0/win-x64/OI.Metrology.Server.dll", | ||||||
|             "args": [], |             "args": [], | ||||||
|             "cwd": "${workspaceFolder}", |             "cwd": "${workspaceFolder}/Server", | ||||||
|             "stopAtEntry": false, |             "stopAtEntry": false, | ||||||
|             // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser |             // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser | ||||||
|             "serverReadyAction": { |             "serverReadyAction": { | ||||||
|                 "action": "openExternally", |                 "action": "openExternally", | ||||||
|                 "pattern": "\\bNow listening on:\\s+(https?://\\S+)" |                 "pattern": "\\bNow listening on:\\s+(https?://\\S+)", | ||||||
|  |                 "uriFormat": "%s/swagger/index.html" | ||||||
|             }, |             }, | ||||||
|             "env": { |             "env": { | ||||||
|                 "ASPNETCORE_ENVIRONMENT": "Development" |                 "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|             }, |             }, | ||||||
|             "sourceFileMap": { |             "sourceFileMap": { | ||||||
|                 "/Views": "${workspaceFolder}/Archive/Views" |                 "/Views": "${workspaceFolder}/Server/Views" | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
|  |         { | ||||||
|  |             "name": ".NET Core Attach - Server", | ||||||
|  |             "type": "coreclr", | ||||||
|  |             "request": "attach", | ||||||
|  |             "preLaunchTask": "watchServer", | ||||||
|  |             "processName": "OI.Metrology.Server.exe" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             // Use IntelliSense to find out which attributes exist for C# debugging | ||||||
|  |             // Use hover for the description of the existing attributes | ||||||
|  |             // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md | ||||||
|  |             "name": ".NET Core Launch (web) - ClientHub", | ||||||
|  |             "type": "coreclr", | ||||||
|  |             "request": "launch", | ||||||
|  |             "preLaunchTask": "buildClientHub", | ||||||
|  |             // If you have changed target frameworks, make sure to update the program path. | ||||||
|  |             "program": "${workspaceFolder}/ClientHub/bin/Debug/net7.0/win-x64/OI.Metrology.ClientHub.dll", | ||||||
|  |             "args": [], | ||||||
|  |             "cwd": "${workspaceFolder}/ClientHub", | ||||||
|  |             "stopAtEntry": false, | ||||||
|  |             // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser | ||||||
|  |             "serverReadyAction": { | ||||||
|  |                 "action": "openExternally", | ||||||
|  |                 "pattern": "\\bNow listening on:\\s+(https?://\\S+)", | ||||||
|  |                 "uriFormat": "%s/swagger/index.html" | ||||||
|  |             }, | ||||||
|  |             "env": { | ||||||
|  |                 "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |             }, | ||||||
|  |             "sourceFileMap": { | ||||||
|  |                 "/Views": "${workspaceFolder}/ClientHub/Views" | ||||||
|  |             } | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "name": ".NET Core Attach - ClientHub", | ||||||
|  |             "type": "coreclr", | ||||||
|  |             "request": "attach", | ||||||
|  |             "preLaunchTask": "watchClientHub", | ||||||
|  |             "processName": "OI.Metrology.ClientHub.exe" | ||||||
|  |         }, | ||||||
|         { |         { | ||||||
|             "name": ".NET Core Attach", |             "name": ".NET Core Attach", | ||||||
|             "type": "coreclr", |             "type": "coreclr", | ||||||
|  | |||||||
							
								
								
									
										104
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							
							
						
						| @ -2,40 +2,132 @@ | |||||||
|     "version": "2.0.0", |     "version": "2.0.0", | ||||||
|     "tasks": [ |     "tasks": [ | ||||||
|         { |         { | ||||||
|             "label": "build", |             "label": "buildServer", | ||||||
|             "command": "dotnet", |             "command": "dotnet", | ||||||
|             "type": "process", |             "type": "process", | ||||||
|             "args": [ |             "args": [ | ||||||
|                 "build", |                 "build", | ||||||
|                 "${workspaceFolder}/Archive/Archive.csproj", |                 "${workspaceFolder}/Server/OI.Metrology.Server.csproj", | ||||||
|                 "/property:GenerateFullPaths=true", |                 "/property:GenerateFullPaths=true", | ||||||
|                 "/consoleloggerparameters:NoSummary" |                 "/consoleloggerparameters:NoSummary" | ||||||
|             ], |             ], | ||||||
|             "problemMatcher": "$msCompile" |             "problemMatcher": "$msCompile" | ||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             "label": "publish", |             "label": "publishServer", | ||||||
|             "command": "dotnet", |             "command": "dotnet", | ||||||
|             "type": "process", |             "type": "process", | ||||||
|             "args": [ |             "args": [ | ||||||
|                 "publish", |                 "publish", | ||||||
|                 "${workspaceFolder}/Archive/Archive.csproj", |                 "${workspaceFolder}/Server/OI.Metrology.Server.csproj", | ||||||
|                 "/property:GenerateFullPaths=true", |                 "/property:GenerateFullPaths=true", | ||||||
|                 "/consoleloggerparameters:NoSummary" |                 "/consoleloggerparameters:NoSummary" | ||||||
|             ], |             ], | ||||||
|             "problemMatcher": "$msCompile" |             "problemMatcher": "$msCompile" | ||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             "label": "watch", |             "label": "old-watch", | ||||||
|             "command": "dotnet", |             "command": "dotnet", | ||||||
|             "type": "process", |             "type": "process", | ||||||
|             "args": [ |             "args": [ | ||||||
|                 "watch", |                 "watch", | ||||||
|                 "run", |                 "run", | ||||||
|                 "--project", |                 "--project", | ||||||
|                 "${workspaceFolder}/Archive/Archive.csproj" |                 "${workspaceFolder}/Server/OI.Metrology.Server.csproj" | ||||||
|             ], |             ], | ||||||
|             "problemMatcher": "$msCompile" |             "problemMatcher": "$msCompile" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "label": "watchServer", | ||||||
|  |             "command": "dotnet", | ||||||
|  |             "type": "process", | ||||||
|  |             "args": [ | ||||||
|  |                 "watch", | ||||||
|  |                 "--launch-profile", | ||||||
|  |                 "http", | ||||||
|  |                 "run", | ||||||
|  |                 "--project", | ||||||
|  |                 "${workspaceFolder}/Server/OI.Metrology.Server.csproj", | ||||||
|  |                 "--verbose" | ||||||
|  |             ], | ||||||
|  |             "isBackground": true, | ||||||
|  |             "dependsOn": [ | ||||||
|  |                 "build" | ||||||
|  |             ], | ||||||
|  |             "problemMatcher": { | ||||||
|  |                 "fileLocation": "relative", | ||||||
|  |                 "pattern": { | ||||||
|  |                     "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", | ||||||
|  |                     "file": 1, | ||||||
|  |                     "location": 2, | ||||||
|  |                     "severity": 3, | ||||||
|  |                     "code": 4, | ||||||
|  |                     "message": 5 | ||||||
|  |                 }, | ||||||
|  |                 "background": { | ||||||
|  |                     "activeOnStart": true, | ||||||
|  |                     "beginsPattern": "^.*Shutdown requested.*", | ||||||
|  |                     "endsPattern": "^.*Application started.*" | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "label": "buildClientHub", | ||||||
|  |             "command": "dotnet", | ||||||
|  |             "type": "process", | ||||||
|  |             "args": [ | ||||||
|  |                 "build", | ||||||
|  |                 "${workspaceFolder}/ClientHub/OI.Metrology.ClientHub.csproj", | ||||||
|  |                 "/property:GenerateFullPaths=true", | ||||||
|  |                 "/consoleloggerparameters:NoSummary" | ||||||
|  |             ], | ||||||
|  |             "problemMatcher": "$msCompile" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "label": "publishClientHub", | ||||||
|  |             "command": "dotnet", | ||||||
|  |             "type": "process", | ||||||
|  |             "args": [ | ||||||
|  |                 "publish", | ||||||
|  |                 "${workspaceFolder}/ClientHub/OI.Metrology.ClientHub.csproj", | ||||||
|  |                 "/property:GenerateFullPaths=true", | ||||||
|  |                 "/consoleloggerparameters:NoSummary" | ||||||
|  |             ], | ||||||
|  |             "problemMatcher": "$msCompile" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "label": "watchClientHub", | ||||||
|  |             "command": "dotnet", | ||||||
|  |             "type": "process", | ||||||
|  |             "args": [ | ||||||
|  |                 "watch", | ||||||
|  |                 "--launch-profile", | ||||||
|  |                 "http", | ||||||
|  |                 "run", | ||||||
|  |                 "--project", | ||||||
|  |                 "${workspaceFolder}/ClientHub/OI.Metrology.ClientHub.csproj", | ||||||
|  |                 "--verbose" | ||||||
|  |             ], | ||||||
|  |             "isBackground": true, | ||||||
|  |             "dependsOn": [ | ||||||
|  |                 "build" | ||||||
|  |             ], | ||||||
|  |             "problemMatcher": { | ||||||
|  |                 "fileLocation": "relative", | ||||||
|  |                 "pattern": { | ||||||
|  |                     "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", | ||||||
|  |                     "file": 1, | ||||||
|  |                     "location": 2, | ||||||
|  |                     "severity": 3, | ||||||
|  |                     "code": 4, | ||||||
|  |                     "message": 5 | ||||||
|  |                 }, | ||||||
|  |                 "background": { | ||||||
|  |                     "activeOnStart": true, | ||||||
|  |                     "beginsPattern": "^.*Shutdown requested.*", | ||||||
|  |                     "endsPattern": "^.*Application started.*" | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     ] |     ] | ||||||
| } | } | ||||||
							
								
								
									
										243
									
								
								Archive/.editorconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,243 @@ | |||||||
|  | [*.cs] | ||||||
|  | csharp_indent_block_contents = true | ||||||
|  | csharp_indent_braces = false | ||||||
|  | csharp_indent_case_contents = true | ||||||
|  | csharp_indent_case_contents_when_block = true | ||||||
|  | csharp_indent_labels = one_less_than_current | ||||||
|  | csharp_indent_switch_labels = true | ||||||
|  | csharp_new_line_before_catch = true | ||||||
|  | csharp_new_line_before_else = true | ||||||
|  | csharp_new_line_before_finally = true | ||||||
|  | csharp_new_line_before_members_in_anonymous_types = true | ||||||
|  | csharp_new_line_before_members_in_object_initializers = true | ||||||
|  | csharp_new_line_before_open_brace = all | ||||||
|  | csharp_new_line_between_query_expression_clauses = true | ||||||
|  | csharp_prefer_braces = false | ||||||
|  | csharp_prefer_simple_default_expression = true:warning | ||||||
|  | csharp_prefer_simple_using_statement = true:warning | ||||||
|  | csharp_prefer_static_local_function = true:warning | ||||||
|  | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async | ||||||
|  | csharp_preserve_single_line_blocks = true | ||||||
|  | csharp_preserve_single_line_statements = false | ||||||
|  | csharp_space_after_cast = false | ||||||
|  | csharp_space_after_colon_in_inheritance_clause = true | ||||||
|  | csharp_space_after_comma = true | ||||||
|  | csharp_space_after_dot = false | ||||||
|  | csharp_space_after_keywords_in_control_flow_statements = true | ||||||
|  | csharp_space_after_semicolon_in_for_statement = true | ||||||
|  | csharp_space_around_binary_operators = before_and_after | ||||||
|  | csharp_space_around_declaration_statements = false | ||||||
|  | csharp_space_before_colon_in_inheritance_clause = true | ||||||
|  | csharp_space_before_comma = false | ||||||
|  | csharp_space_before_dot = false | ||||||
|  | csharp_space_before_open_square_brackets = false | ||||||
|  | csharp_space_before_semicolon_in_for_statement = false | ||||||
|  | csharp_space_between_empty_square_brackets = false | ||||||
|  | csharp_space_between_method_call_empty_parameter_list_parentheses = false | ||||||
|  | csharp_space_between_method_call_name_and_opening_parenthesis = false | ||||||
|  | csharp_space_between_method_call_parameter_list_parentheses = false | ||||||
|  | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false | ||||||
|  | csharp_space_between_method_declaration_name_and_open_parenthesis = false | ||||||
|  | csharp_space_between_method_declaration_parameter_list_parentheses = false | ||||||
|  | csharp_space_between_parentheses = false | ||||||
|  | csharp_space_between_square_brackets = false | ||||||
|  | csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true | ||||||
|  | csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true | ||||||
|  | csharp_style_allow_embedded_statements_on_same_line_experimental = true | ||||||
|  | csharp_style_conditional_delegate_call = true | ||||||
|  | csharp_style_deconstructed_variable_declaration = false | ||||||
|  | csharp_style_expression_bodied_accessors = when_on_single_line:warning | ||||||
|  | csharp_style_expression_bodied_constructors = when_on_single_line:warning | ||||||
|  | csharp_style_expression_bodied_indexers = when_on_single_line:warning | ||||||
|  | csharp_style_expression_bodied_lambdas = when_on_single_line:warning | ||||||
|  | csharp_style_expression_bodied_local_functions = when_on_single_line:warning | ||||||
|  | csharp_style_expression_bodied_methods = when_on_single_line:warning | ||||||
|  | csharp_style_expression_bodied_operators = when_on_single_line:warning | ||||||
|  | csharp_style_expression_bodied_properties = when_on_single_line:warning | ||||||
|  | csharp_style_implicit_object_creation_when_type_is_apparent = true:warning | ||||||
|  | csharp_style_inlined_variable_declaration = false | ||||||
|  | csharp_style_namespace_declarations = file_scoped:warning | ||||||
|  | csharp_style_pattern_local_over_anonymous_function = true:warning | ||||||
|  | csharp_style_pattern_matching_over_as_with_null_check = true:warning | ||||||
|  | csharp_style_pattern_matching_over_is_with_cast_check = true:warning | ||||||
|  | csharp_style_prefer_index_operator = false:warning | ||||||
|  | csharp_style_prefer_not_pattern = true:warning | ||||||
|  | csharp_style_prefer_null_check_over_type_check = true | ||||||
|  | csharp_style_prefer_pattern_matching = true:warning | ||||||
|  | csharp_style_prefer_range_operator = false:warning | ||||||
|  | csharp_style_prefer_switch_expression = true:warning | ||||||
|  | csharp_style_throw_expression = true | ||||||
|  | csharp_style_unused_value_assignment_preference = discard_variable:warning | ||||||
|  | csharp_style_unused_value_expression_statement_preference = discard_variable:warning | ||||||
|  | csharp_style_var_elsewhere = false:warning | ||||||
|  | csharp_style_var_for_built_in_types = false:warning | ||||||
|  | csharp_style_var_when_type_is_apparent = false:warning | ||||||
|  | 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.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.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.IDE0005.severity = warning # Using directive is unnecessary | ||||||
|  | dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed | ||||||
|  | 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 | ||||||
|  | dotnet_naming_rule.abstract_method_should_be_pascal_case.symbols = abstract_method | ||||||
|  | dotnet_naming_rule.class_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.class_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.class_should_be_pascal_case.symbols = class | ||||||
|  | dotnet_naming_rule.delegate_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.delegate_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.delegate_should_be_pascal_case.symbols = delegate | ||||||
|  | dotnet_naming_rule.enum_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.enum_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.enum_should_be_pascal_case.symbols = enum | ||||||
|  | dotnet_naming_rule.event_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.event_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.event_should_be_pascal_case.symbols = event | ||||||
|  | dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning | ||||||
|  | dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i | ||||||
|  | dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface | ||||||
|  | dotnet_naming_rule.method_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.method_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.method_should_be_pascal_case.symbols = method | ||||||
|  | dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members | ||||||
|  | dotnet_naming_rule.private_method_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.private_method_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.private_method_should_be_pascal_case.symbols = private_method | ||||||
|  | dotnet_naming_rule.private_or_internal_field_should_be_private_of_internal_field.severity = warning | ||||||
|  | dotnet_naming_rule.private_or_internal_field_should_be_private_of_internal_field.style = private_of_internal_field | ||||||
|  | dotnet_naming_rule.private_or_internal_field_should_be_private_of_internal_field.symbols = private_or_internal_field | ||||||
|  | dotnet_naming_rule.private_or_internal_static_field_should_be_private_of_internal_field.severity = warning | ||||||
|  | dotnet_naming_rule.private_or_internal_static_field_should_be_private_of_internal_field.style = private_of_internal_field | ||||||
|  | dotnet_naming_rule.private_or_internal_static_field_should_be_private_of_internal_field.symbols = private_or_internal_static_field | ||||||
|  | dotnet_naming_rule.property_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.property_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.property_should_be_pascal_case.symbols = property | ||||||
|  | dotnet_naming_rule.public_or_protected_field_should_be_private_of_internal_field.severity = warning | ||||||
|  | dotnet_naming_rule.public_or_protected_field_should_be_private_of_internal_field.style = private_of_internal_field | ||||||
|  | dotnet_naming_rule.public_or_protected_field_should_be_private_of_internal_field.symbols = public_or_protected_field | ||||||
|  | dotnet_naming_rule.static_field_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.static_field_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.static_field_should_be_pascal_case.symbols = static_field | ||||||
|  | dotnet_naming_rule.static_method_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.static_method_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.static_method_should_be_pascal_case.symbols = static_method | ||||||
|  | dotnet_naming_rule.struct_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.struct_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.struct_should_be_pascal_case.symbols = struct | ||||||
|  | dotnet_naming_rule.types_should_be_pascal_case.severity = warning | ||||||
|  | dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case | ||||||
|  | dotnet_naming_rule.types_should_be_pascal_case.symbols = types | ||||||
|  | dotnet_naming_style.begins_with_i.capitalization = pascal_case | ||||||
|  | dotnet_naming_style.begins_with_i.required_prefix = I | ||||||
|  | dotnet_naming_style.begins_with_i.required_suffix =  | ||||||
|  | dotnet_naming_style.begins_with_i.word_separator =  | ||||||
|  | dotnet_naming_style.pascal_case.capitalization = pascal_case | ||||||
|  | dotnet_naming_style.pascal_case.required_prefix =  | ||||||
|  | dotnet_naming_style.pascal_case.required_suffix =  | ||||||
|  | dotnet_naming_style.pascal_case.word_separator =  | ||||||
|  | dotnet_naming_style.private_of_internal_field.capitalization = pascal_case | ||||||
|  | dotnet_naming_style.private_of_internal_field.required_prefix = _ | ||||||
|  | dotnet_naming_style.private_of_internal_field.required_suffix =  | ||||||
|  | dotnet_naming_style.private_of_internal_field.word_separator =  | ||||||
|  | dotnet_naming_symbols.abstract_method.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.abstract_method.applicable_kinds = method | ||||||
|  | dotnet_naming_symbols.abstract_method.required_modifiers = abstract | ||||||
|  | dotnet_naming_symbols.class.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.class.applicable_kinds = class | ||||||
|  | dotnet_naming_symbols.class.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.delegate.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.delegate.applicable_kinds = delegate | ||||||
|  | dotnet_naming_symbols.delegate.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.enum.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.enum.applicable_kinds = enum | ||||||
|  | dotnet_naming_symbols.enum.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.event.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.event.applicable_kinds = event | ||||||
|  | dotnet_naming_symbols.event.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.interface.applicable_kinds = interface | ||||||
|  | dotnet_naming_symbols.interface.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.method.applicable_accessibilities = public | ||||||
|  | dotnet_naming_symbols.method.applicable_kinds = method | ||||||
|  | dotnet_naming_symbols.method.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method | ||||||
|  | dotnet_naming_symbols.non_field_members.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.private_method.applicable_accessibilities = private | ||||||
|  | dotnet_naming_symbols.private_method.applicable_kinds = method | ||||||
|  | dotnet_naming_symbols.private_method.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected | ||||||
|  | dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field | ||||||
|  | dotnet_naming_symbols.private_or_internal_field.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.private_or_internal_static_field.applicable_accessibilities = internal, private, private_protected | ||||||
|  | dotnet_naming_symbols.private_or_internal_static_field.applicable_kinds = field | ||||||
|  | dotnet_naming_symbols.private_or_internal_static_field.required_modifiers = static | ||||||
|  | dotnet_naming_symbols.property.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.property.applicable_kinds = property | ||||||
|  | dotnet_naming_symbols.property.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.public_or_protected_field.applicable_accessibilities = public, protected | ||||||
|  | dotnet_naming_symbols.public_or_protected_field.applicable_kinds = field | ||||||
|  | dotnet_naming_symbols.public_or_protected_field.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.static_field.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.static_field.applicable_kinds = field | ||||||
|  | dotnet_naming_symbols.static_field.required_modifiers = static | ||||||
|  | dotnet_naming_symbols.static_method.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.static_method.applicable_kinds = method | ||||||
|  | dotnet_naming_symbols.static_method.required_modifiers = static | ||||||
|  | dotnet_naming_symbols.struct.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.struct.applicable_kinds = struct | ||||||
|  | dotnet_naming_symbols.struct.required_modifiers =  | ||||||
|  | dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||||||
|  | dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum | ||||||
|  | dotnet_naming_symbols.types.required_modifiers =  | ||||||
|  | dotnet_remove_unnecessary_suppression_exclusions = 0 | ||||||
|  | dotnet_separate_import_directive_groups = false | ||||||
|  | dotnet_sort_system_directives_first = false | ||||||
|  | dotnet_style_allow_multiple_blank_lines_experimental = false:warning | ||||||
|  | dotnet_style_allow_statement_immediately_after_block_experimental = true | ||||||
|  | dotnet_style_coalesce_expression = true | ||||||
|  | dotnet_style_collection_initializer = true:warning | ||||||
|  | dotnet_style_explicit_tuple_names = true:warning | ||||||
|  | dotnet_style_namespace_match_folder = true | ||||||
|  | dotnet_style_null_propagation = true:warning | ||||||
|  | dotnet_style_object_initializer = true:warning | ||||||
|  | dotnet_style_operator_placement_when_wrapping = beginning_of_line | ||||||
|  | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity | ||||||
|  | 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_prefer_auto_properties = true:warning | ||||||
|  | dotnet_style_prefer_compound_assignment = true:warning | ||||||
|  | dotnet_style_prefer_conditional_expression_over_assignment = false | ||||||
|  | dotnet_style_prefer_conditional_expression_over_return = false | ||||||
|  | dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning | ||||||
|  | dotnet_style_prefer_inferred_tuple_names = true:warning | ||||||
|  | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning | ||||||
|  | dotnet_style_prefer_simplified_boolean_expressions = true:warning | ||||||
|  | dotnet_style_prefer_simplified_interpolation = true | ||||||
|  | dotnet_style_qualification_for_event = false:error | ||||||
|  | dotnet_style_qualification_for_field = false | ||||||
|  | dotnet_style_qualification_for_method = false:error | ||||||
|  | dotnet_style_qualification_for_property = false:error | ||||||
|  | dotnet_style_readonly_field = true:warning | ||||||
|  | dotnet_style_require_accessibility_modifiers = for_non_interface_members | ||||||
|  | end_of_line = crlf | ||||||
|  | file_header_template = unset | ||||||
|  | indent_size = 4 | ||||||
|  | indent_style = space | ||||||
|  | insert_final_newline = false | ||||||
|  | root = true | ||||||
|  | tab_width = 4 | ||||||
|  | # https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1822 | ||||||
|  | # https://github.com/dotnet/aspnetcore/blob/main/.editorconfig | ||||||
|  | # https://github.com/dotnet/project-system/blob/main/.editorconfig | ||||||
| @ -1,6 +1,6 @@ | |||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using System; | using System; | ||||||
| using System.IO; | using System.IO; | ||||||
| @ -8,13 +8,13 @@ using System.IO; | |||||||
| namespace OI.Metrology.Archive.ApiControllers; | namespace OI.Metrology.Archive.ApiControllers; | ||||||
| public class AttachmentsController : Controller | public class AttachmentsController : Controller | ||||||
| { | { | ||||||
|     private readonly IMetrologyRepo _Repo; |  | ||||||
|     private readonly IAttachmentsService _AttachmentsService; |     private readonly IAttachmentsService _AttachmentsService; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|     public AttachmentsController(IMetrologyRepo repo, IAttachmentsService attachmentsService) |     public AttachmentsController(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService) | ||||||
|     { |     { | ||||||
|         _Repo = repo; |  | ||||||
|         _AttachmentsService = attachmentsService; |         _AttachmentsService = attachmentsService; | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // this endpoint was created in hope that it would make retrieving attachments to display in OpenInsight easier |     // this endpoint was created in hope that it would make retrieving attachments to display in OpenInsight easier | ||||||
| @ -27,7 +27,7 @@ public class AttachmentsController : Controller | |||||||
|         string title, |         string title, | ||||||
|         string filename) |         string filename) | ||||||
|     { |     { | ||||||
|         ToolType tt = _Repo.GetToolTypeByName(toolTypeName); |         ToolType tt = _MetrologyRepository.GetToolTypeByName(toolTypeName); | ||||||
|  |  | ||||||
|         bool header = !string.Equals(tabletype.Trim(), "data", StringComparison.OrdinalIgnoreCase); |         bool header = !string.Equals(tabletype.Trim(), "data", StringComparison.OrdinalIgnoreCase); | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,17 +1,17 @@ | |||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  |  | ||||||
| namespace OI.Metrology.Archive.ApiContollers; | namespace OI.Metrology.Archive.ApiControllers; | ||||||
|  |  | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using System.Text.Json; | using System.Text.Json; | ||||||
|  |  | ||||||
| // this controller is for the Awaiting Dispo functionality | // this controller is for the Awaiting Dispo functionality | ||||||
|  |  | ||||||
| public class AwaitingDispoController : Controller | public class AwaitingDispoController : Controller | ||||||
| { | { | ||||||
|     private readonly IMetrologyRepo _Repo; |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|     public AwaitingDispoController(IMetrologyRepo repo) => _Repo = repo; |     public AwaitingDispoController(IMetrologyRepository metrologyRepository) => _MetrologyRepository = metrologyRepository; | ||||||
|  |  | ||||||
|     // returns the data to show in the Awaiting Dispo grid |     // returns the data to show in the Awaiting Dispo grid | ||||||
|     // marked no-cache, just-in-case since igniteUI automatically adds a query string parameter to prevent caching |     // marked no-cache, just-in-case since igniteUI automatically adds a query string parameter to prevent caching | ||||||
| @ -21,7 +21,7 @@ public class AwaitingDispoController : Controller | |||||||
|     { |     { | ||||||
|         var r = new |         var r = new | ||||||
|         { |         { | ||||||
|             Results = _Repo.GetAwaitingDispo() |             Results = _MetrologyRepository.GetAwaitingDisposition() | ||||||
|         }; |         }; | ||||||
|         return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); |         return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||||
|     } |     } | ||||||
| @ -30,7 +30,7 @@ public class AwaitingDispoController : Controller | |||||||
|     [HttpPost("/api/awaitingdispo/markasreviewed")] |     [HttpPost("/api/awaitingdispo/markasreviewed")] | ||||||
|     public IActionResult MarkAsReviewed([FromQuery] long headerid, [FromQuery] int tooltypeid) |     public IActionResult MarkAsReviewed([FromQuery] long headerid, [FromQuery] int tooltypeid) | ||||||
|     { |     { | ||||||
|         _ = _Repo.UpdateReviewDate(tooltypeid, headerid, false); |         _ = _MetrologyRepository.UpdateReviewDate(tooltypeid, headerid, false); | ||||||
|         return Ok(); |         return Ok(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -38,7 +38,7 @@ public class AwaitingDispoController : Controller | |||||||
|     [HttpPost("/api/awaitingdispo/markasawaiting")] |     [HttpPost("/api/awaitingdispo/markasawaiting")] | ||||||
|     public IActionResult MarkAsAwaiting([FromQuery] long headerid, [FromQuery] int tooltypeid) |     public IActionResult MarkAsAwaiting([FromQuery] long headerid, [FromQuery] int tooltypeid) | ||||||
|     { |     { | ||||||
|         if (_Repo.UpdateReviewDate(tooltypeid, headerid, true) <= 1) |         if (_MetrologyRepository.UpdateReviewDate(tooltypeid, headerid, true) <= 1) | ||||||
|             return Ok(); |             return Ok(); | ||||||
|         else |         else | ||||||
|             return StatusCode(444); |             return StatusCode(444); | ||||||
|  | |||||||
| @ -4,30 +4,30 @@ using Microsoft.Extensions.Logging; | |||||||
| using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||||
| using OI.Metrology.Archive.Models; | using OI.Metrology.Archive.Models; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Linq; | using System.Linq; | ||||||
|  |  | ||||||
| namespace OI.Metrology.Archive.ApiContollers; | namespace OI.Metrology.Archive.ApiControllers; | ||||||
|  |  | ||||||
| [ApiController] | [ApiController] | ||||||
| public class InboundController : ControllerBase | public class InboundController : ControllerBase | ||||||
| { | { | ||||||
|     private readonly ILogger _Logger; |     private readonly ILogger _Logger; | ||||||
|     private readonly IMetrologyRepo _Repo; |  | ||||||
|     private readonly AppSettings _AppSettings; |     private readonly AppSettings _AppSettings; | ||||||
|     private readonly IAttachmentsService _AttachmentService; |     private readonly IAttachmentsService _AttachmentService; | ||||||
|     private readonly IInboundDataService _InboundDataService; |     private readonly IInboundDataService _InboundDataService; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|     public InboundController(AppSettings appSettings, ILogger<InboundController> logger, IMetrologyRepo repo, IInboundDataService inboundDataService, IAttachmentsService attachmentService) |     public InboundController(AppSettings appSettings, ILogger<InboundController> logger, IMetrologyRepository metrologyRepository, IInboundDataService inboundDataService, IAttachmentsService attachmentService) | ||||||
|     { |     { | ||||||
|         _Repo = repo; |  | ||||||
|         _Logger = logger; |         _Logger = logger; | ||||||
|         _AppSettings = appSettings; |         _AppSettings = appSettings; | ||||||
|         _AttachmentService = attachmentService; |         _AttachmentService = attachmentService; | ||||||
|         _InboundDataService = inboundDataService; |         _InboundDataService = inboundDataService; | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // this class represents the API response back to the client |     // this class represents the API response back to the client | ||||||
| @ -61,9 +61,9 @@ public class InboundController : ControllerBase | |||||||
|             return Unauthorized(r); |             return Unauthorized(r); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         ToolType toolType = _Repo.GetToolTypeByName(tooltype); |         ToolType toolType = _MetrologyRepository.GetToolTypeByName(tooltype); | ||||||
|  |  | ||||||
|         if (toolType == null) |         if (toolType is null) | ||||||
|         { |         { | ||||||
|             r.Errors.Add("Invalid tool type: " + tooltype); |             r.Errors.Add("Invalid tool type: " + tooltype); | ||||||
|             return BadRequest(r); |             return BadRequest(r); | ||||||
| @ -71,9 +71,9 @@ public class InboundController : ControllerBase | |||||||
|  |  | ||||||
|         // get metadata |         // get metadata | ||||||
|  |  | ||||||
|         List<ToolTypeMetadata> metaData = _Repo.GetToolTypeMetadataByToolTypeID(toolType.ID).ToList(); |         List<ToolTypeMetadata> metaData = _MetrologyRepository.GetToolTypeMetadataByToolTypeID(toolType.ID).ToList(); | ||||||
|  |  | ||||||
|         if (metaData == null) |         if (metaData is null) | ||||||
|         { |         { | ||||||
|             r.Errors.Add("Invalid metadata for tool type: " + tooltype); |             r.Errors.Add("Invalid metadata for tool type: " + tooltype); | ||||||
|             return BadRequest(r); |             return BadRequest(r); | ||||||
| @ -81,7 +81,7 @@ public class InboundController : ControllerBase | |||||||
|  |  | ||||||
|         // validate fields |         // validate fields | ||||||
|  |  | ||||||
|         if (jsonbody != null) |         if (jsonbody is not null) | ||||||
|             _InboundDataService.ValidateJSONFields(jsonbody, 0, metaData, r.Errors, r.Warnings); |             _InboundDataService.ValidateJSONFields(jsonbody, 0, metaData, r.Errors, r.Warnings); | ||||||
|         else |         else | ||||||
|             r.Errors.Add("Invalid json"); |             r.Errors.Add("Invalid json"); | ||||||
| @ -118,12 +118,12 @@ public class InboundController : ControllerBase | |||||||
|             return Unauthorized("Remote IP is not on allowed list"); |             return Unauthorized("Remote IP is not on allowed list"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         ToolType toolType = _Repo.GetToolTypeByName(tooltype); |         ToolType toolType = _MetrologyRepository.GetToolTypeByName(tooltype); | ||||||
|  |  | ||||||
|         if (toolType == null) |         if (toolType is null) | ||||||
|             return BadRequest($"Invalid tool type: {tooltype}"); |             return BadRequest($"Invalid tool type: {tooltype}"); | ||||||
|  |  | ||||||
|         if (Request.Form == null) |         if (Request.Form is null) | ||||||
|             return BadRequest($"Invalid form"); |             return BadRequest($"Invalid form"); | ||||||
|  |  | ||||||
|         if (Request.Form.Files.Count != 1) |         if (Request.Form.Files.Count != 1) | ||||||
|  | |||||||
							
								
								
									
										99
									
								
								Archive/ApiControllers/ReactorsController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,99 @@ | |||||||
|  | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using System.Linq; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Archive.ApiControllers; | ||||||
|  |  | ||||||
|  | using OI.Metrology.Archive.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  | using System.Text.Json; | ||||||
|  |  | ||||||
|  | public class ReactorsController : Controller | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly AppSettings _AppSettings; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|  |     public ReactorsController(AppSettings appSettings, IMetrologyRepository metrologyRepository) | ||||||
|  |     { | ||||||
|  |         _AppSettings = appSettings; | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static int[] EvenReactors() | ||||||
|  |     { | ||||||
|  |         int[] results = new int[] { | ||||||
|  |             20, | ||||||
|  |             22, | ||||||
|  |             24, | ||||||
|  |             26, | ||||||
|  |             28, | ||||||
|  |             30, | ||||||
|  |             32, | ||||||
|  |             34, | ||||||
|  |             36, | ||||||
|  |             38, | ||||||
|  |             40, | ||||||
|  |             42, | ||||||
|  |             44, | ||||||
|  |             46, | ||||||
|  |             48, | ||||||
|  |             50, | ||||||
|  |             52, | ||||||
|  |             54, | ||||||
|  |             56, | ||||||
|  |             58, | ||||||
|  |             60, | ||||||
|  |             62, | ||||||
|  |             64, | ||||||
|  |             66, | ||||||
|  |             68, | ||||||
|  |             70, | ||||||
|  |             72, | ||||||
|  |             74 | ||||||
|  |         }; | ||||||
|  |         return results; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static int[] OddReactors() | ||||||
|  |     { | ||||||
|  |         int[] results = new int[] { | ||||||
|  |             21, | ||||||
|  |             23, | ||||||
|  |             25, | ||||||
|  |             27, | ||||||
|  |             29, | ||||||
|  |             31, | ||||||
|  |             33, | ||||||
|  |             35, | ||||||
|  |             37, | ||||||
|  |             39, | ||||||
|  |             41, | ||||||
|  |             43, | ||||||
|  |             45, | ||||||
|  |             47, | ||||||
|  |             49, | ||||||
|  |             51, | ||||||
|  |             53, | ||||||
|  |             55, | ||||||
|  |             57, | ||||||
|  |             59, | ||||||
|  |             61, | ||||||
|  |             63, | ||||||
|  |             65, | ||||||
|  |             73, | ||||||
|  |             75, | ||||||
|  |             77, | ||||||
|  |             79 | ||||||
|  |         }; | ||||||
|  |         return results; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpGet("/api/reactors/{even}")] | ||||||
|  |     public IActionResult Index(bool even) | ||||||
|  |     { | ||||||
|  |         int[] n = even ? EvenReactors() : OddReactors(); | ||||||
|  |         var r = n.Select(l => new { Name = $"R{l}", Id = l }); | ||||||
|  |         return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -4,11 +4,11 @@ using System; | |||||||
| using System.IO; | using System.IO; | ||||||
| using System.Linq; | using System.Linq; | ||||||
|  |  | ||||||
| namespace OI.Metrology.Archive.ApiContollers; | namespace OI.Metrology.Archive.ApiControllers; | ||||||
|  |  | ||||||
| using OI.Metrology.Archive.Models; | using OI.Metrology.Archive.Models; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Text.Json; | using System.Text.Json; | ||||||
| @ -21,15 +21,15 @@ public class ToolTypesController : Controller | |||||||
|     // it is named after the /api/tooltypes prefix |     // it is named after the /api/tooltypes prefix | ||||||
|     // the URL pattern is RESTful and the tool type is the root of every request |     // the URL pattern is RESTful and the tool type is the root of every request | ||||||
|  |  | ||||||
|     private readonly IMetrologyRepo _Repo; |  | ||||||
|     private readonly AppSettings _AppSettings; |     private readonly AppSettings _AppSettings; | ||||||
|     private readonly IAttachmentsService _AttachmentsService; |     private readonly IAttachmentsService _AttachmentsService; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|     public ToolTypesController(AppSettings appSettings, IMetrologyRepo repo, IAttachmentsService attachmentsService) |     public ToolTypesController(AppSettings appSettings, IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService) | ||||||
|     { |     { | ||||||
|         _Repo = repo; |  | ||||||
|         _AppSettings = appSettings; |         _AppSettings = appSettings; | ||||||
|         _AttachmentsService = attachmentsService; |         _AttachmentsService = attachmentsService; | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Get a list of tooltypes, returns just Name and ID |     // Get a list of tooltypes, returns just Name and ID | ||||||
| @ -38,7 +38,7 @@ public class ToolTypesController : Controller | |||||||
|     { |     { | ||||||
|         var r = new |         var r = new | ||||||
|         { |         { | ||||||
|             Results = _Repo.GetToolTypes().Select(tt => new { tt.ToolTypeName, tt.ID }) |             Results = _MetrologyRepository.GetToolTypes().Select(tt => new { tt.ToolTypeName, tt.ID }) | ||||||
|         }; |         }; | ||||||
|         return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); |         return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||||
|     } |     } | ||||||
| @ -48,8 +48,8 @@ public class ToolTypesController : Controller | |||||||
|     [HttpGet("/api/tooltypes/{id}")] |     [HttpGet("/api/tooltypes/{id}")] | ||||||
|     public IActionResult GetToolTypeMetadata(int id, string sortby = "") |     public IActionResult GetToolTypeMetadata(int id, string sortby = "") | ||||||
|     { |     { | ||||||
|         ToolType tt = _Repo.GetToolTypeByID(id); |         ToolType tt = _MetrologyRepository.GetToolTypeByID(id); | ||||||
|         IEnumerable<ToolTypeMetadata> md = _Repo.GetToolTypeMetadataByToolTypeID(id); |         IEnumerable<ToolTypeMetadata> md = _MetrologyRepository.GetToolTypeMetadataByToolTypeID(id); | ||||||
|  |  | ||||||
|         if (string.Equals(sortby, "grid", StringComparison.OrdinalIgnoreCase)) |         if (string.Equals(sortby, "grid", StringComparison.OrdinalIgnoreCase)) | ||||||
|             md = md.OrderBy(f => f.GridDisplayOrder).ToList(); |             md = md.OrderBy(f => f.GridDisplayOrder).ToList(); | ||||||
| @ -80,7 +80,7 @@ public class ToolTypesController : Controller | |||||||
|     { |     { | ||||||
|         long totalRecs; |         long totalRecs; | ||||||
|  |  | ||||||
|         System.Data.DataTable dt = _Repo.GetHeaders(id, datebegin, dateend, page, pagesize, headerid, out totalRecs); |         System.Data.DataTable dt = _MetrologyRepository.GetHeaders(id, datebegin, dateend, page, pagesize, headerid, out totalRecs); | ||||||
|  |  | ||||||
|         var r = new |         var r = new | ||||||
|         { |         { | ||||||
| @ -101,7 +101,7 @@ public class ToolTypesController : Controller | |||||||
|     { |     { | ||||||
|         long totalRecs; |         long totalRecs; | ||||||
|  |  | ||||||
|         IEnumerable<HeaderCommon> dt = _Repo.GetHeaderTitles(id, page, pagesize, out totalRecs); |         IEnumerable<HeaderCommon> dt = _MetrologyRepository.GetHeaderTitles(id, page, pagesize, out totalRecs); | ||||||
|  |  | ||||||
|         var r = new |         var r = new | ||||||
|         { |         { | ||||||
| @ -121,7 +121,7 @@ public class ToolTypesController : Controller | |||||||
|     { |     { | ||||||
|         var r = new |         var r = new | ||||||
|         { |         { | ||||||
|             Results = _Repo.GetHeaderFields(id, headerid).Select(x => new { Column = x.Key, x.Value }).ToList() |             Results = _MetrologyRepository.GetHeaderFields(id, headerid).Select(x => new { Column = x.Key, x.Value }).ToList() | ||||||
|         }; |         }; | ||||||
|         string json = JsonConvert.SerializeObject(r); |         string json = JsonConvert.SerializeObject(r); | ||||||
|  |  | ||||||
| @ -137,7 +137,7 @@ public class ToolTypesController : Controller | |||||||
|  |  | ||||||
|         var r = new |         var r = new | ||||||
|         { |         { | ||||||
|             Results = _Repo.GetDataSharePoint(id, title) |             Results = _MetrologyRepository.GetDataSharePoint(id, title) | ||||||
|         }; |         }; | ||||||
|         string json = JsonConvert.SerializeObject(r); |         string json = JsonConvert.SerializeObject(r); | ||||||
|  |  | ||||||
| @ -152,7 +152,7 @@ public class ToolTypesController : Controller | |||||||
|  |  | ||||||
|         var r = new |         var r = new | ||||||
|         { |         { | ||||||
|             Results = _Repo.GetData(id, headerid) |             Results = _MetrologyRepository.GetData(id, headerid) | ||||||
|         }; |         }; | ||||||
|         string json = JsonConvert.SerializeObject(r); |         string json = JsonConvert.SerializeObject(r); | ||||||
|  |  | ||||||
| @ -168,7 +168,7 @@ public class ToolTypesController : Controller | |||||||
|         string filename) |         string filename) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|         ToolType tt = _Repo.GetToolTypeByID(toolTypeId); |         ToolType tt = _MetrologyRepository.GetToolTypeByID(toolTypeId); | ||||||
|  |  | ||||||
|         bool header = !string.Equals(tabletype.Trim(), "data", StringComparison.OrdinalIgnoreCase); |         bool header = !string.Equals(tabletype.Trim(), "data", StringComparison.OrdinalIgnoreCase); | ||||||
|  |  | ||||||
| @ -191,7 +191,7 @@ public class ToolTypesController : Controller | |||||||
|     public IActionResult OIExport(int toolTypeId, long headerid) |     public IActionResult OIExport(int toolTypeId, long headerid) | ||||||
|     { |     { | ||||||
|         // Call the export stored procedure |         // Call the export stored procedure | ||||||
|         System.Data.DataSet ds = _Repo.GetOIExportData(toolTypeId, headerid); |         System.Data.DataSet ds = _MetrologyRepository.GetOIExportData(toolTypeId, headerid); | ||||||
|  |  | ||||||
|         try |         try | ||||||
|         { |         { | ||||||
| @ -213,7 +213,7 @@ public class ToolTypesController : Controller | |||||||
|  |  | ||||||
|             foreach (object o in ds.Tables[1].Rows[0].ItemArray) |             foreach (object o in ds.Tables[1].Rows[0].ItemArray) | ||||||
|             { |             { | ||||||
|                 if ((o != null) && (!Convert.IsDBNull(o))) |                 if ((o is not null) && (!Convert.IsDBNull(o))) | ||||||
|                     _ = sb.Append(Convert.ToString(o)); |                     _ = sb.Append(Convert.ToString(o)); | ||||||
|                 _ = sb.Append('\t'); |                 _ = sb.Append('\t'); | ||||||
|             } |             } | ||||||
| @ -223,7 +223,7 @@ public class ToolTypesController : Controller | |||||||
|             { |             { | ||||||
|                 foreach (object o in dr.ItemArray) |                 foreach (object o in dr.ItemArray) | ||||||
|                 { |                 { | ||||||
|                     if ((o != null) && (!Convert.IsDBNull(o))) |                     if ((o is not null) && (!Convert.IsDBNull(o))) | ||||||
|                         _ = sb.Append(Convert.ToString(o)); |                         _ = sb.Append(Convert.ToString(o)); | ||||||
|                     _ = sb.Append('\t'); |                     _ = sb.Append('\t'); | ||||||
|                 } |                 } | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ public class ErrorHandlerController : Controller | |||||||
|     public IActionResult Index() |     public IActionResult Index() | ||||||
|     { |     { | ||||||
|         IExceptionHandlerFeature error = HttpContext.Features.Get<IExceptionHandlerFeature>(); |         IExceptionHandlerFeature error = HttpContext.Features.Get<IExceptionHandlerFeature>(); | ||||||
|         if (error == null) |         if (error is null) | ||||||
|         { |         { | ||||||
|             return Redirect("~/"); |             return Redirect("~/"); | ||||||
|         } |         } | ||||||
| @ -24,7 +24,7 @@ public class ErrorHandlerController : Controller | |||||||
|             _Logger.LogError("Unhandled exception: " + error.Error.ToString()); |             _Logger.LogError("Unhandled exception: " + error.Error.ToString()); | ||||||
|             dynamic r = new |             dynamic r = new | ||||||
|             { |             { | ||||||
|                 Message = error.Error == null ? "Error" : error.Error.Message |                 Message = error.Error is null ? "Error" : error.Error.Message | ||||||
|             }; |             }; | ||||||
|             return StatusCode(StatusCodes.Status500InternalServerError, r); |             return StatusCode(StatusCodes.Status500InternalServerError, r); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc.Filters; | |||||||
| using Microsoft.Extensions.Logging; | using Microsoft.Extensions.Logging; | ||||||
| using OI.Metrology.Archive.Models; | using OI.Metrology.Archive.Models; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.ViewModels; | using OI.Metrology.Shared.ViewModels; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| @ -17,14 +17,14 @@ public class ExportController : Controller | |||||||
| { | { | ||||||
|     private readonly ILogger _Logger; |     private readonly ILogger _Logger; | ||||||
|     private readonly bool _IsTestDatabase; |     private readonly bool _IsTestDatabase; | ||||||
|     private readonly IMetrologyRepo _Repo; |  | ||||||
|     private readonly AppSettings _AppSettings; |     private readonly AppSettings _AppSettings; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|     public ExportController(AppSettings appSettings, ILogger<ExportController> logger, IMetrologyRepo repo) |     public ExportController(AppSettings appSettings, ILogger<ExportController> logger, IMetrologyRepository metrologyRepository) | ||||||
|     { |     { | ||||||
|         _Repo = repo; |  | ||||||
|         _Logger = logger; |         _Logger = logger; | ||||||
|         _AppSettings = appSettings; |         _AppSettings = appSettings; | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|         _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); |         _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -40,7 +40,6 @@ public class ExportController : Controller | |||||||
|     { |     { | ||||||
|         Export model = new() |         Export model = new() | ||||||
|         { |         { | ||||||
|             ToolType = "", |  | ||||||
|             StartTime = DateTime.Now.AddMonths(-1), |             StartTime = DateTime.Now.AddMonths(-1), | ||||||
|             EndTime = DateTime.Now |             EndTime = DateTime.Now | ||||||
|         }; |         }; | ||||||
| @ -60,7 +59,7 @@ public class ExportController : Controller | |||||||
|         { |         { | ||||||
|             if (model.StartTime > model.EndTime) |             if (model.StartTime > model.EndTime) | ||||||
|                 ModelState.AddModelError("EndTime", "End time must be after start time"); |                 ModelState.AddModelError("EndTime", "End time must be after start time"); | ||||||
|             IEnumerable<ToolType> toolTypes = _Repo.GetToolTypes(); |             IEnumerable<ToolType> toolTypes = _MetrologyRepository.GetToolTypes(); | ||||||
|             toolType = toolTypes.Where(tt => tt.ID.ToString() == model.ToolType).SingleOrDefault(); |             toolType = toolTypes.Where(tt => tt.ID.ToString() == model.ToolType).SingleOrDefault(); | ||||||
|             if (toolType is null) |             if (toolType is null) | ||||||
|                 ModelState.AddModelError("ToolType", "Invalid selection"); |                 ModelState.AddModelError("ToolType", "Invalid selection"); | ||||||
| @ -94,7 +93,7 @@ public class ExportController : Controller | |||||||
|         string fileName = string.Format("Export_{0}_{1:yyyyMMddHHmm}_to_{2:yyyyMMddHHmm}.csv", toolTypeName, startTime, endTime); |         string fileName = string.Format("Export_{0}_{1:yyyyMMddHHmm}_to_{2:yyyyMMddHHmm}.csv", toolTypeName, startTime, endTime); | ||||||
|         StringBuilder sb = new(); |         StringBuilder sb = new(); | ||||||
|  |  | ||||||
|         System.Data.DataTable dt = _Repo.ExportData(spName, startTime, endTime); |         System.Data.DataTable dt = _MetrologyRepository.ExportData(spName, startTime, endTime); | ||||||
|  |  | ||||||
|         _ = sb.AppendLine(GetColumnHeaders(dt)); |         _ = sb.AppendLine(GetColumnHeaders(dt)); | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using Microsoft.AspNetCore.Mvc.Filters; | using Microsoft.AspNetCore.Mvc.Filters; | ||||||
| using OI.Metrology.Archive.Models; | using OI.Metrology.Archive.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Repositories; | ||||||
| using OI.Metrology.Shared.ViewModels; | using OI.Metrology.Shared.ViewModels; | ||||||
| using System; | using System; | ||||||
| @ -13,12 +14,12 @@ public class PagesController : Controller | |||||||
| { | { | ||||||
|     private readonly bool _IsTestDatabase; |     private readonly bool _IsTestDatabase; | ||||||
|     private readonly IRdsMaxRepo _RdsMaxRepo; |     private readonly IRdsMaxRepo _RdsMaxRepo; | ||||||
|     private readonly IMetrologyRepo _MetrologyRepo; |     private readonly IMetrologyRepository _MetrologyRepo; | ||||||
|  |  | ||||||
|     public PagesController(AppSettings appSettings, IMetrologyRepo metrologyRepo, IRdsMaxRepo rdsMaxRepo) |     public PagesController(AppSettings appSettings, IMetrologyRepository metrologyRepository, IRdsMaxRepo rdsMaxRepo) | ||||||
|     { |     { | ||||||
|         _RdsMaxRepo = rdsMaxRepo; |         _RdsMaxRepo = rdsMaxRepo; | ||||||
|         _MetrologyRepo = metrologyRepo; |         _MetrologyRepo = metrologyRepository; | ||||||
|         _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); |         _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -122,4 +123,9 @@ public class PagesController : Controller | |||||||
|         return View(results); |         return View(results); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("/Reactor")] | ||||||
|  |     [Route("/Metrology/Reactor")] | ||||||
|  |     public IActionResult Reactor() => View(new RunInfo()); | ||||||
|  |  | ||||||
| } | } | ||||||
| @ -1,61 +1,24 @@ | |||||||
| using System.Text.Json; | using System.Text.Json; | ||||||
| using System.Text.Json.Serialization; |  | ||||||
|  |  | ||||||
| namespace OI.Metrology.Archive.Models; | namespace OI.Metrology.Archive.Models; | ||||||
|  |  | ||||||
| public class AppSettings | public record AppSettings(string ApiLoggingContentTypes, | ||||||
|  |                           string ApiLoggingPathPrefixes, | ||||||
|  |                           string ApiLogPath, | ||||||
|  |                           string AttachmentPath, | ||||||
|  |                           string BuildNumber, | ||||||
|  |                           string Company, | ||||||
|  |                           string ConnectionString, | ||||||
|  |                           string GitCommitSeven, | ||||||
|  |                           string InboundApiAllowedIPList, | ||||||
|  |                           string MonAResource, | ||||||
|  |                           string MonASite, | ||||||
|  |                           string Oi2SqlConnectionString, | ||||||
|  |                           string OIExportPath, | ||||||
|  |                           string URLs, | ||||||
|  |                           string WorkingDirectoryName) | ||||||
| { | { | ||||||
|  |  | ||||||
|     public string ApiLoggingContentTypes { init; get; } |  | ||||||
|     public string ApiLoggingPathPrefixes { init; get; } |  | ||||||
|     public string ApiLogPath { init; get; } |  | ||||||
|     public string AttachmentPath { init; get; } |  | ||||||
|     public string BuildNumber { init; get; } |  | ||||||
|     public string Company { init; get; } |  | ||||||
|     public string ConnectionString { init; get; } |  | ||||||
|     public string GitCommitSeven { init; get; } |  | ||||||
|     public string InboundApiAllowedIPList { init; get; } |  | ||||||
|     public string MonAResource { init; get; } |  | ||||||
|     public string MonASite { init; get; } |  | ||||||
|     public string OIExportPath { init; get; } |  | ||||||
|     public string Oi2SqlConnectionString { init; get; } |  | ||||||
|     public string URLs { init; get; } |  | ||||||
|     public string WorkingDirectoryName { init; get; } |  | ||||||
|  |  | ||||||
|     [JsonConstructor] |  | ||||||
|     public AppSettings(string apiLoggingContentTypes, |  | ||||||
|                        string apiLoggingPathPrefixes, |  | ||||||
|                        string apiLogPath, |  | ||||||
|                        string attachmentPath, |  | ||||||
|                        string buildNumber, |  | ||||||
|                        string company, |  | ||||||
|                        string connectionString, |  | ||||||
|                        string gitCommitSeven, |  | ||||||
|                        string inboundApiAllowedIPList, |  | ||||||
|                        string monAResource, |  | ||||||
|                        string monASite, |  | ||||||
|                        string oi2SqlConnectionString, |  | ||||||
|                        string oiExportPath, |  | ||||||
|                        string urls, |  | ||||||
|                        string workingDirectoryName) |  | ||||||
|     { |  | ||||||
|         ApiLoggingContentTypes = apiLoggingContentTypes; |  | ||||||
|         ApiLoggingPathPrefixes = apiLoggingPathPrefixes; |  | ||||||
|         ApiLogPath = apiLogPath; |  | ||||||
|         AttachmentPath = attachmentPath; |  | ||||||
|         BuildNumber = buildNumber; |  | ||||||
|         Company = company; |  | ||||||
|         ConnectionString = connectionString; |  | ||||||
|         GitCommitSeven = gitCommitSeven; |  | ||||||
|         InboundApiAllowedIPList = inboundApiAllowedIPList; |  | ||||||
|         MonAResource = monAResource; |  | ||||||
|         MonASite = monASite; |  | ||||||
|         Oi2SqlConnectionString = oi2SqlConnectionString; |  | ||||||
|         OIExportPath = oiExportPath; |  | ||||||
|         URLs = urls; |  | ||||||
|         WorkingDirectoryName = workingDirectoryName; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public override string ToString() |     public override string ToString() | ||||||
|     { |     { | ||||||
|         string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); |         string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| using Microsoft.Extensions.Configuration; | using Microsoft.Extensions.Configuration; | ||||||
|  | using System; | ||||||
| using System.ComponentModel.DataAnnotations; | using System.ComponentModel.DataAnnotations; | ||||||
| using System.Text.Json; | using System.Text.Json; | ||||||
|  |  | ||||||
| @ -36,6 +37,38 @@ public class AppSettings | |||||||
|     private static Models.AppSettings Get(AppSettings appSettings) |     private static Models.AppSettings Get(AppSettings appSettings) | ||||||
|     { |     { | ||||||
|         Models.AppSettings result; |         Models.AppSettings result; | ||||||
|  |         if (appSettings is null) | ||||||
|  |             throw new NullReferenceException(nameof(appSettings)); | ||||||
|  |         if (appSettings.ApiLoggingContentTypes is null) | ||||||
|  |             throw new NullReferenceException(nameof(ApiLoggingContentTypes)); | ||||||
|  |         if (appSettings.ApiLoggingPathPrefixes is null) | ||||||
|  |             throw new NullReferenceException(nameof(ApiLoggingPathPrefixes)); | ||||||
|  |         if (appSettings.ApiLogPath is null) | ||||||
|  |             throw new NullReferenceException(nameof(ApiLogPath)); | ||||||
|  |         if (appSettings.AttachmentPath is null) | ||||||
|  |             throw new NullReferenceException(nameof(AttachmentPath)); | ||||||
|  |         if (appSettings.BuildNumber is null) | ||||||
|  |             throw new NullReferenceException(nameof(BuildNumber)); | ||||||
|  |         if (appSettings.Company is null) | ||||||
|  |             throw new NullReferenceException(nameof(Company)); | ||||||
|  |         if (appSettings.ConnectionString is null) | ||||||
|  |             throw new NullReferenceException(nameof(ConnectionString)); | ||||||
|  |         if (appSettings.GitCommitSeven is null) | ||||||
|  |             throw new NullReferenceException(nameof(GitCommitSeven)); | ||||||
|  |         if (appSettings.InboundApiAllowedIPList is null) | ||||||
|  |             throw new NullReferenceException(nameof(InboundApiAllowedIPList)); | ||||||
|  |         if (appSettings.MonAResource is null) | ||||||
|  |             throw new NullReferenceException(nameof(MonAResource)); | ||||||
|  |         if (appSettings.MonASite is null) | ||||||
|  |             throw new NullReferenceException(nameof(MonASite)); | ||||||
|  |         if (appSettings.Oi2SqlConnectionString is null) | ||||||
|  |             throw new NullReferenceException(nameof(Oi2SqlConnectionString)); | ||||||
|  |         if (appSettings.OIExportPath is null) | ||||||
|  |             throw new NullReferenceException(nameof(OIExportPath)); | ||||||
|  |         if (appSettings.URLs is null) | ||||||
|  |             throw new NullReferenceException(nameof(URLs)); | ||||||
|  |         if (appSettings.WorkingDirectoryName is null) | ||||||
|  |             throw new NullReferenceException(nameof(WorkingDirectoryName)); | ||||||
|         result = new( |         result = new( | ||||||
|             appSettings.ApiLoggingContentTypes, |             appSettings.ApiLoggingContentTypes, | ||||||
|             appSettings.ApiLoggingPathPrefixes, |             appSettings.ApiLoggingPathPrefixes, | ||||||
|  | |||||||
| @ -12,8 +12,11 @@ | |||||||
|         <Nullable>disable</Nullable> |         <Nullable>disable</Nullable> | ||||||
|         <OutputType>Exe</OutputType> |         <OutputType>Exe</OutputType> | ||||||
|         <RuntimeIdentifier>win-x64</RuntimeIdentifier> |         <RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||||||
|         <TargetFramework>net6.0</TargetFramework> |         <TargetFramework>net7.0</TargetFramework> | ||||||
|     </PropertyGroup> |     </PropertyGroup> | ||||||
|  |     <ItemGroup> | ||||||
|  |         <InternalsVisibleTo Include="Tests" /> | ||||||
|  |     </ItemGroup> | ||||||
|     <ItemGroup> |     <ItemGroup> | ||||||
|         <Compile Remove="logs\**" /> |         <Compile Remove="logs\**" /> | ||||||
|         <Content Remove="logs\**" /> |         <Content Remove="logs\**" /> | ||||||
| @ -26,28 +29,22 @@ | |||||||
|     <ItemGroup> |     <ItemGroup> | ||||||
|         <PackageReference Include="Dapper" Version="2.0.123" /> |         <PackageReference Include="Dapper" Version="2.0.123" /> | ||||||
|         <PackageReference Include="EntityFramework" Version="6.4.4" /> |         <PackageReference Include="EntityFramework" Version="6.4.4" /> | ||||||
|         <PackageReference Include="jQuery" Version="3.6.0" /> |         <PackageReference Include="jQuery" Version="3.6.3" /> | ||||||
|         <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> |         <PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> | ||||||
|     </ItemGroup> |         <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" /> | ||||||
|     <ItemGroup> |         <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" /> | ||||||
|         <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" /> |         <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" /> | ||||||
|         <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" /> |         <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" /> | ||||||
|         <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" /> |         <PackageReference Include="Serilog.AspNetCore" Version="6.1.0" /> | ||||||
|         <PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" /> |         <PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" /> | ||||||
|     </ItemGroup> |         <PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" /> | ||||||
|     <ItemGroup> |         <PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" /> | ||||||
|         <PackageReference Include="Serilog.AspNetCore" Version="5.0.0" /> |  | ||||||
|         <PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" /> |  | ||||||
|         <PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" /> |  | ||||||
|         <PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" /> |  | ||||||
|         <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> |         <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> | ||||||
|         <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> |         <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> | ||||||
|  |         <PackageReference Include="System.Data.SqlClient" Version="4.8.5" /> | ||||||
|     </ItemGroup> |     </ItemGroup> | ||||||
|     <ItemGroup> |     <ItemGroup> | ||||||
|         <PackageReference Include="System.Data.SqlClient" Version="4.8.3" /> |         <ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" /> | ||||||
|     </ItemGroup> |  | ||||||
|     <ItemGroup> |  | ||||||
|         <ProjectReference Include="..\Shared\Shared.csproj" /> |  | ||||||
|     </ItemGroup> |     </ItemGroup> | ||||||
|     <ItemGroup> |     <ItemGroup> | ||||||
|         <Folder Include="moves\" /> |         <Folder Include="moves\" /> | ||||||
| @ -9,6 +9,7 @@ using OI.Metrology.Archive.Models; | |||||||
| using OI.Metrology.Archive.Repositories; | using OI.Metrology.Archive.Repositories; | ||||||
| using OI.Metrology.Archive.Services; | using OI.Metrology.Archive.Services; | ||||||
| using OI.Metrology.Shared.Models; | using OI.Metrology.Shared.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Repositories; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using Serilog; | using Serilog; | ||||||
| @ -21,6 +22,8 @@ namespace OI.Metrology.Archive; | |||||||
| public class Program | public class Program | ||||||
| { | { | ||||||
|  |  | ||||||
|  |     internal readonly AppSettings _AppSettings; | ||||||
|  |  | ||||||
|     private static (string, WebApplicationOptions) Get(string[] args) |     private static (string, WebApplicationOptions) Get(string[] args) | ||||||
|     { |     { | ||||||
|         string webRootPath; |         string webRootPath; | ||||||
| @ -50,10 +53,10 @@ public class Program | |||||||
|         (string assemblyName, WebApplicationOptions _) = Get(args); |         (string assemblyName, WebApplicationOptions _) = Get(args); | ||||||
|         WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args); |         WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args); | ||||||
|         _ = webApplicationBuilder.Configuration.AddUserSecrets<Program>(); |         _ = webApplicationBuilder.Configuration.AddUserSecrets<Program>(); | ||||||
|         AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration); |         AppSettings _AppSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration); | ||||||
|         if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName)) |         if (string.IsNullOrEmpty(_AppSettings.WorkingDirectoryName)) | ||||||
|             throw new Exception("Working directory name must have a value!"); |             throw new Exception("Working directory name must have a value!"); | ||||||
|         string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assemblyName, appSettings.WorkingDirectoryName); |         string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assemblyName, _AppSettings.WorkingDirectoryName); | ||||||
|         Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory); |         Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory); | ||||||
|         _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, webApplicationBuilder.Configuration); |         _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, webApplicationBuilder.Configuration); | ||||||
|         _ = SerilogHostBuilderExtensions.UseSerilog(webApplicationBuilder.Host); |         _ = SerilogHostBuilderExtensions.UseSerilog(webApplicationBuilder.Host); | ||||||
| @ -63,13 +66,13 @@ public class Program | |||||||
|         { |         { | ||||||
|             _ = webApplicationBuilder.Services.Configure<ApiBehaviorOptions>(options => options.SuppressModelStateInvalidFilter = true); |             _ = webApplicationBuilder.Services.Configure<ApiBehaviorOptions>(options => options.SuppressModelStateInvalidFilter = true); | ||||||
|             _ = webApplicationBuilder.Services.AddControllersWithViews(); |             _ = webApplicationBuilder.Services.AddControllersWithViews(); | ||||||
|             _ = new MetrologyRepo(new SQLDbConnectionFactory(appSettings), null); |             _ = new MetrologyRepository(new SQLDbConnectionFactory(_AppSettings), null); | ||||||
|             _ = webApplicationBuilder.Services.AddDistributedMemoryCache(); |             _ = webApplicationBuilder.Services.AddDistributedMemoryCache(); | ||||||
|             _ = webApplicationBuilder.Services.AddMemoryCache(); |             _ = webApplicationBuilder.Services.AddMemoryCache(); | ||||||
|             _ = webApplicationBuilder.Services.AddSingleton<AppSettings, AppSettings>(_ => appSettings); |             _ = webApplicationBuilder.Services.AddSingleton<AppSettings, AppSettings>(_ => _AppSettings); | ||||||
|             _ = webApplicationBuilder.Services.AddScoped<IAttachmentsService, AttachmentsService>(); |             _ = webApplicationBuilder.Services.AddScoped<IAttachmentsService, AttachmentsService>(); | ||||||
|             _ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>(); |             _ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>(); | ||||||
|             _ = webApplicationBuilder.Services.AddScoped<IMetrologyRepo, MetrologyRepo>(); |             _ = webApplicationBuilder.Services.AddScoped<IMetrologyRepository, MetrologyRepository>(); | ||||||
|             _ = webApplicationBuilder.Services.AddScoped<IRdsMaxRepo, RdsMaxRepo>(); |             _ = webApplicationBuilder.Services.AddScoped<IRdsMaxRepo, RdsMaxRepo>(); | ||||||
|             _ = webApplicationBuilder.Services.AddSingleton<IDbConnectionFactory, SQLDbConnectionFactory>(); |             _ = webApplicationBuilder.Services.AddSingleton<IDbConnectionFactory, SQLDbConnectionFactory>(); | ||||||
|             _ = webApplicationBuilder.Services.AddSwaggerGen(); |             _ = webApplicationBuilder.Services.AddSwaggerGen(); | ||||||
| @ -85,8 +88,10 @@ public class Program | |||||||
|                 _ = webApplicationBuilder.Services.AddSingleton<IHostLifetime, WindowsServiceLifetime>(); |                 _ = webApplicationBuilder.Services.AddSingleton<IHostLifetime, WindowsServiceLifetime>(); | ||||||
|                 _ = webApplicationBuilder.Logging.AddEventLog(settings => |                 _ = webApplicationBuilder.Logging.AddEventLog(settings => | ||||||
|                 { |                 { | ||||||
|  | #pragma warning disable CA1416 | ||||||
|                     if (string.IsNullOrEmpty(settings.SourceName)) |                     if (string.IsNullOrEmpty(settings.SourceName)) | ||||||
|                         settings.SourceName = webApplicationBuilder.Environment.ApplicationName; |                         settings.SourceName = webApplicationBuilder.Environment.ApplicationName; | ||||||
|  | #pragma warning restore | ||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
|             WebApplication webApplication = webApplicationBuilder.Build(); |             WebApplication webApplication = webApplicationBuilder.Build(); | ||||||
| @ -97,7 +102,7 @@ public class Program | |||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 if (string.IsNullOrEmpty(appSettings.URLs)) |                 if (string.IsNullOrEmpty(_AppSettings.URLs)) | ||||||
|                 { |                 { | ||||||
|                     Environment.ExitCode = -1; |                     Environment.ExitCode = -1; | ||||||
|                     webApplication.Lifetime.StopApplication(); |                     webApplication.Lifetime.StopApplication(); | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ | |||||||
| using Microsoft.Extensions.Caching.Memory; | using Microsoft.Extensions.Caching.Memory; | ||||||
| using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Repositories; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| @ -12,12 +13,12 @@ using System.Transactions; | |||||||
|  |  | ||||||
| namespace OI.Metrology.Archive.Repositories; | namespace OI.Metrology.Archive.Repositories; | ||||||
|  |  | ||||||
| public class MetrologyRepo : IMetrologyRepo | public class MetrologyRepository : IMetrologyRepository | ||||||
| { | { | ||||||
|     private readonly IDbConnectionFactory _DBConnectionFactory; |     private readonly IDbConnectionFactory _DBConnectionFactory; | ||||||
|     private readonly IMemoryCache _Cache; |     private readonly IMemoryCache _Cache; | ||||||
|  |  | ||||||
|     public MetrologyRepo(IDbConnectionFactory dbConnectionFactory, IMemoryCache memoryCache) |     public MetrologyRepository(IDbConnectionFactory dbConnectionFactory, IMemoryCache memoryCache) | ||||||
|     { |     { | ||||||
|         _DBConnectionFactory = dbConnectionFactory; |         _DBConnectionFactory = dbConnectionFactory; | ||||||
|         _Cache = memoryCache; |         _Cache = memoryCache; | ||||||
| @ -28,20 +29,6 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     protected DbProviderFactory GetDbProviderFactory(IDbConnection conn) => |     protected DbProviderFactory GetDbProviderFactory(IDbConnection conn) => | ||||||
|         DbProviderFactories.GetFactory(conn.GetType().Namespace); |         DbProviderFactories.GetFactory(conn.GetType().Namespace); | ||||||
|  |  | ||||||
|     public bool IsTestDatabase() |  | ||||||
|     { |  | ||||||
|         int c = 0; |  | ||||||
|         using (DbConnection conn = GetDbConnection()) |  | ||||||
|         { |  | ||||||
|             c = conn.Query<int>( |  | ||||||
|                 "SELECT COUNT(*) " + |  | ||||||
|                 "FROM Configuration " + |  | ||||||
|                 "WHERE KeyName = 'TestDatabase' " + |  | ||||||
|                 "AND ValueString = '1'").FirstOrDefault(); |  | ||||||
|         } |  | ||||||
|         return c > 0; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public TransactionScope StartTransaction() => new(); |     public TransactionScope StartTransaction() => new(); | ||||||
|  |  | ||||||
|     protected void CacheItem(string key, object v) |     protected void CacheItem(string key, object v) | ||||||
| @ -136,10 +123,10 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|             // build field map |             // build field map | ||||||
|             foreach (ToolTypeMetadata f in fields) |             foreach (ToolTypeMetadata f in fields) | ||||||
|             { |             { | ||||||
|                 if ((f.ApiName != null) && f.ApiName.Contains('\\')) |                 if ((f.ApiName is not null) && f.ApiName.Contains('\\')) | ||||||
|                 { |                 { | ||||||
|                     string n = f.ApiName.Split('\\')[0].Trim().ToUpper(); |                     string n = f.ApiName.Split('\\')[0].Trim().ToUpper(); | ||||||
|                     if (containerField == null) |                     if (containerField is null) | ||||||
|                         containerField = n; |                         containerField = n; | ||||||
|                     else if (!string.Equals(containerField, n)) |                     else if (!string.Equals(containerField, n)) | ||||||
|                         throw new Exception("Only one container field is allowed"); |                         throw new Exception("Only one container field is allowed"); | ||||||
| @ -153,7 +140,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (containerField == null) |             if (containerField is null) | ||||||
|             { |             { | ||||||
|                 // No container field, just  insert a single row |                 // No container field, just  insert a single row | ||||||
|  |  | ||||||
| @ -164,7 +151,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|                 // Find the container field in the json |                 // Find the container field in the json | ||||||
|                 JProperty contJP = jsonrow.Children<JProperty>().Where(c => string.Equals(c.Name.Trim(), containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); |                 JProperty contJP = jsonrow.Children<JProperty>().Where(c => string.Equals(c.Name.Trim(), containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); | ||||||
|  |  | ||||||
|                 if ((contJP != null) && (contJP.Value is JArray array)) |                 if ((contJP is not null) && (contJP.Value is JArray array)) | ||||||
|                 { |                 { | ||||||
|                     JArray contRows = array; |                     JArray contRows = array; | ||||||
|  |  | ||||||
| @ -227,14 +214,13 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|                 parmnumber += 1; |                 parmnumber += 1; | ||||||
|  |  | ||||||
|                 object sqlValue = ((JValue)jp.Value).Value; |                 object sqlValue = ((JValue)jp.Value).Value; | ||||||
|                 if (sqlValue == null) |                 sqlValue ??= DBNull.Value; | ||||||
|                     sqlValue = DBNull.Value; |  | ||||||
|  |  | ||||||
|                 AddParameter(cmd, parmname, sqlValue); |                 AddParameter(cmd, parmname, sqlValue); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if ((containerrow != null) && (containerFieldmap != null)) |         if ((containerrow is not null) && (containerFieldmap is not null)) | ||||||
|         { |         { | ||||||
|  |  | ||||||
|             foreach (JProperty jp in containerrow.Children<JProperty>()) |             foreach (JProperty jp in containerrow.Children<JProperty>()) | ||||||
| @ -251,8 +237,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|                     parmnumber += 1; |                     parmnumber += 1; | ||||||
|  |  | ||||||
|                     object sqlValue = ((JValue)jp.Value).Value; |                     object sqlValue = ((JValue)jp.Value).Value; | ||||||
|                     if (sqlValue == null) |                     sqlValue ??= DBNull.Value; | ||||||
|                         sqlValue = DBNull.Value; |  | ||||||
|  |  | ||||||
|                     AddParameter(cmd, parmname, sqlValue); |                     AddParameter(cmd, parmname, sqlValue); | ||||||
|                 } |                 } | ||||||
| @ -266,7 +251,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         cmd.CommandText = columns.TrimEnd(',') + parms.TrimEnd(',') + ";SELECT SCOPE_IDENTITY();"; |         cmd.CommandText = columns.TrimEnd(',') + parms.TrimEnd(',') + ";SELECT SCOPE_IDENTITY();"; | ||||||
|  |  | ||||||
|         object o = cmd.ExecuteScalar(); |         object o = cmd.ExecuteScalar(); | ||||||
|         if ((o == null) || Convert.IsDBNull(o)) |         if ((o is null) || Convert.IsDBNull(o)) | ||||||
|             throw new Exception("Unexpected query result"); |             throw new Exception("Unexpected query result"); | ||||||
|         return Convert.ToInt64(o); |         return Convert.ToInt64(o); | ||||||
|     } |     } | ||||||
| @ -306,7 +291,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|             { |             { | ||||||
|                 if (!firstField) |                 if (!firstField) | ||||||
|                     _ = sb.Append(','); |                     _ = sb.Append(','); | ||||||
|                 if (f.GridAttributes != null && f.GridAttributes.Contains("isNull")) |                 if (f.GridAttributes is not null && f.GridAttributes.Contains("isNull")) | ||||||
|                 { |                 { | ||||||
|                     _ = sb.AppendFormat("{0}", "ISNULL(" + f.ColumnName + ", '')[" + f.ColumnName + "]"); |                     _ = sb.AppendFormat("{0}", "ISNULL(" + f.ColumnName + ", '')[" + f.ColumnName + "]"); | ||||||
|                 } |                 } | ||||||
| @ -324,11 +309,11 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     public DataTable GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerId, out long totalRecords) |     public DataTable GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerId, out long totalRecords) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); |         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); | ||||||
|         if (md == null) |         if (md is null) | ||||||
|             throw new Exception("Invalid tool type metadata"); |             throw new Exception("Invalid tool type metadata"); | ||||||
|  |  | ||||||
|         DataTable dt = new(); |         DataTable dt = new(); | ||||||
| @ -420,11 +405,11 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     public DataTable GetData(int toolTypeId, long headerid) |     public DataTable GetData(int toolTypeId, long headerid) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); |         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); | ||||||
|         if (md == null) |         if (md is null) | ||||||
|             throw new Exception("Invalid tool type metadata"); |             throw new Exception("Invalid tool type metadata"); | ||||||
|  |  | ||||||
|         DataTable dt = new(); |         DataTable dt = new(); | ||||||
| @ -531,11 +516,11 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     public DataTable GetDataSharePoint(int toolTypeId, string headerid) |     public DataTable GetDataSharePoint(int toolTypeId, string headerid) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); |         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); | ||||||
|         if (md == null) |         if (md is null) | ||||||
|             throw new Exception("Invalid tool type metadata"); |             throw new Exception("Invalid tool type metadata"); | ||||||
|  |  | ||||||
|         DataTable dt = new(); |         DataTable dt = new(); | ||||||
| @ -626,7 +611,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     public Guid GetHeaderAttachmentID(int toolTypeId, long headerId) |     public Guid GetHeaderAttachmentID(int toolTypeId, long headerId) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -639,7 +624,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     public Guid GetDataAttachmentID(int toolTypeId, long headerId, string title) |     public Guid GetDataAttachmentID(int toolTypeId, long headerId, string title) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -658,7 +643,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     public DataSet GetOIExportData(int toolTypeId, long headerid) |     public DataSet GetOIExportData(int toolTypeId, long headerid) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         if (string.IsNullOrWhiteSpace(tt.OIExportSPName)) |         if (string.IsNullOrWhiteSpace(tt.OIExportSPName)) | ||||||
| @ -684,10 +669,13 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return ds; |         return ds; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public IEnumerable<HeaderCommon> GetHeaderTitles(int toolTypeId, int? pageNo, int? pageSize, out long totalRecords) |     public HeaderCommon[] GetHeaderTitles(int? toolTypeId, int? pageNo, int? pageSize, out long totalRecords) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         if (toolTypeId is null) | ||||||
|         if (tt == null) |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|  |         ToolType tt = GetToolTypeByID(toolTypeId.Value); | ||||||
|  |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         DbConnection conn = GetDbConnection(); |         DbConnection conn = GetDbConnection(); | ||||||
| @ -695,17 +683,17 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         { |         { | ||||||
|             string sql = $"SELECT ID, InsertDate, AttachmentID, Title, [Date] FROM {tt.HeaderTableName} ORDER BY [Date] DESC "; |             string sql = $"SELECT ID, InsertDate, AttachmentID, Title, [Date] FROM {tt.HeaderTableName} ORDER BY [Date] DESC "; | ||||||
|  |  | ||||||
|             IEnumerable<HeaderCommon> headers; |             HeaderCommon[] headers; | ||||||
|  |  | ||||||
|             if (pageNo.HasValue && pageSize.HasValue) |             if (pageNo.HasValue && pageSize.HasValue) | ||||||
|             { |             { | ||||||
|                 sql += "OFFSET @PageNum * @PageSize ROWS FETCH NEXT @PageSize ROWS ONLY"; |                 sql += "OFFSET @PageNum * @PageSize ROWS FETCH NEXT @PageSize ROWS ONLY"; | ||||||
|  |  | ||||||
|                 headers = conn.Query<HeaderCommon>(sql, param: new { PageNum = pageNo.Value, PageSize = pageSize.Value }).ToList(); |                 headers = conn.Query<HeaderCommon>(sql, param: new { PageNum = pageNo.Value, PageSize = pageSize.Value }).ToArray(); | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 headers = conn.Query<HeaderCommon>(sql).ToList(); |                 headers = conn.Query<HeaderCommon>(sql).ToArray(); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             sql = $"SELECT COUNT(*) FROM [{tt.HeaderTableName}] "; |             sql = $"SELECT COUNT(*) FROM [{tt.HeaderTableName}] "; | ||||||
| @ -719,11 +707,11 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     public IEnumerable<KeyValuePair<string, string>> GetHeaderFields(int toolTypeId, long headerid) |     public IEnumerable<KeyValuePair<string, string>> GetHeaderFields(int toolTypeId, long headerid) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); |         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); | ||||||
|         if (md == null) |         if (md is null) | ||||||
|             throw new Exception("Invalid tool type metadata"); |             throw new Exception("Invalid tool type metadata"); | ||||||
|  |  | ||||||
|         List<KeyValuePair<string, string>> r = new(); |         List<KeyValuePair<string, string>> r = new(); | ||||||
| @ -751,10 +739,10 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|             foreach (ToolTypeMetadata m in md.Where(m => m.Header == true && m.TableDisplayOrder > 0).OrderBy(m => m.TableDisplayOrder)) |             foreach (ToolTypeMetadata m in md.Where(m => m.Header == true && m.TableDisplayOrder > 0).OrderBy(m => m.TableDisplayOrder)) | ||||||
|             { |             { | ||||||
|                 string v = ""; |                 string v = ""; | ||||||
|                 if (dr != null) |                 if (dr is not null) | ||||||
|                 { |                 { | ||||||
|                     object o = dr[m.ColumnName]; |                     object o = dr[m.ColumnName]; | ||||||
|                     if (o != null && !Convert.IsDBNull(o)) |                     if (o is not null && !Convert.IsDBNull(o)) | ||||||
|                         v = Convert.ToString(o); |                         v = Convert.ToString(o); | ||||||
|                 } |                 } | ||||||
|                 KeyValuePair<string, string> kvp = new(m.DisplayTitle, v); |                 KeyValuePair<string, string> kvp = new(m.DisplayTitle, v); | ||||||
| @ -764,16 +752,16 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return r; |         return r; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public IEnumerable<AwaitingDispo> GetAwaitingDispo() |     public IEnumerable<AwaitingDisposition> GetAwaitingDisposition() | ||||||
|     { |     { | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
|         return conn.Query<AwaitingDispo>("GetAwaitingDispo", commandType: CommandType.StoredProcedure); |         return conn.Query<AwaitingDisposition>("GetAwaitingDispo", commandType: CommandType.StoredProcedure); | ||||||
|     } |     } | ||||||
|     // Jonathan changed this to remove the reviewDate update on the database. |     // Jonathan changed this to remove the reviewDate update on the database. | ||||||
|     public int UpdateReviewDate(int toolTypeId, long headerId, bool clearDate) |     public int UpdateReviewDate(int toolTypeId, long headerId, bool clearDate) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -794,7 +782,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     public Guid GetHeaderAttachmentIDByTitle(int toolTypeId, string title) |     public Guid GetHeaderAttachmentIDByTitle(int toolTypeId, string title) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -806,7 +794,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     public Guid GetDataAttachmentIDByTitle(int toolTypeId, string title) |     public Guid GetDataAttachmentIDByTitle(int toolTypeId, string title) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
|  |  | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -815,8 +803,8 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return conn.ExecuteScalar<Guid>(sql, param: new { Title = title }); |         return conn.ExecuteScalar<Guid>(sql, param: new { Title = title }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     string IMetrologyRepo.GetHeaderInsertDate(int toolTypeId, long headerId) => throw new NotImplementedException(); |     string IMetrologyRepository.GetHeaderInsertDate(int toolTypeId, long headerId) => throw new NotImplementedException(); | ||||||
|     void IMetrologyRepo.SetHeaderDirName(string tableName, long headerId, string dateDir) => throw new NotImplementedException(); |     void IMetrologyRepository.SetHeaderDirName(string tableName, long headerId, string dateDir) => throw new NotImplementedException(); | ||||||
|     string IMetrologyRepo.GetDataInsertDate(int toolTypeId, long headerId, string title) => throw new NotImplementedException(); |     string IMetrologyRepository.GetDataInsertDate(int toolTypeId, long headerId, string title) => throw new NotImplementedException(); | ||||||
|     void IMetrologyRepo.SetDataDirName(string tableName, long headerId, string title, string dateDir) => throw new NotImplementedException(); |     void IMetrologyRepository.SetDataDirName(string tableName, long headerId, string title, string dateDir) => throw new NotImplementedException(); | ||||||
| } | } | ||||||
| @ -6,27 +6,27 @@ namespace OI.Metrology.Archive.Services; | |||||||
|  |  | ||||||
| using OI.Metrology.Archive.Models; | using OI.Metrology.Archive.Models; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using System.Data.SqlClient; | using System.Data.SqlClient; | ||||||
|  |  | ||||||
| public class AttachmentsService : IAttachmentsService | public class AttachmentsService : IAttachmentsService | ||||||
| { | { | ||||||
|  |  | ||||||
|     private readonly IMetrologyRepo _Repo; |  | ||||||
|     private readonly AppSettings _AppSettings; |     private readonly AppSettings _AppSettings; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|     public AttachmentsService(AppSettings appSettings, IMetrologyRepo repo) |     public AttachmentsService(AppSettings appSettings, IMetrologyRepository metrologyRepository) | ||||||
|     { |     { | ||||||
|         _Repo = repo; |  | ||||||
|         _AppSettings = appSettings; |         _AppSettings = appSettings; | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|     } |     } | ||||||
|     protected Stream GetAttachmentStream(string tableName, Guid attachmentId, string filename) |     protected Stream GetAttachmentStream(string tableName, Guid attachmentId, string filename) | ||||||
|     { |     { | ||||||
|         if (attachmentId.Equals(Guid.Empty)) |         if (attachmentId.Equals(Guid.Empty)) | ||||||
|             throw new Exception("No attachments found"); |             throw new Exception("No attachments found"); | ||||||
|  |  | ||||||
|         DateTime insertDate = Convert.ToDateTime(_Repo.GetAttachmentInsertDateByGUID(tableName, attachmentId)); |         DateTime insertDate = Convert.ToDateTime(_MetrologyRepository.GetAttachmentInsertDateByGUID(tableName, attachmentId)); | ||||||
|         int year = insertDate.Year; |         int year = insertDate.Year; | ||||||
|         DateTime d = insertDate; |         DateTime d = insertDate; | ||||||
|         CultureInfo cul = CultureInfo.CurrentCulture; |         CultureInfo cul = CultureInfo.CurrentCulture; | ||||||
| @ -63,7 +63,7 @@ public class AttachmentsService : IAttachmentsService | |||||||
|  |  | ||||||
|     public Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename) |     public Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename) | ||||||
|     { |     { | ||||||
|         if (toolType == null) |         if (toolType is null) | ||||||
|             throw new Exception("Invalid tool type"); |             throw new Exception("Invalid tool type"); | ||||||
|  |  | ||||||
|         string queryString = "SELECT * FROM " + toolType.DataTableName + " WHERE AttachmentId = @attachmentId"; |         string queryString = "SELECT * FROM " + toolType.DataTableName + " WHERE AttachmentId = @attachmentId"; | ||||||
| @ -103,19 +103,19 @@ public class AttachmentsService : IAttachmentsService | |||||||
|         if (header) |         if (header) | ||||||
|         { |         { | ||||||
|             tableName = toolType.HeaderTableName; |             tableName = toolType.HeaderTableName; | ||||||
|             attachmentId = _Repo.GetHeaderAttachmentIDByTitle(toolType.ID, title); |             attachmentId = _MetrologyRepository.GetHeaderAttachmentIDByTitle(toolType.ID, title); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             tableName = toolType.DataTableName; |             tableName = toolType.DataTableName; | ||||||
|             attachmentId = _Repo.GetDataAttachmentIDByTitle(toolType.ID, title); |             attachmentId = _MetrologyRepository.GetDataAttachmentIDByTitle(toolType.ID, title); | ||||||
|         } |         } | ||||||
|         return GetAttachmentStream(tableName, attachmentId, filename); |         return GetAttachmentStream(tableName, attachmentId, filename); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public Stream GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename) |     public Stream GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename) | ||||||
|     { |     { | ||||||
|         if (toolType == null) |         if (toolType is null) | ||||||
|             throw new Exception("Invalid tool type"); |             throw new Exception("Invalid tool type"); | ||||||
|         string tableName; |         string tableName; | ||||||
|         if (header) |         if (header) | ||||||
| @ -126,7 +126,7 @@ public class AttachmentsService : IAttachmentsService | |||||||
|     } |     } | ||||||
|     public Stream GetAttachmentStreamByAttachmentIdArchive(ToolType toolType, bool header, Guid attachmentId, string filename) |     public Stream GetAttachmentStreamByAttachmentIdArchive(ToolType toolType, bool header, Guid attachmentId, string filename) | ||||||
|     { |     { | ||||||
|         if (toolType == null) |         if (toolType is null) | ||||||
|             throw new Exception("Invalid tool type"); |             throw new Exception("Invalid tool type"); | ||||||
|         string tableName; |         string tableName; | ||||||
|         if (header) |         if (header) | ||||||
| @ -139,21 +139,21 @@ public class AttachmentsService : IAttachmentsService | |||||||
|  |  | ||||||
|     private void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, Microsoft.AspNetCore.Http.IFormFile uploadedFile) |     private void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, Microsoft.AspNetCore.Http.IFormFile uploadedFile) | ||||||
|     { |     { | ||||||
|         if (toolType == null) |         if (toolType is null) | ||||||
|             throw new Exception("Invalid tool type"); |             throw new Exception("Invalid tool type"); | ||||||
|  |  | ||||||
|         using System.Transactions.TransactionScope trans = _Repo.StartTransaction(); |         using System.Transactions.TransactionScope trans = _MetrologyRepository.StartTransaction(); | ||||||
|         Guid attachmentId = Guid.Empty; |         Guid attachmentId = Guid.Empty; | ||||||
|         string tableName = ""; |         string tableName = ""; | ||||||
|  |  | ||||||
|         if (string.IsNullOrWhiteSpace(dataUniqueId)) |         if (string.IsNullOrWhiteSpace(dataUniqueId)) | ||||||
|         { |         { | ||||||
|             attachmentId = _Repo.GetHeaderAttachmentID(toolType.ID, headerId); |             attachmentId = _MetrologyRepository.GetHeaderAttachmentID(toolType.ID, headerId); | ||||||
|             tableName = toolType.HeaderTableName; |             tableName = toolType.HeaderTableName; | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             attachmentId = _Repo.GetDataAttachmentID(toolType.ID, headerId, dataUniqueId); |             attachmentId = _MetrologyRepository.GetDataAttachmentID(toolType.ID, headerId, dataUniqueId); | ||||||
|             tableName = toolType.DataTableName; |             tableName = toolType.DataTableName; | ||||||
|         } |         } | ||||||
|         if (Equals(attachmentId, Guid.Empty)) |         if (Equals(attachmentId, Guid.Empty)) | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| @ -10,9 +10,9 @@ namespace OI.Metrology.Archive.Services; | |||||||
|  |  | ||||||
| public class InboundDataService : IInboundDataService | public class InboundDataService : IInboundDataService | ||||||
| { | { | ||||||
|     private readonly IMetrologyRepo _Repo; |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|     public InboundDataService(IMetrologyRepo repo) => _Repo = repo; |     public InboundDataService(IMetrologyRepository metrologyRepository) => _MetrologyRepository = metrologyRepository; | ||||||
|  |  | ||||||
|     public long DoSQLInsert(JToken jsonbody, ToolType toolType, List<ToolTypeMetadata> metaData) |     public long DoSQLInsert(JToken jsonbody, ToolType toolType, List<ToolTypeMetadata> metaData) | ||||||
|     { |     { | ||||||
| @ -37,11 +37,11 @@ public class InboundDataService : IInboundDataService | |||||||
|  |  | ||||||
|         long headerId = 0; |         long headerId = 0; | ||||||
|  |  | ||||||
|         using (System.Transactions.TransactionScope transScope = _Repo.StartTransaction()) |         using (System.Transactions.TransactionScope transScope = _MetrologyRepository.StartTransaction()) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 _Repo.PurgeExistingData(toolType.ID, uniqueId); |                 _MetrologyRepository.PurgeExistingData(toolType.ID, uniqueId); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
| @ -50,7 +50,7 @@ public class InboundDataService : IInboundDataService | |||||||
|  |  | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 headerId = _Repo.InsertToolDataJSON(jsonbody, -1, metaData, toolType.HeaderTableName); |                 headerId = _MetrologyRepository.InsertToolDataJSON(jsonbody, -1, metaData, toolType.HeaderTableName); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
| @ -60,11 +60,11 @@ public class InboundDataService : IInboundDataService | |||||||
|             int detailrow = 1; |             int detailrow = 1; | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 if (detailsArray != null) |                 if (detailsArray is not null) | ||||||
|                 { |                 { | ||||||
|                     foreach (JToken detail in detailsArray) |                     foreach (JToken detail in detailsArray) | ||||||
|                     { |                     { | ||||||
|                         _ = _Repo.InsertToolDataJSON(detail, headerId, metaData, toolType.DataTableName); |                         _ = _MetrologyRepository.InsertToolDataJSON(detail, headerId, metaData, toolType.DataTableName); | ||||||
|                         detailrow += 1; |                         detailrow += 1; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @ -133,7 +133,7 @@ public class InboundDataService : IInboundDataService | |||||||
|  |  | ||||||
|                     if (jp.First is JArray array) |                     if (jp.First is JArray array) | ||||||
|                         detailsArray = array; |                         detailsArray = array; | ||||||
|                     else if ((jp.First is JValue value) && (value.Value == null)) |                     else if ((jp.First is JValue value) && (value.Value is null)) | ||||||
|                         detailsArray = null; |                         detailsArray = null; | ||||||
|                     else |                     else | ||||||
|                         errors.Add("Invalid details field"); |                         errors.Add("Invalid details field"); | ||||||
| @ -169,7 +169,7 @@ public class InboundDataService : IInboundDataService | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         // if a Details container if found, process it by recursion |         // if a Details container if found, process it by recursion | ||||||
|         if (detailsArray != null) |         if (detailsArray is not null) | ||||||
|         { |         { | ||||||
|             int i = 1; |             int i = 1; | ||||||
|             foreach (JToken detail in detailsArray) |             foreach (JToken detail in detailsArray) | ||||||
| @ -189,7 +189,7 @@ public class InboundDataService : IInboundDataService | |||||||
|         { |         { | ||||||
|             // get the json data for this container field, ex: Points |             // get the json data for this container field, ex: Points | ||||||
|             JProperty contJP = jsonbody.Children<JProperty>().Where(jp => string.Equals(jp.Name, containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); |             JProperty contJP = jsonbody.Children<JProperty>().Where(jp => string.Equals(jp.Name, containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); | ||||||
|             if ((contJP != null) && (contJP.Value is JArray array)) |             if ((contJP is not null) && (contJP.Value is JArray array)) | ||||||
|             { |             { | ||||||
|                 JArray contJPArray = array; |                 JArray contJPArray = array; | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,111 +1,81 @@ | |||||||
| @model OI.Metrology.Shared.ViewModels.RunInfo | @model OI.Metrology.Shared.ViewModels.RunInfo | ||||||
| @{ | @{ | ||||||
|     ViewData["Title"] = "Run Information"; |     ViewData["Title"] = "Reactor"; | ||||||
| } | } | ||||||
| <style> | <style> | ||||||
|     #HeaderGridDiv, |     #RunGridDiv, | ||||||
|     #DetailsGridDiv { |     #DetailsGridDiv { | ||||||
|         font-size: 12px; |         font-size: 12px; | ||||||
|     } |     } | ||||||
| </style> | </style> | ||||||
| 
 | 
 | ||||||
| <h4>Run Information</h4> | <h4>Reactor</h4> | ||||||
| 
 | 
 | ||||||
| <form class="form-inline mb-4"> | <form class="form-inline mb-4"> | ||||||
|     <div class="form-group"> |     <div class="form-group" id="EvenReactorDiv"> | ||||||
|         <label for="ToolType">Tool Type</label> |         <button for="EvenReactor">Even Reactor</button> | ||||||
|         <div class="form-control" id="ToolType"></div> |         <label for="EvenReactor">Even Reactor</label> | ||||||
|  |         <div class="form-control" id="EvenReactor" hidden></div> | ||||||
|     </div> |     </div> | ||||||
|     <div class="form-group"> |     <div class="form-group" id="OddReactorDiv"> | ||||||
|         <label for="StartDate">Start Time</label> |         <button for="OddReactor">Odd Reactor</button> | ||||||
|         <div class="form-control mb-2 mr-sm-2" id="StartDate"></div> |         <label for="OddReactor">Odd Reactor</label> | ||||||
|         <div class="form-control mb-2 mr-sm-2" id="StartTime"></div> |         <div class="form-control" id="OddReactor" hidden></div> | ||||||
|     </div> |  | ||||||
|     <div class="form-group"> |  | ||||||
|         <label for="EndDate">End Time</label> |  | ||||||
|         <div class="form-control mb-2 mr-sm-2" id="EndDate"></div> |  | ||||||
|         <div class="form-control mb-2 mr-sm-2" id="EndTime"></div> |  | ||||||
|     </div>   |     </div>   | ||||||
|     <div class="form-group"> |     <div class="form-group"> | ||||||
|         <input class="btn btn-primary" type="button" value="Load Headers" id="LoadHeadersButton" /> |         <input class="btn btn-primary" type="button" value="Load Runs" id="LoadRunsButton" /> | ||||||
|     </div>   |     </div>   | ||||||
|     <div class="form-group"> |  | ||||||
|         <label class="form-check-label" for="chkAutoRefresh"> |  | ||||||
|             Auto-Refresh |  | ||||||
|         </label> |  | ||||||
|         <input class="form-check-input" type="checkbox" id="chkAutoRefresh"> |  | ||||||
|     </div> |  | ||||||
| </form> | </form> | ||||||
| 
 | 
 | ||||||
| <div style="height: 300px;" id="HeaderGridDiv"> | <div style="height: 300px;" id="RunGridDiv"> | ||||||
|     <span id="ToolTypeID" hidden></span> |     <span id="EvenReactorID" hidden></span> | ||||||
|     <table id="HeaderGrid"></table> |     <span id="OddReactorID" hidden></span> | ||||||
|  |     <table id="RunGrid"></table> | ||||||
| </div> | </div> | ||||||
| 
 | 
 | ||||||
| <div class="row" style="margin-top: 10px; margin-bottom: 20px;"> | <div class="row" style="margin-top: 10px; margin-bottom: 20px;"> | ||||||
|     <div class="col-xs-1"> |     <div class="col-xs-1"> | ||||||
|         <input type="button" class="btn" id="GetDataButton" value="Get Data" disabled /> |         <input type="button" class="btn" id="GetDataButton" value="Get Data" disabled /> | ||||||
|     </div> |     </div> | ||||||
|     <div class="col-xs-1"> |  | ||||||
|         <input type="button" class="btn" id="ReviewButton" value="Review" disabled /> |  | ||||||
|     </div> |  | ||||||
| </div> |  | ||||||
| 
 |  | ||||||
| <div id="DetailsDiv" hidden> |  | ||||||
| 
 |  | ||||||
|     <span id="HeaderId" hidden></span> |  | ||||||
|     <span id="HeaderAttachmentId" hidden></span> |  | ||||||
|     <div style="padding-bottom: 20px;" id="DetailsGridDiv"> |  | ||||||
|         <table id="DetailsGrid"></table> |  | ||||||
|     </div> |  | ||||||
| 
 |  | ||||||
|     <div id="ExportDiv" style="margin-top: 10px;" hidden> |  | ||||||
|         <input type="button" value="Send to OpenInsight" id="OIExportButton" /> |  | ||||||
|         <span id="OIExportResult" style="margin-left: 10px; font-weight: bold; color: #366b02;"></span> |  | ||||||
|     </div> |  | ||||||
| 
 |  | ||||||
|     <p style="text-align: center; margin-top: 20px;"> |  | ||||||
|         <iframe id="DataAttachmentFrame" style="height:900px; border-width:thin; margin-right: 10px;" hidden></iframe> |  | ||||||
|         <iframe id="HeaderAttachmentFrame" style="height:900px; border-width:thin;" hidden></iframe> |  | ||||||
|     </p> |  | ||||||
| 
 |  | ||||||
| </div> | </div> | ||||||
| 
 | 
 | ||||||
| <script> | <script> | ||||||
| 
 | 
 | ||||||
|     var toolType = null; |     var EvenReactor = null; | ||||||
|     var toolTypeMetaData = null; |     var OddReactor = null; | ||||||
| 
 | 
 | ||||||
|     function LoadHeaderGrid() { |     function LoadRunGrid() { | ||||||
| 
 | 
 | ||||||
|         var toolTypeID = $("#ToolType").igCombo("value"); |         var EvenReactorID = $("#EvenReactor").igCombo("value"); | ||||||
| 
 | 
 | ||||||
|         $("#ToolTypeID").text(toolTypeID); |         $("#EvenReactorID").text(EvenReactorID); | ||||||
| 
 | 
 | ||||||
|         HideDetailsDiv(); |         HideDetailsDiv(); | ||||||
|         DisableHeaderButtons(); |         DisableHeaderButtons(); | ||||||
| 
 | 
 | ||||||
|         $("#HeaderId").text(""); |         $("#HeaderId").text(""); | ||||||
|         $("#HeaderAttachmentId").text(""); |         $("#HeaderAttachmentId").text(""); | ||||||
|  |         $("#HeaderDate").text(""); | ||||||
|  |         $("#SPHeaderID").text(""); | ||||||
| 
 | 
 | ||||||
|         var gridCreated = $("#HeaderGrid").data("igGrid"); |         var gridCreated = $("#RunGrid").data("igGrid"); | ||||||
|         if (gridCreated) |         if (gridCreated) | ||||||
|             $("#HeaderGrid").igGrid("destroy"); |             $("#RunGrid").igGrid("destroy"); | ||||||
| 
 | 
 | ||||||
|         $.ajax({ |         $.ajax({ | ||||||
|             type: "GET", |             type: "GET", | ||||||
|             url: "@Url.Content("~/api/tooltypes/")" + toolTypeID + "?sortby=grid", |             url: "@Url.Content("~/api/EvenReactors/")" + EvenReactorID + "?sortby=grid", | ||||||
|             success: function (r) { |             success: function (r) { | ||||||
|                 if ((r.Results == null) || (r.Results.ToolType == null) || (r.Results.Metadata == null)) |                 if ((r.Results == null) || (r.Results.EvenReactor == null) || (r.Results.Metadata == null)) | ||||||
|                     ShowErrorMessage("Invalid tool type: " + toolTypeID); |                     ShowErrorMessage("Invalid Even Reactor: " + EvenReactorID); | ||||||
|                 else { |                 else { | ||||||
|                     toolType = r.Results.ToolType; |                     EvenReactor = r.Results.EvenReactor; | ||||||
|                     toolTypeMetaData = r.Results.Metadata; |                     EvenReactorMetaData = r.Results.Metadata; | ||||||
|                     RequestHeaderData(); |                     RequestHeaderData(); | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|             error: function (e) { |             error: function (e) { | ||||||
|                 DisplayWSMessage("error", "There was an error getting tooltype info.", e); |                 DisplayWSMessage("error", "There was an error getting EvenReactor info.", e); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
| @ -130,21 +100,20 @@ | |||||||
|         $("#DetailsDiv").prop("hidden", false); |         $("#DetailsDiv").prop("hidden", false); | ||||||
| 
 | 
 | ||||||
|         $("#ExportDiv").prop("hidden", true); |         $("#ExportDiv").prop("hidden", true); | ||||||
|         if ((toolType != null) && (toolType.OIExportSPName != null) && (toolType.OIExportSPName.length > 0)) { |         if ((EvenReactor != null) && (EvenReactor.OIExportSPName != null) && (EvenReactor.OIExportSPName.length > 0)) { | ||||||
|             $("#ExportDiv").prop("hidden", false); |             $("#ExportDiv").prop("hidden", false); | ||||||
|             $("#OIExportButton").prop("disabled", false); |  | ||||||
|             $("#OIExportResult").text(''); |             $("#OIExportResult").text(''); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $("#DataAttachmentFrame").prop("hidden", true); |         $("#DataAttachmentFrame").prop("hidden", true); | ||||||
|         $("#HeaderAttachmentFrame").prop("hidden", true); |         $("#HeaderAttachmentFrame").prop("hidden", true); | ||||||
|         if (toolType != null) { |         if (EvenReactor != null) { | ||||||
|             var visibleFrames = 0; |             var visibleFrames = 0; | ||||||
|             if (toolType.DisplayDataAttachment && toolType.DisplayDataAttachment.length > 0) { |             if (EvenReactor.DisplayDataAttachment && EvenReactor.DisplayDataAttachment.length > 0) { | ||||||
|                 visibleFrames += 1; |                 visibleFrames += 1; | ||||||
|                 $("#DataAttachmentFrame").prop("hidden", false); |                 $("#DataAttachmentFrame").prop("hidden", false); | ||||||
|             } |             } | ||||||
|             if (toolType.DisplayHeaderAttachment && toolType.DisplayHeaderAttachment.length > 0) { |             if (EvenReactor.DisplayHeaderAttachment && EvenReactor.DisplayHeaderAttachment.length > 0) { | ||||||
|                 visibleFrames += 1; |                 visibleFrames += 1; | ||||||
|                 $("#HeaderAttachmentFrame").prop("hidden", false); |                 $("#HeaderAttachmentFrame").prop("hidden", false); | ||||||
|             } |             } | ||||||
| @ -167,6 +136,8 @@ | |||||||
|             $("#HeaderId").text(ui.row.id); |             $("#HeaderId").text(ui.row.id); | ||||||
|             var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index]; |             var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index]; | ||||||
|             $("#HeaderAttachmentId").text(rowData.AttachmentID); |             $("#HeaderAttachmentId").text(rowData.AttachmentID); | ||||||
|  |             $("#HeaderDate").text(rowData.Date); | ||||||
|  |             $("#SPHeaderID").text(rowData.Title); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -180,73 +151,65 @@ | |||||||
| 
 | 
 | ||||||
|         if (ui.row.index >= 0) { |         if (ui.row.index >= 0) { | ||||||
|             var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index]; |             var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index]; | ||||||
|             var toolTypeID = $("#ToolTypeID").text(); |             var EvenReactorID = $("#EvenReactorID").text(); | ||||||
|             var attachmentUrlBase = '@Url.Content("~/api/tooltypes/")' + toolTypeID; |             var attachmentUrlBase = '@Url.Content("~/api/EvenReactors/")' + EvenReactorID; | ||||||
|             var attachmentId = rowData.AttachmentID; |             var attachmentId = rowData.AttachmentID; | ||||||
| 
 |             var test = rowData.date | ||||||
|             if ((attachmentId == null) || (attachmentId === '')) |             if ((attachmentId == null) || (attachmentId === '')) | ||||||
|                 return; |                 return; | ||||||
| 
 | 
 | ||||||
|             if ((toolType.DisplayDataAttachment == null) || (toolType.DisplayDataAttachment === '')) |             if ((EvenReactor.DisplayDataAttachment == null) || (EvenReactor.DisplayDataAttachment === '')) | ||||||
|                 return; |                 return; | ||||||
| 
 | 
 | ||||||
|             $("#DataAttachmentFrame").prop("src", attachmentUrlBase + "/data/files/" + attachmentId + "/" + toolType.DisplayDataAttachment); |             $("#DataAttachmentFrame").prop("src", attachmentUrlBase + "/data/files/" + attachmentId + "/" + EvenReactor.DisplayDataAttachment); | ||||||
| 
 |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function LoadHeaderAttachment() { |     function LoadHeaderAttachment() { | ||||||
|         var toolTypeID = $("#ToolTypeID").text(); |         var EvenReactorID = $("#EvenReactorID").text(); | ||||||
|  |         var attachmentUrlBase = '@Url.Content("~/api/EvenReactors/")' + EvenReactorID; | ||||||
|         var attachmentId = $("#HeaderAttachmentId").text(); |         var attachmentId = $("#HeaderAttachmentId").text(); | ||||||
|         var attachmentUrlBase = '@Url.Content("~/api/tooltypes/")' + toolTypeID; |         var dateToUse = new Date($("#HeaderDate").text()); | ||||||
|         if ((attachmentId == null) || (attachmentId === '') || (toolType.DisplayHeaderAttachment == null) || (toolType.DisplayHeaderAttachment === '')) { |         var month = dateToUse.getMonth + 1; | ||||||
|  |         var year = dateToUse.getFullYear; | ||||||
|  |         if ((attachmentId == null) || (attachmentId === '') || (EvenReactor.DisplayHeaderAttachment == null) || (EvenReactor.DisplayHeaderAttachment === '')) { | ||||||
|             $("#HeaderAttachmentFrame").prop("src", ""); |             $("#HeaderAttachmentFrame").prop("src", ""); | ||||||
|         } else { |         } else { | ||||||
|             $("#HeaderAttachmentFrame").prop("src", attachmentUrlBase + "/header/files/" + attachmentId + "/" + toolType.DisplayHeaderAttachment); |             $("#HeaderAttachmentFrame").prop("src", attachmentUrlBase + "/header/files/" + attachmentId + "/" + EvenReactor.DisplayHeaderAttachment + "?date=" + dateToUse); | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|         $("#DataAttachmentFrame").prop("src", ""); |         $("#DataAttachmentFrame").prop("src", ""); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function MarkAsReviewed() { |     function CheckDate() { | ||||||
| 
 |         var date = new Date($("#HeaderDate").text()); | ||||||
|         var toolTypeId = $("#ToolTypeID").text(); |         return date; | ||||||
|         var headerId = $("#HeaderId").text(); |  | ||||||
| 
 |  | ||||||
|         $.ajax({ |  | ||||||
|             type: "POST", |  | ||||||
|             url: "@Url.Content("~/api/awaitingdispo/markasreviewed")?tooltypeid=" + toolTypeId + "&headerid=" + headerId, |  | ||||||
|             success: function () { |  | ||||||
|             }, |  | ||||||
|             error: function (e, ajaxOptions, ex) { |  | ||||||
|                 DisplayWSMessage("error", "There was an error marking header as reviewed.", e, ex); |  | ||||||
|                 $("#ReviewButton").prop("disabled", false); |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function LoadDetails() { |     function LoadDetails() { | ||||||
| 
 |  | ||||||
|         ShowDetailsDiv(); |         ShowDetailsDiv(); | ||||||
| 
 |  | ||||||
|         LoadHeaderAttachment(); |         LoadHeaderAttachment(); | ||||||
| 
 |         var dateToUse = $("#HeaderDate").text(); | ||||||
|         var gridCreated = $("#DetailsGrid").data("igGrid"); |         var gridCreated = $("#DetailsGrid").data("igGrid"); | ||||||
|         if (gridCreated) |         if (gridCreated) | ||||||
|             $("#DetailsGrid").igGrid("destroy"); |             $("#DetailsGrid").igGrid("destroy"); | ||||||
| 
 |         var dateID = Date.parse($("#HeaderDate").text()); | ||||||
|  |         var cutoffDt = Date.parse('2019-07-08') | ||||||
|         var headerId = $("#HeaderId").text(); |         var headerId = $("#HeaderId").text(); | ||||||
|         var toolTypeID = $("#ToolTypeID").text(); |         var EvenReactorID = $("#EvenReactorID").text(); | ||||||
| 
 |         var spHeaderID = $("#SPHeaderID").text(); | ||||||
|         var detailsURL = "@Url.Content("~/api/tooltypes/")" + toolTypeID + "/headers/" + headerId + "/data"; |         if (dateID < cutoffDt) { | ||||||
| 
 |             detailsURL = "@Url.Content("~/api/EvenReactors/")" + EvenReactorID + "/headers/" + spHeaderID + "/data/isSharePoint"; | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             var detailsURL = "@Url.Content("~/api/EvenReactors/")" + EvenReactorID + "/headers/" + headerId + "/data"; | ||||||
|  |         } | ||||||
|         var gridColumns = [ |         var gridColumns = [ | ||||||
|             { key: "AttachmentID", dataType: "string", hidden: true }, |             { key: "AttachmentID", dataType: "string", hidden: true }, | ||||||
|             { key: "Title", dataType: "string", hidden: true }, |             { key: "Title", dataType: "string", hidden: true }, | ||||||
|         ]; |         ]; | ||||||
| 
 | 
 | ||||||
|         for (var i = 0; i < toolTypeMetaData.length; i++) { |         for (var i = 0; i < EvenReactorMetaData.length; i++) { | ||||||
|             var f = toolTypeMetaData[i]; |             var f = EvenReactorMetaData[i]; | ||||||
|             if ((f.Header == false) && (f.GridDisplayOrder > 0)) { |             if ((f.Header == false) && (f.GridDisplayOrder > 0)) { | ||||||
|                 var col = { |                 var col = { | ||||||
|                     key: f.ColumnName, |                     key: f.ColumnName, | ||||||
| @ -264,6 +227,7 @@ | |||||||
|                 gridColumns.push(col); |                 gridColumns.push(col); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         var date = EvenReactorMetaData[2]; | ||||||
| 
 | 
 | ||||||
|         var gridParms = { |         var gridParms = { | ||||||
|             autoGenerateColumns: false, |             autoGenerateColumns: false, | ||||||
| @ -275,13 +239,11 @@ | |||||||
|             ], |             ], | ||||||
|             columns: gridColumns, |             columns: gridColumns, | ||||||
|             dataSource: detailsURL, |             dataSource: detailsURL, | ||||||
|             responseDataKey: "Results", |             responseDataKey: "Results" | ||||||
|             dataBound: MarkAsReviewed, |  | ||||||
| 
 |  | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if ((toolType != null) && (toolType.DataGridAttributes != null)) { |         if ((EvenReactor != null) && (EvenReactor.DataGridAttributes != null)) { | ||||||
|             jQuery.extend(gridParms, JSON.parse(toolType.DataGridAttributes)); |             jQuery.extend(gridParms, JSON.parse(EvenReactor.DataGridAttributes)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $("#DetailsGrid").igGrid(gridParms); |         $("#DetailsGrid").igGrid(gridParms); | ||||||
| @ -315,7 +277,7 @@ | |||||||
|             initialHeaderId = -1; |             initialHeaderId = -1; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         var headerURL = "@Url.Content("~/api/tooltypes/")" + toolType.ID + "/headers?" + $.param(parms); |         var headerURL = "@Url.Content("~/api/EvenReactors/")" + EvenReactor.ID + "/headers?" + $.param(parms); | ||||||
| 
 | 
 | ||||||
|         var gridColumns = [ |         var gridColumns = [ | ||||||
|             { key: "ID", dataType: "number", hidden: true }, |             { key: "ID", dataType: "number", hidden: true }, | ||||||
| @ -323,8 +285,8 @@ | |||||||
|             { key: "Title", dataType: "string", hidden: true }, |             { key: "Title", dataType: "string", hidden: true }, | ||||||
|         ]; |         ]; | ||||||
| 
 | 
 | ||||||
|         for (var i = 0; i < toolTypeMetaData.length; i++) { |         for (var i = 0; i < EvenReactorMetaData.length; i++) { | ||||||
|             var f = toolTypeMetaData[i]; |             var f = EvenReactorMetaData[i]; | ||||||
|             if ((f.Header == true) && (f.GridDisplayOrder > 0)) { |             if ((f.Header == true) && (f.GridDisplayOrder > 0)) { | ||||||
|                 var col = { |                 var col = { | ||||||
|                     key: f.ColumnName, |                     key: f.ColumnName, | ||||||
| @ -360,123 +322,56 @@ | |||||||
|             responseDataKey: "Results", |             responseDataKey: "Results", | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if ((toolType != null) && (toolType.HeaderGridAttributes != null)) { |         if ((EvenReactor != null) && (EvenReactor.RunGridAttributes != null)) { | ||||||
|             jQuery.extend(gridParms, JSON.parse(toolType.HeaderGridAttributes)); |             jQuery.extend(gridParms, JSON.parse(EvenReactor.RunGridAttributes)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $("#HeaderGrid").igGrid(gridParms); |         $("#RunGrid").igGrid(gridParms); | ||||||
| 
 | 
 | ||||||
|         if (headerId > 0) { |         if (headerId > 0) { | ||||||
|             LoadDetails(); |             LoadDetails(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function ReviewButton() { |  | ||||||
| 
 |  | ||||||
|         var toolTypeId = $("#ToolTypeID").text(); |  | ||||||
|         var headerId = parseInt($("#HeaderId").text()); |  | ||||||
| 
 |  | ||||||
|         $("#ReviewButton").prop("disabled", true); |  | ||||||
|         $.ajax({ |  | ||||||
|             type: "POST", |  | ||||||
|             url: "@Url.Content("~/api/awaitingdispo/markasawaiting")?tooltypeid=" + toolTypeId + "&headerid=" + headerId, |  | ||||||
|             success: function (e) { |  | ||||||
|                 DisplayWSMessage("info", "Marked as awaiting disposition", e); |  | ||||||
|                 $("#ReviewButton").prop("disabled", false); |  | ||||||
|             }, |  | ||||||
|             error: function (e, ajaxOptions, ex) { |  | ||||||
|                 DisplayWSMessage("error", "There was an error marking header as awaiting disposition.", e, ex); |  | ||||||
|                 $("#ReviewButton").prop("disabled", false); |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     function OIExportButton() { |  | ||||||
| 
 |  | ||||||
|         var headerId = $("#HeaderId").text(); |  | ||||||
|         var toolTypeID = $("#ToolTypeID").text(); |  | ||||||
| 
 |  | ||||||
|         $("#OIExportButton").prop("disabled", true); |  | ||||||
| 
 |  | ||||||
|         $.ajax({ |  | ||||||
|             type: "POST", |  | ||||||
|             url: "@Url.Content("~/api/tooltypes/")" + toolTypeID + "/headers/" + headerId + "/oiexport", |  | ||||||
|             success: function (r) { |  | ||||||
|                 $("#OIExportResult").text("Exported!"); |  | ||||||
|             }, |  | ||||||
|             error: function (e, ajaxOptions, ex) { |  | ||||||
|                 DisplayWSMessage("error", "There was an error exporting.", e, ex); |  | ||||||
|                 $("#OIExportButton").prop("disabled", false); |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     function SetInitialDateTimes() { |  | ||||||
| 
 |  | ||||||
|         var startTime = new Date(Date.now() - 6 * 60 * 60 * 1000);//6 hours back from now |  | ||||||
| 
 |  | ||||||
|         $("#StartDate").igDatePicker({ |  | ||||||
|             dateInputFormat: "date", |  | ||||||
|             value: startTime, |  | ||||||
|             width: 125 |  | ||||||
|         }); |  | ||||||
| 
 |  | ||||||
|         $("#StartTime").igTimePicker({ |  | ||||||
|             dateInputFormat: "time", |  | ||||||
|             value: startTime, |  | ||||||
|             width: 110 |  | ||||||
|         }); |  | ||||||
| 
 |  | ||||||
|         var endTime = new Date(Date.now()); |  | ||||||
| 
 |  | ||||||
|         $("#EndDate").igDatePicker({ |  | ||||||
|             dateInputFormat: "date", |  | ||||||
|             value: endTime, |  | ||||||
|             width: 125 |  | ||||||
|         }); |  | ||||||
| 
 |  | ||||||
|         $("#EndTime").igTimePicker({ |  | ||||||
|             dateInputFormat: "time", |  | ||||||
|             value: endTime, |  | ||||||
|             width: 110 |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     $(document).ready(function () { |     $(document).ready(function () { | ||||||
| 
 | 
 | ||||||
|         $("#ToolType").igCombo({ |         $("#EvenReactor").igCombo({ | ||||||
|             dataSource: '@Url.Content("~/api/tooltypes")', |             dataSource: '@Url.Content("~/api/reactors/true")', | ||||||
|             responseDataKey: "Results", |             responseDataKey: "Results", | ||||||
|             textKey: "ToolTypeName", |             textKey: "Name", | ||||||
|             valueKey: "ID", |             valueKey: "Id", | ||||||
|             mode: "dropdown", |             mode: "dropdown", | ||||||
|             width: 150, |             width: 150, | ||||||
|             itemsRendered: function (evt, ui) { |             itemsRendered: function (evt, ui) { | ||||||
|                 LoadHeaderGrid(); |                 LoadRunGrid(); | ||||||
|             }, |             }, | ||||||
|             selectionChanged: LoadHeaderGrid, |             selectionChanged: LoadRunGrid, | ||||||
|             initialSelectedItems: [{ value: @Model.ToolTypeID }] |             initialSelectedItems: [{ value: @Model.HeaderID }] | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         SetInitialDateTimes(); |         $("#OddReactor").igCombo({ | ||||||
|  |             dataSource: '@Url.Content("~/api/reactors/false")', | ||||||
|  |             responseDataKey: "Results", | ||||||
|  |             textKey: "Name", | ||||||
|  |             valueKey: "Id", | ||||||
|  |             mode: "dropdown", | ||||||
|  |             width: 150, | ||||||
|  |             itemsRendered: function (evt, ui) { | ||||||
|  |                 LoadRunGrid(); | ||||||
|  |             }, | ||||||
|  |             selectionChanged: LoadRunGrid, | ||||||
|  |             initialSelectedItems: [{ value: @Model.HeaderID }] | ||||||
|  |         }); | ||||||
| 
 | 
 | ||||||
|         $("#HeaderGrid").on("dblclick", "tr", LoadDetails); |         $("#EvenReactorDiv").prop("hidden", true); | ||||||
|  |         $("#OddReactorDiv").prop("hidden", true); | ||||||
| 
 | 
 | ||||||
|         $("#LoadHeadersButton").click(LoadHeaderGrid); |         $("#RunGrid").on("dblclick", "tr", LoadDetails); | ||||||
|  | 
 | ||||||
|  |         $("#LoadRunsButton").click(LoadRunGrid); | ||||||
| 
 | 
 | ||||||
|         $("#GetDataButton").click(LoadDetails); |         $("#GetDataButton").click(LoadDetails); | ||||||
| 
 | 
 | ||||||
|         $("#ReviewButton").click(ReviewButton); |  | ||||||
| 
 |  | ||||||
|         $("#OIExportButton").click(OIExportButton); |  | ||||||
| 
 |  | ||||||
|         setInterval(function () { |  | ||||||
|             if ($("#chkAutoRefresh").is(':checked')) { |  | ||||||
|                 SetInitialDateTimes(); |  | ||||||
|                 $("#LoadHeadersButton").click(); |  | ||||||
|             } |  | ||||||
|         }, 180000); |  | ||||||
| 
 |  | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
| </script> | </script> | ||||||
							
								
								
									
										266
									
								
								Jenkinsfile
									
									
									
									
										vendored
									
									
								
							
							
						
						| @ -1,266 +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 _ExePath = '...' |  | ||||||
| @Field String _NGINXFile = '...' |  | ||||||
| @Field String _PortNumber = '...' |  | ||||||
| @Field String _AssemblyName = '...' |  | ||||||
| @Field String _AgentDevelopment = '' |  | ||||||
| @Field String _NetVersion = 'net6.0' |  | ||||||
| @Field String _GitCommitSeven = '...' |  | ||||||
| @Field String _TargetLocation = '...' |  | ||||||
| @Field String _FirstBeforePlus = '5000' |  | ||||||
| @Field String _GitName = 'OI-Metrology' |  | ||||||
| @Field String _MonARessource = 'OI_Metrology' |  | ||||||
| @Field String _WorkingDirectoryName = 'IFXApps' |  | ||||||
| @Field String _DDriveNet = "${_DDrive}${_NetVersion}" |  | ||||||
| @Field String _AgentStaging = 'messa010ec-ecfisysadmin' |  | ||||||
| @Field String _AgentProduction = 'messa010ec-ecfisysadmin' |  | ||||||
| @Field String _CredentialsId = 'Metrology-Username-Password' |  | ||||||
| @Field String _Company = 'Infineon Technologies Americas Corp.' |  | ||||||
| @Field String _ProgramFilesDotnet = 'C:/program files/dotnet/dotnet.exe' |  | ||||||
|  |  | ||||||
| pipeline { |  | ||||||
|     agent { |  | ||||||
|         label env.JENKINS_ENVIRONMENT == 'Development' ? _AgentDevelopment : env.JENKINS_ENVIRONMENT == 'Staging' ? _AgentStaging : env.JENKINS_ENVIRONMENT == 'Production' ? _AgentProduction : 'Else' |  | ||||||
|     } |  | ||||||
|     parameters { |  | ||||||
|         string(name: 'MONA_SUFFIX', defaultValue: env.JENKINS_ENVIRONMENT == 'Development' ? '_IFX' : '_EC', description: 'MonA Suffix') |  | ||||||
|         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...') |  | ||||||
|         string(name: 'PROJECT_DIRECTORY', defaultValue: 'Archive', description: 'Archive|Viewer') |  | ||||||
|     } |  | ||||||
|     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}-${env.PROJECT_DIRECTORY}" |  | ||||||
|                     // _GitCommitSeven = '1234567' |  | ||||||
|                     _GitCommitSeven = env.GIT_COMMIT.substring(0, 7) |  | ||||||
|                     dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                         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}" |  | ||||||
|                     withCredentials([usernamePassword(credentialsId: _CredentialsId, passwordVariable: 'password', usernameVariable: 'username')]) { |  | ||||||
|                         dir("C:/Users/${username}/AppData/Local/IFXApps/nginx-1.20.1/conf/includes") { |  | ||||||
|                             _NGINXFile = "C:/Users/${username}/AppData/Local/IFXApps/nginx-1.20.1/conf/includes/${_AssemblyName}.conf" |  | ||||||
|                             def files = findFiles(glob: "${_AssemblyName}.conf") |  | ||||||
|                             if (files.length != 1) { |  | ||||||
|                                 writeFile(file: _NGINXFile, text: "location / { proxy_pass http://localhost:${_FirstBeforePlus}; }") |  | ||||||
|                             } |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Read NGINX') { |  | ||||||
|             steps { |  | ||||||
|                 script { |  | ||||||
|                     String text = readFile(file: _NGINXFile) |  | ||||||
|                     String check = text == null ? _FirstBeforePlus : text.split(';')[0] |  | ||||||
|                     String[] segments = check.split(':') |  | ||||||
|                     if (segments.length != 3) { |  | ||||||
|                         _PortNumber = check |  | ||||||
|                     } |  | ||||||
|                     else { |  | ||||||
|                         _PortNumber = (segments[2].toInteger() + 2).toString() |  | ||||||
|                     } |  | ||||||
|                     _ExePath = "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-${env.PROJECT_DIRECTORY}/${_AssemblyName}.exe" |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Info') { |  | ||||||
|             steps { |  | ||||||
|                 // echo "GIT_URL_N - ${env.GIT_URL_N}" |  | ||||||
|                 // echo "BRANCH_NAME ${env.BRANCH_NAME}" |  | ||||||
|                 // echo "DEPLOY_VERSION ${env.DEPLOY_VERSION}" |  | ||||||
|                 // echo "GIT_AUTHOR_NAME ${env.GIT_AUTHOR_NAME}" |  | ||||||
|                 // echo "GIT_LOCAL_BRANCH ${env.GIT_LOCAL_BRANCH}" |  | ||||||
|                 // echo "GIT_COMMITTER_EMAIL ${env.GIT_COMMITTER_EMAIL}" |  | ||||||
|                 // echo "GIT_PREVIOUS_COMMIT ${env.GIT_PREVIOUS_COMMIT}" |  | ||||||
|                 // echo "GIT_PREVIOUS_SUCCESSFUL_COMMIT ${env.GIT_PREVIOUS_SUCCESSFUL_COMMIT}" |  | ||||||
|                 echo "_AssemblyName ${_AssemblyName}" // ... |  | ||||||
|                 echo "_ExePath ${_ExePath}" // ... |  | ||||||
|                 echo "_PortNumber ${_PortNumber}" // ... |  | ||||||
|                 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 "PROJECT_DIRECTORY ${env.PROJECT_DIRECTORY}" // ... |  | ||||||
|                 echo "WORKSPACE ${env.WORKSPACE}" // D:\.jenkins\_\... |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         // stage('Restore') { |  | ||||||
|         //     steps { |  | ||||||
|         //         bat(returnStatus: true, script: 'dotnet --info') |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         stage('Safe storage of app secrets') { |  | ||||||
|             steps { |  | ||||||
|                 withCredentials([usernamePassword(credentialsId: _CredentialsId, passwordVariable: 'password', usernameVariable: 'username')]) { |  | ||||||
|                     dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets init') |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "Company" "' + _Company + '"') |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "ServiceUser" "' + username + '"') |  | ||||||
|                         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 + '"') |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "URLs" "' + 'http://localhost:' + _PortNumber) |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "WorkingDirectoryName" "' + _WorkingDirectoryName + '"') |  | ||||||
|                         bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                             'user-secrets set "MonARessource" "' + _MonARessource + '_' + env.PROJECT_DIRECTORY + env.MONA_SUFFIX + '"') |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         // stage('Core Build (packagemanagement.eu.infineon.com)') { |  | ||||||
|         //     steps { |  | ||||||
|         //         echo "Build number is ${currentBuild.number}" |  | ||||||
|         //         dir(env.PROJECT_DIRECTORY) { |  | ||||||
|         //             bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|         //                 'build --runtime win-x64 --self-contained --verbosity quiet --source ' + |  | ||||||
|         //                 'https://packagemanagement.eu.infineon.com:4430/api/v2/') |  | ||||||
|         //         } |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         stage('Core Build') { |  | ||||||
|             steps { |  | ||||||
|                 echo "Build number is ${currentBuild.number}" |  | ||||||
|                 dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                     bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                         'build --runtime win-x64 --self-contained --verbosity quiet') |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Commit Id') { |  | ||||||
|             steps { |  | ||||||
|                 dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                     writeFile(file: 'bin/Debug/' + _NetVersion + "/win-x64/${env.GIT_COMMIT}-${env.BUILD_NUMBER}.txt", text: "${env.GIT_URL}") |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         // stage('Test') { |  | ||||||
|         //     options { |  | ||||||
|         //         timeout(time: 10, unit: 'MINUTES') |  | ||||||
|         //     } |  | ||||||
|         //     steps { |  | ||||||
|         //         dir(env.PROJECT_DIRECTORY) { |  | ||||||
|         //             bat('dotnet --info') |  | ||||||
|         //         } |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         // stage('Version') { |  | ||||||
|         //     steps { |  | ||||||
|         //         bat('dotnet --info') |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         stage('Package') { |  | ||||||
|             steps { |  | ||||||
|                 dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                     fileOperations([fileZipOperation(folderPath: 'bin/Debug/' + _NetVersion + '/win-x64', outputFolderPath: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-Debug")]) |  | ||||||
|                     fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: "${_AssemblyName}*", renameFiles: false, sourceCaptureExpression: '', targetLocation: "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-Debug", targetNameExpression: '')]) |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Publish') { |  | ||||||
|             steps { |  | ||||||
|                 dir(env.PROJECT_DIRECTORY) { |  | ||||||
|                     bat(returnStatus: true, script: '"' + _ProgramFilesDotnet + '" ' + |  | ||||||
|                         'publish --configuration Release --runtime win-x64 --verbosity quiet ' + |  | ||||||
|                         "--self-contained true --p:Version=6.0.202-${_GitCommitSeven}-${env.BUILD_NUMBER} -o " + |  | ||||||
|                         '"' + "${_DDriveNet}/${_GitCommitSeven}-${env.BUILD_NUMBER}-${_PortNumber}-${env.JOB_NAME}-${env.PROJECT_DIRECTORY}" + '"') |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Service') { |  | ||||||
|             steps { |  | ||||||
|                 withCredentials([usernamePassword(credentialsId: _CredentialsId, passwordVariable: 'password', usernameVariable: 'username')]) { |  | ||||||
|                     bat(returnStatus: true, script: 'sc create "' + "${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-${_PortNumber}" + '" ' + |  | ||||||
|                         'start= delayed-auto DisplayName="' + "${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-${_PortNumber}" + '" ' + |  | ||||||
|                         'binPath= "' + _ExePath + '" ' + |  | ||||||
|                         'obj= "' + "${env.USERDOMAIN}\\${username}" + '" password= "' + password + '"') |  | ||||||
|                     bat(returnStatus: true, script: 'sc start "' + "${env.JOB_NAME}-${env.PROJECT_DIRECTORY}-${_PortNumber}" + '"') |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('Upadate NGINX') { |  | ||||||
|             steps { |  | ||||||
|                 writeFile(file: _NGINXFile, text: "location / { proxy_pass http://localhost:${_PortNumber}; }") |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         stage('NGINX Test and Reload') { |  | ||||||
|             steps { |  | ||||||
|                 withCredentials([usernamePassword(credentialsId: _CredentialsId, passwordVariable: 'password', usernameVariable: 'username')]) { |  | ||||||
|                     dir("C:/Users/${username}/AppData/Local/IFXApps/nginx-1.20.1") { |  | ||||||
|                         script { |  | ||||||
|                             int returnStatus = bat(returnStatus: true, script: 'nginx.exe -t') |  | ||||||
|                             println("returnStatus ################ ${returnStatus} ####################") |  | ||||||
|                             if (returnStatus == 0) { |  | ||||||
|                                 bat(returnStatus: true, script: 'nginx.exe -s reload') |  | ||||||
|                             } |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         // stage('Force Fail') { |  | ||||||
|         //     steps { |  | ||||||
|         //         error("Build failed because of this and that..") |  | ||||||
|         //     } |  | ||||||
|         // } |  | ||||||
|         // stage('Copy Files to: file-share') { |  | ||||||
|         //     steps { |  | ||||||
|         //         dir(env.PROJECT_DIRECTORY + '/bin/Debug/' + _NetVersion + '/win-x64') { |  | ||||||
|         //             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(env.PROJECT_DIRECTORY + '/bin') { |  | ||||||
|                 deleteDir() |  | ||||||
|             } |  | ||||||
|             dir(env.PROJECT_DIRECTORY + '/obj') { |  | ||||||
|                 deleteDir() |  | ||||||
|             } |  | ||||||
|             cleanWs() |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -3,13 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 | |||||||
| # Visual Studio Version 16 | # Visual Studio Version 16 | ||||||
| VisualStudioVersion = 16.0.30114.105 | VisualStudioVersion = 16.0.30114.105 | ||||||
| MinimumVisualStudioVersion = 10.0.40219.1 | MinimumVisualStudioVersion = 10.0.40219.1 | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Archive", "Archive\Archive.csproj", "{D02BA20E-0ACE-4D1C-9132-90773AF3CF5A}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Archive", "Archive\OI.Metrology.Archive.csproj", "{D02BA20E-0ACE-4D1C-9132-90773AF3CF5A}" | ||||||
| EndProject | EndProject | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{A807EAE3-7DCB-4E5E-BE54-0D7410D18B3E}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\OI.Metrology.Shared.csproj", "{A807EAE3-7DCB-4E5E-BE54-0D7410D18B3E}" | ||||||
| EndProject | EndProject | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Viewer", "Viewer\Viewer.csproj", "{25C86DF8-EC1A-4D4B-AD4E-6561174824B9}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\OI.Metrology.Server.csproj", "{25C86DF8-EC1A-4D4B-AD4E-6561174824B9}" | ||||||
| EndProject | EndProject | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{B67FB8C4-402E-4D53-90A6-90F6FDB9D082}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\OI.Metrology.Tests.csproj", "{B67FB8C4-402E-4D53-90A6-90F6FDB9D082}" | ||||||
| EndProject | EndProject | ||||||
| Global | Global | ||||||
| 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||||
|  | |||||||
| @ -10,14 +10,15 @@ | |||||||
|             "request": "launch", |             "request": "launch", | ||||||
|             "preLaunchTask": "build", |             "preLaunchTask": "build", | ||||||
|             // If you have changed target frameworks, make sure to update the program path. |             // If you have changed target frameworks, make sure to update the program path. | ||||||
|             "program": "${workspaceFolder}/bin/Debug/net6.0/win-x64/Archive.dll", |             "program": "${workspaceFolder}/bin/Debug/net7.0/win-x64/OI.Metrology.Server.dll", | ||||||
|             "args": [], |             "args": [], | ||||||
|             "cwd": "${workspaceFolder}", |             "cwd": "${workspaceFolder}", | ||||||
|             "stopAtEntry": false, |             "stopAtEntry": false, | ||||||
|             // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser |             // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser | ||||||
|             "serverReadyAction": { |             "serverReadyAction": { | ||||||
|                 "action": "openExternally", |                 "action": "openExternally", | ||||||
|                 "pattern": "\\bNow listening on:\\s+(https?://\\S+)" |                 "pattern": "\\bNow listening on:\\s+(https?://\\S+)", | ||||||
|  |                 "uriFormat": "%s/swagger/index.html" | ||||||
|             }, |             }, | ||||||
|             "env": { |             "env": { | ||||||
|                 "ASPNETCORE_ENVIRONMENT": "Development" |                 "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
| @ -30,7 +31,8 @@ | |||||||
|             "name": ".NET Core Attach", |             "name": ".NET Core Attach", | ||||||
|             "type": "coreclr", |             "type": "coreclr", | ||||||
|             "request": "attach", |             "request": "attach", | ||||||
|             "processName": "Archive" |             "preLaunchTask": "watch", | ||||||
|  |             "processName": "OI.Metrology.Server.exe" | ||||||
|         } |         } | ||||||
|     ] |     ] | ||||||
| } | } | ||||||
							
								
								
									
										75
									
								
								Server/.vscode/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,75 @@ | |||||||
|  | { | ||||||
|  |     "version": "2.0.0", | ||||||
|  |     "tasks": [ | ||||||
|  |         { | ||||||
|  |             "label": "build", | ||||||
|  |             "command": "dotnet", | ||||||
|  |             "type": "process", | ||||||
|  |             "args": [ | ||||||
|  |                 "build", | ||||||
|  |                 "${workspaceFolder}/OI.Metrology.Server.csproj", | ||||||
|  |                 "/property:GenerateFullPaths=true", | ||||||
|  |                 "/consoleloggerparameters:NoSummary" | ||||||
|  |             ], | ||||||
|  |             "problemMatcher": "$msCompile" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "label": "publish", | ||||||
|  |             "command": "dotnet", | ||||||
|  |             "type": "process", | ||||||
|  |             "args": [ | ||||||
|  |                 "publish", | ||||||
|  |                 "${workspaceFolder}/OI.Metrology.Server.csproj", | ||||||
|  |                 "/property:GenerateFullPaths=true", | ||||||
|  |                 "/consoleloggerparameters:NoSummary" | ||||||
|  |             ], | ||||||
|  |             "problemMatcher": "$msCompile" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "label": "old-watch", | ||||||
|  |             "command": "dotnet", | ||||||
|  |             "type": "process", | ||||||
|  |             "args": [ | ||||||
|  |                 "watch", | ||||||
|  |                 "run", | ||||||
|  |                 "--project", | ||||||
|  |                 "${workspaceFolder}/OI.Metrology.Server.csproj" | ||||||
|  |             ], | ||||||
|  |             "problemMatcher": "$msCompile" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "label": "watch", | ||||||
|  |             "command": "dotnet", | ||||||
|  |             "type": "process", | ||||||
|  |             "args": [ | ||||||
|  |                 "watch", | ||||||
|  |                 "--launch-profile", | ||||||
|  |                 "http", | ||||||
|  |                 "run", | ||||||
|  |                 "--project", | ||||||
|  |                 "${workspaceFolder}/OI.Metrology.Server.csproj", | ||||||
|  |                 "--verbose" | ||||||
|  |             ], | ||||||
|  |             "isBackground": true, | ||||||
|  |             "dependsOn": [ | ||||||
|  |                 "build" | ||||||
|  |             ], | ||||||
|  |             "problemMatcher": { | ||||||
|  |                 "fileLocation": "relative", | ||||||
|  |                 "pattern": { | ||||||
|  |                     "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", | ||||||
|  |                     "file": 1, | ||||||
|  |                     "location": 2, | ||||||
|  |                     "severity": 3, | ||||||
|  |                     "code": 4, | ||||||
|  |                     "message": 5 | ||||||
|  |                 }, | ||||||
|  |                 "background": { | ||||||
|  |                     "activeOnStart": true, | ||||||
|  |                     "beginsPattern": "^.*Shutdown requested.*", | ||||||
|  |                     "endsPattern": "^.*Application started.*" | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     ] | ||||||
|  | } | ||||||
							
								
								
									
										23
									
								
								Server/ApiControllers/AppSettingsController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,23 @@ | |||||||
|  | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.ApiControllers; | ||||||
|  |  | ||||||
|  | [ApiController] | ||||||
|  | [Route("api/[controller]")] | ||||||
|  | public class AppSettingsController : ControllerBase, IAppSettingsController<ActionResult> | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly IAppSettingsRepository<Models.Binder.AppSettings> _AppSettingsRepository; | ||||||
|  |  | ||||||
|  |     public AppSettingsController(IAppSettingsRepository<Models.Binder.AppSettings> AppSettingsRepository) => _AppSettingsRepository = AppSettingsRepository; | ||||||
|  |  | ||||||
|  |     [HttpGet(nameof(IAppSettingsController<ActionResult>.Action.App))] | ||||||
|  |     public ActionResult GetAppSettings() => | ||||||
|  |         Ok(_AppSettingsRepository.GetAppSettings()); | ||||||
|  |  | ||||||
|  |     [HttpGet(nameof(IAppSettingsController<ActionResult>.Action.DevOps))] | ||||||
|  |     public ActionResult GetBuildNumberAndGitCommitSeven() => | ||||||
|  |          Ok(_AppSettingsRepository.GetBuildNumberAndGitCommitSeven()); | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -1,50 +1,39 @@ | |||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using System; |  | ||||||
| using System.IO; |  | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer.ApiControllers; | namespace OI.Metrology.Server.ApiControllers; | ||||||
|  | 
 | ||||||
| public class AttachmentsController : Controller | public class AttachmentsController : Controller | ||||||
| { | { | ||||||
|     private readonly IMetrologyRepo _Repo; |  | ||||||
|     private readonly IAttachmentsService _AttachmentsService; |  | ||||||
| 
 | 
 | ||||||
|     public AttachmentsController(IMetrologyRepo repo, IAttachmentsService attachmentsService) |     private readonly IAttachmentsService _AttachmentsService; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  | 
 | ||||||
|  |     public AttachmentsController(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService) | ||||||
|     { |     { | ||||||
|         _Repo = repo; |  | ||||||
|         _AttachmentsService = attachmentsService; |         _AttachmentsService = attachmentsService; | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // this endpoint was created in hope that it would make retrieving attachments to display in OpenInsight easier |     // this endpoint was created in hope that it would make retrieving attachments to display in OpenInsight easier | ||||||
|     // url would be like /api/attachments/mercuryprobe/header/HgProbe_66-232268-4329_20180620052640032/data.pdf |     // url would be like /api/attachments/mercuryprobe/header/HgProbe_66-232268-4329_20180620052640032/data.pdf | ||||||
| 
 | 
 | ||||||
|     [HttpGet("/api/attachments/{toolTypeName}/{tabletype}/{title}/{filename}")] |     [HttpGet("/api/attachments/{toolTypeName}/{tabletype}/{title}/{filename}")] | ||||||
|     public IActionResult GetAttachment( |     public IActionResult GetAttachment(string toolTypeName, string tabletype, string title, string filename) | ||||||
|         string toolTypeName, |  | ||||||
|         string tabletype, |  | ||||||
|         string title, |  | ||||||
|         string filename) |  | ||||||
|     { |     { | ||||||
|         ToolType tt = _Repo.GetToolTypeByName(toolTypeName); |         ToolType tt = _MetrologyRepository.GetToolTypeByName(toolTypeName); | ||||||
| 
 |  | ||||||
|         bool header = !string.Equals(tabletype.Trim(), "data", StringComparison.OrdinalIgnoreCase); |         bool header = !string.Equals(tabletype.Trim(), "data", StringComparison.OrdinalIgnoreCase); | ||||||
| 
 |  | ||||||
|         try |         try | ||||||
|         { |         { | ||||||
|             string contenttype = "application/pdf"; |             string contenttype = "application/pdf"; | ||||||
|             if (filename.ToLower().TrimEnd().EndsWith(".txt")) |             if (filename.ToLower().TrimEnd().EndsWith(".txt")) | ||||||
|                 contenttype = "text/plain"; |                 contenttype = "text/plain"; | ||||||
| 
 |  | ||||||
|             Stream fs = _AttachmentsService.GetAttachmentStreamByTitle(tt, header, title, filename); |             Stream fs = _AttachmentsService.GetAttachmentStreamByTitle(tt, header, title, filename); | ||||||
|             return File(fs, contenttype); |             return File(fs, contenttype); | ||||||
|         } |         } | ||||||
|         catch (Exception ex) |         catch (Exception ex) { return Content(ex.Message); } | ||||||
|         { |  | ||||||
|             return Content(ex.Message); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| @ -1,37 +1,31 @@ | |||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer.ApiContollers; | namespace OI.Metrology.Server.ApiControllers; | ||||||
| 
 | 
 | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using System.Text.Json; | using System.Text.Json; | ||||||
| 
 | 
 | ||||||
| // this controller is for the Awaiting Dispo functionality | // this controller is for the Awaiting Dispo functionality | ||||||
| 
 | 
 | ||||||
| public class AwaitingDispoController : Controller | [Route("api/[controller]")]
 | ||||||
|  | public class AwaitingDispoController : Controller, IAwaitingDispoController<IActionResult> | ||||||
| { | { | ||||||
|     private readonly IMetrologyRepo _Repo; |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
| 
 |     public AwaitingDispoController(IMetrologyRepository metrologyRepository) => | ||||||
|     public AwaitingDispoController(IMetrologyRepo repo) => _Repo = repo; |         _MetrologyRepository = metrologyRepository; | ||||||
| 
 | 
 | ||||||
|     // returns the data to show in the Awaiting Dispo grid |     // returns the data to show in the Awaiting Dispo grid | ||||||
|     // marked no-cache, just-in-case since igniteUI automatically adds a query string parameter to prevent caching |     // marked no-cache, just-in-case since igniteUI automatically adds a query string parameter to prevent caching | ||||||
|     [HttpGet("/api/awaitingdispo")] |     [HttpGet] | ||||||
|     [ResponseCache(NoStore = true)] |     [ResponseCache(NoStore = true)] | ||||||
|     public IActionResult Index() |     public IActionResult Index() => | ||||||
|     { |         Json(_MetrologyRepository.GetAwaitingDisposition(), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||||
| 
 |  | ||||||
|         var r = new |  | ||||||
|         { |  | ||||||
|             Results = _Repo.GetAwaitingDispo() |  | ||||||
|         }; |  | ||||||
|         return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // this endpoint is used to set the ReviewDate column, causing the header to no longer show in Awaiting Dispo     |     // this endpoint is used to set the ReviewDate column, causing the header to no longer show in Awaiting Dispo     | ||||||
|     [HttpPost("/api/awaitingdispo/markasreviewed")] |     [HttpPost("/api/awaitingdispo/markasreviewed")] | ||||||
|     public IActionResult MarkAsReviewed([FromQuery] long headerid, [FromQuery] int tooltypeid) |     public IActionResult MarkAsReviewed([FromQuery] long headerid, [FromQuery] int tooltypeid) | ||||||
|     { |     { | ||||||
|         _ = _Repo.UpdateReviewDate(tooltypeid, headerid, false); |         _ = _MetrologyRepository.UpdateReviewDate(tooltypeid, headerid, false); | ||||||
|         return Ok(); |         return Ok(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -39,7 +33,7 @@ public class AwaitingDispoController : Controller | |||||||
|     [HttpPost("/api/awaitingdispo/markasawaiting")] |     [HttpPost("/api/awaitingdispo/markasawaiting")] | ||||||
|     public IActionResult MarkAsAwaiting([FromQuery] long headerid, [FromQuery] int tooltypeid) |     public IActionResult MarkAsAwaiting([FromQuery] long headerid, [FromQuery] int tooltypeid) | ||||||
|     { |     { | ||||||
|         if (_Repo.UpdateReviewDate(tooltypeid, headerid, true) <= 1) |         if (_MetrologyRepository.UpdateReviewDate(tooltypeid, headerid, true) <= 1) | ||||||
|             return Ok(); |             return Ok(); | ||||||
|         else |         else | ||||||
|             return StatusCode(444); |             return StatusCode(444); | ||||||
							
								
								
									
										29
									
								
								Server/ApiControllers/ClientSettingsController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,29 @@ | |||||||
|  | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.ApiControllers; | ||||||
|  |  | ||||||
|  | [ApiController] | ||||||
|  | [Route("api/[controller]")] | ||||||
|  | public class ClientSettingsController : ControllerBase, IClientSettingsController<ActionResult> | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly IClientSettingsRepository _ClientSettingsRepository; | ||||||
|  |  | ||||||
|  |     public ClientSettingsController(IClientSettingsRepository clientSettingsRepository) => _ClientSettingsRepository = clientSettingsRepository; | ||||||
|  |  | ||||||
|  |     [HttpGet(nameof(IClientSettingsController<ActionResult>.Action.Client))] | ||||||
|  |     public ActionResult GetClientSettings() | ||||||
|  |     { | ||||||
|  |         List<string> results = _ClientSettingsRepository.GetClientSettings(Request.HttpContext.Connection?.RemoteIpAddress); | ||||||
|  |         return Ok(results); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpGet(nameof(IClientSettingsController<ActionResult>.Action.IP))] | ||||||
|  |     public ActionResult GetIpAddress() | ||||||
|  |     { | ||||||
|  |         string result = _ClientSettingsRepository.GetIpAddress(Request.HttpContext.Connection?.RemoteIpAddress); | ||||||
|  |         return Ok(result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										78
									
								
								Server/ApiControllers/InboundController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,78 @@ | |||||||
|  | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using Newtonsoft.Json.Linq; | ||||||
|  | using OI.Metrology.Server.Models; | ||||||
|  | using OI.Metrology.Shared.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  | using OI.Metrology.Shared.Services; | ||||||
|  | using System.Net; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.ApiControllers; | ||||||
|  |  | ||||||
|  | [ApiController] | ||||||
|  | [Route("api/[controller]")] | ||||||
|  | public partial class InboundController : ControllerBase, IInboundController<IActionResult> | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly ILogger _Logger; | ||||||
|  |     private readonly AppSettings _AppSettings; | ||||||
|  |     private readonly IInboundRepository _InboundRepository; | ||||||
|  |     private readonly IAttachmentsService _AttachmentsService; | ||||||
|  |     private readonly IInboundDataService _InboundDataService; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|  |     public InboundController(AppSettings appSettings, ILogger<InboundController> logger, IMetrologyRepository metrologyRepository, IInboundRepository inboundRepository, IInboundDataService inboundDataService, IAttachmentsService attachmentsService) | ||||||
|  |     { | ||||||
|  |         _Logger = logger; | ||||||
|  |         _AppSettings = appSettings; | ||||||
|  |         _InboundRepository = inboundRepository; | ||||||
|  |         _AttachmentsService = attachmentsService; | ||||||
|  |         _InboundDataService = inboundDataService; | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpPost] | ||||||
|  |     [Route("{tooltype}")] | ||||||
|  |     public IActionResult Data(string tooltype, [FromBody] JToken jsonbody) | ||||||
|  |     { | ||||||
|  |         IPAddress? remoteIP = HttpContext.Connection.RemoteIpAddress; | ||||||
|  |         if (!_InboundRepository.IsIPAddressAllowed(_AppSettings.InboundApiAllowedIPList, remoteIP)) | ||||||
|  |         { | ||||||
|  |             _Logger.LogInformation($"Rejected remote IP: {remoteIP}"); | ||||||
|  |             return Unauthorized("Remote IP is not on allowed list"); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             DataResponse dataResponse = _InboundRepository.Data(_MetrologyRepository, _InboundDataService, tooltype, jsonbody); | ||||||
|  |             if (!dataResponse.Errors.Any()) | ||||||
|  |                 return Ok(dataResponse); | ||||||
|  |             else | ||||||
|  |                 return BadRequest(dataResponse); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpPost] | ||||||
|  |     [Route("{tooltype}/attachment")] | ||||||
|  |     public IActionResult AttachFile(string tooltype, [FromQuery] long headerid, [FromQuery] string datauniqueid = "") | ||||||
|  |     { | ||||||
|  |         IPAddress? remoteIP = HttpContext.Connection.RemoteIpAddress; | ||||||
|  |         if (!_InboundRepository.IsIPAddressAllowed(_AppSettings.InboundApiAllowedIPList, remoteIP)) | ||||||
|  |         { | ||||||
|  |             _Logger.LogInformation($"Rejected remote IP: {remoteIP}"); | ||||||
|  |             return Unauthorized("Remote IP is not on allowed list"); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             if (Request.Form is null) | ||||||
|  |                 return BadRequest($"Invalid form"); | ||||||
|  |             if (Request.Form.Files.Count != 1) | ||||||
|  |                 return BadRequest($"Invalid file count"); | ||||||
|  |             IFormFile formFile = Request.Form.Files[0]; | ||||||
|  |             string? message = _InboundRepository.AttachFile(_MetrologyRepository, _AttachmentsService, tooltype, headerid, datauniqueid, formFile.FileName, formFile); | ||||||
|  |             if (message is null) | ||||||
|  |                 return Ok(); | ||||||
|  |             else | ||||||
|  |                 return BadRequest(message); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										33
									
								
								Server/ApiControllers/PinController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,33 @@ | |||||||
|  | using Microsoft.AspNetCore.Mvc; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.ApiControllers; | ||||||
|  |  | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  | using System.Text.Json; | ||||||
|  |  | ||||||
|  | [Route("api/[controller]")] | ||||||
|  | public class PinController : Controller, IPinController<IActionResult> | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly IPinRepository _PinRepository; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  |  | ||||||
|  |     public PinController(ILogger<InboundController> logger, IMetrologyRepository metrologyRepository, IPinRepository pinRepository) | ||||||
|  |     { | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|  |         _PinRepository = pinRepository; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpPost("{toolTypeId}/markAsPinned")] | ||||||
|  |     public IActionResult MarkAsPinned(Shared.DataModels.HeaderCommon headerCommon) | ||||||
|  |     { | ||||||
|  |         _PinRepository.SetPinnedTable(headerCommon); | ||||||
|  |         return Ok(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{toolTypeId}/pinned")] | ||||||
|  |     public IActionResult GetPinnedTable(int toolTypeId, string? biorad_id = null, string? cde_id = null, string? rds = null) => | ||||||
|  |         Json(_PinRepository.GetPinnedTable(_MetrologyRepository, toolTypeId, biorad_id, cde_id, rds), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										46
									
								
								Server/ApiControllers/ServiceShopOrderController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,46 @@ | |||||||
|  | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.ApiControllers; | ||||||
|  |  | ||||||
|  | [ApiController] | ||||||
|  | [Route("api/[controller]")] | ||||||
|  | public class ServiceShopOrderController : ControllerBase, IServiceShopOrderController<ActionResult> | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly IServiceShopOrderRepository _ServiceShopOrderRepository; | ||||||
|  |  | ||||||
|  |     public ServiceShopOrderController(IServiceShopOrderRepository ServiceShopOrderRepository) => _ServiceShopOrderRepository = ServiceShopOrderRepository; | ||||||
|  |  | ||||||
|  |     [HttpGet(nameof(IServiceShopOrderController<ActionResult>.Action.All))] | ||||||
|  |     public async Task<ActionResult> GetAllServiceShopOrders() | ||||||
|  |     { | ||||||
|  |         try | ||||||
|  |         { | ||||||
|  |             Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderRepository.GetAllServiceShopOrders(); | ||||||
|  |             return Ok(results); | ||||||
|  |         } | ||||||
|  |         catch (Exception) | ||||||
|  |         { | ||||||
|  |             return StatusCode(StatusCodes.Status500InternalServerError, | ||||||
|  |                 "Error retrieving data from the database"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{id}")] | ||||||
|  |     public async Task<ActionResult> GetServiceShopOrders(string id) | ||||||
|  |     { | ||||||
|  |         try | ||||||
|  |         { | ||||||
|  |             Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderRepository.GetServiceShopOrders(id); | ||||||
|  |             return Ok(results); | ||||||
|  |         } | ||||||
|  |         catch (Exception) | ||||||
|  |         { | ||||||
|  |             return StatusCode(StatusCodes.Status500InternalServerError, | ||||||
|  |                 "Error retrieving data from the database"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										110
									
								
								Server/ApiControllers/ToolTypesController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,110 @@ | |||||||
|  | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using Newtonsoft.Json; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.ApiControllers; | ||||||
|  |  | ||||||
|  | using OI.Metrology.Server.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  | using OI.Metrology.Shared.Services; | ||||||
|  | using System.Data; | ||||||
|  | using System.Text.Json; | ||||||
|  |  | ||||||
|  | [Route("api/[controller]")] | ||||||
|  | public class ToolTypesController : Controller, IToolTypesController<IActionResult> | ||||||
|  | { | ||||||
|  |     // this controller powers the bulk of the UI | ||||||
|  |     // it is named after the /api/tooltypes prefix | ||||||
|  |     // the URL pattern is RESTful and the tool type is the root of every request | ||||||
|  |  | ||||||
|  |     private readonly AppSettings _AppSettings; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepo; | ||||||
|  |     private readonly IAttachmentsService _AttachmentsService; | ||||||
|  |     private readonly IToolTypesRepository _ToolTypesRepository; | ||||||
|  |  | ||||||
|  |     public ToolTypesController(AppSettings appSettings, IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, IToolTypesRepository toolTypesRepository) | ||||||
|  |     { | ||||||
|  |         _AppSettings = appSettings; | ||||||
|  |         _MetrologyRepo = metrologyRepository; | ||||||
|  |         _AttachmentsService = attachmentsService; | ||||||
|  |         _ToolTypesRepository = toolTypesRepository; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     public IActionResult Index() => | ||||||
|  |         Json(_ToolTypesRepository.Index(_MetrologyRepo), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{id}")] | ||||||
|  |     public IActionResult GetToolTypeMetadata(int id, string sortby = "") => | ||||||
|  |         Json(_ToolTypesRepository.GetToolTypeMetadata(_MetrologyRepo, id, sortby), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{id}/headers")] | ||||||
|  |     public IActionResult GetHeaders(int id, [FromQuery] DateTime? datebegin, [FromQuery] DateTime? dateend, [FromQuery] int? page, [FromQuery] int? pagesize, [FromQuery] long? headerid) | ||||||
|  |     { | ||||||
|  |         Shared.DataModels.Result<DataTable> r = _ToolTypesRepository.GetHeaders(_MetrologyRepo, id, datebegin, dateend, page, pagesize, headerid); | ||||||
|  |         string json = JsonConvert.SerializeObject(r); | ||||||
|  |         return Content(json); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{id}/headertitles")] | ||||||
|  |     public IActionResult GetHeaderTitles(int id, [FromQuery] int? page, [FromQuery] int? pagesize) => | ||||||
|  |         Json(_ToolTypesRepository.GetHeaderTitles(_MetrologyRepo, id, page, pagesize), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{id}/headers/{headerid}/fields")] | ||||||
|  |     public IActionResult GetHeaderFields(int id, long headerid) => | ||||||
|  |         Json(_ToolTypesRepository.GetHeaderFields(_MetrologyRepo, id, headerid), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{id}/headers/{headerid}/data")] | ||||||
|  |     public IActionResult GetData(int id, long headerid) | ||||||
|  |     { | ||||||
|  |         Shared.DataModels.Result<DataTable> r = _ToolTypesRepository.GetData(_MetrologyRepo, id, headerid); | ||||||
|  |         string json = JsonConvert.SerializeObject(r); | ||||||
|  |         return Content(json); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{toolTypeId}/export")] | ||||||
|  |     public IActionResult GetExportData(int toolTypeId, [FromQuery] DateTime? datebegin, [FromQuery] DateTime? dateend) | ||||||
|  |     { | ||||||
|  |         Shared.DataModels.Result<DataTable> r = _ToolTypesRepository.GetExportData(_MetrologyRepo, toolTypeId, datebegin, dateend); | ||||||
|  |         string json = JsonConvert.SerializeObject(r); | ||||||
|  |         return Content(json); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{toolTypeId}/csv")] | ||||||
|  |     public IActionResult GetCSVExport(int toolTypeId, [FromQuery] DateTime? datebegin, [FromQuery] DateTime? dateend, [FromQuery] string? filename) | ||||||
|  |     { | ||||||
|  |         byte[] r = _ToolTypesRepository.GetCSVExport(_MetrologyRepo, toolTypeId, datebegin, dateend); | ||||||
|  |         return File(r, "application/octet-stream", filename); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpGet] | ||||||
|  |     [Route("{toolTypeId}/{tabletype}/files/{attachmentId}/{filename}")] | ||||||
|  |     public IActionResult GetAttachment(int toolTypeId, string tabletype, string attachmentId, string filename) | ||||||
|  |     { | ||||||
|  |         (string? message, string? contenttype, Stream? stream) = _ToolTypesRepository.GetAttachment(_MetrologyRepo, _AttachmentsService, toolTypeId, tabletype, attachmentId, filename); | ||||||
|  |         if (message is not null) | ||||||
|  |             return Content(message); | ||||||
|  |         else if (contenttype is not null && stream is not null) | ||||||
|  |             return File(stream, contenttype); | ||||||
|  |         else | ||||||
|  |             throw new Exception(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     [HttpPost] | ||||||
|  |     [Route("{toolTypeId}/headers/{headerid}/oiexport")] | ||||||
|  |     public IActionResult OIExport(int toolTypeId, long headerid) | ||||||
|  |     { | ||||||
|  |         Exception? exception = _ToolTypesRepository.OIExport(_MetrologyRepo, _AppSettings.OIExportPath, toolTypeId, headerid); | ||||||
|  |         if (exception is null) | ||||||
|  |             return Ok(new { Message = "OK" }); | ||||||
|  |         else | ||||||
|  |             return BadRequest(JsonConvert.SerializeObject(new { exception.Message })); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -1,13 +1,7 @@ | |||||||
| using Microsoft.AspNetCore.Builder; | using OI.Metrology.Server.Models; | ||||||
| using Microsoft.AspNetCore.Http; |  | ||||||
| using OI.Metrology.Viewer.Models; |  | ||||||
| using System; |  | ||||||
| using System.IO; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; |  | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer; | namespace OI.Metrology.Server; | ||||||
| 
 | 
 | ||||||
| // You may need to install the Microsoft.AspNetCore.Http.Abstractions package into your project | // You may need to install the Microsoft.AspNetCore.Http.Abstractions package into your project | ||||||
| public class ApiLoggingMiddleware | public class ApiLoggingMiddleware | ||||||
| @ -43,7 +37,8 @@ public class ApiLoggingMiddleware | |||||||
|                     else |                     else | ||||||
|                     { |                     { | ||||||
|                         // if there are content type filters configured, only log is the request begins with one of them |                         // if there are content type filters configured, only log is the request begins with one of them | ||||||
|                         doLogging = _AppSettings.ApiLoggingContentTypes.Split(';').Any(ct => httpContext.Request.ContentType.StartsWith(ct)); |                         string? contentType = httpContext.Request.ContentType; | ||||||
|  |                         doLogging = contentType is not null && _AppSettings.ApiLoggingContentTypes.Split(';').Any(ct => contentType.StartsWith(ct)); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @ -1,9 +1,7 @@ | |||||||
| using Microsoft.AspNetCore.Diagnostics; | using Microsoft.AspNetCore.Diagnostics; | ||||||
| using Microsoft.AspNetCore.Http; |  | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using Microsoft.Extensions.Logging; |  | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer.Controllers; | namespace OI.Metrology.Server.Controllers; | ||||||
| 
 | 
 | ||||||
| [Route("/error")] | [Route("/error")] | ||||||
| public class ErrorHandlerController : Controller | public class ErrorHandlerController : Controller | ||||||
| @ -14,8 +12,8 @@ public class ErrorHandlerController : Controller | |||||||
| 
 | 
 | ||||||
|     public IActionResult Index() |     public IActionResult Index() | ||||||
|     { |     { | ||||||
|         IExceptionHandlerFeature error = HttpContext.Features.Get<IExceptionHandlerFeature>(); |         IExceptionHandlerFeature? error = HttpContext.Features.Get<IExceptionHandlerFeature>(); | ||||||
|         if (error == null) |         if (error is null) | ||||||
|         { |         { | ||||||
|             return Redirect("~/"); |             return Redirect("~/"); | ||||||
|         } |         } | ||||||
| @ -24,7 +22,7 @@ public class ErrorHandlerController : Controller | |||||||
|             _Logger.LogError("Unhandled exception: " + error.Error.ToString()); |             _Logger.LogError("Unhandled exception: " + error.Error.ToString()); | ||||||
|             dynamic r = new |             dynamic r = new | ||||||
|             { |             { | ||||||
|                 Message = error.Error == null ? "Error" : error.Error.Message |                 Message = error.Error is null ? "Error" : error.Error.Message | ||||||
|             }; |             }; | ||||||
|             return StatusCode(StatusCodes.Status500InternalServerError, r); |             return StatusCode(StatusCodes.Status500InternalServerError, r); | ||||||
|         } |         } | ||||||
| @ -1,31 +1,30 @@ | |||||||
| using Infineon.Monitoring.MonA; | using Infineon.Monitoring.MonA; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using Microsoft.AspNetCore.Mvc.Filters; | using Microsoft.AspNetCore.Mvc.Filters; | ||||||
| using Microsoft.Extensions.Logging; | using OI.Metrology.Server.Models; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.ViewModels; | using OI.Metrology.Shared.ViewModels; | ||||||
| using OI.Metrology.Viewer.Models; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; | using System.Text; | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer.Controllers; | namespace OI.Metrology.Server.Controllers; | ||||||
| 
 | 
 | ||||||
| public class ExportController : Controller | public class ExportController : Controller | ||||||
| { | { | ||||||
|  | 
 | ||||||
|  |     private readonly string _ApiUrl; | ||||||
|     private readonly ILogger _Logger; |     private readonly ILogger _Logger; | ||||||
|     private readonly bool _IsTestDatabase; |     private readonly bool _IsTestDatabase; | ||||||
|     private readonly IMetrologyRepo _Repo; |  | ||||||
|     private readonly AppSettings _AppSettings; |     private readonly AppSettings _AppSettings; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
| 
 | 
 | ||||||
|     public ExportController(AppSettings appSettings, ILogger<ExportController> logger, IMetrologyRepo repo) |     public ExportController(AppSettings appSettings, ILogger<ExportController> logger, IMetrologyRepository metrologyRepository) | ||||||
|     { |     { | ||||||
|         _Repo = repo; |  | ||||||
|         _Logger = logger; |         _Logger = logger; | ||||||
|         _AppSettings = appSettings; |         _AppSettings = appSettings; | ||||||
|  |         _MetrologyRepository = metrologyRepository; | ||||||
|         _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); |         _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); | ||||||
|  |         _ApiUrl = string.IsNullOrEmpty(appSettings.ApiUrl) ? Url.Content("~/") : appSettings.ApiUrl[0] == '~' ? Url.Content(appSettings.ApiUrl) : appSettings.ApiUrl; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public override void OnActionExecuted(ActionExecutedContext context) |     public override void OnActionExecuted(ActionExecutedContext context) | ||||||
| @ -33,18 +32,19 @@ public class ExportController : Controller | |||||||
|         base.OnActionExecuted(context); |         base.OnActionExecuted(context); | ||||||
|         ViewBag.IsTestDatabase = _IsTestDatabase; |         ViewBag.IsTestDatabase = _IsTestDatabase; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     [Route("/Export")] |     [Route("/Export")] | ||||||
|     public ActionResult Index() |     public ActionResult Index() | ||||||
|     { |     { | ||||||
|         Export model = new() |         Export model = new() | ||||||
|         { |         { | ||||||
|             ToolType = "", |  | ||||||
|             StartTime = DateTime.Now.AddMonths(-1), |             StartTime = DateTime.Now.AddMonths(-1), | ||||||
|             EndTime = DateTime.Now |             EndTime = DateTime.Now | ||||||
|         }; |         }; | ||||||
|         MonIn monIn = MonIn.GetInstance(); |         MonIn monIn = MonIn.GetInstance(); | ||||||
|         _ = monIn.SendStatus(_AppSettings.MonASite, _AppSettings.MonAResource, "Heartbeat", State.Up); |         _ = monIn.SendStatus(_AppSettings.MonASite, _AppSettings.MonAResource, "Heartbeat", State.Up); | ||||||
|  |         ViewBag.ApiUrl = _ApiUrl; | ||||||
|         return View(model); |         return View(model); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -52,14 +52,14 @@ public class ExportController : Controller | |||||||
|     [Route("/ExportData")] |     [Route("/ExportData")] | ||||||
|     public ActionResult ExportData(Export model) |     public ActionResult ExportData(Export model) | ||||||
|     { |     { | ||||||
|         ToolType toolType = null; |         ToolType? toolType = null; | ||||||
|         if (string.IsNullOrEmpty(model.ToolType)) |         if (string.IsNullOrEmpty(model.ToolType)) | ||||||
|             ModelState.AddModelError("Exception", "Invalid selection"); |             ModelState.AddModelError("Exception", "Invalid selection"); | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             if (model.StartTime > model.EndTime) |             if (model.StartTime > model.EndTime) | ||||||
|                 ModelState.AddModelError("EndTime", "End time must be after start time"); |                 ModelState.AddModelError("EndTime", "End time must be after start time"); | ||||||
|             IEnumerable<ToolType> toolTypes = _Repo.GetToolTypes(); |             IEnumerable<ToolType> toolTypes = _MetrologyRepository.GetToolTypes(); | ||||||
|             toolType = toolTypes.Where(tt => tt.ID.ToString() == model.ToolType).SingleOrDefault(); |             toolType = toolTypes.Where(tt => tt.ID.ToString() == model.ToolType).SingleOrDefault(); | ||||||
|             if (toolType is null) |             if (toolType is null) | ||||||
|                 ModelState.AddModelError("ToolType", "Invalid selection"); |                 ModelState.AddModelError("ToolType", "Invalid selection"); | ||||||
| @ -73,7 +73,7 @@ public class ExportController : Controller | |||||||
|                 DateTime startDT = model.StartDate.Date.Add(model.StartTime.TimeOfDay); |                 DateTime startDT = model.StartDate.Date.Add(model.StartTime.TimeOfDay); | ||||||
|                 DateTime endDT = model.EndDate.Date.Add(model.EndTime.TimeOfDay); |                 DateTime endDT = model.EndDate.Date.Add(model.EndTime.TimeOfDay); | ||||||
| 
 | 
 | ||||||
|                 return DoCSVExport(toolType.ToolTypeName, toolType.ExportSPName, startDT, endDT); |                 return DoCSVExport(toolType?.ToolTypeName, toolType?.ExportSPName, startDT, endDT); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
| @ -81,27 +81,25 @@ public class ExportController : Controller | |||||||
|                 ModelState.AddModelError("Exception", ex.Message); |                 ModelState.AddModelError("Exception", ex.Message); | ||||||
|                 string errorMessage = $"Error exporting: {ex}"; |                 string errorMessage = $"Error exporting: {ex}"; | ||||||
|                 _Logger.LogError(message: errorMessage); |                 _Logger.LogError(message: errorMessage); | ||||||
|  |                 MonIn monIn = MonIn.GetInstance(); | ||||||
|  |                 _ = monIn.SendStatus(_AppSettings.MonASite, _AppSettings.MonAResource, "Heartbeat", State.Warning); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         ViewBag.ApiUrl = _ApiUrl; | ||||||
|         return View("Index", model); |         return View("Index", model); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     protected ActionResult DoCSVExport(string toolTypeName, string spName, DateTime startTime, DateTime endTime) |     protected ActionResult DoCSVExport(string? toolTypeName, string? spName, DateTime startTime, DateTime endTime) | ||||||
|     { |     { | ||||||
|         string fileName = string.Format("Export_{0}_{1:yyyyMMddHHmm}_to_{2:yyyyMMddHHmm}.csv", toolTypeName, startTime, endTime); |         string fileName = string.Format("Export_{0}_{1:yyyyMMddHHmm}_to_{2:yyyyMMddHHmm}.csv", toolTypeName, startTime, endTime); | ||||||
|         StringBuilder sb = new(); |         StringBuilder sb = new(); | ||||||
| 
 |         if (spName is null) | ||||||
|         System.Data.DataTable dt = _Repo.ExportData(spName, startTime, endTime); |             throw new NullReferenceException(nameof(spName)); | ||||||
| 
 |         System.Data.DataTable dt = _MetrologyRepository.ExportData(spName, startTime, endTime); | ||||||
|         _ = sb.AppendLine(GetColumnHeaders(dt)); |         _ = sb.AppendLine(GetColumnHeaders(dt)); | ||||||
| 
 |  | ||||||
|         foreach (System.Data.DataRow dr in dt.Rows) |         foreach (System.Data.DataRow dr in dt.Rows) | ||||||
|         { |  | ||||||
|             _ = sb.AppendLine(GetRowData(dr)); |             _ = sb.AppendLine(GetRowData(dr)); | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         byte[] contents = Encoding.UTF8.GetBytes(sb.ToString()); |         byte[] contents = Encoding.UTF8.GetBytes(sb.ToString()); | ||||||
| 
 |  | ||||||
|         return File(contents, "application/octet-stream", fileName); |         return File(contents, "application/octet-stream", fileName); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -112,10 +110,13 @@ public class ExportController : Controller | |||||||
|         { |         { | ||||||
|             if (i > 0) |             if (i > 0) | ||||||
|                 _ = r.Append(','); |                 _ = r.Append(','); | ||||||
| 
 |  | ||||||
|             object v = dr[i]; |             object v = dr[i]; | ||||||
|             if (!Convert.IsDBNull(v)) |             if (!Convert.IsDBNull(v)) | ||||||
|                 _ = r.Append(FormatForCSV(Convert.ToString(v))); |             { | ||||||
|  |                 string? c = Convert.ToString(v); | ||||||
|  |                 if (c is not null) | ||||||
|  |                     _ = r.Append(FormatForCSV(c)); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|         return r.ToString(); |         return r.ToString(); | ||||||
|     } |     } | ||||||
| @ -135,16 +136,13 @@ public class ExportController : Controller | |||||||
| 
 | 
 | ||||||
|     protected static string FormatForCSV(string v) |     protected static string FormatForCSV(string v) | ||||||
|     { |     { | ||||||
|         StringBuilder r = new(v.Length + 2); |  | ||||||
| 
 |  | ||||||
|         bool doubleQuoted = false; |         bool doubleQuoted = false; | ||||||
| 
 |         StringBuilder r = new(v.Length + 2); | ||||||
|         if (v.StartsWith(' ') || v.EndsWith(' ') || v.Contains(',') || v.Contains('"')) |         if (v.StartsWith(' ') || v.EndsWith(' ') || v.Contains(',') || v.Contains('"')) | ||||||
|         { |         { | ||||||
|             _ = r.Append('"'); |             _ = r.Append('"'); | ||||||
|             doubleQuoted = true; |             doubleQuoted = true; | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|         foreach (char c in v) |         foreach (char c in v) | ||||||
|         { |         { | ||||||
|             _ = c switch |             _ = c switch | ||||||
| @ -154,10 +152,8 @@ public class ExportController : Controller | |||||||
|                 _ => r.Append(c), |                 _ => r.Append(c), | ||||||
|             }; |             }; | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|         if (doubleQuoted) |         if (doubleQuoted) | ||||||
|             _ = r.Append('"'); |             _ = r.Append('"'); | ||||||
| 
 |  | ||||||
|         return r.ToString(); |         return r.ToString(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1,21 +1,23 @@ | |||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using Microsoft.AspNetCore.Mvc.Filters; | using Microsoft.AspNetCore.Mvc.Filters; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Server.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.ViewModels; | using OI.Metrology.Shared.ViewModels; | ||||||
| using OI.Metrology.Viewer.Models; |  | ||||||
| using System; |  | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer.Controllers; | namespace OI.Metrology.Server.Controllers; | ||||||
| 
 | 
 | ||||||
| public class PagesController : Controller | public class PagesController : Controller | ||||||
| { | { | ||||||
|     private readonly IMetrologyRepo _Repo; |  | ||||||
|     private readonly bool _IsTestDatabase; |  | ||||||
| 
 | 
 | ||||||
|     public PagesController(AppSettings appSettings, IMetrologyRepo repo) |     private readonly string _ApiUrl; | ||||||
|  |     private readonly bool _IsTestDatabase; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
|  | 
 | ||||||
|  |     public PagesController(AppSettings appSettings, IMetrologyRepository metrologyRepository) | ||||||
|     { |     { | ||||||
|         _Repo = repo; |         _MetrologyRepository = metrologyRepository; | ||||||
|         _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); |         _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); | ||||||
|  |         _ApiUrl = string.IsNullOrEmpty(appSettings.ApiUrl) ? Url.Content("~/") : appSettings.ApiUrl[0] == '~' ? Url.Content(appSettings.ApiUrl) : appSettings.ApiUrl; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public override void OnActionExecuted(ActionExecutedContext context) |     public override void OnActionExecuted(ActionExecutedContext context) | ||||||
| @ -26,14 +28,20 @@ public class PagesController : Controller | |||||||
| 
 | 
 | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     [Route("/")] |     [Route("/")] | ||||||
|     public IActionResult Index() => |     public IActionResult Index() | ||||||
|         View("AwaitingDispo"); |     { | ||||||
|  |         ViewBag.ApiUrl = _ApiUrl; | ||||||
|  |         return View("AwaitingDispo"); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     [Route("/AwaitingDispo")] |     [Route("/AwaitingDispo")] | ||||||
|     [Route("/Metrology/AwaitingDispo")] |     [Route("/Metrology/AwaitingDispo")] | ||||||
|     public IActionResult AwaitingDispo() => |     public IActionResult AwaitingDispo() | ||||||
|         View(); |     { | ||||||
|  |         ViewBag.ApiUrl = _ApiUrl; | ||||||
|  |         return View(); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     [Route("/RunInfo")] |     [Route("/RunInfo")] | ||||||
| @ -48,16 +56,20 @@ public class PagesController : Controller | |||||||
|         }; |         }; | ||||||
|         if (headerid > 0) |         if (headerid > 0) | ||||||
|         { |         { | ||||||
|             m.HeaderAttachmentID = _Repo.GetHeaderAttachmentID(tooltypeid, headerid); |             m.HeaderAttachmentID = _MetrologyRepository.GetHeaderAttachmentID(tooltypeid, headerid); | ||||||
|         } |         } | ||||||
|  |         ViewBag.ApiUrl = _ApiUrl; | ||||||
|         return View(m); |         return View(m); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     [Route("/RunHeaders")] |     [Route("/RunHeaders")] | ||||||
|     [Route("/Metrology/RunHeaders")] |     [Route("/Metrology/RunHeaders")] | ||||||
|     public IActionResult RunHeaders() => |     public IActionResult RunHeaders() | ||||||
|         View(); |     { | ||||||
|  |         ViewBag.ApiUrl = _ApiUrl; | ||||||
|  |         return View(); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     [Route("/Crash")] |     [Route("/Crash")] | ||||||
							
								
								
									
										8035
									
								
								Server/Data/Mike/service-shop.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										1
									
								
								Server/Data/Tests/GetAllServiceShopOrdersApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										1
									
								
								Server/Data/Tests/GetAppSettingsApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1 @@ | |||||||
|  | ["application/json","/api/inbound","D:\\Metrology\\MetrologyAPILogs","\\\\messv02ecc1.ec.local\\EC_Metrology_Si\\MetrologyAttachments","1","Infineon Technologies Americas Corp.","Data Source=MESSAD1001\\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;","1234567","","True","False","OI_Metrology_Viewer_IFX","auc","Data Source=MESSAD1001\\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;","\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data","https://localhost:7130;http://localhost:5126","IFXApps"] | ||||||
							
								
								
									
										1742
									
								
								Server/Data/Tests/GetAwaitingDispositionApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1 @@ | |||||||
|  | 1-1234567 | ||||||
							
								
								
									
										1
									
								
								Server/Data/Tests/GetClientSettingsApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1 @@ | |||||||
|  | ["remoteIpAddress"] | ||||||
							
								
								
									
										1
									
								
								Server/Data/Tests/GetDataApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										1
									
								
								Server/Data/Tests/GetExportDataApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1 @@ | |||||||
|  | {"Results":[],"TotalRows":0} | ||||||
							
								
								
									
										89
									
								
								Server/Data/Tests/GetHeaderFieldsApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,89 @@ | |||||||
|  | { | ||||||
|  |   "Results": [ | ||||||
|  |     { | ||||||
|  |       "Column": "ID", | ||||||
|  |       "Value": "1" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "InsertDate", | ||||||
|  |       "Value": "9/12/2019 4:02:17 PM" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Title", | ||||||
|  |       "Value": "Bio-RadQS400MEPI_99-999999-9999.1_201909121559040648" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Recipe", | ||||||
|  |       "Value": "6in_thick" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Date", | ||||||
|  |       "Value": "9/12/2019 3:59:05 PM" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Operator", | ||||||
|  |       "Value": "" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Batch", | ||||||
|  |       "Value": "BIORAD #4" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Cassette", | ||||||
|  |       "Value": "" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Wafer", | ||||||
|  |       "Value": "99-999999-9999.1" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Mean Thickness", | ||||||
|  |       "Value": "114.785" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "RV Thickness", | ||||||
|  |       "Value": "0.0000" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Status", | ||||||
|  |       "Value": "PASS" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Std Dev", | ||||||
|  |       "Value": "1.1047" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "SentToMetrology", | ||||||
|  |       "Value": "True" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "SentToSPC", | ||||||
|  |       "Value": "False" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Reactor", | ||||||
|  |       "Value": "99" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "RDS", | ||||||
|  |       "Value": "999999" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "PSN", | ||||||
|  |       "Value": "9999" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Path", | ||||||
|  |       "Value": "" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Layer", | ||||||
|  |       "Value": "1" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "Column": "Zone", | ||||||
|  |       "Value": "" | ||||||
|  |     } | ||||||
|  |   ], | ||||||
|  |   "TotalRows": 21 | ||||||
|  | } | ||||||
							
								
								
									
										21
									
								
								Server/Data/Tests/GetHeaderTitlesApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,21 @@ | |||||||
|  | { | ||||||
|  |   "Results": [ | ||||||
|  |     { | ||||||
|  |       "ID": 2, | ||||||
|  |       "InsertDate": "2019-09-12T16:24:18.617", | ||||||
|  |       "AttachmentID": "00000000-0000-0000-0000-000000000000", | ||||||
|  |       "Title": "Bio-RadQS400MEPI_99-999999-9999.1_201909121623333616", | ||||||
|  |       "Recipe": null, | ||||||
|  |       "Date": "2019-09-12T16:23:43" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "ID": 1, | ||||||
|  |       "InsertDate": "2019-09-12T16:02:17.253", | ||||||
|  |       "AttachmentID": "00000000-0000-0000-0000-000000000000", | ||||||
|  |       "Title": "Bio-RadQS400MEPI_99-999999-9999.1_201909121559040648", | ||||||
|  |       "Recipe": null, | ||||||
|  |       "Date": "2019-09-12T15:59:05" | ||||||
|  |     } | ||||||
|  |   ], | ||||||
|  |   "TotalRows": 2 | ||||||
|  | } | ||||||
							
								
								
									
										1
									
								
								Server/Data/Tests/GetHeadersApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1 @@ | |||||||
|  | {"Results":[{"Batch":"BIORAD #4","Cassette":"","Date":"2019-09-12T16:23:43","ID":2,"InsertDate":"2019-09-12T16:24:18.617","Layer":"1","Mean Thickness":"114.785","Operator":"","Path":null,"PSN":"9999","RDS":"999999","Reactor":"99","Recipe":"6in_thick","RV Thickness":"0.0000","SentToMetrology":false,"SentToSPC":false,"Status":"PASS","Std Dev":"1.1047","Title":"Bio-RadQS400MEPI_99-999999-9999.1_201909121623333616","Wafer":"99-999999-9999.1","Zone":null,"AttachmentID":null},{"Batch":"BIORAD #4","Cassette":"","Date":"2019-09-12T15:59:05","ID":1,"InsertDate":"2019-09-12T16:02:17.253","Layer":"1","Mean Thickness":"114.785","Operator":"","Path":null,"PSN":"9999","RDS":"999999","Reactor":"99","Recipe":"6in_thick","RV Thickness":"0.0000","SentToMetrology":true,"SentToSPC":false,"Status":"PASS","Std Dev":"1.1047","Title":"Bio-RadQS400MEPI_99-999999-9999.1_201909121559040648","Wafer":"99-999999-9999.1","Zone":null,"AttachmentID":null}],"TotalRows":2} | ||||||
							
								
								
									
										0
									
								
								Server/Data/Tests/GetIpAddressApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										6
									
								
								Server/Data/Tests/GetPinnedTableApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,6 @@ | |||||||
|  | { | ||||||
|  |     { | ||||||
|  |         "Results": [], | ||||||
|  |         "TotalRows": 0 | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										334
									
								
								Server/Data/Tests/GetToolTypeMetadataApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,334 @@ | |||||||
|  | { | ||||||
|  |   "Results": { | ||||||
|  |     "ToolType": { | ||||||
|  |       "ID": 1, | ||||||
|  |       "ToolTypeName": "BioRad", | ||||||
|  |       "HasHeaderAttachments": false, | ||||||
|  |       "HasDataAttachments": false, | ||||||
|  |       "HeaderTableName": "BioRadRunHeader", | ||||||
|  |       "DataTableName": "BioRadRunData", | ||||||
|  |       "ExportSPName": "Export_BioRad", | ||||||
|  |       "HeaderGridAttributes": null, | ||||||
|  |       "DataGridAttributes": null, | ||||||
|  |       "DataGridSortBy": "LEN(Position), Position", | ||||||
|  |       "DataGridStatsColumn": "Thickness", | ||||||
|  |       "DataGridStatsStdDevType": " ", | ||||||
|  |       "DisplayHeaderAttachment": null, | ||||||
|  |       "DisplayDataAttachment": null, | ||||||
|  |       "OIExportSPName": "OIExport_BioRad" | ||||||
|  |     }, | ||||||
|  |     "Metadata": [ | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": false, | ||||||
|  |         "ApiName": null, | ||||||
|  |         "ColumnName": "ID", | ||||||
|  |         "DisplayTitle": "ID", | ||||||
|  |         "GridDisplayOrder": 3, | ||||||
|  |         "GridAttributes": "{ \u0022dataType\u0022: \u0022number\u0022, \u0022hidden\u0022: \u0022true\u0022 }", | ||||||
|  |         "TableDisplayOrder": 1 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": false, | ||||||
|  |         "ApiName": null, | ||||||
|  |         "ColumnName": "InsertDate", | ||||||
|  |         "DisplayTitle": "InsertDate", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 2 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": false, | ||||||
|  |         "ApiName": "Position", | ||||||
|  |         "ColumnName": "Position", | ||||||
|  |         "DisplayTitle": "Position", | ||||||
|  |         "GridDisplayOrder": 1, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 4 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": false, | ||||||
|  |         "ApiName": "HeaderUniqueId", | ||||||
|  |         "ColumnName": "Run Header", | ||||||
|  |         "DisplayTitle": "Run Header", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 6 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": false, | ||||||
|  |         "ApiName": "Thickness", | ||||||
|  |         "ColumnName": "Thickness", | ||||||
|  |         "DisplayTitle": "Thickness", | ||||||
|  |         "GridDisplayOrder": 2, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 5 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": false, | ||||||
|  |         "ApiName": "UniqueId", | ||||||
|  |         "ColumnName": "Title", | ||||||
|  |         "DisplayTitle": "Title", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 3 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Batch", | ||||||
|  |         "ColumnName": "Batch", | ||||||
|  |         "DisplayTitle": "Batch", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 7 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Cassette", | ||||||
|  |         "ColumnName": "Cassette", | ||||||
|  |         "DisplayTitle": "Cassette", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 8 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Date", | ||||||
|  |         "ColumnName": "Date", | ||||||
|  |         "DisplayTitle": "Date", | ||||||
|  |         "GridDisplayOrder": 1, | ||||||
|  |         "GridAttributes": "{ \u0022dataType\u0022: \u0022date\u0022, \u0022format\u0022: \u0022dateTime\u0022 }", | ||||||
|  |         "TableDisplayOrder": 5 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": null, | ||||||
|  |         "ColumnName": "ID", | ||||||
|  |         "DisplayTitle": "ID", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 1 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": null, | ||||||
|  |         "ColumnName": "InsertDate", | ||||||
|  |         "DisplayTitle": "InsertDate", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 2 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Layer", | ||||||
|  |         "ColumnName": "Layer", | ||||||
|  |         "DisplayTitle": "Layer", | ||||||
|  |         "GridDisplayOrder": 5, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 20 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "MeanThickness", | ||||||
|  |         "ColumnName": "Mean Thickness", | ||||||
|  |         "DisplayTitle": "Mean Thickness", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 10 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Op", | ||||||
|  |         "ColumnName": "Operator", | ||||||
|  |         "DisplayTitle": "Operator", | ||||||
|  |         "GridDisplayOrder": 8, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 6 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "FilePath", | ||||||
|  |         "ColumnName": "Path", | ||||||
|  |         "DisplayTitle": "Path", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 19 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "PSN", | ||||||
|  |         "ColumnName": "PSN", | ||||||
|  |         "DisplayTitle": "PSN", | ||||||
|  |         "GridDisplayOrder": 4, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 18 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "RDS", | ||||||
|  |         "ColumnName": "RDS", | ||||||
|  |         "DisplayTitle": "RDS", | ||||||
|  |         "GridDisplayOrder": 3, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 17 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Reactor", | ||||||
|  |         "ColumnName": "Reactor", | ||||||
|  |         "DisplayTitle": "Reactor", | ||||||
|  |         "GridDisplayOrder": 2, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 16 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Recipe", | ||||||
|  |         "ColumnName": "Recipe", | ||||||
|  |         "DisplayTitle": "Recipe", | ||||||
|  |         "GridDisplayOrder": 7, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 4 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "RVThickness", | ||||||
|  |         "ColumnName": "RV Thickness", | ||||||
|  |         "DisplayTitle": "RV Thickness", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 11 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "SentToMetrology", | ||||||
|  |         "ColumnName": "SentToMetrology", | ||||||
|  |         "DisplayTitle": "SentToMetrology", | ||||||
|  |         "GridDisplayOrder": 9, | ||||||
|  |         "GridAttributes": "{ \u0022dataType:\u0022: \u0022bool\u0022, \u0022formatter\u0022: \u0022boolToYesNo\u0022 }", | ||||||
|  |         "TableDisplayOrder": 14 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "SentToSPC", | ||||||
|  |         "ColumnName": "SentToSPC", | ||||||
|  |         "DisplayTitle": "SentToSPC", | ||||||
|  |         "GridDisplayOrder": 10, | ||||||
|  |         "GridAttributes": "{ \u0022dataType:\u0022: \u0022bool\u0022, \u0022formatter\u0022: \u0022boolToYesNo\u0022 }", | ||||||
|  |         "TableDisplayOrder": 15 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "PassFail", | ||||||
|  |         "ColumnName": "Status", | ||||||
|  |         "DisplayTitle": "Status", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 12 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "StdDev", | ||||||
|  |         "ColumnName": "Std Dev", | ||||||
|  |         "DisplayTitle": "Std Dev", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 13 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "UniqueId", | ||||||
|  |         "ColumnName": "Title", | ||||||
|  |         "DisplayTitle": "Title", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 3 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Wafer", | ||||||
|  |         "ColumnName": "Wafer", | ||||||
|  |         "DisplayTitle": "Wafer", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 9 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Zone", | ||||||
|  |         "ColumnName": "Zone", | ||||||
|  |         "DisplayTitle": "Zone", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 21 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": false, | ||||||
|  |         "ApiName": null, | ||||||
|  |         "ColumnName": "AttachmentID", | ||||||
|  |         "DisplayTitle": "AttachmentID", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 0 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": null, | ||||||
|  |         "ColumnName": "AttachmentID", | ||||||
|  |         "DisplayTitle": "AttachmentID", | ||||||
|  |         "GridDisplayOrder": 0, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": 0 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Id", | ||||||
|  |         "ColumnName": null, | ||||||
|  |         "DisplayTitle": "Ignore", | ||||||
|  |         "GridDisplayOrder": -1, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": -1 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "ToolTypeID": 1, | ||||||
|  |         "Header": true, | ||||||
|  |         "ApiName": "Title", | ||||||
|  |         "ColumnName": null, | ||||||
|  |         "DisplayTitle": "Ignore", | ||||||
|  |         "GridDisplayOrder": -1, | ||||||
|  |         "GridAttributes": null, | ||||||
|  |         "TableDisplayOrder": -1 | ||||||
|  |       } | ||||||
|  |     ] | ||||||
|  |   }, | ||||||
|  |   "TotalRows": 31 | ||||||
|  | } | ||||||
							
								
								
									
										29
									
								
								Server/Data/Tests/IndexApi.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,29 @@ | |||||||
|  | { | ||||||
|  |   "Results": [ | ||||||
|  |     { | ||||||
|  |       "ToolTypeName": "BioRad", | ||||||
|  |       "ID": 1 | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "ToolTypeName": "CDE", | ||||||
|  |       "ID": 2 | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "ToolTypeName": "Tencor", | ||||||
|  |       "ID": 3 | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "ToolTypeName": "MercuryProbe", | ||||||
|  |       "ID": 4 | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "ToolTypeName": "StratusBioRad", | ||||||
|  |       "ID": 5 | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "ToolTypeName": "TencorSP1", | ||||||
|  |       "ID": 6 | ||||||
|  |     } | ||||||
|  |   ], | ||||||
|  |   "TotalRows": 6 | ||||||
|  | } | ||||||
							
								
								
									
										32
									
								
								Server/Models/AppSettings.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,32 @@ | |||||||
|  | using System.Text.Json; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.Models; | ||||||
|  |  | ||||||
|  | public record AppSettings(string ApiLoggingContentTypes, | ||||||
|  |                           string ApiLoggingPathPrefixes, | ||||||
|  |                           string ApiLogPath, | ||||||
|  |                           string ApiUrl, | ||||||
|  |                           string AttachmentPath, | ||||||
|  |                           string BuildNumber, | ||||||
|  |                           string Company, | ||||||
|  |                           string ConnectionString, | ||||||
|  |                           string GitCommitSeven, | ||||||
|  |                           string InboundApiAllowedIPList, | ||||||
|  |                           bool IsDevelopment, | ||||||
|  |                           bool IsStaging, | ||||||
|  |                           string MockRoot, | ||||||
|  |                           string MonAResource, | ||||||
|  |                           string MonASite, | ||||||
|  |                           string OI2SqlConnectionString, | ||||||
|  |                           string OIExportPath, | ||||||
|  |                           string URLs, | ||||||
|  |                           string WorkingDirectoryName) | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     public override string ToString() | ||||||
|  |     { | ||||||
|  |         string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										113
									
								
								Server/Models/Binder/AppSettings.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,113 @@ | |||||||
|  | using System.ComponentModel.DataAnnotations; | ||||||
|  | using System.Text.Json; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.Models.Binder; | ||||||
|  |  | ||||||
|  | public class AppSettings | ||||||
|  | { | ||||||
|  |  | ||||||
|  | #nullable disable | ||||||
|  |  | ||||||
|  |     [Display(Name = "Api Logging Content Types"), Required] public string ApiLoggingContentTypes { get; set; } | ||||||
|  |     [Display(Name = "Api Logging Path Prefixes"), Required] public string ApiLoggingPathPrefixes { get; set; } | ||||||
|  |     [Display(Name = "Api Log Path"), Required] public string ApiLogPath { get; set; } | ||||||
|  |     [Display(Name = "Api URL"), Required] public string ApiUrl { get; set; } | ||||||
|  |     [Display(Name = "Attachment Path"), Required] public string AttachmentPath { get; set; } | ||||||
|  |     [Display(Name = "Build Number"), Required] public string BuildNumber { get; set; } | ||||||
|  |     [Display(Name = "Company"), Required] public string Company { get; set; } | ||||||
|  |     [Display(Name = "Connection String"), Required] public string ConnectionString { get; set; } | ||||||
|  |     [Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; } | ||||||
|  |     [Display(Name = "Inbound Api Allowed IP List"), Required] public string InboundApiAllowedIPList { get; set; } | ||||||
|  |     [Display(Name = "Is Development"), Required] public bool? IsDevelopment { get; set; } | ||||||
|  |     [Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; } | ||||||
|  |     [Display(Name = "Mock Root"), Required] public string MockRoot { get; set; } | ||||||
|  |     [Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; } | ||||||
|  |     [Display(Name = "MonA Site"), Required] public string MonASite { get; set; } | ||||||
|  |     [Display(Name = "Oi 2 Sql Connection String"), Required] public string Oi2SqlConnectionString { get; set; } | ||||||
|  |     [Display(Name = "OI Export Path"), Required] public string OIExportPath { get; set; } | ||||||
|  |     [Display(Name = "URLs"), Required] public string URLs { get; set; } | ||||||
|  |     [Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; } | ||||||
|  |  | ||||||
|  | #nullable restore | ||||||
|  |  | ||||||
|  |     public override string ToString() | ||||||
|  |     { | ||||||
|  |         string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static Models.AppSettings Get(AppSettings? appSettings) | ||||||
|  |     { | ||||||
|  |         Models.AppSettings result; | ||||||
|  |         if (appSettings is null) | ||||||
|  |             throw new NullReferenceException(nameof(appSettings)); | ||||||
|  |         if (appSettings.ApiLoggingContentTypes is null) | ||||||
|  |             throw new NullReferenceException(nameof(ApiLoggingContentTypes)); | ||||||
|  |         if (appSettings.ApiLoggingPathPrefixes is null) | ||||||
|  |             throw new NullReferenceException(nameof(ApiLoggingPathPrefixes)); | ||||||
|  |         if (appSettings.ApiLogPath is null) | ||||||
|  |             throw new NullReferenceException(nameof(ApiLogPath)); | ||||||
|  |         if (appSettings.ApiUrl is null) | ||||||
|  |             throw new NullReferenceException(nameof(ApiUrl)); | ||||||
|  |         if (appSettings.AttachmentPath is null) | ||||||
|  |             throw new NullReferenceException(nameof(AttachmentPath)); | ||||||
|  |         if (appSettings.BuildNumber is null) | ||||||
|  |             throw new NullReferenceException(nameof(BuildNumber)); | ||||||
|  |         if (appSettings.Company is null) | ||||||
|  |             throw new NullReferenceException(nameof(Company)); | ||||||
|  |         if (appSettings.ConnectionString is null) | ||||||
|  |             throw new NullReferenceException(nameof(ConnectionString)); | ||||||
|  |         if (appSettings.GitCommitSeven is null) | ||||||
|  |             throw new NullReferenceException(nameof(GitCommitSeven)); | ||||||
|  |         if (appSettings.InboundApiAllowedIPList is null) | ||||||
|  |             throw new NullReferenceException(nameof(InboundApiAllowedIPList)); | ||||||
|  |         if (appSettings.IsDevelopment is null) | ||||||
|  |             throw new NullReferenceException(nameof(IsDevelopment)); | ||||||
|  |         if (appSettings.IsStaging is null) | ||||||
|  |             throw new NullReferenceException(nameof(IsStaging)); | ||||||
|  |         if (appSettings.MockRoot is null) | ||||||
|  |             throw new NullReferenceException(nameof(MockRoot)); | ||||||
|  |         if (appSettings.MonAResource is null) | ||||||
|  |             throw new NullReferenceException(nameof(MonAResource)); | ||||||
|  |         if (appSettings.MonASite is null) | ||||||
|  |             throw new NullReferenceException(nameof(MonASite)); | ||||||
|  |         if (appSettings.Oi2SqlConnectionString is null) | ||||||
|  |             throw new NullReferenceException(nameof(Oi2SqlConnectionString)); | ||||||
|  |         if (appSettings.OIExportPath is null) | ||||||
|  |             throw new NullReferenceException(nameof(OIExportPath)); | ||||||
|  |         if (appSettings.URLs is null) | ||||||
|  |             throw new NullReferenceException(nameof(URLs)); | ||||||
|  |         if (appSettings.WorkingDirectoryName is null) | ||||||
|  |             throw new NullReferenceException(nameof(WorkingDirectoryName)); | ||||||
|  |         result = new( | ||||||
|  |             appSettings.ApiLoggingContentTypes, | ||||||
|  |             appSettings.ApiLoggingPathPrefixes, | ||||||
|  |             appSettings.ApiLogPath, | ||||||
|  |             appSettings.ApiUrl, | ||||||
|  |             appSettings.AttachmentPath, | ||||||
|  |             appSettings.BuildNumber, | ||||||
|  |             appSettings.Company, | ||||||
|  |             appSettings.ConnectionString, | ||||||
|  |             appSettings.GitCommitSeven, | ||||||
|  |             appSettings.InboundApiAllowedIPList, | ||||||
|  |             appSettings.IsDevelopment.Value, | ||||||
|  |             appSettings.IsStaging.Value, | ||||||
|  |             appSettings.MockRoot, | ||||||
|  |             appSettings.MonAResource, | ||||||
|  |             appSettings.MonASite, | ||||||
|  |             appSettings.Oi2SqlConnectionString, | ||||||
|  |             appSettings.OIExportPath, | ||||||
|  |             appSettings.URLs, | ||||||
|  |             appSettings.WorkingDirectoryName); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static Models.AppSettings Get(IConfigurationRoot configurationRoot) | ||||||
|  |     { | ||||||
|  |         Models.AppSettings result; | ||||||
|  |         AppSettings? appSettings = configurationRoot.Get<AppSettings>(); | ||||||
|  |         result = Get(appSettings); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										110
									
								
								Server/OI.Metrology.Server.csproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,110 @@ | |||||||
|  | <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||||
|  |     <PropertyGroup Label="Globals"> | ||||||
|  |         <SccProjectName>SAK</SccProjectName> | ||||||
|  |         <SccProvider>SAK</SccProvider> | ||||||
|  |         <SccAuxPath>SAK</SccAuxPath> | ||||||
|  |         <SccLocalPath>SAK</SccLocalPath> | ||||||
|  |     </PropertyGroup> | ||||||
|  |     <PropertyGroup> | ||||||
|  |         <ImplicitUsings>enable</ImplicitUsings> | ||||||
|  |         <IsPackable>false</IsPackable> | ||||||
|  |         <LangVersion>10.0</LangVersion> | ||||||
|  |         <Nullable>enable</Nullable> | ||||||
|  |         <OutputType>Exe</OutputType> | ||||||
|  |         <RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||||||
|  |         <TargetFramework>net7.0</TargetFramework> | ||||||
|  |     </PropertyGroup> | ||||||
|  |     <ItemGroup> | ||||||
|  |         <Compile Remove="logs\**" /> | ||||||
|  |         <Content Remove="logs\**" /> | ||||||
|  |         <EmbeddedResource Remove="logs\**" /> | ||||||
|  |         <None Remove="logs\**" /> | ||||||
|  |     </ItemGroup> | ||||||
|  |     <ItemGroup> | ||||||
|  |         <Content Remove="compilerconfig.json" /> | ||||||
|  |     </ItemGroup> | ||||||
|  |     <ItemGroup> | ||||||
|  |         <PackageReference Include="Dapper" Version="2.0.123" /> | ||||||
|  |         <PackageReference Include="EntityFramework" Version="6.4.4" /> | ||||||
|  |         <PackageReference Include="jQuery" Version="3.6.3" /> | ||||||
|  |         <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.2" /> | ||||||
|  |         <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" /> | ||||||
|  |         <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" /> | ||||||
|  |         <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" /> | ||||||
|  |         <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> | ||||||
|  |         <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" /> | ||||||
|  |         <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" /> | ||||||
|  |         <PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> | ||||||
|  |         <PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" /> | ||||||
|  |         <PackageReference Include="Serilog.AspNetCore" Version="6.1.0" /> | ||||||
|  |         <PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" /> | ||||||
|  |         <PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" /> | ||||||
|  |         <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> | ||||||
|  |         <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> | ||||||
|  |         <PackageReference Include="System.Data.SqlClient" Version="4.8.5" /> | ||||||
|  |     </ItemGroup> | ||||||
|  |     <ItemGroup> | ||||||
|  |         <ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" /> | ||||||
|  |     </ItemGroup> | ||||||
|  |     <ItemGroup> | ||||||
|  |         <Folder Include="moves\" /> | ||||||
|  |         <Folder Include="wwwroot\images\" /> | ||||||
|  |         <Folder Include="wwwroot\styles\" /> | ||||||
|  |     </ItemGroup> | ||||||
|  |     <ItemGroup> | ||||||
|  |         <None Include="compilerconfig.json" /> | ||||||
|  |     </ItemGroup> | ||||||
|  |     <ItemGroup> | ||||||
|  |         <None Include="appsettings.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="appsettings.Development.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Mike\service-shop.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetAllServiceShopOrdersApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetAppSettingsApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetAwaitingDispositionApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetBuildNumberAndGitCommitSevenApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetClientSettingsApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetDataApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetExportDataApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetHeaderFieldsApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetHeadersApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetHeaderTitlesApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetIpAddressApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetPinnedTableApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\GetToolTypeMetadataApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |         <None Include="Data\Tests\IndexApi.json"> | ||||||
|  |             <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||||
|  |         </None> | ||||||
|  |     </ItemGroup> | ||||||
|  | </Project> | ||||||
| @ -1,22 +1,17 @@ | |||||||
| using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Mvc; | ||||||
| using Microsoft.AspNetCore.Mvc; |  | ||||||
| using Microsoft.Extensions.Configuration; |  | ||||||
| using Microsoft.Extensions.DependencyInjection; |  | ||||||
| using Microsoft.Extensions.Hosting; |  | ||||||
| using Microsoft.Extensions.Hosting.WindowsServices; | using Microsoft.Extensions.Hosting.WindowsServices; | ||||||
| using Microsoft.Extensions.Logging; | using OI.Metrology.Server.Models; | ||||||
|  | using OI.Metrology.Server.Repositories; | ||||||
|  | using OI.Metrology.Server.Repository; | ||||||
|  | using OI.Metrology.Server.Services; | ||||||
| using OI.Metrology.Shared.Models; | using OI.Metrology.Shared.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Repositories; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using OI.Metrology.Viewer.Models; |  | ||||||
| using OI.Metrology.Viewer.Repositories; |  | ||||||
| using OI.Metrology.Viewer.Services; |  | ||||||
| using Serilog; | using Serilog; | ||||||
| using System; |  | ||||||
| using System.IO; |  | ||||||
| using System.Reflection; | using System.Reflection; | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer; | namespace OI.Metrology.Server; | ||||||
| 
 | 
 | ||||||
| public class Program | public class Program | ||||||
| { | { | ||||||
| @ -25,7 +20,7 @@ public class Program | |||||||
|     { |     { | ||||||
|         string webRootPath; |         string webRootPath; | ||||||
|         Assembly assembly = Assembly.GetExecutingAssembly(); |         Assembly assembly = Assembly.GetExecutingAssembly(); | ||||||
|         string assemblyName = assembly.GetName()?.Name; |         string? assemblyName = assembly.GetName()?.Name; | ||||||
|         if (string.IsNullOrEmpty(assemblyName)) |         if (string.IsNullOrEmpty(assemblyName)) | ||||||
|             throw new Exception(); |             throw new Exception(); | ||||||
|         string baseAssemblyName = assemblyName.Split('.')[0]; |         string baseAssemblyName = assemblyName.Split('.')[0]; | ||||||
| @ -63,14 +58,26 @@ public class Program | |||||||
|         { |         { | ||||||
|             _ = webApplicationBuilder.Services.Configure<ApiBehaviorOptions>(options => options.SuppressModelStateInvalidFilter = true); |             _ = webApplicationBuilder.Services.Configure<ApiBehaviorOptions>(options => options.SuppressModelStateInvalidFilter = true); | ||||||
|             _ = webApplicationBuilder.Services.AddControllersWithViews(); |             _ = webApplicationBuilder.Services.AddControllersWithViews(); | ||||||
|             _ = new MetrologyRepo(new SQLDbConnectionFactory(appSettings), null); |  | ||||||
|             _ = webApplicationBuilder.Services.AddDistributedMemoryCache(); |             _ = webApplicationBuilder.Services.AddDistributedMemoryCache(); | ||||||
|             _ = webApplicationBuilder.Services.AddMemoryCache(); |             _ = webApplicationBuilder.Services.AddMemoryCache(); | ||||||
|             _ = webApplicationBuilder.Services.AddSingleton<AppSettings, AppSettings>(_ => appSettings); | 
 | ||||||
|  |             AppSettingsRepository appSettingsRepository = new(appSettings); | ||||||
|  |             SQLDbConnectionFactory sqlDbConnectionFactory = new(appSettings); | ||||||
|  |             ClientSettingsRepository clientSettingsRepository = new(appSettings); | ||||||
|  | 
 | ||||||
|  |             _ = webApplicationBuilder.Services.AddSingleton(_ => appSettings); | ||||||
|  |             _ = webApplicationBuilder.Services.AddSingleton<IInboundRepository, InboundRepository>(); | ||||||
|  |             _ = webApplicationBuilder.Services.AddSingleton<IClientSettingsRepository>(_ => clientSettingsRepository); | ||||||
|  |             _ = webApplicationBuilder.Services.AddSingleton<IServiceShopOrderRepository, ServiceShopOrderRepository>(); | ||||||
|  |             _ = webApplicationBuilder.Services.AddSingleton<IPinRepository, PinRepository>(_ => new(appSettings.MockRoot)); | ||||||
|  |             _ = webApplicationBuilder.Services.AddSingleton<IDbConnectionFactory, SQLDbConnectionFactory>(_ => sqlDbConnectionFactory); | ||||||
|  |             _ = webApplicationBuilder.Services.AddSingleton<IToolTypesRepository, ToolTypesRepository>(_ => new(appSettings.MockRoot)); | ||||||
|  |             _ = webApplicationBuilder.Services.AddSingleton<IAppSettingsRepository<Models.Binder.AppSettings>>(_ => appSettingsRepository); | ||||||
|  | 
 | ||||||
|             _ = webApplicationBuilder.Services.AddScoped<IAttachmentsService, AttachmentsService>(); |             _ = webApplicationBuilder.Services.AddScoped<IAttachmentsService, AttachmentsService>(); | ||||||
|             _ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>(); |             _ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>(); | ||||||
|             _ = webApplicationBuilder.Services.AddScoped<IMetrologyRepo, MetrologyRepo>(); |             _ = webApplicationBuilder.Services.AddScoped<IMetrologyRepository, MetrologyRepository>(); | ||||||
|             _ = webApplicationBuilder.Services.AddSingleton<IDbConnectionFactory, SQLDbConnectionFactory>(); | 
 | ||||||
|             _ = webApplicationBuilder.Services.AddSwaggerGen(); |             _ = webApplicationBuilder.Services.AddSwaggerGen(); | ||||||
|             _ = webApplicationBuilder.Services.AddSession(sessionOptions => |             _ = webApplicationBuilder.Services.AddSession(sessionOptions => | ||||||
|                 { |                 { | ||||||
| @ -84,14 +91,18 @@ public class Program | |||||||
|                 _ = webApplicationBuilder.Services.AddSingleton<IHostLifetime, WindowsServiceLifetime>(); |                 _ = webApplicationBuilder.Services.AddSingleton<IHostLifetime, WindowsServiceLifetime>(); | ||||||
|                 _ = webApplicationBuilder.Logging.AddEventLog(settings => |                 _ = webApplicationBuilder.Logging.AddEventLog(settings => | ||||||
|                 { |                 { | ||||||
|  | #pragma warning disable CA1416 | ||||||
|                     if (string.IsNullOrEmpty(settings.SourceName)) |                     if (string.IsNullOrEmpty(settings.SourceName)) | ||||||
|                         settings.SourceName = webApplicationBuilder.Environment.ApplicationName; |                         settings.SourceName = webApplicationBuilder.Environment.ApplicationName; | ||||||
|  | #pragma warning restore | ||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
|             WebApplication webApplication = webApplicationBuilder.Build(); |             WebApplication webApplication = webApplicationBuilder.Build(); | ||||||
|  |             _ = webApplication.UseCors(corsPolicyBuilder => corsPolicyBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); | ||||||
|             if (!webApplicationBuilder.Environment.IsDevelopment()) |             if (!webApplicationBuilder.Environment.IsDevelopment()) | ||||||
|             { |             { | ||||||
|                 _ = webApplication.UseExceptionHandler("/Error"); |                 _ = webApplication.UseExceptionHandler("/Error"); | ||||||
|  |                 _ = webApplication.UseHttpsRedirection(); | ||||||
|                 _ = webApplication.UseHsts(); |                 _ = webApplication.UseHsts(); | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
| @ -102,7 +113,7 @@ public class Program | |||||||
|                     webApplication.Lifetime.StopApplication(); |                     webApplication.Lifetime.StopApplication(); | ||||||
|                 } |                 } | ||||||
|                 _ = webApplication.UseSwagger(); |                 _ = webApplication.UseSwagger(); | ||||||
|                 _ = webApplication.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Viewer V1")); |                 _ = webApplication.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Server V1")); | ||||||
|             } |             } | ||||||
|             _ = webApplication.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush); |             _ = webApplication.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush); | ||||||
|             _ = ApplicationBuilderSerilogClientExtensions.UseSerilogIngestion(webApplication); |             _ = ApplicationBuilderSerilogClientExtensions.UseSerilogIngestion(webApplication); | ||||||
| @ -110,7 +121,6 @@ public class Program | |||||||
|             _ = webApplication.UseFileServer(enableDirectoryBrowsing: true); |             _ = webApplication.UseFileServer(enableDirectoryBrowsing: true); | ||||||
|             _ = webApplication.UseStaticFiles(); |             _ = webApplication.UseStaticFiles(); | ||||||
|             _ = webApplication.UseSession(); |             _ = webApplication.UseSession(); | ||||||
|             _ = webApplication.UseHttpsRedirection(); |  | ||||||
|             _ = webApplication.UseMiddleware<ApiLoggingMiddleware>(); |             _ = webApplication.UseMiddleware<ApiLoggingMiddleware>(); | ||||||
|             _ = webApplication.MapControllers(); |             _ = webApplication.MapControllers(); | ||||||
|             log.Information("Starting Web Application"); |             log.Information("Starting Web Application"); | ||||||
							
								
								
									
										31
									
								
								Server/Properties/launchSettings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,31 @@ | |||||||
|  | { | ||||||
|  |   "profiles": { | ||||||
|  |     "http": { | ||||||
|  |       "commandName": "Project", | ||||||
|  |       "dotnetRunMessages": true, | ||||||
|  |       "launchBrowser": false, | ||||||
|  |       "applicationUrl": "http://localhost:5126", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "https": { | ||||||
|  |       "commandName": "Project", | ||||||
|  |       "dotnetRunMessages": true, | ||||||
|  |       "launchBrowser": false, | ||||||
|  |       "applicationUrl": "https://localhost:7130;http://localhost:5126", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "https-prod": { | ||||||
|  |       "commandName": "Project", | ||||||
|  |       "dotnetRunMessages": true, | ||||||
|  |       "launchBrowser": false, | ||||||
|  |       "applicationUrl": "https://localhost:7130;http://localhost:5126", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Production" | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										36
									
								
								Server/Repositories/AppSettingsRepository.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,36 @@ | |||||||
|  | using OI.Metrology.Server.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.Repository; | ||||||
|  |  | ||||||
|  | public class AppSettingsRepository : IAppSettingsRepository<Models.Binder.AppSettings> | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly AppSettings _AppSettings; | ||||||
|  |  | ||||||
|  |     public AppSettingsRepository(AppSettings appSettings) => _AppSettings = appSettings; | ||||||
|  |  | ||||||
|  |     internal Models.Binder.AppSettings GetAppSettings() | ||||||
|  |     { | ||||||
|  |         Models.Binder.AppSettings result = new() | ||||||
|  |         { | ||||||
|  |             BuildNumber = _AppSettings.BuildNumber, | ||||||
|  |             Company = _AppSettings.Company, | ||||||
|  |             GitCommitSeven = _AppSettings.GitCommitSeven, | ||||||
|  |             IsDevelopment = _AppSettings.IsDevelopment, | ||||||
|  |             IsStaging = _AppSettings.IsStaging, | ||||||
|  |         }; | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     Models.Binder.AppSettings IAppSettingsRepository<Models.Binder.AppSettings>.GetAppSettings() => GetAppSettings(); | ||||||
|  |  | ||||||
|  |     internal string GetBuildNumberAndGitCommitSeven() | ||||||
|  |     { | ||||||
|  |         string result = string.Concat(_AppSettings.BuildNumber, '-', _AppSettings.GitCommitSeven); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     string IAppSettingsRepository<Models.Binder.AppSettings>.GetBuildNumberAndGitCommitSeven() => GetBuildNumberAndGitCommitSeven(); | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										36
									
								
								Server/Repositories/ClientSettingsRepository.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,36 @@ | |||||||
|  | using OI.Metrology.Server.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  | using System.Net; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.Repository; | ||||||
|  |  | ||||||
|  | public class ClientSettingsRepository : IClientSettingsRepository | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly AppSettings _AppSettings; | ||||||
|  |  | ||||||
|  |     public ClientSettingsRepository(AppSettings appSettings) => _AppSettings = appSettings; | ||||||
|  |  | ||||||
|  |     internal List<string> GetClientSettings(IPAddress? remoteIpAddress) | ||||||
|  |     { | ||||||
|  |         List<string> results = new(); | ||||||
|  |         if (remoteIpAddress is null) | ||||||
|  |             results.Add(nameof(remoteIpAddress)); | ||||||
|  |         else | ||||||
|  |             results.Add(remoteIpAddress.ToString()); | ||||||
|  |         if (!_AppSettings.IsDevelopment) | ||||||
|  |             throw new Exception("Shouldn't expose!"); | ||||||
|  |         return results; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     List<string> IClientSettingsRepository.GetClientSettings(IPAddress? remoteIpAddress) => GetClientSettings(remoteIpAddress); | ||||||
|  |  | ||||||
|  |     internal static string GetIpAddress(IPAddress? remoteIpAddress) | ||||||
|  |     { | ||||||
|  |         string result = remoteIpAddress is null ? string.Empty : remoteIpAddress.ToString(); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     string IClientSettingsRepository.GetIpAddress(IPAddress? remoteIpAddress) => GetIpAddress(remoteIpAddress); | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										88
									
								
								Server/Repositories/InboundRepository.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,88 @@ | |||||||
|  | using Newtonsoft.Json.Linq; | ||||||
|  | using OI.Metrology.Shared.DataModels; | ||||||
|  | using OI.Metrology.Shared.Models; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  | using OI.Metrology.Shared.Services; | ||||||
|  | using System.Net; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.Repository; | ||||||
|  |  | ||||||
|  | public class InboundRepository : IInboundRepository | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly Serilog.ILogger _Log; | ||||||
|  |  | ||||||
|  |     public InboundRepository() => _Log = Serilog.Log.ForContext<InboundRepository>(); | ||||||
|  |  | ||||||
|  |     bool IInboundRepository.IsIPAddressAllowed(string inboundApiAllowedIPList, IPAddress? remoteIP) | ||||||
|  |     { | ||||||
|  |         if (string.IsNullOrWhiteSpace(inboundApiAllowedIPList)) | ||||||
|  |             return true; | ||||||
|  |         if (remoteIP is null) | ||||||
|  |             return false; | ||||||
|  |         byte[] remoteIPBytes = remoteIP.GetAddressBytes(); | ||||||
|  |         string[] allowedIPs = inboundApiAllowedIPList.Split(';'); | ||||||
|  |         foreach (string ip in allowedIPs) | ||||||
|  |         { | ||||||
|  |             IPAddress? parsedIP; | ||||||
|  |             if (IPAddress.TryParse(ip, out parsedIP)) | ||||||
|  |             { | ||||||
|  |                 if (parsedIP.GetAddressBytes().SequenceEqual(remoteIPBytes)) | ||||||
|  |                     return true; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // this is the main endpoint, it accepts a JSON message that contains both the header and data records together | ||||||
|  |     // tooltype is the ToolTypeName column from the ToolType table | ||||||
|  |     // JToken is how you can accept a JSON message without deserialization. | ||||||
|  |     // Using "string" doesn't work because ASP.NET Core will expect a json encoded string, not give you the actual string. | ||||||
|  |     DataResponse IInboundRepository.Data(IMetrologyRepository metrologyRepository, IInboundDataService inboundDataService, string tooltype, JToken jsonbody) | ||||||
|  |     { | ||||||
|  |         DataResponse result = new(); | ||||||
|  |         ToolType? toolType = metrologyRepository.GetToolTypeByName(tooltype); | ||||||
|  |         if (toolType is null) | ||||||
|  |             result.Errors.Add("Invalid tool type: " + tooltype); | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             List<ToolTypeMetadata> metaData = metrologyRepository.GetToolTypeMetadataByToolTypeID(toolType.ID).ToList(); | ||||||
|  |             if (metaData is null) | ||||||
|  |                 result.Errors.Add("Invalid metadata for tool type: " + tooltype); | ||||||
|  |             else if (jsonbody is null) | ||||||
|  |                 result.Errors.Add("Invalid json"); | ||||||
|  |             else | ||||||
|  |                 inboundDataService.ValidateJSONFields(jsonbody, 0, metaData, result.Errors, result.Warnings); | ||||||
|  |             if (metaData is not null && jsonbody is not null && !result.Errors.Any()) | ||||||
|  |             { | ||||||
|  |                 try | ||||||
|  |                 { | ||||||
|  |                     result.HeaderID = inboundDataService.DoSQLInsert(jsonbody, toolType, metaData); | ||||||
|  |                     result.Success = result.HeaderID > 0; | ||||||
|  |                 } | ||||||
|  |                 catch (Exception ex) { result.Errors.Add(ex.Message); } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // this is the endpoint for attaching a field.  It is not JSON, it is form-data/multipart like an HTML form because that's the normal way. | ||||||
|  |     // header ID is the ID value from the Header table | ||||||
|  |     // datauniqueid is the Title value from the Data/Detail table | ||||||
|  |     string? IInboundRepository.AttachFile(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, string tooltype, long headerid, string datauniqueid, string fileName, object uploadedFile) | ||||||
|  |     { | ||||||
|  |         string? result = null; | ||||||
|  |         ToolType toolType = metrologyRepository.GetToolTypeByName(tooltype); | ||||||
|  |         if (toolType is null) | ||||||
|  |             result = $"Invalid tool type: {tooltype}"; | ||||||
|  |         string filename = Path.GetFileName(fileName); | ||||||
|  |         if (string.IsNullOrWhiteSpace(filename)) | ||||||
|  |             result = "Empty filename"; | ||||||
|  |         if (filename.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) | ||||||
|  |             result = "Invalid filename"; | ||||||
|  |         if (result is null && toolType is not null) | ||||||
|  |             attachmentsService.SaveAttachment(toolType, headerid, datauniqueid, filename, uploadedFile); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -1,25 +1,29 @@ | |||||||
| using Dapper; | using Dapper; | ||||||
| using Microsoft.Extensions.Caching.Memory; | using Microsoft.Extensions.Caching.Memory; | ||||||
| using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||||
|  | using OI.Metrology.Server.Models; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Repositories; | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Data; | using System.Data; | ||||||
| using System.Data.Common; | using System.Data.Common; | ||||||
| using System.Linq; | using System.Text; | ||||||
| using System.Transactions; | using System.Transactions; | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer.Repositories; | #pragma warning disable CS8600, CS8602, CS8603, CS8604, CS8625 | ||||||
| 
 | 
 | ||||||
| public class MetrologyRepo : IMetrologyRepo | namespace OI.Metrology.Server.Repositories; | ||||||
|  | 
 | ||||||
|  | public class MetrologyRepository : IMetrologyRepository | ||||||
| { | { | ||||||
|  |     private readonly string _MockRoot; | ||||||
|     private readonly IMemoryCache _Cache; |     private readonly IMemoryCache _Cache; | ||||||
|     private readonly IDbConnectionFactory _DBConnectionFactory; |     private readonly IDbConnectionFactory _DBConnectionFactory; | ||||||
| 
 | 
 | ||||||
|     public MetrologyRepo(IDbConnectionFactory dbConnectionFactory, IMemoryCache memoryCache) |     public MetrologyRepository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IMemoryCache memoryCache) | ||||||
|     { |     { | ||||||
|         _Cache = memoryCache; |         _Cache = memoryCache; | ||||||
|  |         _MockRoot = appSettings.MockRoot; | ||||||
|         _DBConnectionFactory = dbConnectionFactory; |         _DBConnectionFactory = dbConnectionFactory; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -28,21 +32,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|     protected DbProviderFactory GetDbProviderFactory(IDbConnection conn) => |     protected DbProviderFactory GetDbProviderFactory(IDbConnection conn) => | ||||||
|         DbProviderFactories.GetFactory(conn.GetType().Namespace); |         DbProviderFactories.GetFactory(conn.GetType().Namespace); | ||||||
| 
 | 
 | ||||||
|     public bool IsTestDatabase() |     internal static TransactionScope StartTransaction() => new(); | ||||||
|     { |  | ||||||
|         int c = 0; |  | ||||||
|         using (DbConnection conn = GetDbConnection()) |  | ||||||
|         { |  | ||||||
|             c = conn.Query<int>( |  | ||||||
|                 "SELECT COUNT(*) " + |  | ||||||
|                 "FROM Configuration " + |  | ||||||
|                 "WHERE KeyName = 'TestDatabase' " + |  | ||||||
|                 "AND ValueString = '1'").FirstOrDefault(); |  | ||||||
|         } |  | ||||||
|         return c > 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public TransactionScope StartTransaction() => new(); |  | ||||||
| 
 | 
 | ||||||
|     protected void CacheItem(string key, object v) |     protected void CacheItem(string key, object v) | ||||||
|     { |     { | ||||||
| @ -51,7 +41,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         _ = _Cache.Set(key, v, new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromHours(1))); |         _ = _Cache.Set(key, v, new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromHours(1))); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public IEnumerable<ToolType> GetToolTypes() |     internal IEnumerable<ToolType> GetToolTypes() | ||||||
|     { |     { | ||||||
|         IEnumerable<ToolType> cached; |         IEnumerable<ToolType> cached; | ||||||
|         string cacheKey = "GetToolTypes"; |         string cacheKey = "GetToolTypes"; | ||||||
| @ -66,7 +56,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return r; |         return r; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public ToolType GetToolTypeByName(string name) |     internal ToolType GetToolTypeByName(string name) | ||||||
|     { |     { | ||||||
|         ToolType cached; |         ToolType cached; | ||||||
|         string cacheKey = "GetToolTypeByName_" + name; |         string cacheKey = "GetToolTypeByName_" + name; | ||||||
| @ -83,7 +73,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return r; |         return r; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public ToolType GetToolTypeByID(int id) |     internal ToolType GetToolTypeByID(int id) | ||||||
|     { |     { | ||||||
|         ToolType cached; |         ToolType cached; | ||||||
|         string cacheKey = "GetToolTypeByID_" + id.ToString(); |         string cacheKey = "GetToolTypeByID_" + id.ToString(); | ||||||
| @ -100,7 +90,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return r; |         return r; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public IEnumerable<ToolTypeMetadata> GetToolTypeMetadataByToolTypeID(int id) |     internal IEnumerable<ToolTypeMetadata> GetToolTypeMetadataByToolTypeID(int id) | ||||||
|     { |     { | ||||||
|         IEnumerable<ToolTypeMetadata> cached; |         IEnumerable<ToolTypeMetadata> cached; | ||||||
|         string cacheKey = "GetToolTypeMetadataByToolTypeID_" + id.ToString(); |         string cacheKey = "GetToolTypeMetadataByToolTypeID_" + id.ToString(); | ||||||
| @ -117,7 +107,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return r; |         return r; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public long InsertToolDataJSON(JToken jsonrow, long headerId, List<ToolTypeMetadata> metaData, string tableName) |     internal long InsertToolDataJSON(JToken jsonrow, long headerId, List<ToolTypeMetadata> metaData, string tableName) | ||||||
|     { |     { | ||||||
|         long r = -1; |         long r = -1; | ||||||
|         using (DbConnection conn = GetDbConnection()) |         using (DbConnection conn = GetDbConnection()) | ||||||
| @ -139,10 +129,10 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|             // build field map |             // build field map | ||||||
|             foreach (ToolTypeMetadata f in fields) |             foreach (ToolTypeMetadata f in fields) | ||||||
|             { |             { | ||||||
|                 if ((f.ApiName != null) && f.ApiName.Contains('\\')) |                 if ((f.ApiName is not null) && f.ApiName.Contains('\\')) | ||||||
|                 { |                 { | ||||||
|                     string n = f.ApiName.Split('\\')[0].Trim().ToUpper(); |                     string n = f.ApiName.Split('\\')[0].Trim().ToUpper(); | ||||||
|                     if (containerField == null) |                     if (containerField is null) | ||||||
|                         containerField = n; |                         containerField = n; | ||||||
|                     else if (!string.Equals(containerField, n)) |                     else if (!string.Equals(containerField, n)) | ||||||
|                         throw new Exception("Only one container field is allowed"); |                         throw new Exception("Only one container field is allowed"); | ||||||
| @ -156,7 +146,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (containerField == null) |             if (containerField is null) | ||||||
|             { |             { | ||||||
|                 // No container field, just  insert a single row |                 // No container field, just  insert a single row | ||||||
| 
 | 
 | ||||||
| @ -167,7 +157,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|                 // Find the container field in the json |                 // Find the container field in the json | ||||||
|                 JProperty contJP = jsonrow.Children<JProperty>().Where(c => string.Equals(c.Name.Trim(), containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); |                 JProperty contJP = jsonrow.Children<JProperty>().Where(c => string.Equals(c.Name.Trim(), containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); | ||||||
| 
 | 
 | ||||||
|                 if ((contJP != null) && (contJP.Value is JArray array)) |                 if ((contJP is not null) && (contJP.Value is JArray array)) | ||||||
|                 { |                 { | ||||||
|                     JArray contRows = array; |                     JArray contRows = array; | ||||||
| 
 | 
 | ||||||
| @ -220,42 +210,40 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         { |         { | ||||||
|             string apifield = jp.Name.Trim().ToUpper(); |             string apifield = jp.Name.Trim().ToUpper(); | ||||||
| 
 | 
 | ||||||
|             if (fieldmap.ContainsKey(apifield)) |             if (fieldmap.TryGetValue(apifield, out string value)) | ||||||
|             { |             { | ||||||
|                 string parmname = string.Format("@p{0}", parmnumber); |                 string parmname = string.Format("@p{0}", parmnumber); | ||||||
| 
 | 
 | ||||||
|                 columns += string.Format("[{0}],", fieldmap[apifield]); |                 columns += string.Format("[{0}],", value); | ||||||
|                 parms += parmname; |                 parms += parmname; | ||||||
|                 parms += ","; |                 parms += ","; | ||||||
|                 parmnumber += 1; |                 parmnumber += 1; | ||||||
| 
 | 
 | ||||||
|                 object sqlValue = ((JValue)jp.Value).Value; |                 object sqlValue = ((JValue)jp.Value).Value; | ||||||
|                 if (sqlValue == null) |                 sqlValue ??= DBNull.Value; | ||||||
|                     sqlValue = DBNull.Value; |  | ||||||
| 
 | 
 | ||||||
|                 AddParameter(cmd, parmname, sqlValue); |                 AddParameter(cmd, parmname, sqlValue); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if ((containerrow != null) && (containerFieldmap != null)) |         if ((containerrow is not null) && (containerFieldmap is not null)) | ||||||
|         { |         { | ||||||
| 
 | 
 | ||||||
|             foreach (JProperty jp in containerrow.Children<JProperty>()) |             foreach (JProperty jp in containerrow.Children<JProperty>()) | ||||||
|             { |             { | ||||||
|                 string apifield = jp.Name.Trim().ToUpper(); |                 string apifield = jp.Name.Trim().ToUpper(); | ||||||
| 
 | 
 | ||||||
|                 if (containerFieldmap.ContainsKey(apifield)) |                 if (containerFieldmap.TryGetValue(apifield, out string value)) | ||||||
|                 { |                 { | ||||||
|                     string parmname = string.Format("@p{0}", parmnumber); |                     string parmname = string.Format("@p{0}", parmnumber); | ||||||
| 
 | 
 | ||||||
|                     columns += string.Format("[{0}],", containerFieldmap[apifield]); |                     columns += string.Format("[{0}],", value); | ||||||
|                     parms += parmname; |                     parms += parmname; | ||||||
|                     parms += ","; |                     parms += ","; | ||||||
|                     parmnumber += 1; |                     parmnumber += 1; | ||||||
| 
 | 
 | ||||||
|                     object sqlValue = ((JValue)jp.Value).Value; |                     object sqlValue = ((JValue)jp.Value).Value; | ||||||
|                     if (sqlValue == null) |                     sqlValue ??= DBNull.Value; | ||||||
|                         sqlValue = DBNull.Value; |  | ||||||
| 
 | 
 | ||||||
|                     AddParameter(cmd, parmname, sqlValue); |                     AddParameter(cmd, parmname, sqlValue); | ||||||
|                 } |                 } | ||||||
| @ -269,12 +257,12 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         cmd.CommandText = columns.TrimEnd(',') + parms.TrimEnd(',') + ";SELECT SCOPE_IDENTITY();"; |         cmd.CommandText = columns.TrimEnd(',') + parms.TrimEnd(',') + ";SELECT SCOPE_IDENTITY();"; | ||||||
| 
 | 
 | ||||||
|         object o = cmd.ExecuteScalar(); |         object o = cmd.ExecuteScalar(); | ||||||
|         if ((o == null) || Convert.IsDBNull(o)) |         if ((o is null) || Convert.IsDBNull(o)) | ||||||
|             throw new Exception("Unexpected query result"); |             throw new Exception("Unexpected query result"); | ||||||
|         return Convert.ToInt64(o); |         return Convert.ToInt64(o); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public DataTable ExportData(string spName, DateTime startTime, DateTime endTime) |     internal DataTable ExportData(string spName, DateTime startTime, DateTime endTime) | ||||||
|     { |     { | ||||||
|         DataTable dt = new(); |         DataTable dt = new(); | ||||||
|         DateTime endTimeLocal = endTime.ToLocalTime(); |         DateTime endTimeLocal = endTime.ToLocalTime(); | ||||||
| @ -300,7 +288,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
| 
 | 
 | ||||||
|     protected string FormDynamicSelectQuery(IEnumerable<ToolTypeMetadata> fields, string tableName) |     protected string FormDynamicSelectQuery(IEnumerable<ToolTypeMetadata> fields, string tableName) | ||||||
|     { |     { | ||||||
|         System.Text.StringBuilder sb = new(); |         StringBuilder sb = new(); | ||||||
|         _ = sb.Append("SELECT "); |         _ = sb.Append("SELECT "); | ||||||
|         bool firstField = true; |         bool firstField = true; | ||||||
|         foreach (ToolTypeMetadata f in fields) |         foreach (ToolTypeMetadata f in fields) | ||||||
| @ -309,7 +297,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|             { |             { | ||||||
|                 if (!firstField) |                 if (!firstField) | ||||||
|                     _ = sb.Append(','); |                     _ = sb.Append(','); | ||||||
|                 if (f.GridAttributes != null && f.GridAttributes.Contains("isNull")) |                 if (f.GridAttributes is not null && f.GridAttributes.Contains("isNull")) | ||||||
|                 { |                 { | ||||||
|                     _ = sb.AppendFormat("{0}", "ISNULL(" + f.ColumnName + ", '')[" + f.ColumnName + "]"); |                     _ = sb.AppendFormat("{0}", "ISNULL(" + f.ColumnName + ", '')[" + f.ColumnName + "]"); | ||||||
|                 } |                 } | ||||||
| @ -324,20 +312,20 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return sb.ToString(); |         return sb.ToString(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public DataTable GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerId, out long totalRecords) |     internal DataTable GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerId, out long totalRecords) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); |         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); | ||||||
|         if (md == null) |         if (md is null) | ||||||
|             throw new Exception("Invalid tool type metadata"); |             throw new Exception("Invalid tool type metadata"); | ||||||
| 
 | 
 | ||||||
|         DataTable dt = new(); |         DataTable dt = new(); | ||||||
|         using (DbConnection conn = GetDbConnection()) |         using (DbConnection conn = GetDbConnection()) | ||||||
|         { |         { | ||||||
|             System.Text.StringBuilder sb = new(); |             StringBuilder sb = new(); | ||||||
|             _ = sb.Append( |             _ = sb.Append( | ||||||
|                 FormDynamicSelectQuery( |                 FormDynamicSelectQuery( | ||||||
|                     md.Where(m => m.Header == true).ToList(), |                     md.Where(m => m.Header == true).ToList(), | ||||||
| @ -417,20 +405,20 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return dt; |         return dt; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public DataTable GetData(int toolTypeId, long headerid) |     internal DataTable GetData(int toolTypeId, long headerid) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); |         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); | ||||||
|         if (md == null) |         if (md is null) | ||||||
|             throw new Exception("Invalid tool type metadata"); |             throw new Exception("Invalid tool type metadata"); | ||||||
| 
 | 
 | ||||||
|         DataTable dt = new(); |         DataTable dt = new(); | ||||||
|         using (DbConnection conn = GetDbConnection()) |         using (DbConnection conn = GetDbConnection()) | ||||||
|         { |         { | ||||||
|             System.Text.StringBuilder sb = new(); |             StringBuilder sb = new(); | ||||||
|             _ = sb.Append( |             _ = sb.Append( | ||||||
|                 FormDynamicSelectQuery( |                 FormDynamicSelectQuery( | ||||||
|                     md.Where(m => m.Header == false).OrderBy(m => m.GridDisplayOrder).ToList(), |                     md.Where(m => m.Header == false).OrderBy(m => m.GridDisplayOrder).ToList(), | ||||||
| @ -512,10 +500,10 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return dt; |         return dt; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Guid GetHeaderAttachmentID(int toolTypeId, long headerId) |     internal Guid GetHeaderAttachmentID(int toolTypeId, long headerId) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -524,10 +512,10 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|             $"SELECT AttachmentID FROM [{tt.HeaderTableName}] WHERE ID = @HeaderID"; |             $"SELECT AttachmentID FROM [{tt.HeaderTableName}] WHERE ID = @HeaderID"; | ||||||
|         return conn.ExecuteScalar<Guid>(sql, param: new { HeaderID = headerId }); |         return conn.ExecuteScalar<Guid>(sql, param: new { HeaderID = headerId }); | ||||||
|     } |     } | ||||||
|     public string GetHeaderInsertDate(int toolTypeId, long headerId) |     internal string GetHeaderInsertDate(int toolTypeId, long headerId) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -535,7 +523,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|             $"SELECT CONVERT(varchar, case when [InsertDate] < [Date] or [Date] is null then [InsertDate] else [Date] end, 120) d FROM[{tt.HeaderTableName}] where ID = @HeaderID"; |             $"SELECT CONVERT(varchar, case when [InsertDate] < [Date] or [Date] is null then [InsertDate] else [Date] end, 120) d FROM[{tt.HeaderTableName}] where ID = @HeaderID"; | ||||||
|         return conn.ExecuteScalar<string>(sql, param: new { HeaderID = headerId }); |         return conn.ExecuteScalar<string>(sql, param: new { HeaderID = headerId }); | ||||||
|     } |     } | ||||||
|     public string GetAttachmentInsertDateByGUID(string tableName, Guid attachmentId) |     internal string GetAttachmentInsertDateByGUID(string tableName, Guid attachmentId) | ||||||
|     { |     { | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
|         string sql = ""; |         string sql = ""; | ||||||
| @ -550,16 +538,16 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
| 
 | 
 | ||||||
|         return conn.ExecuteScalar<string>(sql, param: new { AttachmentID = attachmentId }); |         return conn.ExecuteScalar<string>(sql, param: new { AttachmentID = attachmentId }); | ||||||
|     } |     } | ||||||
|     public void SetHeaderDirName(string tableName, long headerId, string dateDir) |     internal void SetHeaderDirName(string tableName, long headerId, string dateDir) | ||||||
|     { |     { | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
|         _ = conn.Execute($"UPDATE [{tableName}] SET AttachDirName = @AttachDirName WHERE ID = @HeaderID;", new { HeaderID = headerId, AttachDirName = dateDir }); |         _ = conn.Execute($"UPDATE [{tableName}] SET AttachDirName = @AttachDirName WHERE ID = @HeaderID;", new { HeaderID = headerId, AttachDirName = dateDir }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Guid GetDataAttachmentID(int toolTypeId, long headerId, string title) |     internal Guid GetDataAttachmentID(int toolTypeId, long headerId, string title) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -569,10 +557,10 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return conn.ExecuteScalar<Guid>(sql, param: new { HeaderID = headerId, Title = title }); |         return conn.ExecuteScalar<Guid>(sql, param: new { HeaderID = headerId, Title = title }); | ||||||
|     } |     } | ||||||
|     // J Ouellette Added |     // J Ouellette Added | ||||||
|     public string GetDataInsertDate(int toolTypeId, long headerId, string title) |     internal string GetDataInsertDate(int toolTypeId, long headerId, string title) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -588,7 +576,7 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
| 
 | 
 | ||||||
|         return conn.ExecuteScalar<string>(sql, param: new { HeaderID = headerId, Title = title }); |         return conn.ExecuteScalar<string>(sql, param: new { HeaderID = headerId, Title = title }); | ||||||
|     } |     } | ||||||
|     public void SetDataDirName(string tableName, long headerId, string title, string dateDir) |     internal void SetDataDirName(string tableName, long headerId, string title, string dateDir) | ||||||
|     { |     { | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
|         string sql = |         string sql = | ||||||
| @ -596,16 +584,16 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         _ = conn.Execute(sql, param: new { HeaderID = headerId, Title = title, AttachDirName = dateDir }); |         _ = conn.Execute(sql, param: new { HeaderID = headerId, Title = title, AttachDirName = dateDir }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void PurgeExistingData(int toolTypeId, string title) |     internal void PurgeExistingData(int toolTypeId, string title) | ||||||
|     { |     { | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
|         _ = conn.Execute("PurgeExistingData", param: new { ToolTypeID = toolTypeId, Title = title }, commandType: CommandType.StoredProcedure); |         _ = conn.Execute("PurgeExistingData", param: new { ToolTypeID = toolTypeId, Title = title }, commandType: CommandType.StoredProcedure); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public DataSet GetOIExportData(int toolTypeId, long headerid) |     internal DataSet GetOIExportData(int toolTypeId, long headerid) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         if (string.IsNullOrWhiteSpace(tt.OIExportSPName)) |         if (string.IsNullOrWhiteSpace(tt.OIExportSPName)) | ||||||
| @ -631,26 +619,60 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return ds; |         return ds; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public IEnumerable<HeaderCommon> GetHeaderTitles(int toolTypeId, int? pageNo, int? pageSize, out long totalRecords) |     private HeaderCommon[] GetHeaderTitles() | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         IEnumerable<HeaderCommon> results; | ||||||
|         if (tt == null) |         ToolType[] toolTypes = GetToolTypes().ToArray(); | ||||||
|  | 
 | ||||||
|  |         if (!toolTypes.Any() || toolTypes.FirstOrDefault() is null) | ||||||
|  |             throw new Exception("Invalid tool type ID"); | ||||||
|  | 
 | ||||||
|  |         ToolType tt; | ||||||
|  |         StringBuilder stringBuilder = new(); | ||||||
|  |         using DbConnection conn = GetDbConnection(); | ||||||
|  |         _ = stringBuilder.Append(" SELECT * FROM ( "); | ||||||
|  |         for (int i = 0; i < toolTypes.Length; i++) | ||||||
|  |         { | ||||||
|  |             tt = toolTypes[i]; | ||||||
|  |             _ = stringBuilder.Append($" SELECT ID, InsertDate, AttachmentID, Title, [Date], {tt.ID} AS ToolTypeID, '{tt.ToolTypeName}' AS ToolTypeName, Reactor, RDS, PSN FROM {tt.HeaderTableName} "); | ||||||
|  |             if (i != toolTypes.Length - 1) | ||||||
|  |                 _ = stringBuilder.Append(" UNION ALL "); | ||||||
|  |         } | ||||||
|  |         _ = stringBuilder.Append(" ) AS A ORDER BY A.[Date] DESC "); | ||||||
|  |         results = conn.Query<HeaderCommon>(stringBuilder.ToString()).ToArray(); | ||||||
|  | 
 | ||||||
|  |         return results.ToArray(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     internal HeaderCommon[] GetHeaderTitles(int? toolTypeId, int? pageNo, int? pageSize, out long totalRecords) | ||||||
|  |     { | ||||||
|  |         HeaderCommon[] headers; | ||||||
|  |         if (toolTypeId is not null && (pageNo is not null || pageSize is not null)) | ||||||
|  |             throw new Exception(); | ||||||
|  | 
 | ||||||
|  |         if (toolTypeId is null) | ||||||
|  |         { | ||||||
|  |             headers = GetHeaderTitles(); | ||||||
|  |             totalRecords = headers.Length; | ||||||
|  |             return headers; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         ToolType tt = GetToolTypeByID(toolTypeId.Value); | ||||||
|  |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
|         string sql = $"SELECT ID, InsertDate, AttachmentID, Title, [Date] FROM {tt.HeaderTableName} ORDER BY [Date] DESC "; |         string sql = $"SELECT ID, InsertDate, AttachmentID, Title, [Date], {tt.ID} AS ToolTypeID, '{tt.ToolTypeName}' AS ToolTypeName, Reactor, RDS, PSN FROM {tt.HeaderTableName} ORDER BY [Date] DESC "; | ||||||
| 
 |  | ||||||
|         IEnumerable<HeaderCommon> headers; |  | ||||||
| 
 | 
 | ||||||
|         if (pageNo.HasValue && pageSize.HasValue) |         if (pageNo.HasValue && pageSize.HasValue) | ||||||
|         { |         { | ||||||
|             sql += "OFFSET @PageNum * @PageSize ROWS FETCH NEXT @PageSize ROWS ONLY"; |             sql += "OFFSET @PageNum * @PageSize ROWS FETCH NEXT @PageSize ROWS ONLY"; | ||||||
| 
 | 
 | ||||||
|             headers = conn.Query<HeaderCommon>(sql, param: new { PageNum = pageNo.Value, PageSize = pageSize.Value }).ToList(); |             headers = conn.Query<HeaderCommon>(sql, param: new { PageNum = pageNo.Value, PageSize = pageSize.Value }).ToArray(); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             headers = conn.Query<HeaderCommon>(sql).ToList(); |             headers = conn.Query<HeaderCommon>(sql).ToArray(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         sql = $"SELECT COUNT(*) FROM [{tt.HeaderTableName}] "; |         sql = $"SELECT COUNT(*) FROM [{tt.HeaderTableName}] "; | ||||||
| @ -660,14 +682,14 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return headers; |         return headers; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public IEnumerable<KeyValuePair<string, string>> GetHeaderFields(int toolTypeId, long headerid) |     internal IEnumerable<KeyValuePair<string, string>> GetHeaderFields(int toolTypeId, long headerid) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); |         IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId); | ||||||
|         if (md == null) |         if (md is null) | ||||||
|             throw new Exception("Invalid tool type metadata"); |             throw new Exception("Invalid tool type metadata"); | ||||||
| 
 | 
 | ||||||
|         List<KeyValuePair<string, string>> r = new(); |         List<KeyValuePair<string, string>> r = new(); | ||||||
| @ -694,10 +716,10 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|             foreach (ToolTypeMetadata m in md.Where(m => m.Header == true && m.TableDisplayOrder > 0).OrderBy(m => m.TableDisplayOrder)) |             foreach (ToolTypeMetadata m in md.Where(m => m.Header == true && m.TableDisplayOrder > 0).OrderBy(m => m.TableDisplayOrder)) | ||||||
|             { |             { | ||||||
|                 string v = ""; |                 string v = ""; | ||||||
|                 if (dr != null) |                 if (dr is not null) | ||||||
|                 { |                 { | ||||||
|                     object o = dr[m.ColumnName]; |                     object o = dr[m.ColumnName]; | ||||||
|                     if (o != null && !Convert.IsDBNull(o)) |                     if (o is not null && !Convert.IsDBNull(o)) | ||||||
|                         v = Convert.ToString(o); |                         v = Convert.ToString(o); | ||||||
|                 } |                 } | ||||||
|                 KeyValuePair<string, string> kvp = new(m.DisplayTitle, v); |                 KeyValuePair<string, string> kvp = new(m.DisplayTitle, v); | ||||||
| @ -707,16 +729,28 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return r; |         return r; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public IEnumerable<AwaitingDispo> GetAwaitingDispo() |     internal IEnumerable<AwaitingDisposition> GetAwaitingDisposition() | ||||||
|     { |     { | ||||||
|         using DbConnection conn = GetDbConnection(); |         IEnumerable<AwaitingDisposition>? r; | ||||||
|         return conn.Query<AwaitingDispo>("GetAwaitingDispo", commandType: CommandType.StoredProcedure); |         if (!string.IsNullOrEmpty(_MockRoot)) | ||||||
|  |         { | ||||||
|  |             string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetAwaitingDispositionApi.json")); | ||||||
|  |             r = System.Text.Json.JsonSerializer.Deserialize<IEnumerable<AwaitingDisposition>>(json); | ||||||
|  |             if (r is null) | ||||||
|  |                 throw new NullReferenceException(nameof(r)); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             using DbConnection conn = GetDbConnection(); | ||||||
|  |             r = conn.Query<AwaitingDisposition>("GetAwaitingDispo", commandType: CommandType.StoredProcedure); | ||||||
|  |         } | ||||||
|  |         return r; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public int UpdateReviewDate(int toolTypeId, long headerId, bool clearDate) |     internal int UpdateReviewDate(int toolTypeId, long headerId, bool clearDate) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -735,10 +769,10 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Guid GetHeaderAttachmentIDByTitle(int toolTypeId, string title) |     internal Guid GetHeaderAttachmentIDByTitle(int toolTypeId, string title) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -747,10 +781,10 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return conn.ExecuteScalar<Guid>(sql, param: new { Title = title }); |         return conn.ExecuteScalar<Guid>(sql, param: new { Title = title }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Guid GetDataAttachmentIDByTitle(int toolTypeId, string title) |     internal Guid GetDataAttachmentIDByTitle(int toolTypeId, string title) | ||||||
|     { |     { | ||||||
|         ToolType tt = GetToolTypeByID(toolTypeId); |         ToolType tt = GetToolTypeByID(toolTypeId); | ||||||
|         if (tt == null) |         if (tt is null) | ||||||
|             throw new Exception("Invalid tool type ID"); |             throw new Exception("Invalid tool type ID"); | ||||||
| 
 | 
 | ||||||
|         using DbConnection conn = GetDbConnection(); |         using DbConnection conn = GetDbConnection(); | ||||||
| @ -759,5 +793,31 @@ public class MetrologyRepo : IMetrologyRepo | |||||||
|         return conn.ExecuteScalar<Guid>(sql, param: new { Title = title }); |         return conn.ExecuteScalar<Guid>(sql, param: new { Title = title }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     DataTable IMetrologyRepo.GetDataSharePoint(int toolTypeId, string headerId) => throw new NotImplementedException(); |     DataTable IMetrologyRepository.GetDataSharePoint(int toolTypeId, string headerId) => throw new NotImplementedException(); | ||||||
|  | 
 | ||||||
|  |     IEnumerable<ToolType> IMetrologyRepository.GetToolTypes() => GetToolTypes(); | ||||||
|  |     ToolType IMetrologyRepository.GetToolTypeByName(string name) => GetToolTypeByName(name); | ||||||
|  |     ToolType IMetrologyRepository.GetToolTypeByID(int id) => GetToolTypeByID(id); | ||||||
|  |     IEnumerable<ToolTypeMetadata> IMetrologyRepository.GetToolTypeMetadataByToolTypeID(int id) => GetToolTypeMetadataByToolTypeID(id); | ||||||
|  |     TransactionScope IMetrologyRepository.StartTransaction() => StartTransaction(); | ||||||
|  |     void IMetrologyRepository.PurgeExistingData(int toolTypeId, string title) => PurgeExistingData(toolTypeId, title); | ||||||
|  |     long IMetrologyRepository.InsertToolDataJSON(JToken jsonbody, long headerId, List<ToolTypeMetadata> metaData, string tableName) => InsertToolDataJSON(jsonbody, headerId, metaData, tableName); | ||||||
|  |     DataTable IMetrologyRepository.ExportData(string spName, DateTime startTime, DateTime endTime) => ExportData(spName, startTime, endTime); | ||||||
|  |     DataTable IMetrologyRepository.GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerid, out long totalRecords) => GetHeaders(toolTypeId, startTime, endTime, pageNo, pageSize, headerid, out totalRecords); | ||||||
|  |     DataTable IMetrologyRepository.GetData(int toolTypeId, long headerId) => GetData(toolTypeId, headerId); | ||||||
|  |     HeaderCommon[] IMetrologyRepository.GetHeaderTitles(int? toolTypeId, int? pageNo, int? pageSize, out long totalRecords) => GetHeaderTitles(toolTypeId, pageNo, pageSize, out totalRecords); | ||||||
|  |     Guid IMetrologyRepository.GetHeaderAttachmentIDByTitle(int toolTypeId, string title) => GetHeaderAttachmentIDByTitle(toolTypeId, title); | ||||||
|  |     Guid IMetrologyRepository.GetDataAttachmentIDByTitle(int toolTypeId, string title) => GetDataAttachmentIDByTitle(toolTypeId, title); | ||||||
|  |     Guid IMetrologyRepository.GetHeaderAttachmentID(int toolTypeId, long headerId) => GetHeaderAttachmentID(toolTypeId, headerId); | ||||||
|  |     string IMetrologyRepository.GetHeaderInsertDate(int toolTypeId, long headerId) => GetHeaderInsertDate(toolTypeId, headerId); | ||||||
|  |     string IMetrologyRepository.GetAttachmentInsertDateByGUID(string tableName, Guid attachmentId) => GetAttachmentInsertDateByGUID(tableName, attachmentId); | ||||||
|  |     void IMetrologyRepository.SetHeaderDirName(string tableName, long headerId, string dateDir) => SetHeaderDirName(tableName, headerId, dateDir); | ||||||
|  |     Guid IMetrologyRepository.GetDataAttachmentID(int toolTypeId, long headerId, string title) => GetDataAttachmentID(toolTypeId, headerId, title); | ||||||
|  |     string IMetrologyRepository.GetDataInsertDate(int toolTypeId, long headerId, string title) => GetDataInsertDate(toolTypeId, headerId, title); | ||||||
|  |     void IMetrologyRepository.SetDataDirName(string tableName, long headerId, string title, string dateDir) => SetDataDirName(tableName, headerId, title, dateDir); | ||||||
|  |     DataSet IMetrologyRepository.GetOIExportData(int toolTypeId, long headerid) => GetOIExportData(toolTypeId, headerid); | ||||||
|  |     IEnumerable<KeyValuePair<string, string>> IMetrologyRepository.GetHeaderFields(int toolTypeId, long headerid) => GetHeaderFields(toolTypeId, headerid); | ||||||
|  |     IEnumerable<AwaitingDisposition> IMetrologyRepository.GetAwaitingDisposition() => GetAwaitingDisposition(); | ||||||
|  |     int IMetrologyRepository.UpdateReviewDate(int toolTypeId, long headerId, bool clearDate) => UpdateReviewDate(toolTypeId, headerId, clearDate); | ||||||
|  | 
 | ||||||
| } | } | ||||||
							
								
								
									
										120
									
								
								Server/Repositories/PinRepository.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,120 @@ | |||||||
|  | using OI.Metrology.Shared.DataModels; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  | using System.Text.Json; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.Repository; | ||||||
|  |  | ||||||
|  | public class PinRepository : IPinRepository | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly string _MockRoot; | ||||||
|  |     private readonly Serilog.ILogger _Log; | ||||||
|  |     private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection; | ||||||
|  |  | ||||||
|  |     public PinRepository(string mockRoot) | ||||||
|  |     { | ||||||
|  |         _MockRoot = mockRoot; | ||||||
|  |         _RdsToHeaderCommonCollection = new(); | ||||||
|  |         _Log = Serilog.Log.ForContext<PinRepository>(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     void IPinRepository.SetPinnedTable(HeaderCommon headerCommon) | ||||||
|  |     { | ||||||
|  |         Dictionary<long, HeaderCommon>? toolIdToHeader; | ||||||
|  |         if (!string.IsNullOrEmpty(headerCommon.RDS)) | ||||||
|  |         { | ||||||
|  |             if (!_RdsToHeaderCommonCollection.TryGetValue(headerCommon.RDS, out toolIdToHeader)) | ||||||
|  |             { | ||||||
|  |                 _RdsToHeaderCommonCollection.Add(headerCommon.RDS, new()); | ||||||
|  |                 if (!_RdsToHeaderCommonCollection.TryGetValue(headerCommon.RDS, out toolIdToHeader)) | ||||||
|  |                     throw new Exception(); | ||||||
|  |             } | ||||||
|  |             if (toolIdToHeader.ContainsKey(headerCommon.ToolTypeID)) | ||||||
|  |                 toolIdToHeader[headerCommon.ToolTypeID] = headerCommon; | ||||||
|  |             else | ||||||
|  |                 toolIdToHeader.Add(headerCommon.ToolTypeID, headerCommon); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private (HeaderCommon?, HeaderCommon?) GetBoth(string rds, long bioRadId, long cdeId) | ||||||
|  |     { | ||||||
|  |         Dictionary<long, HeaderCommon>? toolIdToHeader; | ||||||
|  |         if (!_RdsToHeaderCommonCollection.TryGetValue(rds, out toolIdToHeader)) | ||||||
|  |         { | ||||||
|  |             _RdsToHeaderCommonCollection.Add(rds, new()); | ||||||
|  |             if (!_RdsToHeaderCommonCollection.TryGetValue(rds, out toolIdToHeader)) | ||||||
|  |                 throw new Exception(); | ||||||
|  |         } | ||||||
|  |         _ = toolIdToHeader.TryGetValue(cdeId, out HeaderCommon? cdeHeader); | ||||||
|  |         _ = toolIdToHeader.TryGetValue(bioRadId, out HeaderCommon? bioRadHeader); | ||||||
|  |         return new(bioRadHeader, cdeHeader); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static Pinned? GetPinned(IMetrologyRepository metrologyRepository, HeaderCommon headerCommon, int points, int column) | ||||||
|  |     { | ||||||
|  |         Pinned? result; | ||||||
|  |         List<string> values; | ||||||
|  |         System.Data.DataTable dataTable = metrologyRepository.GetData((int)headerCommon.ToolTypeID, headerCommon.ID); | ||||||
|  |         if (dataTable.Rows.Count <= points || dataTable.Columns.Count <= column) | ||||||
|  |             result = null; | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             values = new(); | ||||||
|  |             for (int i = 0; i < dataTable.Rows.Count - 1; i++) | ||||||
|  |             { | ||||||
|  |                 if (dataTable.Rows[i]?.ItemArray[column] is null) | ||||||
|  |                     break; | ||||||
|  |                 values.Add(string.Concat(dataTable.Rows[i].ItemArray[column])); | ||||||
|  |             } | ||||||
|  |             if (values.Count <= points) | ||||||
|  |                 result = null; | ||||||
|  |             else | ||||||
|  |                 result = new(headerCommon, values); | ||||||
|  |         } | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     Result<Pinned[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? biorad_id, string? cde_id, string? rds) | ||||||
|  |     { | ||||||
|  |         Result<Pinned[]>? r; | ||||||
|  |         if (!string.IsNullOrEmpty(_MockRoot)) | ||||||
|  |         { | ||||||
|  |             string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetPinnedTableApi.json")); | ||||||
|  |             r = JsonSerializer.Deserialize<Result<Pinned[]>>(json); | ||||||
|  |             if (r is null) | ||||||
|  |                 throw new NullReferenceException(nameof(r)); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             if (string.IsNullOrEmpty(rds) || !long.TryParse(biorad_id, out long bioRadId) || !long.TryParse(cde_id, out long cdeId)) | ||||||
|  |                 r = new() { Results = Array.Empty<Pinned>(), TotalRows = 0 }; | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 const int points = 9; | ||||||
|  |                 List<Pinned> results = new(); | ||||||
|  |                 (HeaderCommon? bioRadHeader, HeaderCommon? cdeHeader) = GetBoth(rds, bioRadId, cdeId); | ||||||
|  |                 if (bioRadHeader is not null) | ||||||
|  |                 { | ||||||
|  |                     const int thickness = 5; | ||||||
|  |                     Pinned? pinned = GetPinned(metrologyRepository, bioRadHeader, points, column: thickness); | ||||||
|  |                     if (pinned is not null) | ||||||
|  |                         results.Add(pinned); | ||||||
|  |                 } | ||||||
|  |                 if (cdeHeader is not null) | ||||||
|  |                 { | ||||||
|  |                     const int rs = 6; | ||||||
|  |                     Pinned? pinned = GetPinned(metrologyRepository, cdeHeader, points, column: rs); | ||||||
|  |                     if (pinned is not null) | ||||||
|  |                         results.Add(pinned); | ||||||
|  |                 } | ||||||
|  |                 r = new() | ||||||
|  |                 { | ||||||
|  |                     Results = results.ToArray(), | ||||||
|  |                     TotalRows = results.Count, | ||||||
|  |                 }; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return r; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										56
									
								
								Server/Repositories/ServiceShopOrderRepository.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,56 @@ | |||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  | using OI.Metrology.Shared.ViewModels; | ||||||
|  | using Serilog.Context; | ||||||
|  | using System.Text.Json; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.Repository; | ||||||
|  |  | ||||||
|  | public class ServiceShopOrderRepository : IServiceShopOrderRepository | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly Serilog.ILogger _Log; | ||||||
|  |  | ||||||
|  |     public ServiceShopOrderRepository() => _Log = Serilog.Log.ForContext<ServiceShopOrderRepository>(); | ||||||
|  |  | ||||||
|  |     private static ServiceShopOrder[] GetServiceShopOrders(Shared.Models.ServiceShop? serviceShop) | ||||||
|  |     { | ||||||
|  |         ServiceShopOrder[] result = IServiceShopOrder.GetServiceShopOrders(serviceShop); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static Shared.Models.ServiceShop? GetServiceShopOrders() | ||||||
|  |     { | ||||||
|  |         Shared.Models.ServiceShop? result; | ||||||
|  |         string jsonFile; | ||||||
|  |         string checkDirectory = Path.Combine(AppContext.BaseDirectory, "Data/Mike"); | ||||||
|  |         if (Directory.Exists(checkDirectory)) | ||||||
|  |             jsonFile = Path.Combine(checkDirectory, "service-shop.json"); | ||||||
|  |         else | ||||||
|  |             jsonFile = Path.Combine(AppContext.BaseDirectory, "service-shop.json"); | ||||||
|  |         string json = File.ReadAllText(jsonFile); | ||||||
|  |         result = JsonSerializer.Deserialize<Shared.Models.ServiceShop>(json); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async Task<ServiceShopOrder[]> IServiceShopOrderRepository.GetAllServiceShopOrders() | ||||||
|  |     { | ||||||
|  |         ServiceShopOrder[] results; | ||||||
|  |         string? methodName = IMethodName.GetActualAsyncMethodName(); | ||||||
|  |         using (LogContext.PushProperty("MethodName", methodName)) | ||||||
|  |         { | ||||||
|  |             _Log.Debug("() => ..."); | ||||||
|  |             Shared.Models.ServiceShop? serviceShop = await Task.Run(GetServiceShopOrders); | ||||||
|  |             results = GetServiceShopOrders(serviceShop); | ||||||
|  |         } | ||||||
|  |         return results.ToArray(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async Task<ServiceShopOrder[]> IServiceShopOrderRepository.GetServiceShopOrders(string id) | ||||||
|  |     { | ||||||
|  |         ServiceShopOrder[] results; | ||||||
|  |         Shared.Models.ServiceShop? serviceShop = await Task.Run(GetServiceShopOrders); | ||||||
|  |         results = GetServiceShopOrders(serviceShop).Where(l => l.Id == id).ToArray(); | ||||||
|  |         return results; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										340
									
								
								Server/Repositories/ToolTypesRepository.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,340 @@ | |||||||
|  | using OI.Metrology.Shared.DataModels; | ||||||
|  | using OI.Metrology.Shared.Models.Stateless; | ||||||
|  | using OI.Metrology.Shared.Services; | ||||||
|  | using System.Data; | ||||||
|  | using System.Text; | ||||||
|  | using System.Text.Json; | ||||||
|  |  | ||||||
|  | namespace OI.Metrology.Server.Repository; | ||||||
|  |  | ||||||
|  | public class ToolTypesRepository : IToolTypesRepository | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private readonly string _MockRoot; | ||||||
|  |     private readonly Serilog.ILogger _Log; | ||||||
|  |  | ||||||
|  |     public ToolTypesRepository(string mockRoot) | ||||||
|  |     { | ||||||
|  |         _MockRoot = mockRoot; | ||||||
|  |         _Log = Serilog.Log.ForContext<ToolTypesRepository>(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // Get a list of tooltypes, returns just Name and ID | ||||||
|  |     Result<ToolTypeNameId[]> IToolTypesRepository.Index(IMetrologyRepository metrologyRepository) | ||||||
|  |     { | ||||||
|  |         Result<ToolTypeNameId[]>? r; | ||||||
|  |         if (!string.IsNullOrEmpty(_MockRoot)) | ||||||
|  |         { | ||||||
|  |             string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "IndexApi.json")); | ||||||
|  |             r = JsonSerializer.Deserialize<Result<ToolTypeNameId[]>>(json); | ||||||
|  |             if (r is null) | ||||||
|  |                 throw new NullReferenceException(nameof(r)); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             ToolTypeNameId[] toolTypeNameIdCollection = metrologyRepository.GetToolTypes().Select(tt => new ToolTypeNameId() { ToolTypeName = tt.ToolTypeName, ID = tt.ID }).ToArray(); | ||||||
|  |             r = new() | ||||||
|  |             { | ||||||
|  |                 Results = toolTypeNameIdCollection, | ||||||
|  |                 TotalRows = toolTypeNameIdCollection.Length, | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |         return r; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // Gets the metadata for a tooltype, accepts a parameter which sorts the results | ||||||
|  |     // This is used to setup the grid displays on the UI | ||||||
|  |     Result<ToolTypeMetadataResult> IToolTypesRepository.GetToolTypeMetadata(IMetrologyRepository metrologyRepository, int id, string sortby) | ||||||
|  |     { | ||||||
|  |         Result<ToolTypeMetadataResult>? r; | ||||||
|  |         if (!string.IsNullOrEmpty(_MockRoot)) | ||||||
|  |         { | ||||||
|  |             string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetToolTypeMetadataApi.json")); | ||||||
|  |             r = JsonSerializer.Deserialize<Result<ToolTypeMetadataResult>>(json); | ||||||
|  |             if (r is null) | ||||||
|  |                 throw new NullReferenceException(nameof(r)); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             ToolType tt = metrologyRepository.GetToolTypeByID(id); | ||||||
|  |             IEnumerable<ToolTypeMetadata> md = metrologyRepository.GetToolTypeMetadataByToolTypeID(id); | ||||||
|  |  | ||||||
|  |             if (string.Equals(sortby, "grid", StringComparison.OrdinalIgnoreCase)) | ||||||
|  |                 md = md.OrderBy(f => f.GridDisplayOrder).ToList(); | ||||||
|  |             if (string.Equals(sortby, "table", StringComparison.OrdinalIgnoreCase)) | ||||||
|  |                 md = md.OrderBy(f => f.GridDisplayOrder).ToList(); | ||||||
|  |  | ||||||
|  |             ToolTypeMetadataResult toolTypeMetadataResult = new(tt, md.ToArray()); | ||||||
|  |             int totalRows = toolTypeMetadataResult.Metadata is not null ? toolTypeMetadataResult.Metadata.Length : 0; | ||||||
|  |             r = new() | ||||||
|  |             { | ||||||
|  |                 Results = toolTypeMetadataResult, | ||||||
|  |                 TotalRows = totalRows, | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |         return r; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // Gets headers, request/response format is to allow paging with igniteUI | ||||||
|  |     // The headerid parameter is used for navigating directly to a header, when the button is clicked in Awaiting Dispo | ||||||
|  |     Result<DataTable> IToolTypesRepository.GetHeaders(IMetrologyRepository metrologyRepository, int id, DateTime? datebegin, DateTime? dateend, int? page, int? pagesize, long? headerid) | ||||||
|  |     { | ||||||
|  |         Result<DataTable>? r; | ||||||
|  |         if (!string.IsNullOrEmpty(_MockRoot)) | ||||||
|  |         { | ||||||
|  |             string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetHeadersApi.json")); | ||||||
|  |             r = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json); | ||||||
|  |             if (r is null) | ||||||
|  |                 throw new NullReferenceException(nameof(r)); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             long totalRecs; | ||||||
|  |             DataTable dataTable = metrologyRepository.GetHeaders(id, datebegin, dateend, page, pagesize, headerid, out totalRecs); | ||||||
|  |             r = new() | ||||||
|  |             { | ||||||
|  |                 Results = dataTable, | ||||||
|  |                 TotalRows = totalRecs, | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |         return r; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // Gets header titles, used in the Run Headers UI | ||||||
|  |     Result<HeaderCommon[]> IToolTypesRepository.GetHeaderTitles(IMetrologyRepository metrologyRepository, int id, int? page, int? pagesize) | ||||||
|  |     { | ||||||
|  |         Result<HeaderCommon[]>? r; | ||||||
|  |         if (!string.IsNullOrEmpty(_MockRoot)) | ||||||
|  |         { | ||||||
|  |             string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetHeaderTitlesApi.json")); | ||||||
|  |             r = JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json); | ||||||
|  |             if (r is null) | ||||||
|  |                 throw new NullReferenceException(nameof(r)); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             long totalRecs; | ||||||
|  |             int? toolTypeId = id > -1 ? id : null; | ||||||
|  |             HeaderCommon[] headerCommonCollection = metrologyRepository.GetHeaderTitles(toolTypeId, page, pagesize, out totalRecs).ToArray(); | ||||||
|  |             r = new() | ||||||
|  |             { | ||||||
|  |                 Results = headerCommonCollection, | ||||||
|  |                 TotalRows = totalRecs, | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |         return r; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // Get all of the fields for a header, used with the Run Header UI | ||||||
|  |     Result<ColumnValue[]> IToolTypesRepository.GetHeaderFields(IMetrologyRepository metrologyRepository, int id, long headerid) | ||||||
|  |     { | ||||||
|  |         Result<ColumnValue[]>? r; | ||||||
|  |         if (!string.IsNullOrEmpty(_MockRoot)) | ||||||
|  |         { | ||||||
|  |             string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetHeaderFieldsApi.json")); | ||||||
|  |             r = JsonSerializer.Deserialize<Result<ColumnValue[]>>(json); | ||||||
|  |             if (r is null) | ||||||
|  |                 throw new NullReferenceException(nameof(r)); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             ColumnValue[] columnValueCollection = metrologyRepository.GetHeaderFields(id, headerid).Select(x => new ColumnValue() { Column = x.Key, Value = x.Value }).ToArray(); | ||||||
|  |             r = new() | ||||||
|  |             { | ||||||
|  |                 Results = columnValueCollection, | ||||||
|  |                 TotalRows = columnValueCollection.Length, | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |         return r; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // Get the data for a header, used with the Run Info UI | ||||||
|  |     Result<DataTable> IToolTypesRepository.GetData(IMetrologyRepository metrologyRepository, int id, long headerid) | ||||||
|  |     { | ||||||
|  |         Result<DataTable>? r; | ||||||
|  |         if (!string.IsNullOrEmpty(_MockRoot)) | ||||||
|  |         { | ||||||
|  |             string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetDataApi.json")); | ||||||
|  |             r = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json); | ||||||
|  |             if (r is null) | ||||||
|  |                 throw new NullReferenceException(nameof(r)); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             DataTable dataTable = metrologyRepository.GetData(id, headerid); | ||||||
|  |             r = new() | ||||||
|  |             { | ||||||
|  |                 Results = dataTable, | ||||||
|  |                 TotalRows = dataTable.Rows.Count, | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |         return r; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // Display an attachment, used for Run Info - note it is by tool type ID and attachment GUID, so it is best for internal use | ||||||
|  |     (string?, string?, Stream?) IToolTypesRepository.GetAttachment(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, int toolTypeId, string tabletype, string attachmentId, string filename) | ||||||
|  |     { | ||||||
|  |         Stream? stream = null; | ||||||
|  |         string? message = null; | ||||||
|  |         Guid attachmentIdParsed; | ||||||
|  |         string? contenttype = null; | ||||||
|  |         ToolType tt = metrologyRepository.GetToolTypeByID(toolTypeId); | ||||||
|  |         bool header = !string.Equals(tabletype.Trim(), "data", StringComparison.OrdinalIgnoreCase); | ||||||
|  |         if (!Guid.TryParse(attachmentId, out attachmentIdParsed)) | ||||||
|  |             message = "Invalid attachment id"; | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 // figure out what content type to use.  this is very simple because there are only two types being used | ||||||
|  |                 contenttype = "application/pdf"; | ||||||
|  |                 if (filename.ToLower().TrimEnd().EndsWith(".txt")) | ||||||
|  |                     contenttype = "text/plain"; | ||||||
|  |                 // Get attachment stream and feed it to the client | ||||||
|  |                 stream = attachmentsService.GetAttachmentStreamByAttachmentId(tt, header, attachmentIdParsed, filename); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) { message = ex.Message; } | ||||||
|  |         } | ||||||
|  |         return new(message, contenttype, stream); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // This endpoint triggers writing of the OI Export file | ||||||
|  |     Exception? IToolTypesRepository.OIExport(IMetrologyRepository metrologyRepository, string oiExportPath, int toolTypeId, long headerid) | ||||||
|  |     { | ||||||
|  |         Exception? result = null; | ||||||
|  |         // Call the export stored procedure | ||||||
|  |         _Log.Debug($"Exporting to <{oiExportPath}>"); | ||||||
|  |         DataSet ds = metrologyRepository.GetOIExportData(toolTypeId, headerid); | ||||||
|  |         try | ||||||
|  |         { | ||||||
|  |             // The SP must return 3 result tables | ||||||
|  |             if (ds.Tables.Count != 3) | ||||||
|  |                 throw new Exception("Error exporting, invalid results"); | ||||||
|  |             // The first table has just one row, which is the export filename | ||||||
|  |             if (ds.Tables[0].Rows.Count != 1) | ||||||
|  |                 throw new Exception("Error exporting, invalid filename"); | ||||||
|  |             string? filename = Convert.ToString(ds.Tables[0].Rows[0][0]); | ||||||
|  |             // The second table has the header data | ||||||
|  |             if (ds.Tables[1].Rows.Count != 1) | ||||||
|  |                 throw new Exception("Error exporting, invalid header data"); | ||||||
|  |             StringBuilder sb = new(); | ||||||
|  |             foreach (object? o in ds.Tables[1].Rows[0].ItemArray) | ||||||
|  |             { | ||||||
|  |                 if ((o is not null) && (!Convert.IsDBNull(o))) | ||||||
|  |                     _ = sb.Append(Convert.ToString(o)); | ||||||
|  |                 _ = sb.Append('\t'); | ||||||
|  |             } | ||||||
|  |             // The third table has the detail data | ||||||
|  |             foreach (DataRow dr in ds.Tables[2].Rows) | ||||||
|  |             { | ||||||
|  |                 foreach (object? o in dr.ItemArray) | ||||||
|  |                 { | ||||||
|  |                     if ((o is not null) && (!Convert.IsDBNull(o))) | ||||||
|  |                         _ = sb.Append(Convert.ToString(o)); | ||||||
|  |                     _ = sb.Append('\t'); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             _ = sb.AppendLine(); | ||||||
|  |             // The output file will only have one line, the header columns are output first | ||||||
|  |             // Then each detail rows has it's columns appended | ||||||
|  |             // H1, H2, H3, D1.1, D1.2, D1.3, D2.1, D2.2, D2.3, etc | ||||||
|  |             // Write the file | ||||||
|  |             File.WriteAllText(Path.Join(oiExportPath, filename), sb.ToString()); | ||||||
|  |         } | ||||||
|  |         catch (Exception ex) { result = ex; } | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     Result<DataTable> IToolTypesRepository.GetExportData(IMetrologyRepository metrologyRepository, int toolTypeId, DateTime? datebegin, DateTime? dateend) | ||||||
|  |     { | ||||||
|  |         Result<DataTable>? r; | ||||||
|  |         if (!string.IsNullOrEmpty(_MockRoot)) | ||||||
|  |         { | ||||||
|  |             string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetExportDataApi.json")); | ||||||
|  |             r = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json); | ||||||
|  |             if (r is null) | ||||||
|  |                 throw new NullReferenceException(nameof(r)); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             dateend ??= DateTime.Now; | ||||||
|  |             datebegin ??= dateend.Value.AddMonths(-1); | ||||||
|  |             ToolType tt = metrologyRepository.GetToolTypeByID(toolTypeId); | ||||||
|  |             if (string.IsNullOrEmpty(tt.ExportSPName)) | ||||||
|  |                 throw new NullReferenceException(nameof(tt.ExportSPName)); | ||||||
|  |             DataTable dataTable = metrologyRepository.ExportData(tt.ExportSPName, datebegin.Value, dateend.Value); | ||||||
|  |             r = new() | ||||||
|  |             { | ||||||
|  |                 Results = dataTable, | ||||||
|  |                 TotalRows = dataTable.Rows.Count, | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |         return r; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     protected static string GetRowData(DataRow dr) | ||||||
|  |     { | ||||||
|  |         StringBuilder result = new(); | ||||||
|  |         for (int i = 0; i < dr.Table.Columns.Count; i++) | ||||||
|  |         { | ||||||
|  |             if (i > 0) | ||||||
|  |                 _ = result.Append(','); | ||||||
|  |             object v = dr[i]; | ||||||
|  |             if (v is not null && !Convert.IsDBNull(v)) | ||||||
|  |                 _ = result.Append(FormatForCSV(string.Concat(Convert.ToString(v)))); | ||||||
|  |         } | ||||||
|  |         return result.ToString(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     protected static string GetColumnHeaders(DataTable dataTable) | ||||||
|  |     { | ||||||
|  |         StringBuilder result = new(); | ||||||
|  |         for (int i = 0; i < dataTable.Columns.Count; i++) | ||||||
|  |         { | ||||||
|  |             if (i > 0) | ||||||
|  |                 _ = result.Append(','); | ||||||
|  |             _ = result.Append(FormatForCSV(dataTable.Columns[i].ColumnName.TrimEnd('_'))); | ||||||
|  |         } | ||||||
|  |         return result.ToString(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     protected static string FormatForCSV(string v) | ||||||
|  |     { | ||||||
|  |         StringBuilder result = new(v.Length + 2); | ||||||
|  |         bool doubleQuoted = false; | ||||||
|  |         if (v.StartsWith(' ') || v.EndsWith(' ') || v.Contains(',') || v.Contains('"')) | ||||||
|  |         { | ||||||
|  |             _ = result.Append('"'); | ||||||
|  |             doubleQuoted = true; | ||||||
|  |         } | ||||||
|  |         foreach (char c in v) | ||||||
|  |         { | ||||||
|  |             _ = c switch | ||||||
|  |             { | ||||||
|  |                 '\r' or '\n' => result.Append(' '), | ||||||
|  |                 '"' => result.Append("\"\""), | ||||||
|  |                 _ => result.Append(c), | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |         if (doubleQuoted) | ||||||
|  |             _ = result.Append('"'); | ||||||
|  |         return result.ToString(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     byte[] IToolTypesRepository.GetCSVExport(IMetrologyRepository metrologyRepository, int toolTypeId, DateTime? datebegin, DateTime? dateend) | ||||||
|  |     { | ||||||
|  |         byte[] results; | ||||||
|  |         Result<DataTable> result; | ||||||
|  |         IToolTypesRepository repository = this; | ||||||
|  |         result = repository.GetExportData(metrologyRepository, toolTypeId, datebegin, dateend); | ||||||
|  |         if (result.Results is null) | ||||||
|  |             throw new NullReferenceException(nameof(result.Results)); | ||||||
|  |         StringBuilder stringBuilder = new(); | ||||||
|  |         _ = stringBuilder.AppendLine(GetColumnHeaders(result.Results)); | ||||||
|  |         foreach (DataRow dr in result.Results.Rows) | ||||||
|  |             _ = stringBuilder.AppendLine(GetRowData(dr)); | ||||||
|  |         results = Encoding.UTF8.GetBytes(stringBuilder.ToString()); | ||||||
|  |         return results; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -1,32 +1,32 @@ | |||||||
| using System; | using System.Globalization; | ||||||
| using System.Globalization; |  | ||||||
| using System.IO; |  | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer.Services; | namespace OI.Metrology.Server.Services; | ||||||
| 
 | 
 | ||||||
|  | using OI.Metrology.Server.Models; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using OI.Metrology.Viewer.Models; |  | ||||||
| 
 | 
 | ||||||
| public class AttachmentsService : IAttachmentsService | public class AttachmentsService : IAttachmentsService | ||||||
| { | { | ||||||
|     private readonly AppSettings _AppSettings; |     private readonly AppSettings _AppSettings; | ||||||
|  |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
| 
 | 
 | ||||||
|     private readonly IMetrologyRepo _Repo; |     public AttachmentsService(AppSettings appSettings, IMetrologyRepository metrologyRepository) | ||||||
| 
 |  | ||||||
|     public AttachmentsService(AppSettings appSettings, IMetrologyRepo repo) |  | ||||||
|     { |     { | ||||||
|         _AppSettings = appSettings; |         _AppSettings = appSettings; | ||||||
|         _Repo = repo; |         _MetrologyRepository = metrologyRepository; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     protected Stream GetAttachmentStream(string tableName, Guid attachmentId, string filename) |     protected Stream GetAttachmentStream(string? tableName, Guid attachmentId, string filename) | ||||||
|     { |     { | ||||||
|         if (attachmentId.Equals(Guid.Empty)) |         if (attachmentId.Equals(Guid.Empty)) | ||||||
|             throw new Exception("No attachments found"); |             throw new Exception("No attachments found"); | ||||||
| 
 | 
 | ||||||
|         DateTime insertDate = Convert.ToDateTime(_Repo.GetAttachmentInsertDateByGUID(tableName, attachmentId)); |         if (tableName is null) | ||||||
|  |             throw new NullReferenceException(nameof(tableName)); | ||||||
|  | 
 | ||||||
|  |         DateTime insertDate = Convert.ToDateTime(_MetrologyRepository.GetAttachmentInsertDateByGUID(tableName, attachmentId)); | ||||||
|         int year = insertDate.Year; |         int year = insertDate.Year; | ||||||
|         DateTime d = insertDate; |         DateTime d = insertDate; | ||||||
|         CultureInfo cul = CultureInfo.CurrentCulture; |         CultureInfo cul = CultureInfo.CurrentCulture; | ||||||
| @ -50,28 +50,28 @@ public class AttachmentsService : IAttachmentsService | |||||||
| 
 | 
 | ||||||
|     public Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename) |     public Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename) | ||||||
|     { |     { | ||||||
|         if (toolType == null) |         if (toolType is null) | ||||||
|             throw new Exception("Invalid tool type"); |             throw new Exception("Invalid tool type"); | ||||||
|         Guid attachmentId; |         Guid attachmentId; | ||||||
|         string tableName; |         string? tableName; | ||||||
|         if (header) |         if (header) | ||||||
|         { |         { | ||||||
|             tableName = toolType.HeaderTableName; |             tableName = toolType.HeaderTableName; | ||||||
|             attachmentId = _Repo.GetHeaderAttachmentIDByTitle(toolType.ID, title); |             attachmentId = _MetrologyRepository.GetHeaderAttachmentIDByTitle(toolType.ID, title); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             tableName = toolType.DataTableName; |             tableName = toolType.DataTableName; | ||||||
|             attachmentId = _Repo.GetDataAttachmentIDByTitle(toolType.ID, title); |             attachmentId = _MetrologyRepository.GetDataAttachmentIDByTitle(toolType.ID, title); | ||||||
|         } |         } | ||||||
|         return GetAttachmentStream(tableName, attachmentId, filename); |         return GetAttachmentStream(tableName, attachmentId, filename); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Stream GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename) |     public Stream GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename) | ||||||
|     { |     { | ||||||
|         if (toolType == null) |         if (toolType is null) | ||||||
|             throw new Exception("Invalid tool type"); |             throw new Exception("Invalid tool type"); | ||||||
|         string tableName; |         string? tableName; | ||||||
|         if (header) |         if (header) | ||||||
|             tableName = toolType.HeaderTableName; |             tableName = toolType.HeaderTableName; | ||||||
|         else |         else | ||||||
| @ -79,27 +79,27 @@ public class AttachmentsService : IAttachmentsService | |||||||
|         return GetAttachmentStream(tableName, attachmentId, filename); |         return GetAttachmentStream(tableName, attachmentId, filename); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, Microsoft.AspNetCore.Http.IFormFile uploadedFile) |     private void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, IFormFile uploadedFile) | ||||||
|     { |     { | ||||||
|         if (toolType == null) |         if (toolType is null) | ||||||
|             throw new Exception("Invalid tool type"); |             throw new Exception("Invalid tool type"); | ||||||
| 
 | 
 | ||||||
|         using System.Transactions.TransactionScope trans = _Repo.StartTransaction(); |         using System.Transactions.TransactionScope trans = _MetrologyRepository.StartTransaction(); | ||||||
|         Guid attachmentId = Guid.Empty; |         Guid attachmentId = Guid.Empty; | ||||||
|         DateTime insertDate = new(); |         DateTime insertDate = new(); | ||||||
|         string tableName = ""; |         string? tableName = ""; | ||||||
| 
 | 
 | ||||||
|         if (string.IsNullOrWhiteSpace(dataUniqueId)) |         if (string.IsNullOrWhiteSpace(dataUniqueId)) | ||||||
|         { |         { | ||||||
|             attachmentId = _Repo.GetHeaderAttachmentID(toolType.ID, headerId); |             attachmentId = _MetrologyRepository.GetHeaderAttachmentID(toolType.ID, headerId); | ||||||
|             insertDate = Convert.ToDateTime(_Repo.GetHeaderInsertDate(toolType.ID, headerId)); |             insertDate = Convert.ToDateTime(_MetrologyRepository.GetHeaderInsertDate(toolType.ID, headerId)); | ||||||
|             tableName = toolType.HeaderTableName; |             tableName = toolType.HeaderTableName; | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             attachmentId = _Repo.GetDataAttachmentID(toolType.ID, headerId, dataUniqueId); |             attachmentId = _MetrologyRepository.GetDataAttachmentID(toolType.ID, headerId, dataUniqueId); | ||||||
|             insertDate = Convert.ToDateTime(_Repo.GetDataInsertDate(toolType.ID, headerId, dataUniqueId)); |             insertDate = Convert.ToDateTime(_MetrologyRepository.GetDataInsertDate(toolType.ID, headerId, dataUniqueId)); | ||||||
|             // Get Date for new directory name |             // Get Date for new directory name | ||||||
|             tableName = toolType.DataTableName; |             tableName = toolType.DataTableName; | ||||||
| 
 | 
 | ||||||
| @ -131,7 +131,7 @@ public class AttachmentsService : IAttachmentsService | |||||||
| 
 | 
 | ||||||
|     public void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, object uploadedFile) |     public void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, object uploadedFile) | ||||||
|     { |     { | ||||||
|         Microsoft.AspNetCore.Http.IFormFile formFile = (Microsoft.AspNetCore.Http.IFormFile)uploadedFile; |         IFormFile formFile = (IFormFile)uploadedFile; | ||||||
|         SaveAttachment(toolType, headerId, dataUniqueId, filename, formFile); |         SaveAttachment(toolType, headerId, dataUniqueId, filename, formFile); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1,18 +1,17 @@ | |||||||
| using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||||
| using OI.Metrology.Shared.DataModels; | using OI.Metrology.Shared.DataModels; | ||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Shared.Models.Stateless; | ||||||
| using OI.Metrology.Shared.Services; | using OI.Metrology.Shared.Services; | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer.Services; | #pragma warning disable CS8600, CS8602, CS8603, CS8604, CS8625 | ||||||
|  | 
 | ||||||
|  | namespace OI.Metrology.Server.Services; | ||||||
| 
 | 
 | ||||||
| public class InboundDataService : IInboundDataService | public class InboundDataService : IInboundDataService | ||||||
| { | { | ||||||
|     private readonly IMetrologyRepo _Repo; |     private readonly IMetrologyRepository _MetrologyRepository; | ||||||
| 
 | 
 | ||||||
|     public InboundDataService(IMetrologyRepo repo) => _Repo = repo; |     public InboundDataService(IMetrologyRepository metrologyRepository) => _MetrologyRepository = metrologyRepository; | ||||||
| 
 | 
 | ||||||
|     public long DoSQLInsert(JToken jsonbody, ToolType toolType, List<ToolTypeMetadata> metaData) |     public long DoSQLInsert(JToken jsonbody, ToolType toolType, List<ToolTypeMetadata> metaData) | ||||||
|     { |     { | ||||||
| @ -37,11 +36,11 @@ public class InboundDataService : IInboundDataService | |||||||
| 
 | 
 | ||||||
|         long headerId = 0; |         long headerId = 0; | ||||||
| 
 | 
 | ||||||
|         using (System.Transactions.TransactionScope transScope = _Repo.StartTransaction()) |         using (System.Transactions.TransactionScope transScope = _MetrologyRepository.StartTransaction()) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 _Repo.PurgeExistingData(toolType.ID, uniqueId); |                 _MetrologyRepository.PurgeExistingData(toolType.ID, uniqueId); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
| @ -50,7 +49,7 @@ public class InboundDataService : IInboundDataService | |||||||
| 
 | 
 | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 headerId = _Repo.InsertToolDataJSON(jsonbody, -1, metaData, toolType.HeaderTableName); |                 headerId = _MetrologyRepository.InsertToolDataJSON(jsonbody, -1, metaData, toolType.HeaderTableName); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
| @ -60,11 +59,11 @@ public class InboundDataService : IInboundDataService | |||||||
|             int detailrow = 1; |             int detailrow = 1; | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 if (detailsArray != null) |                 if (detailsArray is not null) | ||||||
|                 { |                 { | ||||||
|                     foreach (JToken detail in detailsArray) |                     foreach (JToken detail in detailsArray) | ||||||
|                     { |                     { | ||||||
|                         _ = _Repo.InsertToolDataJSON(detail, headerId, metaData, toolType.DataTableName); |                         _ = _MetrologyRepository.InsertToolDataJSON(detail, headerId, metaData, toolType.DataTableName); | ||||||
|                         detailrow += 1; |                         detailrow += 1; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @ -133,7 +132,7 @@ public class InboundDataService : IInboundDataService | |||||||
| 
 | 
 | ||||||
|                     if (jp.First is JArray array) |                     if (jp.First is JArray array) | ||||||
|                         detailsArray = array; |                         detailsArray = array; | ||||||
|                     else if ((jp.First is JValue value) && (value.Value == null)) |                     else if ((jp.First is JValue value) && (value.Value is null)) | ||||||
|                         detailsArray = null; |                         detailsArray = null; | ||||||
|                     else |                     else | ||||||
|                         errors.Add("Invalid details field"); |                         errors.Add("Invalid details field"); | ||||||
| @ -169,7 +168,7 @@ public class InboundDataService : IInboundDataService | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // if a Details container if found, process it by recursion |         // if a Details container if found, process it by recursion | ||||||
|         if (detailsArray != null) |         if (detailsArray is not null) | ||||||
|         { |         { | ||||||
|             int i = 1; |             int i = 1; | ||||||
|             foreach (JToken detail in detailsArray) |             foreach (JToken detail in detailsArray) | ||||||
| @ -189,7 +188,7 @@ public class InboundDataService : IInboundDataService | |||||||
|         { |         { | ||||||
|             // get the json data for this container field, ex: Points |             // get the json data for this container field, ex: Points | ||||||
|             JProperty contJP = jsonbody.Children<JProperty>().Where(jp => string.Equals(jp.Name, containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); |             JProperty contJP = jsonbody.Children<JProperty>().Where(jp => string.Equals(jp.Name, containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); | ||||||
|             if ((contJP != null) && (contJP.Value is JArray array)) |             if ((contJP is not null) && (contJP.Value is JArray array)) | ||||||
|             { |             { | ||||||
|                 JArray contJPArray = array; |                 JArray contJPArray = array; | ||||||
| 
 | 
 | ||||||
| @ -1,10 +1,11 @@ | |||||||
| using OI.Metrology.Shared.Repositories; | using OI.Metrology.Server.Models; | ||||||
| using OI.Metrology.Viewer.Models; | using OI.Metrology.Shared.Repositories; | ||||||
| using System; |  | ||||||
| using System.Data.Common; | using System.Data.Common; | ||||||
| using System.Data.SqlClient; | using System.Data.SqlClient; | ||||||
| 
 | 
 | ||||||
| namespace OI.Metrology.Viewer.Repositories; | #pragma warning disable CS8600, CS8602, CS8603, CS8604, CS8625 | ||||||
|  | 
 | ||||||
|  | namespace OI.Metrology.Server.Services; | ||||||
| 
 | 
 | ||||||
| public class SQLDbConnectionFactory : IDbConnectionFactory | public class SQLDbConnectionFactory : IDbConnectionFactory | ||||||
| { | { | ||||||
| @ -47,9 +47,11 @@ | |||||||
| <script> | <script> | ||||||
| 
 | 
 | ||||||
|     $(document).ready(function () { |     $(document).ready(function () { | ||||||
| 
 |          | ||||||
|  |         var apiUrl = "@ViewBag.ApiUrl"; | ||||||
|  |          | ||||||
|         $("#ToolType").igCombo({ |         $("#ToolType").igCombo({ | ||||||
|             dataSource: '@Url.Content("~/api/tooltypes")', |             dataSource: apiUrl + '/tooltypes', | ||||||
|             responseDataKey: "Results", |             responseDataKey: "Results", | ||||||
|             textKey: "ToolTypeName", |             textKey: "ToolTypeName", | ||||||
|             valueKey: "ID", |             valueKey: "ID", | ||||||
							
								
								
									
										28
									
								
								Server/Views/Pages/AwaitingDispo.cshtml
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,28 @@ | |||||||
|  | @{ | ||||||
|  |     ViewData["Title"] = "Awaiting Disposition"; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | <h4>Awaiting Disposition</h4> | ||||||
|  |  | ||||||
|  | <div style="height: 450px;"> | ||||||
|  |     <table id="grid"></table> | ||||||
|  | </div> | ||||||
|  |  | ||||||
|  | <div class="row" style="margin-top: 10px; margin-bottom: 20px;"> | ||||||
|  |     <div class="col-xs-1"> | ||||||
|  |         <input type="button" id="OpenButton" value="Open" /> | ||||||
|  |     </div> | ||||||
|  |     <div class="col-xs-1"> | ||||||
|  |         <input type="button" id="RefreshButton" value="Refresh" /> | ||||||
|  |     </div> | ||||||
|  | </div> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  |  | ||||||
|  |     $(document).ready(function () { | ||||||
|  |  | ||||||
|  |         initAwaitingDisposition("@ViewBag.ApiUrl"); | ||||||
|  |  | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  | </script> | ||||||
							
								
								
									
										57
									
								
								Server/Views/Pages/RunHeaders.cshtml
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,57 @@ | |||||||
|  | @{ | ||||||
|  |     ViewData["Title"] = "Run Headers"; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | <style> | ||||||
|  |     html, | ||||||
|  |     body { | ||||||
|  |         height: 100%; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     div.container-fluid { | ||||||
|  |         height: 90%; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     #HeaderGrid, | ||||||
|  |     #FieldsGrid { | ||||||
|  |         font-size: 12px; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     .FieldTitle { | ||||||
|  |         font-weight: bold; | ||||||
|  |     } | ||||||
|  | </style> | ||||||
|  |  | ||||||
|  | <h4>Run Headers</h4> | ||||||
|  |  | ||||||
|  | <table> | ||||||
|  |     <tr> | ||||||
|  |         <td> | ||||||
|  |             <label for="ToolType">Tool Type:</label> | ||||||
|  |         </td> | ||||||
|  |         <td> | ||||||
|  |             <div id="ToolType"></div> | ||||||
|  |         </td> | ||||||
|  |     </tr> | ||||||
|  | </table> | ||||||
|  |  | ||||||
|  | <table width="100%" height="80%"> | ||||||
|  |     <tr> | ||||||
|  |         <td width="50%"> | ||||||
|  |             <table id="HeaderGrid"></table> | ||||||
|  |         </td> | ||||||
|  |         <td width="50%"> | ||||||
|  |             <table id="FieldsGrid"></table> | ||||||
|  |         </td> | ||||||
|  |     </tr> | ||||||
|  | </table> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  |  | ||||||
|  |     $(document).ready(function () { | ||||||
|  |  | ||||||
|  |         initRunHeaders("@ViewBag.ApiUrl"); | ||||||
|  |  | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  | </script> | ||||||
							
								
								
									
										85
									
								
								Server/Views/Pages/RunInfo.cshtml
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,85 @@ | |||||||
|  | @model OI.Metrology.Shared.ViewModels.RunInfo | ||||||
|  | @{ | ||||||
|  |     ViewData["Title"] = "Run Information"; | ||||||
|  | } | ||||||
|  | <style> | ||||||
|  |     #HeaderGridDiv, | ||||||
|  |     #DetailsGridDiv { | ||||||
|  |         font-size: 12px; | ||||||
|  |     } | ||||||
|  | </style> | ||||||
|  |  | ||||||
|  | <h4>Run Information</h4> | ||||||
|  |  | ||||||
|  | <form class="form-inline mb-4"> | ||||||
|  |     <div class="form-group"> | ||||||
|  |         <label for="ToolType">Tool Type</label> | ||||||
|  |         <div class="form-control" id="ToolType"></div> | ||||||
|  |     </div> | ||||||
|  |     <div class="form-group"> | ||||||
|  |         <label for="StartDate">Start Time</label> | ||||||
|  |         <div class="form-control mb-2 mr-sm-2" id="StartDate"></div> | ||||||
|  |         <div class="form-control mb-2 mr-sm-2" id="StartTime"></div> | ||||||
|  |     </div> | ||||||
|  |     <div class="form-group"> | ||||||
|  |         <label for="EndDate">End Time</label> | ||||||
|  |         <div class="form-control mb-2 mr-sm-2" id="EndDate"></div> | ||||||
|  |         <div class="form-control mb-2 mr-sm-2" id="EndTime"></div> | ||||||
|  |     </div>   | ||||||
|  |     <div class="form-group"> | ||||||
|  |         <input class="btn btn-primary" type="button" value="Load Headers" id="LoadHeadersButton" /> | ||||||
|  |     </div>   | ||||||
|  |     <div class="form-group"> | ||||||
|  |         <label class="form-check-label" for="chkAutoRefresh"> | ||||||
|  |             Auto-Refresh | ||||||
|  |         </label> | ||||||
|  |         <input class="form-check-input" type="checkbox" id="chkAutoRefresh"> | ||||||
|  |     </div> | ||||||
|  | </form> | ||||||
|  |  | ||||||
|  | <div style="height: 300px;" id="HeaderGridDiv"> | ||||||
|  |     <span id="ToolTypeID" hidden></span> | ||||||
|  |     <table id="HeaderGrid"></table> | ||||||
|  | </div> | ||||||
|  |  | ||||||
|  | <div class="row" style="margin-top: 10px; margin-bottom: 20px;"> | ||||||
|  |     <div class="col-xs-1"> | ||||||
|  |         <input type="button" class="btn" id="GetDataButton" value="Get Data" disabled /> | ||||||
|  |     </div> | ||||||
|  |     <div class="col-xs-1"> | ||||||
|  |         <input type="button" class="btn" id="ReviewButton" value="Review" disabled /> | ||||||
|  |     </div> | ||||||
|  |     <div class="col-xs-1"> | ||||||
|  |         <input type="button" class="btn" id="PinButton" value="Pin" disabled /> | ||||||
|  |     </div> | ||||||
|  | </div> | ||||||
|  |  | ||||||
|  | <div id="DetailsDiv" hidden> | ||||||
|  |  | ||||||
|  |     <span id="HeaderId" hidden></span> | ||||||
|  |     <span id="HeaderAttachmentId" hidden></span> | ||||||
|  |     <div style="padding-bottom: 20px;" id="DetailsGridDiv"> | ||||||
|  |         <table id="DetailsGrid"></table> | ||||||
|  |     </div> | ||||||
|  |  | ||||||
|  |     <div id="ExportDiv" style="margin-top: 10px;" hidden> | ||||||
|  |         <input type="button" value="Send to OpenInsight" id="OIExportButton" /> | ||||||
|  |         <span id="OIExportResult" style="margin-left: 10px; font-weight: bold; color: #366b02;"></span> | ||||||
|  |     </div> | ||||||
|  |  | ||||||
|  |     <p style="text-align: center; margin-top: 20px;"> | ||||||
|  |         <iframe id="DataAttachmentFrame" style="height:900px; border-width:thin; margin-right: 10px;" hidden></iframe> | ||||||
|  |         <iframe id="HeaderAttachmentFrame" style="height:900px; border-width:thin;" hidden></iframe> | ||||||
|  |     </p> | ||||||
|  |  | ||||||
|  | </div> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  |  | ||||||
|  |     $(document).ready(function () { | ||||||
|  |  | ||||||
|  |         initRunInfo("@ViewBag.ApiUrl", "@Model.ToolTypeID", "@Model.HeaderID", "@Model.HeaderAttachmentID"); | ||||||
|  |  | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  | </script> | ||||||
| @ -21,6 +21,7 @@ | |||||||
|     <script src="~/igniteui/js/infragistics.dv.js" type="text/javascript" asp-append-version="true"></script> |     <script src="~/igniteui/js/infragistics.dv.js" type="text/javascript" asp-append-version="true"></script> | ||||||
| 
 | 
 | ||||||
|     <script src="~/js/common.js" type="text/javascript" asp-append-version="true"></script> |     <script src="~/js/common.js" type="text/javascript" asp-append-version="true"></script> | ||||||
|  |     <script src="~/js/site.js" type="text/javascript" asp-append-version="true"></script> | ||||||
|     <script> |     <script> | ||||||
|         $(document).ready(function () { |         $(document).ready(function () { | ||||||
|             if (location.pathname == "/") { |             if (location.pathname == "/") { | ||||||
| @ -73,7 +74,7 @@ | |||||||
|                     <li><a href="https://oi-metrology-viewer-archive.mes.infineon.com/" target="_blank">Archive</a></li> |                     <li><a href="https://oi-metrology-viewer-archive.mes.infineon.com/" target="_blank">Archive</a></li> | ||||||
|                 </ul> |                 </ul> | ||||||
|                 <p class="navbar-text navbar-right"> |                 <p class="navbar-text navbar-right"> | ||||||
|                     @User.Identity.Name |                     @User.Identity?.Name | ||||||
|                 </p> |                 </p> | ||||||
|             </div> |             </div> | ||||||
|         </div> |         </div> | ||||||
| @ -1,26 +1,15 @@ | |||||||
| { | { | ||||||
|   "AllowedHosts": "*", |   "xApiUrl": "http://messa010ec.ec.local:50301/api", | ||||||
|   "ApiLoggingContentTypes": "application/json", |   "ApiUrl": "http://localhost:5126/api", | ||||||
|   "ApiLoggingPathPrefixes": "/api/inbound", |   "xxxApiUrl": "http://localhost:50301/api", | ||||||
|   "ApiLogPath": "D:\\Metrology\\MetrologyAPILogs", |   "xxxxApiUrl": "http://messa010ec.ec.local:50301/api", | ||||||
|   "AttachmentPath": "\\\\messv02ecc1.ec.local\\EC_Metrology_Si\\MetrologyAttachments", |   "ConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;", | ||||||
|   "BuildNumber": "1",   |   "xConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology;", | ||||||
|   "Company": "Infineon Technologies Americas Corp.", |   "IsDevelopment": true, | ||||||
|   "ConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology;", |   "xMockRoot": "/Data/Tests", | ||||||
|   "GitCommitSeven": "1234567", |   "MockRoot": "", | ||||||
|   "Logging": { |  | ||||||
|     "LogLevel": { |  | ||||||
|       "Default": "Information", |  | ||||||
|       "Microsoft": "Warning", |  | ||||||
|       "Log4netProvider": "Debug", |  | ||||||
|       "Microsoft.Hosting.Lifetime": "Information" |  | ||||||
|     } |  | ||||||
|   }, |  | ||||||
|   "InboundApiAllowedIPList": "", |  | ||||||
|   "MonAResource": "OI_Metrology_Viewer_IFX", |   "MonAResource": "OI_Metrology_Viewer_IFX", | ||||||
|   "MonASite": "auc", |   "Oi2SqlConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;", | ||||||
|   "Oi2SqlConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;", |  | ||||||
|   "OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data", |  | ||||||
|   "Serilog": { |   "Serilog": { | ||||||
|     "Using": [ |     "Using": [ | ||||||
|       "Serilog.Sinks.Console", |       "Serilog.Sinks.Console", | ||||||
| @ -58,6 +47,5 @@ | |||||||
|       "Application": "Sample" |       "Application": "Sample" | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   "URLs": "https://localhost:7130;http://localhost:5126", |   "URLs": "https://localhost:7130;http://localhost:5126" | ||||||
|   "WorkingDirectoryName": "IFXApps" |  | ||||||
| } | } | ||||||
| @ -2,6 +2,7 @@ | |||||||
|   "AllowedHosts": "*", |   "AllowedHosts": "*", | ||||||
|   "ApiLoggingContentTypes": "application/json", |   "ApiLoggingContentTypes": "application/json", | ||||||
|   "ApiLoggingPathPrefixes": "/api/inbound", |   "ApiLoggingPathPrefixes": "/api/inbound", | ||||||
|  |   "ApiUrl": "~/api", | ||||||
|   "ApiLogPath": "D:\\Metrology\\MetrologyAPILogs", |   "ApiLogPath": "D:\\Metrology\\MetrologyAPILogs", | ||||||
|   "AttachmentPath": "\\\\messv02ecc1.ec.local\\EC_Metrology_Si\\MetrologyAttachments", |   "AttachmentPath": "\\\\messv02ecc1.ec.local\\EC_Metrology_Si\\MetrologyAttachments", | ||||||
|   "BuildNumber": "1",   |   "BuildNumber": "1",   | ||||||
| @ -17,6 +18,9 @@ | |||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   "InboundApiAllowedIPList": "", |   "InboundApiAllowedIPList": "", | ||||||
|  |   "IsDevelopment": false, | ||||||
|  |   "IsStaging": false, | ||||||
|  |   "MockRoot": "", | ||||||
|   "MonAResource": "OI_Metrology_Viewer_EC", |   "MonAResource": "OI_Metrology_Viewer_EC", | ||||||
|   "MonASite": "auc", |   "MonASite": "auc", | ||||||
|   "Oi2SqlConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;", |   "Oi2SqlConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;", | ||||||
| @ -26,7 +30,7 @@ | |||||||
|       "Serilog.Sinks.Console", |       "Serilog.Sinks.Console", | ||||||
|       "Serilog.Sinks.File" |       "Serilog.Sinks.File" | ||||||
|     ], |     ], | ||||||
|     "MinimumLevel": "Debug", |     "MinimumLevel": "Information", | ||||||
|     "WriteTo": [ |     "WriteTo": [ | ||||||
|       { |       { | ||||||
|         "Name": "Debug", |         "Name": "Debug", | ||||||
| Before Width: | Height: | Size: 272 KiB After Width: | Height: | Size: 272 KiB | 
| Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB | 
| Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB | 
| Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 210 B | 
| Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 225 B | 
| Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB | 
| Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB | 
| Before Width: | Height: | Size: 418 B After Width: | Height: | Size: 418 B | 
| Before Width: | Height: | Size: 985 B After Width: | Height: | Size: 985 B | 
| Before Width: | Height: | Size: 964 B After Width: | Height: | Size: 964 B | 
| Before Width: | Height: | Size: 486 B After Width: | Height: | Size: 486 B | 
| Before Width: | Height: | Size: 483 B After Width: | Height: | Size: 483 B | 
| Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB | 
| Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |