Test Pinned via API ||
This commit is contained in:
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@ -44,7 +44,7 @@
|
||||
"args": [
|
||||
"watch",
|
||||
"--launch-profile",
|
||||
"https",
|
||||
"http",
|
||||
"run",
|
||||
"--project",
|
||||
"${workspaceFolder}/Server/OI.Metrology.Server.csproj",
|
||||
|
@ -29,16 +29,17 @@ public class PinController : Controller, IPinController<IActionResult>
|
||||
if (was is not null)
|
||||
_Logger.LogDebug($"{toolTypeId} was: {was}");
|
||||
HttpContext.Session.SetString(toolTypeId, json);
|
||||
_PinRepository.SetPinnedTable(headerCommon);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}/pinned")]
|
||||
public IActionResult GetPinnedTable(int id)
|
||||
[Route("{id}/pinned/{rds}")]
|
||||
public IActionResult GetPinnedTable(int id, string rds = "")
|
||||
{
|
||||
string? cde = HttpContext.Session.GetString(((int)IPinRepository.ToolId.CDE).ToString());
|
||||
string? bioRad = HttpContext.Session.GetString(((int)IPinRepository.ToolId.BioRad).ToString());
|
||||
return Json(_PinRepository.GetPinnedTable(_MetrologyRepository, id, bioRad, cde), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
|
||||
return Json(_PinRepository.GetPinnedTable(_MetrologyRepository, id, rds, bioRad, cde), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
|
||||
}
|
||||
|
||||
}
|
@ -11,6 +11,8 @@ namespace OI.Metrology.Server.Controllers;
|
||||
|
||||
public class ExportController : Controller
|
||||
{
|
||||
|
||||
private readonly string _ApiUrl;
|
||||
private readonly ILogger _Logger;
|
||||
private readonly bool _IsTestDatabase;
|
||||
private readonly AppSettings _AppSettings;
|
||||
@ -22,6 +24,7 @@ public class ExportController : Controller
|
||||
_AppSettings = appSettings;
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
||||
_ApiUrl = string.IsNullOrEmpty(appSettings.ApiUrl) ? Url.Content("~/") : appSettings.ApiUrl[0] == '~' ? Url.Content(appSettings.ApiUrl) : appSettings.ApiUrl;
|
||||
}
|
||||
|
||||
public override void OnActionExecuted(ActionExecutedContext context)
|
||||
@ -29,7 +32,7 @@ public class ExportController : Controller
|
||||
base.OnActionExecuted(context);
|
||||
ViewBag.IsTestDatabase = _IsTestDatabase;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[Route("/Export")]
|
||||
public ActionResult Index()
|
||||
@ -41,6 +44,7 @@ public class ExportController : Controller
|
||||
};
|
||||
MonIn monIn = MonIn.GetInstance();
|
||||
_ = monIn.SendStatus(_AppSettings.MonASite, _AppSettings.MonAResource, "Heartbeat", State.Up);
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@ -81,6 +85,7 @@ public class ExportController : Controller
|
||||
_ = monIn.SendStatus(_AppSettings.MonASite, _AppSettings.MonAResource, "Heartbeat", State.Warning);
|
||||
}
|
||||
}
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View("Index", model);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ namespace OI.Metrology.Server.Controllers;
|
||||
|
||||
public class PagesController : Controller
|
||||
{
|
||||
|
||||
private readonly string _ApiUrl;
|
||||
private readonly bool _IsTestDatabase;
|
||||
private readonly IMetrologyRepository _MetrologyRepository;
|
||||
|
||||
@ -15,6 +17,7 @@ public class PagesController : Controller
|
||||
{
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
||||
_ApiUrl = string.IsNullOrEmpty(appSettings.ApiUrl) ? Url.Content("~/") : appSettings.ApiUrl[0] == '~' ? Url.Content(appSettings.ApiUrl) : appSettings.ApiUrl;
|
||||
}
|
||||
|
||||
public override void OnActionExecuted(ActionExecutedContext context)
|
||||
@ -25,14 +28,20 @@ public class PagesController : Controller
|
||||
|
||||
[HttpGet]
|
||||
[Route("/")]
|
||||
public IActionResult Index() =>
|
||||
View("AwaitingDispo");
|
||||
public IActionResult Index()
|
||||
{
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View("AwaitingDispo");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/AwaitingDispo")]
|
||||
[Route("/Metrology/AwaitingDispo")]
|
||||
public IActionResult AwaitingDispo() =>
|
||||
View();
|
||||
public IActionResult AwaitingDispo()
|
||||
{
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/RunInfo")]
|
||||
@ -49,14 +58,18 @@ public class PagesController : Controller
|
||||
{
|
||||
m.HeaderAttachmentID = _MetrologyRepository.GetHeaderAttachmentID(tooltypeid, headerid);
|
||||
}
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View(m);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/RunHeaders")]
|
||||
[Route("/Metrology/RunHeaders")]
|
||||
public IActionResult RunHeaders() =>
|
||||
View();
|
||||
public IActionResult RunHeaders()
|
||||
{
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/Crash")]
|
||||
|
@ -5,6 +5,7 @@ namespace OI.Metrology.Server.Models;
|
||||
public record AppSettings(string ApiLoggingContentTypes,
|
||||
string ApiLoggingPathPrefixes,
|
||||
string ApiLogPath,
|
||||
string ApiUrl,
|
||||
string AttachmentPath,
|
||||
string BuildNumber,
|
||||
string Company,
|
||||
|
@ -11,6 +11,7 @@ public class AppSettings
|
||||
[Display(Name = "Api Logging Content Types"), Required] public string ApiLoggingContentTypes { get; set; }
|
||||
[Display(Name = "Api Logging Path Prefixes"), Required] public string ApiLoggingPathPrefixes { get; set; }
|
||||
[Display(Name = "Api Log Path"), Required] public string ApiLogPath { get; set; }
|
||||
[Display(Name = "Api URL"), Required] public string ApiUrl { get; set; }
|
||||
[Display(Name = "Attachment Path"), Required] public string AttachmentPath { get; set; }
|
||||
[Display(Name = "Build Number"), Required] public string BuildNumber { get; set; }
|
||||
[Display(Name = "Company"), Required] public string Company { get; set; }
|
||||
@ -46,6 +47,8 @@ public class AppSettings
|
||||
throw new NullReferenceException(nameof(ApiLoggingPathPrefixes));
|
||||
if (appSettings.ApiLogPath is null)
|
||||
throw new NullReferenceException(nameof(ApiLogPath));
|
||||
if (appSettings.ApiUrl is null)
|
||||
throw new NullReferenceException(nameof(ApiUrl));
|
||||
if (appSettings.AttachmentPath is null)
|
||||
throw new NullReferenceException(nameof(AttachmentPath));
|
||||
if (appSettings.BuildNumber is null)
|
||||
@ -80,6 +83,7 @@ public class AppSettings
|
||||
appSettings.ApiLoggingContentTypes,
|
||||
appSettings.ApiLoggingPathPrefixes,
|
||||
appSettings.ApiLogPath,
|
||||
appSettings.ApiUrl,
|
||||
appSettings.AttachmentPath,
|
||||
appSettings.BuildNumber,
|
||||
appSettings.Company,
|
||||
|
@ -102,6 +102,7 @@ public class Program
|
||||
if (!webApplicationBuilder.Environment.IsDevelopment())
|
||||
{
|
||||
_ = webApplication.UseExceptionHandler("/Error");
|
||||
_ = webApplication.UseHttpsRedirection();
|
||||
_ = webApplication.UseHsts();
|
||||
}
|
||||
else
|
||||
@ -120,7 +121,6 @@ public class Program
|
||||
_ = webApplication.UseFileServer(enableDirectoryBrowsing: true);
|
||||
_ = webApplication.UseStaticFiles();
|
||||
_ = webApplication.UseSession();
|
||||
_ = webApplication.UseHttpsRedirection();
|
||||
_ = webApplication.UseMiddleware<ApiLoggingMiddleware>();
|
||||
_ = webApplication.MapControllers();
|
||||
log.Information("Starting Web Application");
|
||||
|
@ -9,20 +9,54 @@ public class PinRepository : IPinRepository
|
||||
|
||||
private readonly string _MockRoot;
|
||||
private readonly Serilog.ILogger _Log;
|
||||
private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection;
|
||||
|
||||
public PinRepository(string mockRoot)
|
||||
{
|
||||
_MockRoot = mockRoot;
|
||||
_RdsToHeaderCommonCollection = new();
|
||||
_Log = Serilog.Log.ForContext<PinRepository>();
|
||||
}
|
||||
|
||||
Result<Pinned[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde)
|
||||
void IPinRepository.SetPinnedTable(HeaderCommon headerCommon)
|
||||
{
|
||||
Dictionary<long, HeaderCommon>? toolIdToHeader;
|
||||
if (!string.IsNullOrEmpty(headerCommon.RDS))
|
||||
{
|
||||
if (!_RdsToHeaderCommonCollection.TryGetValue(headerCommon.RDS, out toolIdToHeader))
|
||||
{
|
||||
_RdsToHeaderCommonCollection.Add(headerCommon.RDS, new());
|
||||
if (!_RdsToHeaderCommonCollection.TryGetValue(headerCommon.RDS, out toolIdToHeader))
|
||||
throw new Exception();
|
||||
}
|
||||
if (toolIdToHeader.ContainsKey(headerCommon.ToolTypeID))
|
||||
toolIdToHeader[headerCommon.ToolTypeID] = headerCommon;
|
||||
else
|
||||
toolIdToHeader.Add(headerCommon.ToolTypeID, headerCommon);
|
||||
}
|
||||
}
|
||||
|
||||
Result<Pinned[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? rds, string? bioRad, string? cde)
|
||||
{
|
||||
Result<Pinned[]>? r;
|
||||
HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize<HeaderCommon>(cde);
|
||||
long cdeId = cdeHeader is null ? (long)IPinRepository.ToolId.CDE : cdeHeader.ToolTypeID;
|
||||
HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize<HeaderCommon>(bioRad);
|
||||
long bioRadId = bioRadHeader is null ? (long)IPinRepository.ToolId.BioRad : bioRadHeader.ToolTypeID;
|
||||
if (!string.IsNullOrEmpty(rds) && (cdeHeader is null || bioRadHeader is null))
|
||||
{
|
||||
Dictionary<long, HeaderCommon>? toolIdToHeader;
|
||||
if (!_RdsToHeaderCommonCollection.TryGetValue(rds, out toolIdToHeader))
|
||||
{
|
||||
_RdsToHeaderCommonCollection.Add(rds, new());
|
||||
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];
|
||||
}
|
||||
if (cdeId != id && bioRadId != id)
|
||||
r = new() { Results = Array.Empty<Pinned>(), TotalRows = 0 };
|
||||
else
|
||||
|
@ -47,9 +47,11 @@
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
var apiUrl = "@ViewBag.ApiUrl";
|
||||
|
||||
$("#ToolType").igCombo({
|
||||
dataSource: '@Url.Content("~/api/tooltypes")',
|
||||
dataSource: apiUrl + '/tooltypes',
|
||||
responseDataKey: "Results",
|
||||
textKey: "ToolTypeName",
|
||||
valueKey: "ID",
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
initAwaitingDisposition("@Url.Content("~/api")");
|
||||
initAwaitingDisposition("@ViewBag.ApiUrl");
|
||||
|
||||
});
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
initRunHeaders("@Url.Content("~/api")");
|
||||
initRunHeaders("@ViewBag.ApiUrl");
|
||||
|
||||
});
|
||||
|
||||
|
@ -52,6 +52,9 @@
|
||||
<div class="col-xs-1">
|
||||
<input type="button" class="btn" id="PinButton" value="Pin" disabled />
|
||||
</div>
|
||||
<div class="col-xs-1">
|
||||
<table style="min-width:600px; min-height:300px;" id="PinnedGrid"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="DetailsDiv" hidden>
|
||||
@ -74,17 +77,11 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div id="PinnedDiv">
|
||||
<div style="padding-bottom: 20px;" id="PinnedGridDiv">
|
||||
<table id="PinnedGrid"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
initRunInfo("@Url.Content("~/api")", "@Model.ToolTypeID", "@Model.HeaderID", "@Model.HeaderAttachmentID");
|
||||
initRunInfo("@ViewBag.ApiUrl", "@Model.ToolTypeID", "@Model.HeaderID", "@Model.HeaderAttachmentID");
|
||||
|
||||
});
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
"ConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;",
|
||||
"IsDevelopment": true,
|
||||
"xMockRoot": "/Data/Tests",
|
||||
"ApiUrl": "http://messa010ec.ec.local:50301/api",
|
||||
"MockRoot": "",
|
||||
"MonAResource": "OI_Metrology_Viewer_IFX",
|
||||
"Oi2SqlConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;",
|
||||
|
@ -2,6 +2,7 @@
|
||||
"AllowedHosts": "*",
|
||||
"ApiLoggingContentTypes": "application/json",
|
||||
"ApiLoggingPathPrefixes": "/api/inbound",
|
||||
"ApiUrl": "~/api",
|
||||
"ApiLogPath": "D:\\Metrology\\MetrologyAPILogs",
|
||||
"AttachmentPath": "\\\\messv02ecc1.ec.local\\EC_Metrology_Si\\MetrologyAttachments",
|
||||
"BuildNumber": "1",
|
||||
|
@ -221,31 +221,6 @@ function loadHeaderGridRunInfo() {
|
||||
DisplayWSMessage("error", "There was an error getting tooltype info.", e);
|
||||
}
|
||||
});
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// url: _apiUrl + "/pin/" + toolTypeID + "/pinned",
|
||||
// success: function (r) {
|
||||
// if ((r.Results == null) || (r.Results.HeaderId == null))
|
||||
// DisplayWSMessage("error", "B) There was an error getting pinned info.");
|
||||
// else
|
||||
// DisplayWSMessage("info", r.Results.HeaderId);
|
||||
// },
|
||||
// error: function (e) {
|
||||
// DisplayWSMessage("error", "There was an error getting pinned info.", e);
|
||||
// }
|
||||
// });
|
||||
$("#PinnedGrid").igGrid({
|
||||
width: "70%",
|
||||
height: "100%",
|
||||
dataSource: _apiUrl + "/pin/" + toolTypeID + "/pinned",
|
||||
responseDataKey: "Results",
|
||||
tabIndex: 1,
|
||||
features: [
|
||||
{ name: "Selection", mode: "row", multipleSelection: false },
|
||||
{ name: "Filtering", type: "local" },
|
||||
{ name: "Sorting", type: "local" },
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
function disableHeaderButtonsRunInfo() {
|
||||
@ -505,6 +480,26 @@ function pinButtonRunInfo() {
|
||||
success: function (e) {
|
||||
DisplayWSMessage("info", "Marked as pinned", e);
|
||||
$("#PinButton").prop("disabled", false);
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// url: _apiUrl + "/pin/" + toolTypeID + "/pinned",
|
||||
// success: function (r) {
|
||||
// if ((r.Results == null) || (r.Results.HeaderId == null))
|
||||
// DisplayWSMessage("error", "B) There was an error getting pinned info.");
|
||||
// else
|
||||
// DisplayWSMessage("info", r.Results.HeaderId);
|
||||
// },
|
||||
// error: function (e) {
|
||||
// DisplayWSMessage("error", "There was an error getting pinned info.", e);
|
||||
// }
|
||||
// });
|
||||
// $.getJSON(_apiUrl + "/awaitingdispo/", function (data) {
|
||||
$.getJSON(_apiUrl + "/pin/" + rowData.ToolTypeID + "/pinned?rds=" + rowData.RDS, function (data) {
|
||||
$("#PinnedGrid").igGrid({
|
||||
dataSource: data,
|
||||
responseDataKey: "Results",
|
||||
});
|
||||
});
|
||||
},
|
||||
error: function (e, ajaxOptions, ex) {
|
||||
DisplayWSMessage("error", "There was an error marking header as pinned.", e, ex);
|
||||
|
@ -15,6 +15,7 @@ public interface IPinRepository
|
||||
SP1 = 6,
|
||||
}
|
||||
|
||||
Result<Pinned[]> GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde);
|
||||
|
||||
Result<Pinned[]> GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? rds, string? bioRad, string? cde);
|
||||
void SetPinnedTable(HeaderCommon headerCommon);
|
||||
|
||||
}
|
@ -45,7 +45,7 @@ public class UnitTestPinController
|
||||
IPinRepository pinRepository = serviceProvider.GetRequiredService<IPinRepository>();
|
||||
string? cde = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 196984, ToolTypeID = 2 });
|
||||
string? bioRad = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 321568, ToolTypeID = 1 });
|
||||
Result<Pinned[]> result = pinRepository.GetPinnedTable(metrologyRepository, id: 1, bioRad, cde);
|
||||
Result<Pinned[]> result = pinRepository.GetPinnedTable(metrologyRepository, id: 1, rds: string.Empty, bioRad, cde);
|
||||
Assert.IsNotNull(result?.Results);
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
|
Reference in New Issue
Block a user