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 bc3b00a..8d9e274 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,6 @@ "**/.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/thunder-tests/thunderActivity.json b/.vscode/thunder-tests/thunderActivity.json new file mode 100644 index 0000000..c7dd363 --- /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/apidev/oiWizard/materials/rds/578941", + "method": "GET", + "sortNum": 0, + "created": "2023-03-02T18:20:01.561Z", + "modified": "2023-03-06T17:18:56.337Z", + "headers": [], + "params": [], + "tests": [ + { + "type": "json-query", + "custom": "json.rds.rdsLayers", + "action": "count", + "value": "1" + } + ] + } +] \ No newline at end of file diff --git a/thunder-tests/thunderCollection.json b/.vscode/thunder-tests/thunderCollection.json similarity index 100% rename from thunder-tests/thunderCollection.json rename to .vscode/thunder-tests/thunderCollection.json diff --git a/thunder-tests/thunderEnvironment.json b/.vscode/thunder-tests/thunderEnvironment.json similarity index 100% rename from thunder-tests/thunderEnvironment.json rename to .vscode/thunder-tests/thunderEnvironment.json diff --git a/thunder-tests/thunderclient.json b/.vscode/thunder-tests/thunderclient.json similarity index 100% rename from thunder-tests/thunderclient.json rename to .vscode/thunder-tests/thunderclient.json 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 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..c98aa9f --- /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.GetLogistics)}.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.GetLogistics)}.txt")); + 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..9f81e0e 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,139 @@ 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/apidev/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].DiluentAdjParam + "\t" + data.rds.rdsLayers[i].DopantFlow + "\t" + data.rds.rdsLayers[i].HCLFlow + "\t" + data.rds.rdsLayers[i].BakeTime + "\t" + data.rds.rdsLayers[i].EpiH2Flow + "\t" + data.rds.rdsLayers[i].TCSFlow + "\t" + data.rds.rdsLayers[i].DCSFlow + "\t" + data.rds.rdsLayers[i].FOffset + "\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: "DopantFlow", key: "DopantFlow", dataType: "number", width: "10%" }, + // { headerText: "HCLFlow", key: "HCLFlow", dataType: "string", width: "10%" }, + // { headerText: "BakeTime", key: "BakeTime", dataType: "string", width: "10%" }, + // { headerText: "DCSFlow", key: "DCSFlow", dataType: "string", width: "10%" }, + // { headerText: "FOffset", key: "FOffset", 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 +607,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: [ @@ -604,6 +740,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 +770,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/thunder-tests/thunderActivity.json b/thunder-tests/thunderActivity.json deleted file mode 100644 index 0637a08..0000000 --- a/thunder-tests/thunderActivity.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file