diff --git a/OI-Metrology.sln b/OI-Metrology.sln index e8a893a..3ecee65 100644 --- a/OI-Metrology.sln +++ b/OI-Metrology.sln @@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Archive", "Archive\OI.Metro EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\OI.Metrology.Shared.csproj", "{A807EAE3-7DCB-4E5E-BE54-0D7410D18B3E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "View", "View\OI.Metrology.View.csproj", "{D7988D0C-FE5D-429B-AA1C-911A1A29A468}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\OI.Metrology.Server.csproj", "{25C86DF8-EC1A-4D4B-AD4E-6561174824B9}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\OI.Metrology.Tests.csproj", "{B67FB8C4-402E-4D53-90A6-90F6FDB9D082}" @@ -38,9 +36,5 @@ Global {B67FB8C4-402E-4D53-90A6-90F6FDB9D082}.Debug|Any CPU.Build.0 = Debug|Any CPU {B67FB8C4-402E-4D53-90A6-90F6FDB9D082}.Release|Any CPU.ActiveCfg = Release|Any CPU {B67FB8C4-402E-4D53-90A6-90F6FDB9D082}.Release|Any CPU.Build.0 = Release|Any CPU - {D7988D0C-FE5D-429B-AA1C-911A1A29A468}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D7988D0C-FE5D-429B-AA1C-911A1A29A468}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D7988D0C-FE5D-429B-AA1C-911A1A29A468}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D7988D0C-FE5D-429B-AA1C-911A1A29A468}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Server/ApiControllers/PinController.cs b/Server/ApiControllers/PinController.cs index 5050f62..c403959 100644 --- a/Server/ApiControllers/PinController.cs +++ b/Server/ApiControllers/PinController.cs @@ -18,7 +18,7 @@ public class PinController : Controller, IPinController _PinRepository = pinRepository; } - [HttpPost("/api/pin/markAsPinned")] + [HttpPost("{toolTypeId}/markAsPinned")] public IActionResult MarkAsPinned(Shared.DataModels.HeaderCommon headerCommon) { _PinRepository.SetPinnedTable(headerCommon); @@ -26,8 +26,8 @@ public class PinController : Controller, IPinController } [HttpGet] - [Route("{id}/pinned")] - public IActionResult GetPinnedTable(int id, string? biorad_id = null, string? cde_id = null, string? rds = null) => - Json(_PinRepository.GetPinnedTable(_MetrologyRepository, id, biorad_id, cde_id, rds), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); + [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 }); } \ No newline at end of file diff --git a/Server/Repositories/PinRepository.cs b/Server/Repositories/PinRepository.cs index 0d5f16d..c91a37a 100644 --- a/Server/Repositories/PinRepository.cs +++ b/Server/Repositories/PinRepository.cs @@ -38,9 +38,6 @@ public class PinRepository : IPinRepository private (HeaderCommon?, HeaderCommon?) GetBoth(string rds, long bioRadId, long cdeId) { - HeaderCommon? cdeHeader, bioRadHeader; - cdeHeader = null; - bioRadHeader = null; Dictionary? toolIdToHeader; if (!_RdsToHeaderCommonCollection.TryGetValue(rds, out toolIdToHeader)) { @@ -48,10 +45,8 @@ public class PinRepository : IPinRepository if (!_RdsToHeaderCommonCollection.TryGetValue(rds, out toolIdToHeader)) throw new Exception(); } - if (cdeHeader is null && toolIdToHeader.ContainsKey(cdeId)) - cdeHeader = toolIdToHeader[cdeId]; - if (bioRadHeader is null && toolIdToHeader.ContainsKey(bioRadId)) - bioRadHeader = toolIdToHeader[bioRadId]; + _ = toolIdToHeader.TryGetValue(cdeId, out HeaderCommon? cdeHeader); + _ = toolIdToHeader.TryGetValue(bioRadId, out HeaderCommon? bioRadHeader); return new(bioRadHeader, cdeHeader); } @@ -79,31 +74,6 @@ public class PinRepository : IPinRepository return result; } - private static Pinned? GetCDE(IMetrologyRepository metrologyRepository, int points, HeaderCommon bioRadHeader) - { - Pinned? result; - List values; - const int thickness = 5; - System.Data.DataTable dataTable = metrologyRepository.GetData((int)bioRadHeader.ToolTypeID, bioRadHeader.ID); - if (dataTable.Rows.Count <= points || dataTable.Columns.Count <= thickness) - result = null; - else - { - values = new(); - for (int i = 0; i < dataTable.Rows.Count - 1; i++) - { - if (dataTable.Rows[i]?.ItemArray[thickness] is null) - break; - values.Add(string.Concat(dataTable.Rows[i].ItemArray[thickness])); - } - if (values.Count <= points) - result = null; - else - result = new(bioRadHeader, values); - } - return result; - } - Result IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? biorad_id, string? cde_id, string? rds) { Result? r; diff --git a/Server/wwwroot/js/site.js b/Server/wwwroot/js/site.js index 3cf5e45..d47e6a8 100644 --- a/Server/wwwroot/js/site.js +++ b/Server/wwwroot/js/site.js @@ -460,18 +460,19 @@ function reviewButtonRunInfo() { } function pinButtonRunInfo() { + var toolTypeId = $("#ToolTypeID").text(); var selectedRow = $("#HeaderGrid").data("igGridSelection").selectedRow(); if (selectedRow !== null) { $("#PinButton").prop("disabled", true); var rowData = $("#HeaderGrid").data("igGrid").dataSource.dataView()[selectedRow.index]; $.ajax({ type: "POST", - url: _apiUrl + "/pin/markAsPinned", + url: _apiUrl + '/pin/' + toolTypeId + "/markAsPinned", data: rowData, success: function (e) { DisplayWSMessage("info", "Marked as pinned", e); $("#PinButton").prop("disabled", false); - $.getJSON(_apiUrl + "/pin/" + rowData.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=" + rowData.RDS, function (data) { $("#PinnedGrid").igGrid({ dataSource: data, responseDataKey: "Results", diff --git a/Shared/Models/Stateless/IPinController.cs b/Shared/Models/Stateless/IPinController.cs index aea380c..61c099f 100644 --- a/Shared/Models/Stateless/IPinController.cs +++ b/Shared/Models/Stateless/IPinController.cs @@ -11,5 +11,6 @@ public interface IPinController static string GetRouteName() => nameof(IPinController)[1..^10]; T MarkAsPinned(DataModels.HeaderCommon headerCommon); + T GetPinnedTable(int toolTypeId, string? biorad_id = null, string? cde_id = null, string? rds = null); } \ No newline at end of file