Need DB
This commit is contained in:
parent
90d58e8e9c
commit
65a3c6e7f6
43
Server/ApiControllers/PinController.cs
Normal file
43
Server/ApiControllers/PinController.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace OI.Metrology.Server.ApiControllers;
|
||||||
|
|
||||||
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class PinController : Controller, IPinController<IActionResult>
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly ILogger _Logger;
|
||||||
|
private readonly IPinRepository _PinRepository;
|
||||||
|
private readonly IMetrologyRepository _MetrologyRepository;
|
||||||
|
|
||||||
|
public PinController(ILogger<InboundController> logger, IMetrologyRepository metrologyRepository, IPinRepository pinRepository)
|
||||||
|
{
|
||||||
|
_Logger = logger;
|
||||||
|
_MetrologyRepository = metrologyRepository;
|
||||||
|
_PinRepository = pinRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("/api/pin/markAsPinned")]
|
||||||
|
public IActionResult MarkAsPinned(Shared.DataModels.HeaderCommon headerCommon)
|
||||||
|
{
|
||||||
|
string toolTypeId = headerCommon.ToolTypeID.ToString();
|
||||||
|
string json = JsonSerializer.Serialize(headerCommon, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
|
||||||
|
string? was = HttpContext.Session.GetString(toolTypeId);
|
||||||
|
if (was is not null)
|
||||||
|
_Logger.LogDebug($"{toolTypeId} was: {was}");
|
||||||
|
HttpContext.Session.SetString(toolTypeId, json);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("{id}/pinned")]
|
||||||
|
public IActionResult GetPinnedTable(int id)
|
||||||
|
{
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
}
|
@ -67,11 +67,12 @@ public class Program
|
|||||||
|
|
||||||
_ = webApplicationBuilder.Services.AddSingleton(_ => appSettings);
|
_ = webApplicationBuilder.Services.AddSingleton(_ => appSettings);
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IInboundRepository, InboundRepository>();
|
_ = webApplicationBuilder.Services.AddSingleton<IInboundRepository, InboundRepository>();
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IAppSettingsRepository<Models.Binder.AppSettings>>(_ => appSettingsRepository);
|
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IClientSettingsRepository>(_ => clientSettingsRepository);
|
_ = webApplicationBuilder.Services.AddSingleton<IClientSettingsRepository>(_ => clientSettingsRepository);
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IServiceShopOrderRepository, ServiceShopOrderRepository>();
|
_ = webApplicationBuilder.Services.AddSingleton<IServiceShopOrderRepository, ServiceShopOrderRepository>();
|
||||||
|
_ = webApplicationBuilder.Services.AddSingleton<IPinRepository, PinRepository>(_ => new(appSettings.MockRoot));
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IDbConnectionFactory, SQLDbConnectionFactory>(_ => sqlDbConnectionFactory);
|
_ = webApplicationBuilder.Services.AddSingleton<IDbConnectionFactory, SQLDbConnectionFactory>(_ => sqlDbConnectionFactory);
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IToolTypesRepository, ToolTypesRepository>(_ => new(appSettings.MockRoot));
|
_ = webApplicationBuilder.Services.AddSingleton<IToolTypesRepository, ToolTypesRepository>(_ => new(appSettings.MockRoot));
|
||||||
|
_ = webApplicationBuilder.Services.AddSingleton<IAppSettingsRepository<Models.Binder.AppSettings>>(_ => appSettingsRepository);
|
||||||
|
|
||||||
_ = webApplicationBuilder.Services.AddScoped<IAttachmentsService, AttachmentsService>();
|
_ = webApplicationBuilder.Services.AddScoped<IAttachmentsService, AttachmentsService>();
|
||||||
_ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>();
|
_ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>();
|
||||||
|
60
Server/Repositories/PinRepository.cs
Normal file
60
Server/Repositories/PinRepository.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using OI.Metrology.Shared.DataModels;
|
||||||
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace OI.Metrology.Server.Repository;
|
||||||
|
|
||||||
|
public class PinRepository : IPinRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly string _MockRoot;
|
||||||
|
private readonly Serilog.ILogger _Log;
|
||||||
|
|
||||||
|
public PinRepository(string mockRoot)
|
||||||
|
{
|
||||||
|
_MockRoot = mockRoot;
|
||||||
|
_Log = Serilog.Log.ForContext<PinRepository>();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<HeaderCommond[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde)
|
||||||
|
{
|
||||||
|
Result<HeaderCommond[]>? r;
|
||||||
|
if (!id.Equals(IPinRepository.ToolId.BioRad) && !id.Equals(IPinRepository.ToolId.CDE))
|
||||||
|
r = new() { Results = Array.Empty<HeaderCommond>(), TotalRows = 0 };
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(_MockRoot))
|
||||||
|
{
|
||||||
|
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetPinnedTableApi.json"));
|
||||||
|
r = JsonSerializer.Deserialize<Result<HeaderCommond[]>>(json);
|
||||||
|
if (r is null)
|
||||||
|
throw new NullReferenceException(nameof(r));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<HeaderCommond> results = new();
|
||||||
|
HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize<HeaderCommon>(cde);
|
||||||
|
HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize<HeaderCommon>(bioRad);
|
||||||
|
if (bioRadHeader is not null)
|
||||||
|
{
|
||||||
|
System.Data.DataTable dataTable = metrologyRepository.GetData((int)IPinRepository.ToolId.BioRad, bioRadHeader.ID);
|
||||||
|
if (dataTable.Rows.Count == 11)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
if (cdeHeader is not null)
|
||||||
|
{
|
||||||
|
System.Data.DataTable dataTable = metrologyRepository.GetData((int)IPinRepository.ToolId.CDE, cdeHeader.ID);
|
||||||
|
if (dataTable.Rows.Count == 11)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
r = new()
|
||||||
|
{
|
||||||
|
Results = results.ToArray(),
|
||||||
|
TotalRows = results.Count,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,59 +18,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
$("#grid").igGrid({
|
initAwaitingDisposition("@Url.Content("~/api")");
|
||||||
autoGenerateColumns: false,
|
|
||||||
width: "70%",
|
|
||||||
height: "100%",
|
|
||||||
primaryKey: "PK",
|
|
||||||
columns: [
|
|
||||||
{ key: "PK", dataType: "string", hidden: true, },
|
|
||||||
{ key: "ID", dataType: "number", hidden: true, },
|
|
||||||
{ key: "ToolTypeID", dataType: "number", hidden: true, },
|
|
||||||
{ headerText: "Tool Type", key: "ToolType", dataType: "string", width: "15%" },
|
|
||||||
{ key: "Tool", 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%" },
|
|
||||||
{ key: "InsertDate", dataType: "date", width: "10%", format: "dateTime" },
|
|
||||||
{ key: "Expiration", dataType: "date", width: "10%", format: "dateTime" }
|
|
||||||
],
|
|
||||||
dataSource: "@Url.Content("~/api/awaitingdispo/")",
|
|
||||||
responseDataKey: "Results",
|
|
||||||
tabIndex: 1,
|
|
||||||
features: [
|
|
||||||
{ name: "Selection", mode: "row", multipleSelection: false },
|
|
||||||
{ name: "Filtering", type: "local" },
|
|
||||||
{ name: "Sorting", type: "local" },
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
function LoadRunInfo() {
|
|
||||||
var row = $("#grid").igGrid("selectedRow");
|
|
||||||
if (row == null)
|
|
||||||
return;
|
|
||||||
var data = $("#grid").igGrid("findRecordByKey", row.id);
|
|
||||||
if (data == null)
|
|
||||||
return;
|
|
||||||
var targetURL = "@Url.Action("RunInfo")?tooltypeid=" + data.ToolTypeID + "&headerid=" + data.ID;
|
|
||||||
window.location.href = targetURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#RefreshButton").click(function () {
|
|
||||||
$("#grid").igGrid("dataBind");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#OpenButton").click(LoadRunInfo);
|
|
||||||
|
|
||||||
$("#grid").on("dblclick", "tr", LoadRunInfo);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setInterval(function () {
|
|
||||||
$("#RefreshButton").click();
|
|
||||||
}, 60000);
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -48,87 +48,10 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function LoadHeaderGrid() {
|
|
||||||
|
|
||||||
var toolTypeID = $("#ToolType").igCombo("value");
|
|
||||||
|
|
||||||
var gridCreated = $("#HeaderGrid").data("igGrid");
|
|
||||||
if (gridCreated)
|
|
||||||
$("#HeaderGrid").igGrid("destroy");
|
|
||||||
|
|
||||||
ClearFieldsGrid();
|
|
||||||
|
|
||||||
var headerURL = "@Url.Content("~/api/tooltypes/")" + toolTypeID + "/headertitles";
|
|
||||||
|
|
||||||
$("#HeaderGrid").igGrid({
|
|
||||||
autoGenerateColumns: false,
|
|
||||||
primaryKey: "ID",
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
features: [
|
|
||||||
{ name: "Paging", type: "local", recordCountKey: "TotalRows", pageSize: 25, pageSizeUrlKey: "pageSize", "pageIndexUrlKey": "page", showPageSizeDropDown: false },
|
|
||||||
{ name: "Selection", mode: "row", rowSelectionChanged: HeaderSelectionChanged },
|
|
||||||
{ name: "Filtering", type: "local" }
|
|
||||||
],
|
|
||||||
columns: [
|
|
||||||
{ key: "ID", dataType: "number", hidden: true },
|
|
||||||
{ key: "Title", dataType: "string", width: "80%" },
|
|
||||||
{ key: "InsertDate", dataType: "date", format: "dateTime", width: "20%" }
|
|
||||||
],
|
|
||||||
dataSource: headerURL,
|
|
||||||
responseDataKey: "Results",
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function ClearFieldsGrid() {
|
|
||||||
var gridCreated = $("#FieldsGrid").data("igGrid");
|
|
||||||
if (gridCreated)
|
|
||||||
$("#FieldsGrid").igGrid("destroy");
|
|
||||||
}
|
|
||||||
|
|
||||||
function HeaderSelectionChanged(evt, ui) {
|
|
||||||
|
|
||||||
var toolTypeID = $("#ToolType").igCombo("value");
|
|
||||||
|
|
||||||
ClearFieldsGrid();
|
|
||||||
|
|
||||||
var url = "@Url.Content("~/api/tooltypes/")" + toolTypeID + "/headers/" + ui.row.id + "/fields";
|
|
||||||
|
|
||||||
$("#FieldsGrid").igGrid({
|
|
||||||
autoGenerateColumns: false,
|
|
||||||
primaryKey: "Column",
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
features: [
|
|
||||||
{ name: 'Resizing' }
|
|
||||||
],
|
|
||||||
columns: [
|
|
||||||
{ key: "Column", dataType: "string", width: "20%", columnCssClass: "FieldTitle", },
|
|
||||||
{ key: "Value", dataType: "string", }
|
|
||||||
],
|
|
||||||
enableHoverStyles: false,
|
|
||||||
dataSource: url,
|
|
||||||
responseDataKey: "Results",
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
$("#ToolType").igCombo({
|
initRunHeaders("@Url.Content("~/api")");
|
||||||
dataSource: '@Url.Content("~/api/tooltypes")',
|
|
||||||
responseDataKey: "Results",
|
|
||||||
textKey: "ToolTypeName",
|
|
||||||
valueKey: "ID",
|
|
||||||
mode: "dropdown",
|
|
||||||
width: 150,
|
|
||||||
dataBound: function (evt, ui) {
|
|
||||||
$("#ToolType").igCombo("index", 0);
|
|
||||||
LoadHeaderGrid();
|
|
||||||
},
|
|
||||||
selectionChanged: LoadHeaderGrid,
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -49,6 +49,9 @@
|
|||||||
<div class="col-xs-1">
|
<div class="col-xs-1">
|
||||||
<input type="button" class="btn" id="ReviewButton" value="Review" disabled />
|
<input type="button" class="btn" id="ReviewButton" value="Review" disabled />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-xs-1">
|
||||||
|
<input type="button" class="btn" id="PinButton" value="Pin" disabled />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="DetailsDiv" hidden>
|
<div id="DetailsDiv" hidden>
|
||||||
@ -73,409 +76,9 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var toolType = null;
|
|
||||||
var toolTypeMetaData = null;
|
|
||||||
|
|
||||||
function LoadHeaderGrid() {
|
|
||||||
|
|
||||||
var toolTypeID = $("#ToolType").igCombo("value");
|
|
||||||
|
|
||||||
$("#ToolTypeID").text(toolTypeID);
|
|
||||||
|
|
||||||
HideDetailsDiv();
|
|
||||||
DisableHeaderButtons();
|
|
||||||
|
|
||||||
$("#HeaderId").text("");
|
|
||||||
$("#HeaderAttachmentId").text("");
|
|
||||||
|
|
||||||
var gridCreated = $("#HeaderGrid").data("igGrid");
|
|
||||||
if (gridCreated)
|
|
||||||
$("#HeaderGrid").igGrid("destroy");
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: "@Url.Content("~/api/tooltypes/")" + toolTypeID + "?sortby=grid",
|
|
||||||
success: function (r) {
|
|
||||||
if ((r.Results == null) || (r.Results.ToolType == null) || (r.Results.Metadata == null))
|
|
||||||
ShowErrorMessage("Invalid tool type: " + toolTypeID);
|
|
||||||
else {
|
|
||||||
toolType = r.Results.ToolType;
|
|
||||||
toolTypeMetaData = r.Results.Metadata;
|
|
||||||
RequestHeaderData();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (e) {
|
|
||||||
DisplayWSMessage("error", "There was an error getting tooltype info.", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function DisableHeaderButtons() {
|
|
||||||
$("#GetDataButton").prop("disabled", true);
|
|
||||||
$("#ReviewButton").prop("disabled", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function EnableHeaderButtons() {
|
|
||||||
$("#GetDataButton").prop("disabled", false);
|
|
||||||
$("#ReviewButton").prop("disabled", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function HideDetailsDiv() {
|
|
||||||
$("#DetailsDiv").prop("hidden", true);
|
|
||||||
$("#DataAttachmentFrame").prop("src", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function ShowDetailsDiv() {
|
|
||||||
$("#DetailsDiv").prop("hidden", false);
|
|
||||||
|
|
||||||
$("#ExportDiv").prop("hidden", true);
|
|
||||||
if ((toolType != null) && (toolType.OIExportSPName != null) && (toolType.OIExportSPName.length > 0)) {
|
|
||||||
$("#ExportDiv").prop("hidden", false);
|
|
||||||
$("#OIExportButton").prop("disabled", false);
|
|
||||||
$("#OIExportResult").text('');
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#DataAttachmentFrame").prop("hidden", true);
|
|
||||||
$("#HeaderAttachmentFrame").prop("hidden", true);
|
|
||||||
if (toolType != null) {
|
|
||||||
var visibleFrames = 0;
|
|
||||||
if (toolType.DisplayDataAttachment && toolType.DisplayDataAttachment.length > 0) {
|
|
||||||
visibleFrames += 1;
|
|
||||||
$("#DataAttachmentFrame").prop("hidden", false);
|
|
||||||
}
|
|
||||||
if (toolType.DisplayHeaderAttachment && toolType.DisplayHeaderAttachment.length > 0) {
|
|
||||||
visibleFrames += 1;
|
|
||||||
$("#HeaderAttachmentFrame").prop("hidden", false);
|
|
||||||
}
|
|
||||||
var frameWidth = (98 / visibleFrames) + "%";
|
|
||||||
$("#DataAttachmentFrame,#HeaderAttachmentFrame").css('width', frameWidth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function HeaderSelectionChanged(evt, ui) {
|
|
||||||
if (ui.row.index >= 0) {
|
|
||||||
if ($("#HeaderId").text() == ui.row.id) {
|
|
||||||
EnableHeaderButtons();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DisableHeaderButtons();
|
|
||||||
HideDetailsDiv();
|
|
||||||
if (ui.row.index >= 0) {
|
|
||||||
EnableHeaderButtons();
|
|
||||||
$("#HeaderId").text(ui.row.id);
|
|
||||||
var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index];
|
|
||||||
$("#HeaderAttachmentId").text(rowData.AttachmentID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function CancelHandler(evt, ui) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function DetailSelectionChanged(evt, ui) {
|
|
||||||
|
|
||||||
$("#DataAttachmentFrame").prop("src", "");
|
|
||||||
|
|
||||||
if (ui.row.index >= 0) {
|
|
||||||
var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index];
|
|
||||||
var toolTypeID = $("#ToolTypeID").text();
|
|
||||||
var attachmentUrlBase = '@Url.Content("~/api/tooltypes/")' + toolTypeID;
|
|
||||||
var attachmentId = rowData.AttachmentID;
|
|
||||||
|
|
||||||
if ((attachmentId == null) || (attachmentId === ''))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((toolType.DisplayDataAttachment == null) || (toolType.DisplayDataAttachment === ''))
|
|
||||||
return;
|
|
||||||
|
|
||||||
$("#DataAttachmentFrame").prop("src", attachmentUrlBase + "/data/files/" + attachmentId + "/" + toolType.DisplayDataAttachment);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function LoadHeaderAttachment() {
|
|
||||||
var toolTypeID = $("#ToolTypeID").text();
|
|
||||||
var attachmentId = $("#HeaderAttachmentId").text();
|
|
||||||
var attachmentUrlBase = '@Url.Content("~/api/tooltypes/")' + toolTypeID;
|
|
||||||
if ((attachmentId == null) || (attachmentId === '') || (toolType.DisplayHeaderAttachment == null) || (toolType.DisplayHeaderAttachment === '')) {
|
|
||||||
$("#HeaderAttachmentFrame").prop("src", "");
|
|
||||||
} else {
|
|
||||||
$("#HeaderAttachmentFrame").prop("src", attachmentUrlBase + "/header/files/" + attachmentId + "/" + toolType.DisplayHeaderAttachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#DataAttachmentFrame").prop("src", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function MarkAsReviewed() {
|
|
||||||
|
|
||||||
var toolTypeId = $("#ToolTypeID").text();
|
|
||||||
var headerId = $("#HeaderId").text();
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "@Url.Content("~/api/awaitingdispo/markasreviewed")?tooltypeid=" + toolTypeId + "&headerid=" + headerId,
|
|
||||||
success: function () {
|
|
||||||
},
|
|
||||||
error: function (e, ajaxOptions, ex) {
|
|
||||||
DisplayWSMessage("error", "There was an error marking header as reviewed.", e, ex);
|
|
||||||
$("#ReviewButton").prop("disabled", false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function LoadDetails() {
|
|
||||||
|
|
||||||
ShowDetailsDiv();
|
|
||||||
|
|
||||||
LoadHeaderAttachment();
|
|
||||||
|
|
||||||
var gridCreated = $("#DetailsGrid").data("igGrid");
|
|
||||||
if (gridCreated)
|
|
||||||
$("#DetailsGrid").igGrid("destroy");
|
|
||||||
|
|
||||||
var headerId = $("#HeaderId").text();
|
|
||||||
var toolTypeID = $("#ToolTypeID").text();
|
|
||||||
|
|
||||||
var detailsURL = "@Url.Content("~/api/tooltypes/")" + toolTypeID + "/headers/" + headerId + "/data";
|
|
||||||
|
|
||||||
var gridColumns = [
|
|
||||||
{ key: "AttachmentID", dataType: "string", hidden: true },
|
|
||||||
{ key: "Title", dataType: "string", hidden: true },
|
|
||||||
];
|
|
||||||
|
|
||||||
for (var i = 0; i < toolTypeMetaData.length; i++) {
|
|
||||||
var f = toolTypeMetaData[i];
|
|
||||||
if ((f.Header == false) && (f.GridDisplayOrder > 0)) {
|
|
||||||
var col = {
|
|
||||||
key: f.ColumnName,
|
|
||||||
headerText: f.DisplayTitle,
|
|
||||||
width: "150px",
|
|
||||||
};
|
|
||||||
if (f.GridAttributes != null)
|
|
||||||
jQuery.extend(col, JSON.parse(f.GridAttributes));
|
|
||||||
if (col.formatter != null) {
|
|
||||||
if (col.formatter == "boolToYesNo")
|
|
||||||
col.formatter = boolToYesNo;
|
|
||||||
else
|
|
||||||
col.formatter = null;
|
|
||||||
}
|
|
||||||
gridColumns.push(col);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var gridParms = {
|
|
||||||
autoGenerateColumns: false,
|
|
||||||
primaryKey: "ID",
|
|
||||||
features: [
|
|
||||||
{ name: "Selection", mode: "row", rowSelectionChanging: DetailSelectionChanged },
|
|
||||||
{ name: "Resizing" },
|
|
||||||
{ name: "Sorting", type: "local" }
|
|
||||||
],
|
|
||||||
columns: gridColumns,
|
|
||||||
dataSource: detailsURL,
|
|
||||||
responseDataKey: "Results",
|
|
||||||
dataBound: MarkAsReviewed,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
if ((toolType != null) && (toolType.DataGridAttributes != null)) {
|
|
||||||
jQuery.extend(gridParms, JSON.parse(toolType.DataGridAttributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#DetailsGrid").igGrid(gridParms);
|
|
||||||
}
|
|
||||||
|
|
||||||
var initialHeaderId = @Model.HeaderID;
|
|
||||||
var initialHeaderAttachmentId = "@Model.HeaderAttachmentID";
|
|
||||||
|
|
||||||
function RequestHeaderData() {
|
|
||||||
var startDate = $("#StartDate").igDatePicker("value");
|
|
||||||
var startTime = $("#StartTime").igTimePicker("value");
|
|
||||||
|
|
||||||
var endDate = $("#EndDate").igDatePicker("value");
|
|
||||||
var endTime = $("#EndTime").igTimePicker("value");
|
|
||||||
|
|
||||||
var parms = {
|
|
||||||
datebegin: new Date(
|
|
||||||
startDate.getFullYear(), startDate.getMonth(), startDate.getDate(),
|
|
||||||
startTime.getHours(), startTime.getMinutes(), startTime.getSeconds()).toISOString(),
|
|
||||||
dateend: new Date(
|
|
||||||
endDate.getFullYear(), endDate.getMonth(), endDate.getDate(),
|
|
||||||
endTime.getHours(), endTime.getMinutes(), endTime.getSeconds()).toISOString(),
|
|
||||||
}
|
|
||||||
|
|
||||||
var headerId = 0;
|
|
||||||
if (initialHeaderId > 0) {
|
|
||||||
headerId = initialHeaderId;
|
|
||||||
parms.headerid = headerId;
|
|
||||||
$("#HeaderId").text(headerId);
|
|
||||||
$("#HeaderAttachmentId").text(initialHeaderAttachmentId);
|
|
||||||
initialHeaderId = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var headerURL = "@Url.Content("~/api/tooltypes/")" + toolType.ID + "/headers?" + $.param(parms);
|
|
||||||
|
|
||||||
var gridColumns = [
|
|
||||||
{ key: "ID", dataType: "number", hidden: true },
|
|
||||||
{ key: "AttachmentID", dataType: "string", hidden: true },
|
|
||||||
{ key: "Title", dataType: "string", hidden: true },
|
|
||||||
];
|
|
||||||
|
|
||||||
for (var i = 0; i < toolTypeMetaData.length; i++) {
|
|
||||||
var f = toolTypeMetaData[i];
|
|
||||||
if ((f.Header == true) && (f.GridDisplayOrder > 0)) {
|
|
||||||
var col = {
|
|
||||||
key: f.ColumnName,
|
|
||||||
headerText: f.DisplayTitle,
|
|
||||||
width: "150px",
|
|
||||||
};
|
|
||||||
if (f.GridAttributes != null)
|
|
||||||
jQuery.extend(col, JSON.parse(f.GridAttributes));
|
|
||||||
if (col.formatter != null) {
|
|
||||||
if (col.formatter == "boolToYesNo")
|
|
||||||
col.formatter = boolToYesNo;
|
|
||||||
else
|
|
||||||
col.formatter = null;
|
|
||||||
}
|
|
||||||
gridColumns.push(col);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var gridParms = {
|
|
||||||
autoGenerateColumns: false,
|
|
||||||
primaryKey: "ID",
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
features: [
|
|
||||||
{ name: "Paging", type: "local", recordCountKey: "TotalRows", pageSize: 100, pageSizeList: [50, 100, 250, 500], pageSizeUrlKey: "pageSize", "pageIndexUrlKey": "page" },
|
|
||||||
{ name: "Selection", mode: "row", rowSelectionChanged: HeaderSelectionChanged },
|
|
||||||
{ name: "Filtering", type: "local" },
|
|
||||||
{ name: 'Resizing' },
|
|
||||||
{ name: "Sorting", type: "local" }
|
|
||||||
],
|
|
||||||
columns: gridColumns,
|
|
||||||
dataSource: headerURL,
|
|
||||||
responseDataKey: "Results",
|
|
||||||
};
|
|
||||||
|
|
||||||
if ((toolType != null) && (toolType.HeaderGridAttributes != null)) {
|
|
||||||
jQuery.extend(gridParms, JSON.parse(toolType.HeaderGridAttributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#HeaderGrid").igGrid(gridParms);
|
|
||||||
|
|
||||||
if (headerId > 0) {
|
|
||||||
LoadDetails();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ReviewButton() {
|
|
||||||
|
|
||||||
var toolTypeId = $("#ToolTypeID").text();
|
|
||||||
var headerId = parseInt($("#HeaderId").text());
|
|
||||||
|
|
||||||
$("#ReviewButton").prop("disabled", true);
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "@Url.Content("~/api/awaitingdispo/markasawaiting")?tooltypeid=" + toolTypeId + "&headerid=" + headerId,
|
|
||||||
success: function (e) {
|
|
||||||
DisplayWSMessage("info", "Marked as awaiting disposition", e);
|
|
||||||
$("#ReviewButton").prop("disabled", false);
|
|
||||||
},
|
|
||||||
error: function (e, ajaxOptions, ex) {
|
|
||||||
DisplayWSMessage("error", "There was an error marking header as awaiting disposition.", e, ex);
|
|
||||||
$("#ReviewButton").prop("disabled", false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function OIExportButton() {
|
|
||||||
|
|
||||||
var headerId = $("#HeaderId").text();
|
|
||||||
var toolTypeID = $("#ToolTypeID").text();
|
|
||||||
|
|
||||||
$("#OIExportButton").prop("disabled", true);
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "@Url.Content("~/api/tooltypes/")" + toolTypeID + "/headers/" + headerId + "/oiexport",
|
|
||||||
success: function (r) {
|
|
||||||
$("#OIExportResult").text("Exported!");
|
|
||||||
},
|
|
||||||
error: function (e, ajaxOptions, ex) {
|
|
||||||
DisplayWSMessage("error", "There was an error exporting.", e, ex);
|
|
||||||
$("#OIExportButton").prop("disabled", false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function SetInitialDateTimes() {
|
|
||||||
|
|
||||||
var startTime = new Date(Date.now() - 6 * 60 * 60 * 1000);//6 hours back from now
|
|
||||||
|
|
||||||
$("#StartDate").igDatePicker({
|
|
||||||
dateInputFormat: "date",
|
|
||||||
value: startTime,
|
|
||||||
width: 125
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#StartTime").igTimePicker({
|
|
||||||
dateInputFormat: "time",
|
|
||||||
value: startTime,
|
|
||||||
width: 110
|
|
||||||
});
|
|
||||||
|
|
||||||
var endTime = new Date(Date.now());
|
|
||||||
|
|
||||||
$("#EndDate").igDatePicker({
|
|
||||||
dateInputFormat: "date",
|
|
||||||
value: endTime,
|
|
||||||
width: 125
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#EndTime").igTimePicker({
|
|
||||||
dateInputFormat: "time",
|
|
||||||
value: endTime,
|
|
||||||
width: 110
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
$("#ToolType").igCombo({
|
initRunInfo("@Url.Content("~/api")", "@Model.ToolTypeID", "@Model.HeaderID", "@Model.HeaderAttachmentID");
|
||||||
dataSource: '@Url.Content("~/api/tooltypes")',
|
|
||||||
responseDataKey: "Results",
|
|
||||||
textKey: "ToolTypeName",
|
|
||||||
valueKey: "ID",
|
|
||||||
mode: "dropdown",
|
|
||||||
width: 150,
|
|
||||||
itemsRendered: function (evt, ui) {
|
|
||||||
LoadHeaderGrid();
|
|
||||||
},
|
|
||||||
selectionChanged: LoadHeaderGrid,
|
|
||||||
initialSelectedItems: [{ value: @Model.ToolTypeID }]
|
|
||||||
});
|
|
||||||
|
|
||||||
SetInitialDateTimes();
|
|
||||||
|
|
||||||
$("#HeaderGrid").on("dblclick", "tr", LoadDetails);
|
|
||||||
|
|
||||||
$("#LoadHeadersButton").click(LoadHeaderGrid);
|
|
||||||
|
|
||||||
$("#GetDataButton").click(LoadDetails);
|
|
||||||
|
|
||||||
$("#ReviewButton").click(ReviewButton);
|
|
||||||
|
|
||||||
$("#OIExportButton").click(OIExportButton);
|
|
||||||
|
|
||||||
setInterval(function () {
|
|
||||||
if ($("#chkAutoRefresh").is(':checked')) {
|
|
||||||
SetInitialDateTimes();
|
|
||||||
$("#LoadHeadersButton").click();
|
|
||||||
}
|
|
||||||
}, 180000);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
<script src="~/igniteui/js/infragistics.dv.js" type="text/javascript" asp-append-version="true"></script>
|
<script src="~/igniteui/js/infragistics.dv.js" type="text/javascript" asp-append-version="true"></script>
|
||||||
|
|
||||||
<script src="~/js/common.js" type="text/javascript" asp-append-version="true"></script>
|
<script src="~/js/common.js" type="text/javascript" asp-append-version="true"></script>
|
||||||
|
<script src="~/js/site.js" type="text/javascript" asp-append-version="true"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
if (location.pathname == "/") {
|
if (location.pathname == "/") {
|
||||||
|
588
Server/wwwroot/js/site.js
Normal file
588
Server/wwwroot/js/site.js
Normal file
@ -0,0 +1,588 @@
|
|||||||
|
var _apiUrl = null;
|
||||||
|
var _initialHeaderAttachmentId = null;
|
||||||
|
var _initialHeaderId = null;
|
||||||
|
var _toolType = null;
|
||||||
|
var _toolTypeMetaData = null;
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
if (location.pathname == "/") {
|
||||||
|
route = "/AwaitingDispo";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
route = location.pathname;
|
||||||
|
}
|
||||||
|
$('ul.nav.navbar-nav').find('a[href="' + route + '"]')
|
||||||
|
.closest('li').addClass('alert-info');
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadRunInfoAwaitingDisposition() {
|
||||||
|
var row = $("#grid").igGrid("selectedRow");
|
||||||
|
if (row == null)
|
||||||
|
return;
|
||||||
|
var data = $("#grid").igGrid("findRecordByKey", row.id);
|
||||||
|
if (data == null)
|
||||||
|
return;
|
||||||
|
var targetURL = "RunInfo?tooltypeid=" + data.ToolTypeID + "&headerid=" + data.ID;
|
||||||
|
window.location.href = targetURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initAwaitingDisposition(apiUrl) {
|
||||||
|
_apiUrl = apiUrl;
|
||||||
|
$("#grid").igGrid({
|
||||||
|
autoGenerateColumns: false,
|
||||||
|
width: "70%",
|
||||||
|
height: "100%",
|
||||||
|
primaryKey: "PK",
|
||||||
|
columns: [
|
||||||
|
{ key: "PK", dataType: "string", hidden: true, },
|
||||||
|
{ key: "ID", dataType: "number", hidden: true, },
|
||||||
|
{ key: "ToolTypeID", dataType: "number", hidden: true, },
|
||||||
|
{ headerText: "Tool Type", key: "ToolType", dataType: "string", width: "15%" },
|
||||||
|
{ key: "Tool", 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%" },
|
||||||
|
{ key: "InsertDate", dataType: "date", width: "10%", format: "dateTime" },
|
||||||
|
{ key: "Expiration", dataType: "date", width: "10%", format: "dateTime" }
|
||||||
|
],
|
||||||
|
dataSource: _apiUrl + "/awaitingdispo/",
|
||||||
|
responseDataKey: "Results",
|
||||||
|
tabIndex: 1,
|
||||||
|
features: [
|
||||||
|
{ name: "Selection", mode: "row", multipleSelection: false },
|
||||||
|
{ name: "Filtering", type: "local" },
|
||||||
|
{ name: "Sorting", type: "local" },
|
||||||
|
]
|
||||||
|
});
|
||||||
|
$("#RefreshButton").click(function () {
|
||||||
|
$("#grid").igGrid("dataBind");
|
||||||
|
});
|
||||||
|
$("#OpenButton").click(loadRunInfoAwaitingDisposition);
|
||||||
|
$("#grid").on("dblclick", "tr", loadRunInfoAwaitingDisposition);
|
||||||
|
};
|
||||||
|
|
||||||
|
function initExport(apiUrl, startTimeValue, endTimeValue) {
|
||||||
|
_apiUrl = apiUrl;
|
||||||
|
var endTime = new Date(endTimeValue);
|
||||||
|
var startTime = new Date(startTimeValue);
|
||||||
|
$("#ToolType").igCombo({
|
||||||
|
dataSource: _apiUrl + '/tooltypes',
|
||||||
|
responseDataKey: "Results",
|
||||||
|
textKey: "ToolTypeName",
|
||||||
|
valueKey: "ID",
|
||||||
|
mode: "dropdown",
|
||||||
|
width: 150
|
||||||
|
});
|
||||||
|
$("#StartDateControl").igDatePicker({
|
||||||
|
dateInputFormat: "date",
|
||||||
|
value: startTime,
|
||||||
|
width: 125,
|
||||||
|
inputName: "StartDate",
|
||||||
|
});
|
||||||
|
$("#StartTimeControl").igTimePicker({
|
||||||
|
dateInputFormat: "time",
|
||||||
|
value: startTime,
|
||||||
|
width: 110,
|
||||||
|
inputName: "StartTime",
|
||||||
|
});
|
||||||
|
$("#EndDateControl").igDatePicker({
|
||||||
|
dateInputFormat: "date",
|
||||||
|
value: endTime,
|
||||||
|
width: 125,
|
||||||
|
inputName: "EndDate",
|
||||||
|
});
|
||||||
|
$("#EndTimeControl").igTimePicker({
|
||||||
|
dateInputFormat: "time",
|
||||||
|
value: endTime,
|
||||||
|
width: 110,
|
||||||
|
inputName: "EndTime",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function loadHeaderGridRunHeaders() {
|
||||||
|
var toolTypeID = -1; // $("#ToolType").igCombo("value");
|
||||||
|
var gridCreated = $("#HeaderGrid").data("igGrid");
|
||||||
|
if (gridCreated)
|
||||||
|
$("#HeaderGrid").igGrid("destroy");
|
||||||
|
clearFieldsGridRunHeaders();
|
||||||
|
var headerURL = _apiUrl + "/tooltypes/" + toolTypeID + "/headertitles";
|
||||||
|
$("#HeaderGrid").igGrid({
|
||||||
|
autoGenerateColumns: false,
|
||||||
|
primaryKey: "ID",
|
||||||
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
features: [
|
||||||
|
{ name: "Paging", type: "local", recordCountKey: "TotalRows", pageSize: 25, pageSizeUrlKey: "pageSize", "pageIndexUrlKey": "page", showPageSizeDropDown: false },
|
||||||
|
{ name: "Selection", mode: "row", rowSelectionChanged: headerSelectionChangedRunHeaders },
|
||||||
|
{ name: "Filtering", type: "local" }
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
{ key: "ID", dataType: "number", hidden: true },
|
||||||
|
{ key: "ToolTypeID", dataType: "number", hidden: true },
|
||||||
|
{ key: "ToolTypeName", dataType: "string", width: "10%" },
|
||||||
|
{ key: "Title", dataType: "string", width: "40%" },
|
||||||
|
{ key: "Reactor", dataType: "string", width: "10%" },
|
||||||
|
{ key: "RDS", dataType: "string", width: "10%" },
|
||||||
|
{ key: "PSN", dataType: "string", width: "10%" },
|
||||||
|
{ key: "InsertDate", dataType: "date", format: "dateTime", width: "20%" }
|
||||||
|
],
|
||||||
|
dataSource: headerURL,
|
||||||
|
responseDataKey: "Results",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearFieldsGridRunHeaders() {
|
||||||
|
var gridCreated = $("#FieldsGrid").data("igGrid");
|
||||||
|
if (gridCreated)
|
||||||
|
$("#FieldsGrid").igGrid("destroy");
|
||||||
|
}
|
||||||
|
|
||||||
|
function headerSelectionChangedRunHeaders(evt, ui) {
|
||||||
|
clearFieldsGridRunHeaders();
|
||||||
|
var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index];
|
||||||
|
var url = _apiUrl + "/tooltypes/" + rowData.ToolTypeID + "/headers/" + ui.row.id + "/fields";
|
||||||
|
$("#FieldsGrid").igGrid({
|
||||||
|
autoGenerateColumns: false,
|
||||||
|
primaryKey: "Column",
|
||||||
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
features: [
|
||||||
|
{ name: 'Resizing' }
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
{ key: "Column", dataType: "string", width: "20%", columnCssClass: "FieldTitle", },
|
||||||
|
{ key: "Value", dataType: "string", }
|
||||||
|
],
|
||||||
|
enableHoverStyles: false,
|
||||||
|
dataSource: url,
|
||||||
|
responseDataKey: "Results",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadRunInfoRunHeaders() {
|
||||||
|
var row = $("#HeaderGrid").igGrid("selectedRow");
|
||||||
|
if (row == null)
|
||||||
|
return;
|
||||||
|
var data = $("#HeaderGrid").igGrid("findRecordByKey", row.id);
|
||||||
|
if (data == null)
|
||||||
|
return;
|
||||||
|
var targetURL = "RunInfo?tooltypeid=" + data.ToolTypeID + "&headerid=" + data.ID;
|
||||||
|
window.location.href = targetURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initRunHeaders(apiUrl) {
|
||||||
|
_apiUrl = apiUrl;
|
||||||
|
// $("#ToolType").igCombo({
|
||||||
|
// dataSource: _apiUrl + '/tooltypes',
|
||||||
|
// responseDataKey: "Results",
|
||||||
|
// textKey: "ToolTypeName",
|
||||||
|
// valueKey: "ID",
|
||||||
|
// mode: "dropdown",
|
||||||
|
// width: 150,
|
||||||
|
// dataBound: function (evt, ui) {
|
||||||
|
// $("#ToolType").igCombo("index", 0);
|
||||||
|
// loadHeaderGridRunHeaders();
|
||||||
|
// },
|
||||||
|
// selectionChanged: loadHeaderGridRunHeaders,
|
||||||
|
// });
|
||||||
|
loadHeaderGridRunHeaders();
|
||||||
|
$("#RefreshButton").click(function () {
|
||||||
|
$("#HeaderGrid").igGrid("dataBind");
|
||||||
|
});
|
||||||
|
$("#OpenButton").click(loadRunInfoRunHeaders);
|
||||||
|
$("#HeaderGrid").on("dblclick", "tr", loadRunInfoRunHeaders);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadHeaderGridRunInfo() {
|
||||||
|
var toolTypeID = $("#ToolType").igCombo("value");
|
||||||
|
$("#ToolTypeID").text(toolTypeID);
|
||||||
|
hideDetailsDivRunInfo();
|
||||||
|
disableHeaderButtonsRunInfo();
|
||||||
|
$("#HeaderId").text("");
|
||||||
|
$("#HeaderAttachmentId").text("");
|
||||||
|
var gridCreated = $("#HeaderGrid").data("igGrid");
|
||||||
|
if (gridCreated)
|
||||||
|
$("#HeaderGrid").igGrid("destroy");
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: _apiUrl + "/tooltypes/" + toolTypeID + "?sortby=grid",
|
||||||
|
success: function (r) {
|
||||||
|
if ((r.Results == null) || (r.Results.ToolType == null) || (r.Results.Metadata == null))
|
||||||
|
ShowErrorMessage("Invalid tool type: " + toolTypeID);
|
||||||
|
else {
|
||||||
|
_toolType = r.Results.ToolType;
|
||||||
|
_toolTypeMetaData = r.Results.Metadata;
|
||||||
|
requestHeaderDataRunInfo();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableHeaderButtonsRunInfo() {
|
||||||
|
$("#GetDataButton").prop("disabled", true);
|
||||||
|
$("#ReviewButton").prop("disabled", true);
|
||||||
|
$("#PinButton").prop("disabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableHeaderButtonsRunInfo() {
|
||||||
|
$("#GetDataButton").prop("disabled", false);
|
||||||
|
$("#ReviewButton").prop("disabled", false);
|
||||||
|
$("#PinButton").prop("disabled", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideDetailsDivRunInfo() {
|
||||||
|
$("#DetailsDiv").prop("hidden", true);
|
||||||
|
$("#DataAttachmentFrame").prop("src", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function showDetailsDivRunInfo() {
|
||||||
|
$("#DetailsDiv").prop("hidden", false);
|
||||||
|
$("#ExportDiv").prop("hidden", true);
|
||||||
|
if ((_toolType != null) && (_toolType.OIExportSPName != null) && (_toolType.OIExportSPName.length > 0)) {
|
||||||
|
$("#ExportDiv").prop("hidden", false);
|
||||||
|
$("#OIExportButton").prop("disabled", false);
|
||||||
|
$("#OIExportResult").text('');
|
||||||
|
}
|
||||||
|
$("#DataAttachmentFrame").prop("hidden", true);
|
||||||
|
$("#HeaderAttachmentFrame").prop("hidden", true);
|
||||||
|
if (_toolType != null) {
|
||||||
|
var visibleFrames = 0;
|
||||||
|
if (_toolType.DisplayDataAttachment && _toolType.DisplayDataAttachment.length > 0) {
|
||||||
|
visibleFrames += 1;
|
||||||
|
$("#DataAttachmentFrame").prop("hidden", false);
|
||||||
|
}
|
||||||
|
if (_toolType.DisplayHeaderAttachment && _toolType.DisplayHeaderAttachment.length > 0) {
|
||||||
|
visibleFrames += 1;
|
||||||
|
$("#HeaderAttachmentFrame").prop("hidden", false);
|
||||||
|
}
|
||||||
|
var frameWidth = (98 / visibleFrames) + "%";
|
||||||
|
$("#DataAttachmentFrame,#HeaderAttachmentFrame").css('width', frameWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function headerSelectionChangedRunInfo(evt, ui) {
|
||||||
|
if (ui.row.index >= 0) {
|
||||||
|
if ($("#HeaderId").text() == ui.row.id) {
|
||||||
|
enableHeaderButtonsRunInfo();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
disableHeaderButtonsRunInfo();
|
||||||
|
hideDetailsDivRunInfo();
|
||||||
|
if (ui.row.index >= 0) {
|
||||||
|
enableHeaderButtonsRunInfo();
|
||||||
|
$("#HeaderId").text(ui.row.id);
|
||||||
|
var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index];
|
||||||
|
$("#HeaderAttachmentId").text(rowData.AttachmentID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelHandlerRunInfo(evt, ui) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function detailSelectionChangedRunInfo(evt, ui) {
|
||||||
|
$("#DataAttachmentFrame").prop("src", "");
|
||||||
|
if (ui.row.index >= 0) {
|
||||||
|
var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index];
|
||||||
|
var toolTypeID = $("#ToolTypeID").text();
|
||||||
|
var attachmentUrlBase = _apiUrl + '/tooltypes/' + toolTypeID;
|
||||||
|
var attachmentId = rowData.AttachmentID;
|
||||||
|
if ((attachmentId == null) || (attachmentId === ''))
|
||||||
|
return;
|
||||||
|
if ((_toolType.DisplayDataAttachment == null) || (_toolType.DisplayDataAttachment === ''))
|
||||||
|
return;
|
||||||
|
$("#DataAttachmentFrame").prop("src", attachmentUrlBase + "/data/files/" + attachmentId + "/" + _toolType.DisplayDataAttachment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadHeaderAttachmentRunInfo() {
|
||||||
|
var toolTypeID = $("#ToolTypeID").text();
|
||||||
|
var attachmentId = $("#HeaderAttachmentId").text();
|
||||||
|
var attachmentUrlBase = _apiUrl + '/tooltypes/' + toolTypeID;
|
||||||
|
if ((attachmentId == null) || (attachmentId === '') || (_toolType.DisplayHeaderAttachment == null) || (_toolType.DisplayHeaderAttachment === '')) {
|
||||||
|
$("#HeaderAttachmentFrame").prop("src", "");
|
||||||
|
} else {
|
||||||
|
$("#HeaderAttachmentFrame").prop("src", attachmentUrlBase + "/header/files/" + attachmentId + "/" + _toolType.DisplayHeaderAttachment);
|
||||||
|
}
|
||||||
|
$("#DataAttachmentFrame").prop("src", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function markAsReviewedRunInfo() {
|
||||||
|
var toolTypeId = $("#ToolTypeID").text();
|
||||||
|
var headerId = $("#HeaderId").text();
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: _apiUrl + "/awaitingdispo/markasreviewed?tooltypeid=" + toolTypeId + "&headerid=" + headerId,
|
||||||
|
success: function () {
|
||||||
|
},
|
||||||
|
error: function (e, ajaxOptions, ex) {
|
||||||
|
DisplayWSMessage("error", "There was an error marking header as reviewed.", e, ex);
|
||||||
|
$("#ReviewButton").prop("disabled", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadDetailsRunInfo() {
|
||||||
|
showDetailsDivRunInfo();
|
||||||
|
loadHeaderAttachmentRunInfo();
|
||||||
|
var gridCreated = $("#DetailsGrid").data("igGrid");
|
||||||
|
if (gridCreated)
|
||||||
|
$("#DetailsGrid").igGrid("destroy");
|
||||||
|
var headerId = $("#HeaderId").text();
|
||||||
|
var toolTypeID = $("#ToolTypeID").text();
|
||||||
|
var detailsURL = _apiUrl + "/tooltypes/" + toolTypeID + "/headers/" + headerId + "/data";
|
||||||
|
var gridColumns = [
|
||||||
|
{ key: "AttachmentID", dataType: "string", hidden: true },
|
||||||
|
{ key: "Title", dataType: "string", hidden: true },
|
||||||
|
];
|
||||||
|
for (var i = 0; i < _toolTypeMetaData.length; i++) {
|
||||||
|
var f = _toolTypeMetaData[i];
|
||||||
|
if ((f.Header == false) && (f.GridDisplayOrder > 0)) {
|
||||||
|
var col = {
|
||||||
|
key: f.ColumnName,
|
||||||
|
headerText: f.DisplayTitle,
|
||||||
|
width: "150px",
|
||||||
|
};
|
||||||
|
if (f.GridAttributes != null)
|
||||||
|
jQuery.extend(col, JSON.parse(f.GridAttributes));
|
||||||
|
if (col.formatter != null) {
|
||||||
|
if (col.formatter == "boolToYesNo")
|
||||||
|
col.formatter = boolToYesNo;
|
||||||
|
else
|
||||||
|
col.formatter = null;
|
||||||
|
}
|
||||||
|
gridColumns.push(col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var gridParms = {
|
||||||
|
autoGenerateColumns: false,
|
||||||
|
primaryKey: "ID",
|
||||||
|
features: [
|
||||||
|
{ name: "Selection", mode: "row", rowSelectionChanging: detailSelectionChangedRunInfo },
|
||||||
|
{ name: "Resizing" },
|
||||||
|
{ name: "Sorting", type: "local" }
|
||||||
|
],
|
||||||
|
columns: gridColumns,
|
||||||
|
dataSource: detailsURL,
|
||||||
|
responseDataKey: "Results",
|
||||||
|
dataBound: markAsReviewedRunInfo,
|
||||||
|
};
|
||||||
|
if ((_toolType != null) && (_toolType.DataGridAttributes != null)) {
|
||||||
|
jQuery.extend(gridParms, JSON.parse(_toolType.DataGridAttributes));
|
||||||
|
}
|
||||||
|
$("#DetailsGrid").igGrid(gridParms);
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestHeaderDataRunInfo() {
|
||||||
|
var startDate = $("#StartDate").igDatePicker("value");
|
||||||
|
var startTime = $("#StartTime").igTimePicker("value");
|
||||||
|
var endDate = $("#EndDate").igDatePicker("value");
|
||||||
|
var endTime = $("#EndTime").igTimePicker("value");
|
||||||
|
var parms = {
|
||||||
|
datebegin: new Date(
|
||||||
|
startDate.getFullYear(), startDate.getMonth(), startDate.getDate(),
|
||||||
|
startTime.getHours(), startTime.getMinutes(), startTime.getSeconds()).toISOString(),
|
||||||
|
dateend: new Date(
|
||||||
|
endDate.getFullYear(), endDate.getMonth(), endDate.getDate(),
|
||||||
|
endTime.getHours(), endTime.getMinutes(), endTime.getSeconds()).toISOString(),
|
||||||
|
}
|
||||||
|
var headerId = 0;
|
||||||
|
if (_initialHeaderId > 0) {
|
||||||
|
headerId = _initialHeaderId;
|
||||||
|
parms.headerid = headerId;
|
||||||
|
$("#HeaderId").text(headerId);
|
||||||
|
$("#HeaderAttachmentId").text(_initialHeaderAttachmentId);
|
||||||
|
_initialHeaderId = -1;
|
||||||
|
}
|
||||||
|
var headerURL = _apiUrl + "/tooltypes/" + _toolType.ID + "/headers?" + $.param(parms);
|
||||||
|
var gridColumns = [
|
||||||
|
{ key: "ID", dataType: "number", hidden: true },
|
||||||
|
{ key: "AttachmentID", dataType: "string", hidden: true },
|
||||||
|
{ key: "Title", dataType: "string", hidden: true },
|
||||||
|
];
|
||||||
|
for (var i = 0; i < _toolTypeMetaData.length; i++) {
|
||||||
|
var f = _toolTypeMetaData[i];
|
||||||
|
if ((f.Header == true) && (f.GridDisplayOrder > 0)) {
|
||||||
|
var col = {
|
||||||
|
key: f.ColumnName,
|
||||||
|
headerText: f.DisplayTitle,
|
||||||
|
width: "150px",
|
||||||
|
};
|
||||||
|
if (f.GridAttributes != null)
|
||||||
|
jQuery.extend(col, JSON.parse(f.GridAttributes));
|
||||||
|
if (col.formatter != null) {
|
||||||
|
if (col.formatter == "boolToYesNo")
|
||||||
|
col.formatter = boolToYesNo;
|
||||||
|
else
|
||||||
|
col.formatter = null;
|
||||||
|
}
|
||||||
|
gridColumns.push(col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var gridParms = {
|
||||||
|
autoGenerateColumns: false,
|
||||||
|
primaryKey: "ID",
|
||||||
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
features: [
|
||||||
|
{ name: "Paging", type: "local", recordCountKey: "TotalRows", pageSize: 100, pageSizeList: [50, 100, 250, 500], pageSizeUrlKey: "pageSize", "pageIndexUrlKey": "page" },
|
||||||
|
{ name: "Selection", mode: "row", rowSelectionChanged: headerSelectionChangedRunInfo },
|
||||||
|
{ name: "Filtering", type: "local" },
|
||||||
|
{ name: 'Resizing' },
|
||||||
|
{ name: "Sorting", type: "local" }
|
||||||
|
],
|
||||||
|
columns: gridColumns,
|
||||||
|
dataSource: headerURL,
|
||||||
|
responseDataKey: "Results",
|
||||||
|
};
|
||||||
|
if ((_toolType != null) && (_toolType.HeaderGridAttributes != null)) {
|
||||||
|
jQuery.extend(gridParms, JSON.parse(_toolType.HeaderGridAttributes));
|
||||||
|
}
|
||||||
|
$("#HeaderGrid").igGrid(gridParms);
|
||||||
|
if (headerId > 0) {
|
||||||
|
loadDetailsRunInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function reviewButtonRunInfo() {
|
||||||
|
var toolTypeId = $("#ToolTypeID").text();
|
||||||
|
var headerId = parseInt($("#HeaderId").text());
|
||||||
|
$("#ReviewButton").prop("disabled", true);
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: _apiUrl + "/awaitingdispo/markasawaiting?tooltypeid=" + toolTypeId + "&headerid=" + headerId,
|
||||||
|
success: function (e) {
|
||||||
|
DisplayWSMessage("info", "Marked as awaiting disposition", e);
|
||||||
|
$("#ReviewButton").prop("disabled", false);
|
||||||
|
},
|
||||||
|
error: function (e, ajaxOptions, ex) {
|
||||||
|
DisplayWSMessage("error", "There was an error marking header as awaiting disposition.", e, ex);
|
||||||
|
$("#ReviewButton").prop("disabled", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pinButtonRunInfo() {
|
||||||
|
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",
|
||||||
|
data: rowData,
|
||||||
|
success: function (e) {
|
||||||
|
DisplayWSMessage("info", "Marked as pinned", e);
|
||||||
|
$("#PinButton").prop("disabled", false);
|
||||||
|
},
|
||||||
|
error: function (e, ajaxOptions, ex) {
|
||||||
|
DisplayWSMessage("error", "There was an error marking header as pinned.", e, ex);
|
||||||
|
$("#PinButton").prop("disabled", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function oiExportButtonRunInfo() {
|
||||||
|
var headerId = $("#HeaderId").text();
|
||||||
|
var toolTypeID = $("#ToolTypeID").text();
|
||||||
|
$("#OIExportButton").prop("disabled", true);
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: _apiUrl + "/tooltypes/" + toolTypeID + "/headers/" + headerId + "/oiexport",
|
||||||
|
success: function (r) {
|
||||||
|
$("#OIExportResult").text("Exported!");
|
||||||
|
},
|
||||||
|
error: function (e, ajaxOptions, ex) {
|
||||||
|
DisplayWSMessage("error", "There was an error exporting.", e, ex);
|
||||||
|
$("#OIExportButton").prop("disabled", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setInitialDateTimesRunInfo() {
|
||||||
|
var startTime = new Date(Date.now() - 6 * 60 * 60 * 1000);//6 hours back from now
|
||||||
|
$("#StartDate").igDatePicker({
|
||||||
|
dateInputFormat: "date",
|
||||||
|
value: startTime,
|
||||||
|
width: 125
|
||||||
|
});
|
||||||
|
$("#StartTime").igTimePicker({
|
||||||
|
dateInputFormat: "time",
|
||||||
|
value: startTime,
|
||||||
|
width: 110
|
||||||
|
});
|
||||||
|
var endTime = new Date(Date.now());
|
||||||
|
$("#EndDate").igDatePicker({
|
||||||
|
dateInputFormat: "date",
|
||||||
|
value: endTime,
|
||||||
|
width: 125
|
||||||
|
});
|
||||||
|
$("#EndTime").igTimePicker({
|
||||||
|
dateInputFormat: "time",
|
||||||
|
value: endTime,
|
||||||
|
width: 110
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initRunInfo(apiUrl, initialToolTypeID, initialHeaderId, initialHeaderAttachmentId) {
|
||||||
|
_apiUrl = apiUrl;
|
||||||
|
_initialHeaderId = initialHeaderId;
|
||||||
|
_initialHeaderAttachmentId = initialHeaderAttachmentId;
|
||||||
|
$("#ToolType").igCombo({
|
||||||
|
dataSource: _apiUrl + '/tooltypes',
|
||||||
|
responseDataKey: "Results",
|
||||||
|
textKey: "ToolTypeName",
|
||||||
|
valueKey: "ID",
|
||||||
|
mode: "dropdown",
|
||||||
|
width: 150,
|
||||||
|
itemsRendered: function (evt, ui) {
|
||||||
|
loadHeaderGridRunInfo();
|
||||||
|
},
|
||||||
|
selectionChanged: loadHeaderGridRunInfo,
|
||||||
|
initialSelectedItems: [{ value: initialToolTypeID }]
|
||||||
|
});
|
||||||
|
setInitialDateTimesRunInfo();
|
||||||
|
$("#HeaderGrid").on("dblclick", "tr", loadDetailsRunInfo);
|
||||||
|
$("#LoadHeadersButton").click(loadHeaderGridRunInfo);
|
||||||
|
$("#GetDataButton").click(loadDetailsRunInfo);
|
||||||
|
$("#ReviewButton").click(reviewButtonRunInfo);
|
||||||
|
$("#PinButton").click(pinButtonRunInfo);
|
||||||
|
$("#OIExportButton").click(oiExportButtonRunInfo);
|
||||||
|
setInterval(function () {
|
||||||
|
if ($("#chkAutoRefresh").is(':checked')) {
|
||||||
|
setInitialDateTimesRunInfo();
|
||||||
|
$("#LoadHeadersButton").click();
|
||||||
|
}
|
||||||
|
}, 180000);
|
||||||
|
};
|
||||||
|
|
||||||
|
function triggerFileDownload(fileName, url) {
|
||||||
|
const anchorElement = document.createElement('a');
|
||||||
|
anchorElement.href = url;
|
||||||
|
anchorElement.download = fileName ?? '';
|
||||||
|
anchorElement.click();
|
||||||
|
anchorElement.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function initIndex() {
|
||||||
|
}
|
17
Shared/DataModels/HeaderCommond.cs
Normal file
17
Shared/DataModels/HeaderCommond.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace OI.Metrology.Shared.DataModels;
|
||||||
|
|
||||||
|
public class HeaderCommond : HeaderCommon
|
||||||
|
{
|
||||||
|
public string? PointA { get; set; }
|
||||||
|
public string? PointB { get; set; }
|
||||||
|
public string? PointC { get; set; }
|
||||||
|
public string? PointD { get; set; }
|
||||||
|
public string? PointE { get; set; }
|
||||||
|
public string? PointF { get; set; }
|
||||||
|
public string? PointG { get; set; }
|
||||||
|
public string? PointH { get; set; }
|
||||||
|
public string? PointI { get; set; }
|
||||||
|
public string? PointJ { get; set; }
|
||||||
|
public string? PointK { get; set; }
|
||||||
|
public string? PointL { get; set; }
|
||||||
|
}
|
15
Shared/Models/Stateless/IPinController.cs
Normal file
15
Shared/Models/Stateless/IPinController.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace OI.Metrology.Shared.Models.Stateless;
|
||||||
|
|
||||||
|
public interface IPinController<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
enum Action : int
|
||||||
|
{
|
||||||
|
Index = 0,
|
||||||
|
MarkAsPinned = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetRouteName() => nameof(IPinController<T>)[1..^10];
|
||||||
|
T MarkAsPinned(DataModels.HeaderCommon headerCommon);
|
||||||
|
|
||||||
|
}
|
20
Shared/Models/Stateless/IPinRepository.cs
Normal file
20
Shared/Models/Stateless/IPinRepository.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using OI.Metrology.Shared.DataModels;
|
||||||
|
|
||||||
|
namespace OI.Metrology.Shared.Models.Stateless;
|
||||||
|
|
||||||
|
public interface IPinRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
enum ToolId
|
||||||
|
{
|
||||||
|
BioRad = 0,
|
||||||
|
CDE = 1,
|
||||||
|
Tencor = 2,
|
||||||
|
HgCV = 3,
|
||||||
|
Stratus = 4,
|
||||||
|
SP1 = 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<HeaderCommond[]> GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde);
|
||||||
|
|
||||||
|
}
|
67
Tests/UnitTestPinController.cs
Normal file
67
Tests/UnitTestPinController.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
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 UnitTestPinController
|
||||||
|
{
|
||||||
|
|
||||||
|
#pragma warning disable CS8618
|
||||||
|
|
||||||
|
private static ILogger _Logger;
|
||||||
|
private static string _ControllerName;
|
||||||
|
private static TestContext _TestContext;
|
||||||
|
private static WebApplicationFactory<Server.Program> _WebApplicationFactory;
|
||||||
|
|
||||||
|
#pragma warning restore
|
||||||
|
|
||||||
|
[ClassInitialize]
|
||||||
|
public static void ClassInitAsync(TestContext testContext)
|
||||||
|
{
|
||||||
|
_TestContext = testContext;
|
||||||
|
_Logger = Log.ForContext<UnitTestPinController>();
|
||||||
|
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
||||||
|
_ControllerName = nameof(Server.ApiControllers.PinController)[..^10];
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestControllerName()
|
||||||
|
{
|
||||||
|
_Logger.Information("Starting Web Application");
|
||||||
|
Assert.AreEqual(IPinController<string>.GetRouteName(), _ControllerName);
|
||||||
|
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GetHeaderTitles()
|
||||||
|
{
|
||||||
|
_Logger.Information("Starting Web Application");
|
||||||
|
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
||||||
|
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
|
||||||
|
IPinRepository pinRepository = serviceProvider.GetRequiredService<IPinRepository>();
|
||||||
|
string? cde = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 0, ToolTypeID = 0 });
|
||||||
|
string? bioRad = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 0, ToolTypeID = 0 });
|
||||||
|
Result<HeaderCommond[]> result = pinRepository.GetPinnedTable(metrologyRepository, id: 0, bioRad, cde);
|
||||||
|
Assert.IsNotNull(result?.Results);
|
||||||
|
Assert.IsTrue(result.Results.Any());
|
||||||
|
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task GetHeaderTitlesApi()
|
||||||
|
{
|
||||||
|
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||||
|
_Logger.Information("Starting Web Application");
|
||||||
|
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/headertitles");
|
||||||
|
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetHeaderTitlesApi)}.json"), json);
|
||||||
|
Result<HeaderCommond[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommond[]>>(json);
|
||||||
|
Assert.IsNotNull(result?.Results);
|
||||||
|
Assert.IsTrue(result.Results.Any());
|
||||||
|
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user