From 1712743c46e9245d53289d40c9e19a0d8999bb70 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Mon, 6 Mar 2023 12:00:24 -0700 Subject: [PATCH] Added View, Recipe Paramaters and Export --- .gitignore | 2 +- .vscode/settings.json | 2 + .vscode/tasks.json | 39 +++ .vscode/thunder-collection_InfinityQS.json | 124 -------- .vscode/thunder-tests/thunderActivity.json | 127 +++++++++ .vscode/thunder-tests/thunderCollection.json | 9 + .vscode/thunder-tests/thunderEnvironment.json | 1 + .vscode/thunder-tests/thunderclient.json | 269 ++++++++++++++++++ Server/ApiControllers/ExportController.cs | 39 +++ Server/ApiControllers/InboundController.cs | 14 +- Server/Data/Tests/Export-GetExport.txt | 1 + Server/Data/Tests/Export-GetHeaders.json | 4 + Server/Data/Tests/Export-GetLogistics.json | 4 + .../Export-GetProcessDataStandardFormat.pdsf | 1 + Server/Models/AppSettings.cs | 3 +- Server/Models/Binder/AppSettings.cs | 4 + Server/OI.Metrology.Server.csproj | 15 +- Server/Program.cs | 1 + Server/Repositories/ExportRepository.cs | 150 ++++++++++ Server/Views/Pages/RunInfo.cshtml | 6 + Server/appsettings.Development.json | 11 +- Server/appsettings.json | 1 + Server/wwwroot/js/common.js | 12 +- Server/wwwroot/js/site.js | 166 ++++++++++- Shared/Models/Stateless/IExportController.cs | 22 ++ Shared/Models/Stateless/IExportRepository.cs | 13 + Shared/Models/Stateless/IInboundController.cs | 2 +- Tests/UnitTestExportController.cs | 132 +++++++++ azure-pipelines-server-development.yml | 1 + azure-pipelines-server.yml | 1 + 30 files changed, 1030 insertions(+), 146 deletions(-) delete mode 100644 .vscode/thunder-collection_InfinityQS.json create mode 100644 .vscode/thunder-tests/thunderActivity.json create mode 100644 .vscode/thunder-tests/thunderCollection.json create mode 100644 .vscode/thunder-tests/thunderEnvironment.json create mode 100644 .vscode/thunder-tests/thunderclient.json create mode 100644 Server/ApiControllers/ExportController.cs create mode 100644 Server/Data/Tests/Export-GetExport.txt create mode 100644 Server/Data/Tests/Export-GetHeaders.json create mode 100644 Server/Data/Tests/Export-GetLogistics.json create mode 100644 Server/Data/Tests/Export-GetProcessDataStandardFormat.pdsf create mode 100644 Server/Repositories/ExportRepository.cs create mode 100644 Shared/Models/Stateless/IExportController.cs create mode 100644 Shared/Models/Stateless/IExportRepository.cs create mode 100644 Tests/UnitTestExportController.cs diff --git a/.gitignore b/.gitignore index ecc7314..e5ca0f7 100644 --- a/.gitignore +++ b/.gitignore @@ -337,7 +337,7 @@ ASALocalRun/ !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json -!.vscode/thunder-collection_InfinityQS.json +!.vscode/thunder-tests/ # Libman.json /wwwroot/lib/* \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 11f27b6..8d9e274 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,7 @@ "files.exclude": { "**/.git": false }, + "thunder-client.saveToWorkspace": true, + "thunder-client.workspaceRelativePath": ".vscode", "coverage-gutters.coverageBaseDir": "../.vscode/TestResults/*" } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b530ca9..9e50e35 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -25,6 +25,45 @@ ], "problemMatcher": "$msCompile" }, + { + "label": "testDebug", + "command": "dotnet", + "type": "process", + "args": [ + "test", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "testRelease", + "command": "dotnet", + "type": "process", + "args": [ + "test", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary", + "-c", + "Release" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "format", + "command": "dotnet", + "type": "process", + "args": [ + "format", + "--report", + ".vscode", + "--verbosity", + "detailed", + "--severity", + "warn" + ], + "problemMatcher": "$msCompile" + }, { "label": "old-watch", "command": "dotnet", diff --git a/.vscode/thunder-collection_InfinityQS.json b/.vscode/thunder-collection_InfinityQS.json deleted file mode 100644 index 4ff7e86..0000000 --- a/.vscode/thunder-collection_InfinityQS.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "client": "Thunder Client", - "collectionName": "InfinityQS", - "dateExported": "2023-02-25T03:56:25.916Z", - "version": "1.1", - "folders": [], - "requests": [ - { - "_id": "9be11307-792b-4177-8ad5-58ee6e1f1ccb", - "colId": "3d9b2497-1dd7-43dd-91de-2e33b22ebab8", - "containerId": "", - "name": "GetCommandText", - "url": "http://messa010ec.ec.local:50301/api/InfinityQS/commandText/?sub_group_id=1677273357&process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 14:15:00", - "method": "GET", - "sortNum": 20000, - "created": "2023-02-24T23:17:08.397Z", - "modified": "2023-02-25T03:56:15.342Z", - "headers": [], - "params": [ - { - "name": "sub_group_id", - "value": "1677273357", - "isPath": false - }, - { - "name": "process", - "value": "61", - "isPath": false - }, - { - "name": "job", - "value": "CDE5", - "isPath": false - }, - { - "name": "part", - "value": "5012", - "isPath": false - }, - { - "name": "lot", - "value": "575908", - "isPath": false - }, - { - "name": "date_time", - "value": "2023-02-24 14:15:00", - "isPath": false - } - ], - "tests": [ - { - "type": "Content-Length", - "custom": "", - "action": ">", - "value": "100" - } - ] - }, - { - "_id": "a9c9329f-3694-4a7c-8e34-f3bbf19ba00b", - "colId": "3d9b2497-1dd7-43dd-91de-2e33b22ebab8", - "containerId": "", - "name": "GetData", - "url": "http://messa010ec.ec.local:50301/api/InfinityQS/1677273357/data", - "method": "GET", - "sortNum": 40000, - "created": "2023-02-24T23:18:20.077Z", - "modified": "2023-02-25T03:40:56.375Z", - "headers": [], - "params": [], - "tests": [ - { - "type": "json-query", - "custom": "json.", - "action": "count", - "value": "2" - } - ] - }, - { - "_id": "13ceb9e6-c6d7-425b-8156-73e518c97d31", - "colId": "3d9b2497-1dd7-43dd-91de-2e33b22ebab8", - "containerId": "", - "name": "GetEvents", - "url": "http://messa010ec.ec.local:50301/api/InfinityQS/1677273357/events", - "method": "GET", - "sortNum": 42500, - "created": "2023-02-24T23:19:03.654Z", - "modified": "2023-02-25T03:55:48.678Z", - "headers": [], - "params": [], - "tests": [ - { - "type": "json-query", - "custom": "json.", - "action": "count", - "value": "2" - } - ] - }, - { - "_id": "1ca7f294-13bd-42c5-b9cf-087352fd7043", - "colId": "3d9b2497-1dd7-43dd-91de-2e33b22ebab8", - "containerId": "", - "name": "GetHeader", - "url": "http://messa010ec.ec.local:50301/api/InfinityQS/1677273357/header", - "method": "GET", - "sortNum": 45000, - "created": "2023-02-25T03:42:07.567Z", - "modified": "2023-02-25T03:42:18.066Z", - "headers": [], - "params": [], - "tests": [ - { - "type": "json-query", - "custom": "json.", - "action": "count", - "value": "2" - } - ] - } - ] -} \ No newline at end of file diff --git a/.vscode/thunder-tests/thunderActivity.json b/.vscode/thunder-tests/thunderActivity.json new file mode 100644 index 0000000..9fb71fd --- /dev/null +++ b/.vscode/thunder-tests/thunderActivity.json @@ -0,0 +1,127 @@ +[ + { + "_id": "646e3a9b-8fe9-4eb3-a532-f94270f752ac", + "colId": "history", + "containerId": "", + "name": "http://localhost:5126/api/inbound/cde", + "url": "http://localhost:5126/api/inbound/cde", + "method": "POST", + "sortNum": 0, + "created": "2023-02-28T14:41:33.596Z", + "modified": "2023-02-28T15:19:48.924Z", + "headers": [], + "params": [], + "body": { + "type": "json", + "raw": "{\n \"SentToMetrology\": false,\n \"SentToSPC\": false,\n \"AutoOptimizeGain\": \"YES\",\n \"AutoProbeHeightSet\": \"NO\",\n \"Avg\": \"1824.053\",\n \"CellName\": \"CDE2\",\n \"DLRatio\": \"0.9680\",\n \"DataReject\": \"> 3.0Sigma\",\n \"Date\": \"02/27/2023 03:03:00 AM\",\n \"Engineer\": \"Engineer\",\n \"EquipId\": \"CDE2\",\n \"FileName\": \"0 C:\\\\4p_NT\\\\LSL8in.prj\\\\10PT_5mm.rcp\\\\3227D036.RsM 03:03 02/27/23\",\n \"FilePath\": \"\",\n \"Id\": \"-1\",\n \"Layer\": \"\",\n \"LotId\": \"LotID\",\n \"Op\": \"Operator\",\n \"PSN\": \"4628\",\n \"RDS\": \"577845\",\n \"Reactor\": \"20\",\n \"Recipe\": \"LSL8in \\\\ 10PT_5mm\",\n \"ResistivitySpec\": \"\",\n \"Run\": \"20-577845-4628\",\n \"SemiRadial\": \"1.55%\",\n \"StDev\": \"1.33%\",\n \"Temp\": \"19.2\",\n \"UniqueId\": \"21.16;1;95.0;1803.847;270.0_Point-1\",\n \"Zone\": null,\n \"Details\": [\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"21.16\",\n \"Pt\": \"1\",\n \"R\": \"95.0\",\n \"Rs\": \"1803.847\",\n \"T\": \"270.0\",\n \"UniqueId\": \"21.16;1;95.0;1803.847;270.0_Point-1\"\n },\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"22.39\",\n \"Pt\": \"2\",\n \"R\": \"71.0\",\n \"Rs\": \"1858.424\",\n \"T\": \"270.0\",\n \"UniqueId\": \"22.39;2;71.0;1858.424;270.0_Point-2\"\n },\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"21.07\",\n \"Pt\": \"3\",\n \"R\": \"47.0\",\n \"Rs\": \"1834.141\",\n \"T\": \"270.0\",\n \"UniqueId\": \"21.07;3;47.0;1834.141;270.0_Point-3\"\n },\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"22.91\",\n \"Pt\": \"4\",\n \"R\": \"23.0\",\n \"Rs\": \"1803.609\",\n \"T\": \"270.0\",\n \"UniqueId\": \"22.91;4;23.0;1803.609;270.0_Point-4\"\n },\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"21.94\",\n \"Pt\": \"5\",\n \"R\": \"0.0\",\n \"Rs\": \"1801.623\",\n \"T\": \"0.0\",\n \"UniqueId\": \"21.94;5;0.0;1801.623;0.0_Point-5\"\n },\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"25.61\",\n \"Pt\": \"6\",\n \"R\": \"11.0\",\n \"Rs\": \"1803.997\",\n \"T\": \"90.0\",\n \"UniqueId\": \"25.61;6;11.0;1803.997;90.0_Point-6\"\n },\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"24.73\",\n \"Pt\": \"7\",\n \"R\": \"35.0\",\n \"Rs\": \"1819.854\",\n \"T\": \"90.0\",\n \"UniqueId\": \"24.73;7;35.0;1819.854;90.0_Point-7\"\n },\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"23.13\",\n \"Pt\": \"8\",\n \"R\": \"59.0\",\n \"Rs\": \"1855.965\",\n \"T\": \"90.0\",\n \"UniqueId\": \"23.13;8;59.0;1855.965;90.0_Point-8\"\n },\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"23.44\",\n \"Pt\": \"9\",\n \"R\": \"83.0\",\n \"Rs\": \"1853.631\",\n \"T\": \"90.0\",\n \"UniqueId\": \"23.44;9;83.0;1853.631;90.0_Point-9\"\n },\n {\n \"HeaderUniqueId\": \"ResMap_20-577845-4628_20230227030723\",\n \"Merit\": \"21.75\",\n \"Pt\": \"10\",\n \"R\": \"95.0\",\n \"Rs\": \"1805.438\",\n \"T\": \"90.0\",\n \"UniqueId\": \"21.75;10;95.0;1805.438;90.0_Point-10\"\n }\n ]\n}", + "form": [] + }, + "tests": [] + }, + { + "_id": "7f723103-2cd6-4d09-b780-28afe34b3cd7", + "colId": "history", + "containerId": "", + "name": "Delete", + "url": "https://tfs.intra.infineon.com/tfs/manufacturingit/APC%20Trend/_apis/test/runs/413094?api-version=6.0", + "method": "DELETE", + "sortNum": 0, + "created": "2023-03-02T15:43:07.175Z", + "modified": "2023-03-02T15:49:54.662Z", + "headers": [ + { + "name": "Authorization", + "value": "Basic OmtzZHJveW9xMmJsdGI2N2xzN3NmZGhyYXlrY3l6cGlmemtkZjNndGs1bnl4ZnZmZHBqa2E=" + } + ], + "params": [ + { + "name": "api-version", + "value": "6.0", + "isPath": false + } + ], + "tests": [] + }, + { + "_id": "2874b1ad-b298-48c1-8edb-6fd78ce7d2d9", + "colId": "history", + "containerId": "", + "name": "Get", + "url": "https://tfs.intra.infineon.com/tfs/manufacturingit/Mesa_FI/_apis/test/runs?branchName=amaster&api-version=6.0", + "method": "GET", + "sortNum": 0, + "created": "2023-03-02T15:53:18.138Z", + "modified": "2023-03-02T16:12:27.892Z", + "headers": [ + { + "name": "Authorization", + "value": "Basic OmtzZHJveW9xMmJsdGI2N2xzN3NmZGhyYXlrY3l6cGlmemtkZjNndGs1bnl4ZnZmZHBqa2E=" + } + ], + "params": [ + { + "name": "branchName", + "value": "amaster", + "isPath": false + }, + { + "name": "api-version", + "value": "6.0", + "isPath": false + } + ], + "tests": [] + }, + { + "_id": "ed8728f5-9afa-4e69-bca3-9c059a9a831b", + "colId": "history", + "containerId": "", + "name": "Patch", + "url": "https://tfs.intra.infineon.com/tfs/manufacturingit/Mesa_FI/_apis/test/runs/410737?api-version=6.0", + "method": "PATCH", + "sortNum": 0, + "created": "2023-03-02T15:53:18.138Z", + "modified": "2023-03-02T15:58:09.720Z", + "headers": [ + { + "name": "Authorization", + "value": "Basic OmtzZHJveW9xMmJsdGI2N2xzN3NmZGhyYXlrY3l6cGlmemtkZjNndGs1bnl4ZnZmZHBqa2E=" + } + ], + "params": [ + { + "name": "api-version", + "value": "6.0", + "isPath": false + } + ], + "body": { + "type": "json", + "raw": "{\n \"name\": \"MET08RESIHGCV\",\n \"comment\": \"40 passed\"\n}", + "form": [] + }, + "tests": [] + }, + { + "_id": "727621f0-63a3-4df2-9cfc-2610c532670d", + "colId": "history", + "containerId": "", + "name": "OI-RDS", + "url": "http://messa020ec.ec.local/api/oiWizard/materials/rds/578941", + "method": "GET", + "sortNum": 0, + "created": "2023-03-02T18:20:01.561Z", + "modified": "2023-03-06T18:40:43.162Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.rds.rdsLayers", + "action": "count", + "value": "1" + } + ] + } +] \ No newline at end of file diff --git a/.vscode/thunder-tests/thunderCollection.json b/.vscode/thunder-tests/thunderCollection.json new file mode 100644 index 0000000..9c740b3 --- /dev/null +++ b/.vscode/thunder-tests/thunderCollection.json @@ -0,0 +1,9 @@ +[ + { + "_id": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "colName": "InfinityQS", + "created": "2023-02-27T20:07:11.913Z", + "sortNum": 10000, + "folders": [] + } +] \ No newline at end of file diff --git a/.vscode/thunder-tests/thunderEnvironment.json b/.vscode/thunder-tests/thunderEnvironment.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/.vscode/thunder-tests/thunderEnvironment.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/.vscode/thunder-tests/thunderclient.json b/.vscode/thunder-tests/thunderclient.json new file mode 100644 index 0000000..3374d9e --- /dev/null +++ b/.vscode/thunder-tests/thunderclient.json @@ -0,0 +1,269 @@ +[ + { + "_id": "acbbcc8d-3daf-43be-9081-f4be2f8a95b9", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetCommandText", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/commandText/?sub_group_id=1677273357&process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 14:15:00", + "method": "GET", + "sortNum": 20000, + "created": "2023-02-27T20:07:11.921Z", + "modified": "2023-02-27T20:07:11.921Z", + "headers": [], + "params": [ + { + "name": "sub_group_id", + "value": "1677273357", + "isPath": false + }, + { + "name": "process", + "value": "61", + "isPath": false + }, + { + "name": "job", + "value": "CDE5", + "isPath": false + }, + { + "name": "part", + "value": "5012", + "isPath": false + }, + { + "name": "lot", + "value": "575908", + "isPath": false + }, + { + "name": "date_time", + "value": "2023-02-24 14:15:00", + "isPath": false + } + ], + "tests": [ + { + "type": "Content-Length", + "custom": "", + "action": ">", + "value": "100" + } + ] + }, + { + "_id": "29e56599-0093-481e-9386-9e6c1bb828a8", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetCommandTextV2", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV2/1677273357/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 14:15:00", + "method": "GET", + "sortNum": 30000, + "created": "2023-02-27T20:07:11.923Z", + "modified": "2023-02-27T20:07:11.923Z", + "headers": [], + "params": [ + { + "name": "process", + "value": "61", + "isPath": false + }, + { + "name": "job", + "value": "CDE5", + "isPath": false + }, + { + "name": "part", + "value": "5012", + "isPath": false + }, + { + "name": "lot", + "value": "575908", + "isPath": false + }, + { + "name": "date_time", + "value": "2023-02-24 14:15:00", + "isPath": false + } + ], + "tests": [ + { + "type": "Content-Length", + "custom": "", + "action": ">", + "value": "100" + } + ] + }, + { + "_id": "2810520f-7a8b-4282-a593-92da3043e491", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetData", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/1677273357/data", + "method": "GET", + "sortNum": 40000, + "created": "2023-02-27T20:07:11.924Z", + "modified": "2023-02-27T20:07:11.924Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.", + "action": "count", + "value": "2" + } + ] + }, + { + "_id": "8628d1b1-cedb-45e3-9958-0ba4e233a2ac", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetDataV2", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV2/1677273357/data", + "method": "GET", + "sortNum": 41250, + "created": "2023-02-27T20:07:11.925Z", + "modified": "2023-02-27T20:07:11.925Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.", + "action": "count", + "value": "2" + } + ] + }, + { + "_id": "55c863ce-b828-4cdb-8a72-26da369c44ee", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetDescriptors", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/1677273357/descriptors", + "method": "GET", + "sortNum": 41875, + "created": "2023-02-27T20:07:11.926Z", + "modified": "2023-02-27T20:07:11.926Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.", + "action": "count", + "value": "2" + } + ] + }, + { + "_id": "b25fade2-44b5-4897-94a6-e31062c27e58", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetDescriptorsV2", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV2/1677273357/descriptors", + "method": "GET", + "sortNum": 42187.5, + "created": "2023-02-27T20:07:11.927Z", + "modified": "2023-02-27T20:07:11.927Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.", + "action": "count", + "value": "2" + } + ] + }, + { + "_id": "f24e826e-578c-45fe-a80a-ce31f0a13dfc", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetEvents", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/1677273357/events", + "method": "GET", + "sortNum": 42500, + "created": "2023-02-27T20:07:11.928Z", + "modified": "2023-02-27T20:07:11.928Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.", + "action": "count", + "value": "2" + } + ] + }, + { + "_id": "81118bd8-5919-4501-aa34-eaa2f4baeabf", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetEventsV2", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV2/1677273357/events", + "method": "GET", + "sortNum": 43750, + "created": "2023-02-27T20:07:11.929Z", + "modified": "2023-02-27T20:07:11.929Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.", + "action": "count", + "value": "2" + } + ] + }, + { + "_id": "26ded486-79ad-4fc8-b526-98187b8fde91", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetHeader", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/1677273357/header", + "method": "GET", + "sortNum": 45000, + "created": "2023-02-27T20:07:11.930Z", + "modified": "2023-02-27T20:07:11.930Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.", + "action": "count", + "value": "2" + } + ] + }, + { + "_id": "b8ee8160-6ca2-4276-be91-d1f6f2dd90dc", + "colId": "3743bec1-1f73-492a-9b9f-5889f239b5fc", + "containerId": "", + "name": "GetHeaderV2", + "url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV2/1677273357/header", + "method": "GET", + "sortNum": 55000, + "created": "2023-02-27T20:07:11.931Z", + "modified": "2023-02-27T20:07:11.931Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.", + "action": "count", + "value": "2" + } + ] + } +] \ No newline at end of file diff --git a/Server/ApiControllers/ExportController.cs b/Server/ApiControllers/ExportController.cs new file mode 100644 index 0000000..3c296b9 --- /dev/null +++ b/Server/ApiControllers/ExportController.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Mvc; + +namespace OI.Metrology.Server.ApiControllers; + +using OI.Metrology.Shared.DataModels; +using OI.Metrology.Shared.Models.Stateless; +using System.Text.Json; + +[Route("api/[controller]")] +public class ExportController : Controller, IExportController +{ + + private readonly IExportRepository _ExportRepository; + + public ExportController(IExportRepository exportRepository) => + _ExportRepository = exportRepository; + + [HttpGet] + [Route("export")] + public IActionResult GetExport(HeaderCommon headerCommon) => + Content(_ExportRepository.GetExport(headerCommon)); + + [HttpGet] + [Route("headers")] + public IActionResult GetHeaders(HeaderCommon headerCommon) => + Json(_ExportRepository.GetHeaders(headerCommon), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); + + [HttpGet] + [Route("logistics")] + public IActionResult GetLogistics(HeaderCommon headerCommon) => + Json(_ExportRepository.GetLogistics(headerCommon), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); + + [HttpGet] + [Route("pdsf")] + [Route("processDataStandardFormat")] + public IActionResult GetProcessDataStandardFormat(HeaderCommon headerCommon) => + Content(_ExportRepository.GetProcessDataStandardFormat(headerCommon)); + +} \ No newline at end of file diff --git a/Server/ApiControllers/InboundController.cs b/Server/ApiControllers/InboundController.cs index ce08469..3fb4908 100644 --- a/Server/ApiControllers/InboundController.cs +++ b/Server/ApiControllers/InboundController.cs @@ -32,7 +32,7 @@ public partial class InboundController : ControllerBase, IInboundController + SAK SAK @@ -13,6 +13,7 @@ Exe win-x64 net7.0 + 6501aa0f-8499-4be5-96a9-e99b11323eeb @@ -76,6 +77,18 @@ Always + + Always + + + Always + + + Always + + + Always + Always diff --git a/Server/Program.cs b/Server/Program.cs index 9e06d7f..18ac690 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -76,6 +76,7 @@ public class Program _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); + _ = webApplicationBuilder.Services.AddScoped(); _ = webApplicationBuilder.Services.AddScoped(); _ = webApplicationBuilder.Services.AddScoped(); _ = webApplicationBuilder.Services.AddScoped(); diff --git a/Server/Repositories/ExportRepository.cs b/Server/Repositories/ExportRepository.cs new file mode 100644 index 0000000..98e892f --- /dev/null +++ b/Server/Repositories/ExportRepository.cs @@ -0,0 +1,150 @@ +using OI.Metrology.Server.Models; +using OI.Metrology.Shared.DataModels; +using OI.Metrology.Shared.Models.Stateless; +using System.Globalization; +using System.Text.Json; + +namespace OI.Metrology.Server.Repository; + +public class ExportRepository : IExportRepository +{ + + private readonly string _MockRoot; + private readonly Serilog.ILogger _Log; + private readonly string _RepositoryName; + private readonly AppSettings _AppSettings; + private readonly Dictionary> _RdsToHeaderCommonCollection; + + public ExportRepository(AppSettings appSettings) + { + _AppSettings = appSettings; + _MockRoot = appSettings.MockRoot; + _RdsToHeaderCommonCollection = new(); + _RepositoryName = nameof(ExportRepository)[..^10]; + _Log = Serilog.Log.ForContext(); + } + + private static string[] Get() + { + DateTime dateTime = DateTime.Now; + Calendar calendar = new CultureInfo("en-US").Calendar; + string weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); + string lastWeekOfYear = calendar.GetWeekOfYear(dateTime.AddDays(7), CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); + return new string[] { weekOfYear, lastWeekOfYear }; + } + + private List GetFiles(HeaderCommon headerCommon, string searchPattern) + { + List results = new(); + string directory; + string[] weeks = Get(); + foreach (string weekYear in weeks) + { + directory = Path.Combine(_AppSettings.ApiExportPath, weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}", $"-{headerCommon.ID}"); + if (!Directory.Exists(directory)) + continue; + results.AddRange(Directory.GetFiles(directory, searchPattern, SearchOption.TopDirectoryOnly)); + } + return results; + } + + string IExportRepository.GetExport(HeaderCommon headerCommon) + { + string result; + if (!string.IsNullOrEmpty(_MockRoot)) + result = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IExportRepository.GetExport)}.txt")); + else + { + List files = GetFiles(headerCommon, "*.txt"); + if (files.Count != 1) + result = string.Empty; + else + result = File.ReadAllText(files.First()); + } + return result; + } + + Result IExportRepository.GetHeaders(HeaderCommon headerCommon) + { + Result? result; + if (!string.IsNullOrEmpty(_MockRoot)) + { + string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IExportRepository.GetHeaders)}.json")); + result = JsonSerializer.Deserialize>(json); + if (result is null) + throw new NullReferenceException(nameof(result)); + } + else + { + List results = new(); + string json; + HeaderCommon? hc; + List files = GetFiles(headerCommon, "*.json"); + foreach (string file in files) + { + json = File.ReadAllText(file); + hc = JsonSerializer.Deserialize(json); + if (hc is null) + continue; + results.Add(hc); + } + result = new() + { + Results = results.ToArray(), + TotalRows = results.Count, + }; + } + return result; + + } + + Result IExportRepository.GetLogistics(HeaderCommon headerCommon) + { + Result? result; + if (!string.IsNullOrEmpty(_MockRoot)) + { + string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IExportRepository.GetLogistics)}.json")); + result = JsonSerializer.Deserialize>(json); + if (result is null) + throw new NullReferenceException(nameof(result)); + } + else + { + List results = new(); + string json; + HeaderCommon? hc; + List files = GetFiles(headerCommon, "*.json"); + foreach (string file in files) + { + json = File.ReadAllText(file); + hc = JsonSerializer.Deserialize(json); + if (hc is null) + continue; + results.Add(hc); + } + result = new() + { + Results = results.ToArray(), + TotalRows = results.Count, + }; + } + return result; + } + + string IExportRepository.GetProcessDataStandardFormat(HeaderCommon headerCommon) + { + string result; + if (!string.IsNullOrEmpty(_MockRoot)) + result = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IExportRepository.GetProcessDataStandardFormat)}.pdsf")); + else + { + List files = GetFiles(headerCommon, "*.pdsf"); + if (files.Count != 1) + result = string.Empty; + else + result = File.ReadAllText(files.First()); + } + return result; + } + +} \ No newline at end of file diff --git a/Server/Views/Pages/RunInfo.cshtml b/Server/Views/Pages/RunInfo.cshtml index 234cfb8..3ddaf5b 100644 --- a/Server/Views/Pages/RunInfo.cshtml +++ b/Server/Views/Pages/RunInfo.cshtml @@ -49,6 +49,12 @@
+
+ +
+
+ +
diff --git a/Server/appsettings.Development.json b/Server/appsettings.Development.json index 68ec4c0..0de2768 100644 --- a/Server/appsettings.Development.json +++ b/Server/appsettings.Development.json @@ -1,14 +1,9 @@ { - "xApiUrl": "~/api", - "ApiUrl": "http://localhost:5126/api", - "xxxApiUrl": "http://messa010ec.ec.local:50301/api", - "xxxxApiUrl": "http://localhost:50301/api", - "xxxxxApiUrl": "http://messa010ec.ec.local:50301/api", - "xConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology;", + "ApiExportPath": "\\\\messdv002.na.infineon.com\\Candela\\Archive\\API", + "ApiUrl": "~/api", "ConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;", "IsDevelopment": true, - "xMockRoot": "", - "MockRoot": "/Data/Tests", + "MockRoot": "", "MonAResource": "OI_Metrology_Viewer_IFX", "Oi2SqlConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;", "Serilog": { diff --git a/Server/appsettings.json b/Server/appsettings.json index 2febcdb..1131189 100644 --- a/Server/appsettings.json +++ b/Server/appsettings.json @@ -1,5 +1,6 @@ { "AllowedHosts": "*", + "ApiExportPath": "\\\\messv02ecc1.ec.local\\EC_Metrology_Si\\Archive\\API", "ApiLoggingContentTypes": "application/json", "ApiLoggingPathPrefixes": "/api/inbound", "ApiUrl": "~/api", diff --git a/Server/wwwroot/js/common.js b/Server/wwwroot/js/common.js index 647cb14..5fc2627 100644 --- a/Server/wwwroot/js/common.js +++ b/Server/wwwroot/js/common.js @@ -60,17 +60,17 @@ function DisplayWSMessage(severity, description, e, ex) { } $("#spanMessageText").text(description); - if (e.status === 403) { + if (e !== null && e.status === 403) { $("#spanMessageText").append("
" + forbiddenMsg + ""); } - else if (e.status === 444) { + else if (e !== null && e.status === 444) { $("#MessageModalContent").removeClass("modal-content-error"); $("#MessageModalContent").addClass("modal-content-info"); $("#MessageModalTitle").text(""); $("#spanMessageText").text(expiredMsg); } - else if (e.responseText !== null) { - if (e.responseText !== "") { + else if (e !== null && e.responseText !== null) { + if (e !== null && e.responseText !== "") { try { wsError = jQuery.parseJSON(e.responseText); if (wsError.Message !== null) @@ -95,7 +95,7 @@ function DisplayWSMessage(severity, description, e, ex) { else { var msg = description + "\r\n"; - if (e.responseText !== null) { + if (e !== null && e.responseText !== null) { if (e.responseText !== "") { wsError = jQuery.parseJSON(e.responseText); if (wsError.ExceptionMessage !== null) { @@ -103,7 +103,7 @@ function DisplayWSMessage(severity, description, e, ex) { } } } - if (e.status === 403) + if (e !== null && e.status === 403) msg += forbiddenMsg; alert(msg); diff --git a/Server/wwwroot/js/site.js b/Server/wwwroot/js/site.js index 013826d..7dfa0fe 100644 --- a/Server/wwwroot/js/site.js +++ b/Server/wwwroot/js/site.js @@ -217,12 +217,16 @@ function loadHeaderGridRunInfo() { function disableHeaderButtonsRunInfo() { $("#GetDataButton").prop("disabled", true); $("#ReviewButton").prop("disabled", true); + $("#RecipeParametersButton").prop("disabled", true); + $("#ViewButton").prop("disabled", true); $("#PinButton").prop("disabled", true); } function enableHeaderButtonsRunInfo() { $("#GetDataButton").prop("disabled", false); $("#ReviewButton").prop("disabled", false); + $("#RecipeParametersButton").prop("disabled", false); + $("#ViewButton").prop("disabled", false); $("#PinButton").prop("disabled", false); } @@ -459,10 +463,151 @@ function reviewButtonRunInfo() { }); } +function recipeParametersButtonRunInfo() { + var selectedRow = $("#HeaderGrid").data("igGridSelection").selectedRow(); + if (selectedRow !== null) { + loadDetailsRunInfo(); + $("#RecipeParametersButton").prop("disabled", true); + var rowData = $("#HeaderGrid").data("igGrid").dataSource.dataView()[selectedRow.index]; + var stringified = JSON.stringify(rowData); + stringified = stringified.replace(/"Tool":/gm, '"MesEntity":'); + stringified = stringified.replace(/"Equipment ID":/gm, '"MesEntity":'); + var jsonObject = JSON.parse(stringified); + DisplayWSMessage("info", "Recipe Parameters - Work In Progress ***", null); + $("#ModalHeaderGrid").igGrid({ + dataSource: jsonObject, + dataSourceType: 'json', + features: [ + { name: 'Resizing' } + ], + columns: [ + { headerText: "Tool", key: "MesEntity", dataType: "string", width: "10%" }, + { key: "Reactor", dataType: "string", width: "10%" }, + { key: "RDS", dataType: "string", width: "10%" }, + { key: "PSN", dataType: "string", width: "10%" }, + { key: "Layer", dataType: "string", width: "10%" }, + { key: "Zone", dataType: "string", width: "10%" } + ] + }); + var gridCreated = $("#ModalBodyGrid").data("igGrid"); + if (gridCreated) + $("#ModalBodyGrid").igGrid("destroy"); + $.getJSON('http://messa020ec.ec.local/api/oiWizard/materials/rds/' + jsonObject.RDS, function (data) { + $("#RecipeParametersButton").prop("disabled", false); + var text = ""; + for (var i = 0; i < data.rds.rdsLayers.length; i++) { + text = text + + data.rds.rdsLayers[i].EpiTime + + "\t" + data.rds.rdsLayers[i].EpiH2Flow + + "\t" + data.rds.rdsLayers[i].TCSFlow + + "\t" + data.rds.rdsLayers[i].DiluentAdjParam + + "\t" + data.rds.rdsLayers[i].EpiH2Flow + + "\t" + data.rds.rdsLayers[i].DopantFlow + + "\t" + data.rds.rdsLayers[i].FOffset + + "\t" + data.rds.rdsLayers[i].SOffset + + "\t" + data.rds.rdsLayers[i].ROffset + + "\t" + data.rds.rdsLayers[i].SuscEtch + + "\r" + } + $("#textareaClipboard").val(text); + $("#ModalBodyGrid").igGrid({ + dataSource: data.rds.rdsLayers, + features: [ + { name: 'Resizing' } + ], + columns: [ + { headerText: "Dep Time", key: "EpiTime", dataType: "number", width: "10%" }, + { headerText: "H2", key: "EpiH2Flow", dataType: "number", width: "10%" }, + { headerText: "TCS", key: "TCSFlow", dataType: "number", width: "10%" }, + { headerText: "DIL", key: "DiluentAdjParam", dataType: "string", width: "10%" }, + { headerText: "SRC", key: "EpiH2Flow", dataType: "number", width: "10%" }, + { headerText: "INJ", key: "DopantFlow", dataType: "string", width: "10%" }, + { headerText: "F", key: "FOffset", dataType: "string", width: "10%" }, + { headerText: "S", key: "SOffset", dataType: "string", width: "10%" }, + { headerText: "R", key: "ROffset", dataType: "string", width: "10%" }, + { headerText: "Susc Etch", key: "SuscEtch", dataType: "string", width: "10%" }, + ], + responseDataKey: "Results", + }); + }); + } +} + +function viewButtonRunInfo() { + var selectedRow = $("#HeaderGrid").data("igGridSelection").selectedRow(); + if (selectedRow !== null) { + $("#ViewButton").prop("disabled", true); + loadDetailsRunInfo(); + var rowData = $("#HeaderGrid").data("igGrid").dataSource.dataView()[selectedRow.index]; + var stringified = JSON.stringify(rowData); + stringified = stringified.replace(/"Tool":/gm, '"MesEntity":'); + stringified = stringified.replace(/"Equipment ID":/gm, '"MesEntity":'); + var jsonObject = JSON.parse(stringified); + DisplayWSMessage("info", "View", null); + $("#ModalHeaderGrid").igGrid({ + dataSource: jsonObject, + dataSourceType: 'json', + features: [ + { name: 'Resizing' } + ], + columns: [ + { headerText: "Tool", key: "MesEntity", dataType: "string", width: "10%" }, + { key: "Reactor", dataType: "string", width: "10%" }, + { key: "RDS", dataType: "string", width: "10%" }, + { key: "PSN", dataType: "string", width: "10%" }, + { key: "Layer", dataType: "string", width: "10%" }, + { key: "Zone", dataType: "string", width: "10%" } + ] + }); + var gridCreated = $("#ModalBodyGrid").data("igGrid"); + if (gridCreated) + $("#ModalBodyGrid").igGrid("destroy"); + var headerId = $("#HeaderId").text(); + var toolTypeID = $("#ToolTypeID").text(); + var detailsURL = _apiUrl + "/tooltypes/" + toolTypeID + "/headers/" + headerId + "/data"; + $.getJSON(detailsURL, function (data) { + var obj = {}; + var text = ""; + for (var i = 0; i < data.Results.length && i < 9; i++) { + if (data.Results[i].Thickness) { + text = text + data.Results[i].Thickness + "\t"; + obj['Point' + (i + 1)] = data.Results[i].Thickness; + } + else if (data.Results[i].Rs) { + text = text + data.Results[i].Rs + "\t"; + obj['Point' + (i + 1)] = data.Results[i].Rs; + } + } + text = text + "\r"; + $("#textareaClipboard").val(text); + $("#ModalBodyGrid").igGrid({ + dataSource: obj, + dataSourceType: 'json', + features: [ + { name: 'Resizing' } + ], + columns: [ + { headerText: "Point 1", key: "Point1", dataType: "string", width: "10%" }, + { headerText: "Point 2", key: "Point2", dataType: "string", width: "10%" }, + { headerText: "Point 3", key: "Point3", dataType: "string", width: "10%" }, + { headerText: "Point 4", key: "Point4", dataType: "string", width: "10%" }, + { headerText: "Point 5", key: "Point5", dataType: "string", width: "10%" }, + { headerText: "Point 6", key: "Point6", dataType: "string", width: "10%" }, + { headerText: "Point 7", key: "Point7", dataType: "string", width: "10%" }, + { headerText: "Point 8", key: "Point8", dataType: "string", width: "10%" }, + { headerText: "Point 9", key: "Point9", dataType: "string", width: "10%" }, + ] + }); + $("#ViewButton").prop("disabled", false); + }); + } +} + function pinButtonRunInfo() { var toolTypeId = $("#ToolTypeID").text(); var selectedRow = $("#HeaderGrid").data("igGridSelection").selectedRow(); if (selectedRow !== null) { + loadDetailsRunInfo(); $("#PinButton").prop("disabled", true); var rowData = $("#HeaderGrid").data("igGrid").dataSource.dataView()[selectedRow.index]; var stringified = JSON.stringify(rowData); @@ -474,10 +619,13 @@ function pinButtonRunInfo() { url: _apiUrl + '/pin/' + toolTypeId + "/markAsPinned", data: jsonObject, success: function (e) { + var gridCreated = $("#ModalBodyGrid").data("igGrid"); + if (gridCreated) + $("#ModalBodyGrid").igGrid("destroy"); DisplayWSMessage("info", "Marked as pinned", e); // DisplayWSMessage("info", stringified, e); $("#PinButton").prop("disabled", false); - $.getJSON(_apiUrl + '/pin/' + toolTypeId + "/pinned?biorad_id=" + _BioRadId + "&cde_id=" + _CdeId + "&rds=" + rowData.RDS, function (data) { + $.getJSON(_apiUrl + '/pin/' + toolTypeId + "/pinned?biorad_id=" + _BioRadId + "&cde_id=" + _CdeId + "&rds=" + jsonObject.RDS, function (data) { $("#ModalHeaderGrid").igGrid({ dataSource: data, features: [ @@ -497,7 +645,17 @@ function pinButtonRunInfo() { }); var text = ""; for (var i = 0; i < data.Results.length; i++) { - text = text + data.Results[i].Point1 + "\t" + data.Results[i].Point2 + "\t" + data.Results[i].Point3 + "\t" + data.Results[i].Point4 + "\t" + data.Results[i].Point5 + "\t" + data.Results[i].Point6 + "\t" + data.Results[i].Point7 + "\t" + data.Results[i].Point8 + "\t" + data.Results[i].Point9 + "\r"; + text = text + + data.Results[i].Point1 + + "\t" + data.Results[i].Point2 + + "\t" + data.Results[i].Point3 + + "\t" + data.Results[i].Point4 + + "\t" + data.Results[i].Point5 + + "\t" + data.Results[i].Point6 + + "\t" + data.Results[i].Point7 + + "\t" + data.Results[i].Point8 + + "\t" + data.Results[i].Point9 + + "\r"; } $("#textareaClipboard").val(text); $("#ModalBodyGrid").igGrid({ @@ -604,6 +762,8 @@ function initRunInfo(apiUrl, initialToolTypeID, initialHeaderId, initialHeaderAt $("#LoadHeadersButton").click(loadHeaderGridRunInfo); $("#GetDataButton").click(loadDetailsRunInfo); $("#ReviewButton").click(reviewButtonRunInfo); + $("#RecipeParametersButton").click(recipeParametersButtonRunInfo); + $("#ViewButton").click(viewButtonRunInfo); $("#PinButton").click(pinButtonRunInfo); $("#OIExportButton").click(oiExportButtonRunInfo); setInterval(function () { @@ -632,6 +792,6 @@ function copy() { copyText.select(); copyText.setSelectionRange(0, 99999); // For mobile devices - // Copy the text inside the text field + // Copy the text inside the text field navigator.clipboard.writeText(copyText.value); } \ No newline at end of file diff --git a/Shared/Models/Stateless/IExportController.cs b/Shared/Models/Stateless/IExportController.cs new file mode 100644 index 0000000..8d949ae --- /dev/null +++ b/Shared/Models/Stateless/IExportController.cs @@ -0,0 +1,22 @@ +using OI.Metrology.Shared.DataModels; + +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IExportController +{ + + enum Action : int + { + Index = 0, + Export = 1, + Headers = 2, + Logistics = 3 + } + + static string GetRouteName() => nameof(IExportController)[1..^10]; + T GetExport(HeaderCommon headerCommon); + T GetHeaders(HeaderCommon headerCommon); + T GetLogistics(HeaderCommon headerCommon); + T GetProcessDataStandardFormat(HeaderCommon headerCommon); + +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IExportRepository.cs b/Shared/Models/Stateless/IExportRepository.cs new file mode 100644 index 0000000..3df9436 --- /dev/null +++ b/Shared/Models/Stateless/IExportRepository.cs @@ -0,0 +1,13 @@ +using OI.Metrology.Shared.DataModels; + +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IExportRepository +{ + + string GetExport(HeaderCommon headerCommon); + Result GetHeaders(HeaderCommon headerCommon); + Result GetLogistics(HeaderCommon headerCommon); + string GetProcessDataStandardFormat(HeaderCommon headerCommon); + +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IInboundController.cs b/Shared/Models/Stateless/IInboundController.cs index 6e05df3..4ae25ed 100644 --- a/Shared/Models/Stateless/IInboundController.cs +++ b/Shared/Models/Stateless/IInboundController.cs @@ -11,7 +11,7 @@ public interface IInboundController } static string GetRouteName() => nameof(IInboundController)[1..^10]; - T Data(string tooltype, JToken jsonbody); + T Post(string tooltype, JToken jsonbody); T AttachFile(string tooltype, long headerid, string datauniqueid = ""); } \ No newline at end of file diff --git a/Tests/UnitTestExportController.cs b/Tests/UnitTestExportController.cs new file mode 100644 index 0000000..c57bee5 --- /dev/null +++ b/Tests/UnitTestExportController.cs @@ -0,0 +1,132 @@ +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.DependencyInjection; +using OI.Metrology.Shared.DataModels; +using OI.Metrology.Shared.Models.Stateless; +using Serilog; + +namespace OI.Metrology.Tests; + +[TestClass] +public class UnitTestExportController +{ + +#pragma warning disable CS8618 + + private static ILogger _Logger; + private static string _ControllerName; + private static TestContext _TestContext; + private static WebApplicationFactory _WebApplicationFactory; + +#pragma warning restore + + [ClassInitialize] + public static void ClassInitAsync(TestContext testContext) + { + _TestContext = testContext; + _Logger = Log.ForContext(); + _WebApplicationFactory = new WebApplicationFactory(); + _ControllerName = nameof(Server.ApiControllers.ExportController)[..^10]; + } + + [TestMethod] + public void TestControllerName() + { + _Logger.Information("Starting Web Application"); + Assert.AreEqual(IExportController.GetRouteName(), _ControllerName); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + private static HeaderCommon GetHeaderCommon() => + new() { PSN = "5008", Reactor = "39", RDS = "578918", ID = 1 }; + + [TestMethod] + public void GetExport() + { + _Logger.Information("Starting Web Application"); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + IExportRepository exportRepository = serviceProvider.GetRequiredService(); + string result = exportRepository.GetExport(GetHeaderCommon()); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task GetExportApi() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/headers"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExport)}.txt"), result); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public void GetHeaders() + { + _Logger.Information("Starting Web Application"); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + IExportRepository exportRepository = serviceProvider.GetRequiredService(); + Result result = exportRepository.GetHeaders(GetHeaderCommon()); + Assert.IsNotNull(result?.Results); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task GetHeadersApi() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/headers"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Assert.IsNotNull(result?.Results); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public void GetLogistics() + { + _Logger.Information("Starting Web Application"); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + IExportRepository exportRepository = serviceProvider.GetRequiredService(); + Result result = exportRepository.GetLogistics(GetHeaderCommon()); + Assert.IsNotNull(result?.Results); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task GetLogisticsApi() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/headers"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLogistics)}.json"), json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Assert.IsNotNull(result?.Results); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public void GetProcessDataStandardFormat() + { + _Logger.Information("Starting Web Application"); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + IExportRepository exportRepository = serviceProvider.GetRequiredService(); + string result = exportRepository.GetProcessDataStandardFormat(GetHeaderCommon()); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task GetProcessDataStandardFormatApi() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/headers"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProcessDataStandardFormat)}.pdsf"), result); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + +} \ No newline at end of file diff --git a/azure-pipelines-server-development.yml b/azure-pipelines-server-development.yml index 478e6b1..22b1729 100644 --- a/azure-pipelines-server-development.yml +++ b/azure-pipelines-server-development.yml @@ -107,6 +107,7 @@ steps: inputs: testResultsFormat: VSTest testResultsFiles: "**/*.trx" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 diff --git a/azure-pipelines-server.yml b/azure-pipelines-server.yml index e41d1d3..5ef60c1 100644 --- a/azure-pipelines-server.yml +++ b/azure-pipelines-server.yml @@ -107,6 +107,7 @@ steps: inputs: testResultsFormat: VSTest testResultsFiles: "**/*.trx" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1