rowData isn't HeaderCommon

This commit is contained in:
Mike Phares 2023-02-10 10:25:38 -07:00
parent 2481c2b3ff
commit 45ea70212e
5 changed files with 10 additions and 44 deletions

View File

@ -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

View File

@ -18,7 +18,7 @@ public class PinController : Controller, IPinController<IActionResult>
_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<IActionResult>
}
[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 });
}

View File

@ -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<long, HeaderCommon>? 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<string> 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<Pinned[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? biorad_id, string? cde_id, string? rds)
{
Result<Pinned[]>? r;

View File

@ -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",

View File

@ -11,5 +11,6 @@ public interface IPinController<T>
static string GetRouteName() => nameof(IPinController<T>)[1..^10];
T MarkAsPinned(DataModels.HeaderCommon headerCommon);
T GetPinnedTable(int toolTypeId, string? biorad_id = null, string? cde_id = null, string? rds = null);
}