net6.0 Ready to test

This commit is contained in:
2022-03-29 07:23:13 -07:00
parent 836f70ed7f
commit 289547180a
135 changed files with 3189 additions and 7648 deletions

View File

@ -0,0 +1,67 @@
@page
@model APCViewer.Pages.BackgroundPage
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Background</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/app.css" rel="stylesheet" />
</head>
<body>
<div class="main">
<div class="content px-4">
<div class="jumbotron">
<h1>@(nameof(APCViewer)) -
@(Model.IsPrimaryInstance) -
@(Model.IsEnvironmentProfile) -
@(Model.AppSettingsURLs) -
020</h1>
<p class="lead">@(Model.WorkingDirectory)</p>
<p class="lead">@(Model.Message)</p>
<h1>@(string.Concat("Exception(s) - ", Model.Exceptions.Count))</h1>
</div>
<div>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/Background">Background Message</a></li>
<li><a href="/Background/?message_clear=true">Background Message Clear</a></li>
<li><a href="/Background/?exceptions_clear=true">Background Exceptions Clear</a></li>
<li><a href="/Background/?set_is_primary_instance=true">Background Set Is Primary Instance</a></li>
<li><a href="/Background/?set_is_primary_instance=false">Background Clear Primary Instance</a></li>
</ul>
</div>
<p>&nbsp;</p>
<hr />
<div>
<form action="">
@if (Model.Exceptions.Any())
{
int i = 0;
@foreach (Exception exception in Model.Exceptions)
{
<p>
@Html.Raw(string.Concat("<textarea name=\"message_", i, "\" rows='1' cols='400'>",
exception.Message, "</textarea>"));
</p>
<p>
@Html.Raw(string.Concat("<textarea name=\"stackTrace_", i, "\" rows='4' cols='400'>",
exception.StackTrace, "</textarea>"));
</p>
<hr />
@(i += 1)
;
}
}
</form>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,67 @@
using APCViewer.Models.Stateless.Methods;
using IFX.Shared;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Serilog.Context;
using System.Text.Json;
namespace APCViewer.Pages;
public class BackgroundPage : PageModel, Models.Properties.IBackgroundPage, IBackgroundPage
{
protected readonly List<Exception> _Exceptions;
protected readonly string _AppSettingsURLs;
protected readonly string _IsEnvironmentProfile;
protected readonly string _IsPrimaryInstance;
protected readonly string _Message;
protected readonly string _WorkingDirectory;
public List<Exception> Exceptions => _Exceptions;
public string AppSettingsURLs => _AppSettingsURLs;
public string IsEnvironmentProfile => _IsEnvironmentProfile;
public string IsPrimaryInstance => _IsPrimaryInstance;
public string Message => _Message;
public string WorkingDirectory => _WorkingDirectory;
private readonly Serilog.ILogger _Log;
private readonly Models.Methods.IBackground _BackgroundMethods;
public BackgroundPage(IsEnvironment isEnvironment, Models.AppSettings appSettings, Singleton.Background background)
{
_BackgroundMethods = background;
_Message = background.Message;
_AppSettingsURLs = appSettings.URLs;
_Exceptions = background.Exceptions;
_Log = Serilog.Log.ForContext<BackgroundPage>();
_IsEnvironmentProfile = isEnvironment.Profile;
_WorkingDirectory = background.WorkingDirectory;
Models.Methods.IBackground backgroundMethods = background;
_IsPrimaryInstance = backgroundMethods.IsPrimaryInstance().ToString();
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
public void OnGet(bool? message_clear = null, bool? exceptions_clear = null, bool? set_is_primary_instance = null)
{
string? methodName = IMethodName.GetActualAsyncMethodName();
using (LogContext.PushProperty("MethodName", methodName))
{
_Log.Debug("() => ...");
if (message_clear.HasValue && message_clear.Value)
_BackgroundMethods.ClearMessage();
if (exceptions_clear.HasValue && exceptions_clear.Value)
_Exceptions.Clear();
if (set_is_primary_instance.HasValue)
{
if (set_is_primary_instance.Value)
_BackgroundMethods.SetIsPrimaryInstance();
else
_BackgroundMethods.ClearIsPrimaryInstance();
}
}
}
}

View File

@ -0,0 +1,42 @@
@page
@model APCViewer.Pages.ErrorModel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Error</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/app.css" rel="stylesheet" asp-append-version="true" />
</head>
<body>
<div class="main">
<div class="content px-4">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;
namespace APCViewer.Pages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _Logger;
public ErrorModel(ILogger<ErrorModel> logger) => _Logger = logger;
public void OnGet() => RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}

View File

@ -0,0 +1,114 @@
@page
@using APCViewer.Pages
@model IPDSFPage
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
string viewLink;
string downloadLink;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>IPDSF</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/app.css" rel="stylesheet" />
</head>
<body>
<div class="main">
<h3>@(Model.Files) File(s)</h3>
<p>
<table id="records" border="1">
<tr>
<th><a href="#b" id="a">Technology - Environment</a></th>
<th>Equipment Type</th>
<th>Sequence</th>
<th>Reactor</th>
<th>RDS</th>
<th>Part Number</th>
<th>File Name</th>
<th>Date</th>
</tr>
@foreach (var item in Model.Sorted)
{
if (!string.IsNullOrEmpty(Model.Directory) && item.Item2.ReportFullPath.Contains(Model.Directory))
{
viewLink = string.Concat("/", nameof(PDSFPage.OnGetViewCustom), "/?iipdsf_file=",
Html.Encode(item.Item2.ReportFullPath));
downloadLink = string.Concat("/", nameof(PDSFPage.OnGetDownloadFileCustom), "/?ipdsf_file=",
Html.Encode(item.Item2.ReportFullPath));
}
else
{
viewLink = string.Concat("/", nameof(PDSFPage.OnGetView), "/sequence_",
item.Item2.Sequence);
downloadLink = string.Concat("/", nameof(PDSFPage.OnGetDownloadFile), "/sequence_",
item.Item2.Sequence);
}
<tr>
<td>@item.Item1[0]</td>
<td>@item.Item1[1]</td>
<td><a href="@Url.Content(viewLink)">@item.Item2.Sequence</a></td>
<td>@item.Item2.ProcessJobID</td>
<td>@item.Item2.MID</td>
<td>@item.Item2.Logistics2[0].PartNumber</td>
<td>@System.IO.Path.GetFileNameWithoutExtension(item.Item2.ReportFullPath)</td>
<td><a href="@Url.Content(downloadLink)">@item.Item2.DateTimeFromSequence</a></td>
</tr>
}
</table>
@if (string.IsNullOrEmpty(Model.Directory))
{
<hr />
<table id="records" border="1">
<tr>
<th><a href="#a" id="b">Technology - Environment</a></th>
<th>Equipment Type</th>
<th>Sequence</th>
<th>Reactor</th>
<th>RDS</th>
<th>Part Number</th>
<th>File Name</th>
<th>Date</th>
</tr>
@foreach (var element in Model.Grouped)
{
foreach (var innerElement in element.Value)
{
foreach (var item in innerElement.Value)
{
viewLink = string.Concat("/", nameof(PDSFPage.OnGetView), "/sequence_", item.Sequence);
downloadLink = string.Concat("/", nameof(PDSFPage.OnGetDownloadFile), "/sequence_",
item.Sequence);
<tr>
<td>@element.Key</td>
<td>@innerElement.Key</td>
<td><a href="@Url.Content(viewLink)">@item.Sequence</a></td>
<td>@item.ProcessJobID</td>
<td>@item.MID</td>
<td>@item.Logistics2[0].PartNumber</td>
<td>@System.IO.Path.GetFileNameWithoutExtension(item.ReportFullPath)</td>
<td><a href="@Url.Content(downloadLink)">@item.DateTimeFromSequence</a></td>
</tr>
}
}
}
</table>
}
</p>
</div>
</body>
</html>
@section scripts {
<script>
$(function () {
console.log("ready!");
});
</script>
}

View File

@ -0,0 +1,164 @@
using APCViewer.Models.Stateless.Methods;
using IFX.Shared;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Serilog.Context;
using Shared;
using System.Text;
using System.Text.Json;
namespace APCViewer.Pages;
public class IPDSFPage : PageModel, Models.Properties.IIPDSFPage, IIPDSFPage
{
protected string? _Directory;
protected int _Files;
protected Dictionary<string, Dictionary<string, List<Shared.Logistics>>> _Grouped;
protected List<Tuple<string[], Shared.Logistics>> _Sorted;
public string? Directory => _Directory;
public int Files => _Files;
public Dictionary<string, Dictionary<string, List<Shared.Logistics>>> Grouped => _Grouped;
public List<Tuple<string[], Shared.Logistics>> Sorted => _Sorted;
private readonly Serilog.ILogger _Log;
private readonly Singleton.Background _Background;
private readonly Models.Methods.IBackground _BackgroundMethods;
#nullable disable
public IPDSFPage(Singleton.Background background)
{
_Background = background;
_BackgroundMethods = background;
_Log = Serilog.Log.ForContext<IPDSFPage>();
}
#nullable enable
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
public void OnGet(string? directory = null, string? filter = null, bool is_gaN = false, bool is_Si = false)
{
string? methodName = IMethodName.GetActualAsyncMethodName();
using (LogContext.PushProperty("MethodName", methodName))
{
_Log.Debug("() => ...");
Tuple<int, Dictionary<string, Dictionary<string, List<Logistics>>>, List<Tuple<string[], Logistics>>, string?> tuple = _BackgroundMethods.SetViewBag(directory, filter, isGaN: is_gaN, isSi: is_Si, forIPDSF: true);
_Files = tuple.Item1;
_Grouped = tuple.Item2;
_Sorted = tuple.Item3;
_Directory = tuple.Item4;
}
}
private static StringBuilder GetIPDSFHtml(string? ipdsfFile)
{
StringBuilder result = new();
_ = result.AppendLine("<html><body><table border = '1'>");
if (string.IsNullOrEmpty(ipdsfFile))
throw new Exception("<tr><td>Invalid input</td></tr>");
else if (!System.IO.File.Exists(ipdsfFile))
_ = result.AppendLine("<tr><td>File doesn't exist!</td></tr>");
else
{
bool header = true;
bool body = false;
bool footer = false;
string logisticsSegment;
List<string> logistics = new();
string[] ipdsfLines = System.IO.File.ReadAllLines(ipdsfFile);
foreach (string ipdsfLine in ipdsfLines)
{
if (ipdsfLine.StartsWith("LOGISTICS_"))
{
logisticsSegment = ipdsfLine.Split('\t')[0];
if (!logistics.Contains(logisticsSegment))
{
logistics.Add(logisticsSegment);
_ = result.AppendLine("</table><hr /><table border = '1'>");
}
}
if (ipdsfLine.StartsWith("NUM_DATA_ROWS") || ipdsfLine.StartsWith("END_HEADER"))
{
body = false;
footer = true;
_ = result.AppendLine("</table><hr /><table border = '1'>");
}
if (header)
_ = result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (body)
_ = result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (footer)
{
if (ipdsfLine.StartsWith("DELIMITER"))
_ = result.Append("<tr><td>").Append(ipdsfLine.Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else
_ = result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
}
else
throw new Exception();
if (ipdsfLine.StartsWith("END_OFFSET"))
{
header = false;
body = true;
_ = result.AppendLine("</table><hr /><table border = '1'>");
}
}
}
_ = result.AppendLine("</table></body>");
return result;
}
public ContentResult OnGetView(string? id = null)
{
string ipdsfFile;
StringBuilder result = new();
if (string.IsNullOrEmpty(id) || !id.Contains('_'))
_ = result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>");
else
{
if (!long.TryParse(id.Split('_')[1], out long sequence))
_ = result.AppendLine("<html><body><table border = '1'><tr><td>B) Error: Invalid input</td></tr></table></body>");
else
{
ipdsfFile = _Background.GetIPDSF(sequence);
result = GetIPDSFHtml(ipdsfFile);
}
}
return Content(result.ToString(), "text/html");
}
public FileResult OnGetDownloadFile(string? id = null)
{
string ipdsfFile;
if (string.IsNullOrEmpty(id) || !id.Contains('_'))
throw new Exception("A) Error: Invalid input");
else
{
if (!long.TryParse(id.Split('_')[1], out long sequence))
throw new Exception("B) Error: Invalid input");
else
ipdsfFile = _Background.GetIPDSF(sequence);
}
return File(ipdsfFile, "text/plain", Path.GetFileName(ipdsfFile));
}
public ContentResult OnGetViewCustom(string? ipdsf_file = null)
{
StringBuilder result = GetIPDSFHtml(ipdsf_file);
return Content(result.ToString(), "text/html");
}
public FileResult OnGetDownloadFileCustom(string? ipdsf_file = null)
{
if (string.IsNullOrEmpty(ipdsf_file))
throw new Exception("Error: Invalid input");
else if (!System.IO.File.Exists(ipdsf_file))
throw new Exception("Error: file does not exist");
return File(ipdsf_file, "text/plain", Path.GetFileName(ipdsf_file));
}
}

View File

@ -0,0 +1,114 @@
@page
@using APCViewer.Pages
@model PDSFPage
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
string viewLink;
string downloadLink;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>PDSF</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/app.css" rel="stylesheet" />
</head>
<body>
<div class="main">
<h3>@(Model.Files) File(s)</h3>
<p>
<table id="records" border="1">
<tr>
<th><a href="#b" id="a">Technology - Environment</a></th>
<th>Equipment Type</th>
<th>Sequence</th>
<th>Reactor</th>
<th>RDS</th>
<th>Part Number</th>
<th>File Name</th>
<th>Date</th>
</tr>
@foreach (var item in Model.Sorted)
{
if (!string.IsNullOrEmpty(Model.Directory) && item.Item2.ReportFullPath.Contains(Model.Directory))
{
viewLink = string.Concat("/", nameof(PDSFPage.OnGetViewCustom), "/?pdsf_file=",
Html.Encode(item.Item2.ReportFullPath));
downloadLink = string.Concat("/", nameof(PDSFPage.OnGetDownloadFileCustom), "/?pdsf_file=",
Html.Encode(item.Item2.ReportFullPath));
}
else
{
viewLink = string.Concat("/", nameof(PDSFPage.OnGetView), "/sequence_",
item.Item2.Sequence);
downloadLink = string.Concat("/", nameof(PDSFPage.OnGetDownloadFile), "/sequence_",
item.Item2.Sequence);
}
<tr>
<td>@item.Item1[0]</td>
<td>@item.Item1[1]</td>
<td><a href="@Url.Content(viewLink)">@item.Item2.Sequence</a></td>
<td>@item.Item2.ProcessJobID</td>
<td>@item.Item2.MID</td>
<td>@item.Item2.Logistics2[0].PartNumber</td>
<td>@System.IO.Path.GetFileNameWithoutExtension(item.Item2.ReportFullPath)</td>
<td><a href="@Url.Content(downloadLink)">@item.Item2.DateTimeFromSequence</a></td>
</tr>
}
</table>
@if (string.IsNullOrEmpty(Model.Directory))
{
<hr />
<table id="records" border="1">
<tr>
<th><a href="#a" id="b">Technology - Environment</a></th>
<th>Equipment Type</th>
<th>Sequence</th>
<th>Reactor</th>
<th>RDS</th>
<th>Part Number</th>
<th>File Name</th>
<th>Date</th>
</tr>
@foreach (var element in Model.Grouped)
{
foreach (var innerElement in element.Value)
{
foreach (var item in innerElement.Value)
{
viewLink = string.Concat("/", nameof(PDSFPage.OnGetView), "/sequence_", item.Sequence);
downloadLink = string.Concat("/", nameof(PDSFPage.OnGetDownloadFile), "/sequence_",
item.Sequence);
<tr>
<td>@element.Key</td>
<td>@innerElement.Key</td>
<td><a href="@Url.Content(viewLink)">@item.Sequence</a></td>
<td>@item.ProcessJobID</td>
<td>@item.MID</td>
<td>@item.Logistics2[0].PartNumber</td>
<td>@System.IO.Path.GetFileNameWithoutExtension(item.ReportFullPath)</td>
<td><a href="@Url.Content(downloadLink)">@item.DateTimeFromSequence</a></td>
</tr>
}
}
}
</table>
}
</p>
</div>
</body>
</html>
@section scripts {
<script>
$(function () {
console.log("ready!");
});
</script>
}

View File

@ -0,0 +1,164 @@
using APCViewer.Models.Stateless.Methods;
using IFX.Shared;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Serilog.Context;
using Shared;
using System.Text;
using System.Text.Json;
namespace APCViewer.Pages;
public class PDSFPage : PageModel, Models.Properties.IPDSFPage, Models.Stateless.Methods.IPDSFPage
{
protected string? _Directory;
protected int _Files;
protected Dictionary<string, Dictionary<string, List<Shared.Logistics>>> _Grouped;
protected List<Tuple<string[], Shared.Logistics>> _Sorted;
public string? Directory => _Directory;
public int Files => _Files;
public Dictionary<string, Dictionary<string, List<Shared.Logistics>>> Grouped => _Grouped;
public List<Tuple<string[], Shared.Logistics>> Sorted => _Sorted;
private readonly Serilog.ILogger _Log;
private readonly Singleton.Background _Background;
private readonly Models.Methods.IBackground _BackgroundMethods;
#nullable disable
public PDSFPage(Singleton.Background background)
{
_Background = background;
_BackgroundMethods = background;
_Log = Serilog.Log.ForContext<PDSFPage>();
}
#nullable enable
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
public void OnGet(string? directory = null, string? filter = null, bool is_gaN = false, bool is_Si = false)
{
string? methodName = IMethodName.GetActualAsyncMethodName();
using (LogContext.PushProperty("MethodName", methodName))
{
_Log.Debug("() => ...");
Tuple<int, Dictionary<string, Dictionary<string, List<Logistics>>>, List<Tuple<string[], Logistics>>, string?> tuple = _BackgroundMethods.SetViewBag(directory, filter, isGaN: is_gaN, isSi: is_Si, forPDSF: true);
_Files = tuple.Item1;
_Grouped = tuple.Item2;
_Sorted = tuple.Item3;
_Directory = tuple.Item4;
}
}
private static StringBuilder GetPDSFHtml(string? pdsfFile)
{
StringBuilder result = new();
_ = result.AppendLine("<html><body><table border = '1'>");
if (string.IsNullOrEmpty(pdsfFile))
throw new Exception("<tr><td>Invalid input</td></tr>");
else if (!System.IO.File.Exists(pdsfFile))
_ = result.AppendLine("<tr><td>File doesn't exist!</td></tr>");
else
{
bool header = true;
bool body = false;
bool footer = false;
string logisticsSegment;
List<string> logistics = new();
string[] pdsfLines = System.IO.File.ReadAllLines(pdsfFile);
foreach (string pdsfLine in pdsfLines)
{
if (pdsfLine.StartsWith("LOGISTICS_"))
{
logisticsSegment = pdsfLine.Split('\t')[0];
if (!logistics.Contains(logisticsSegment))
{
logistics.Add(logisticsSegment);
_ = result.AppendLine("</table><hr /><table border = '1'>");
}
}
if (pdsfLine.StartsWith("NUM_DATA_ROWS") || pdsfLine.StartsWith("END_HEADER"))
{
body = false;
footer = true;
_ = result.AppendLine("</table><hr /><table border = '1'>");
}
if (header)
_ = result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (body)
_ = result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (footer)
{
if (pdsfLine.StartsWith("DELIMITER"))
_ = result.Append("<tr><td>").Append(pdsfLine.Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else
_ = result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
}
else
throw new Exception();
if (pdsfLine.StartsWith("END_OFFSET"))
{
header = false;
body = true;
_ = result.AppendLine("</table><hr /><table border = '1'>");
}
}
}
_ = result.AppendLine("</table></body>");
return result;
}
public ContentResult OnGetView(string? id = null)
{
string pdsfFile;
StringBuilder result = new();
if (string.IsNullOrEmpty(id) || !id.Contains('_'))
_ = result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>");
else
{
if (!long.TryParse(id.Split('_')[1], out long sequence))
_ = result.AppendLine("<html><body><table border = '1'><tr><td>B) Error: Invalid input</td></tr></table></body>");
else
{
pdsfFile = _Background.GetPDSF(sequence);
result = GetPDSFHtml(pdsfFile);
}
}
return Content(result.ToString(), "text/html");
}
public FileResult OnGetDownloadFile(string? id = null)
{
string pdsfFile;
if (string.IsNullOrEmpty(id) || !id.Contains('_'))
throw new Exception("A) Error: Invalid input");
else
{
if (!long.TryParse(id.Split('_')[1], out long sequence))
throw new Exception("B) Error: Invalid input");
else
pdsfFile = _Background.GetPDSF(sequence);
}
return File(pdsfFile, "text/plain", Path.GetFileName(pdsfFile));
}
public ContentResult OnGetViewCustom(string? pdsf_file = null)
{
StringBuilder result = GetPDSFHtml(pdsf_file);
return Content(result.ToString(), "text/html");
}
public FileResult OnGetDownloadFileCustom(string? pdsf_file = null)
{
if (string.IsNullOrEmpty(pdsf_file))
throw new Exception("Error: Invalid input");
else if (!System.IO.File.Exists(pdsf_file))
throw new Exception("Error: file does not exist");
return File(pdsf_file, "text/plain", Path.GetFileName(pdsf_file));
}
}

View File

@ -0,0 +1,53 @@
@page
@model APCViewer.Pages.TimePivotPage
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>TimePivot</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/app.css" rel="stylesheet" />
</head>
<body>
<div class="main">
<h3>*.ipdsf</h3>
<table id="forIPDSF" border="1">
@foreach (var segments in Model.ForIPDSF)
{
<tr>
@for (int i = 0; i < segments.Length; i++)
{
<td>@(segments[i])</td>
}
</tr>
}
</table>
<hr />
<h3>*.pdsf</h3>
<table id="forPDSF" border="1">
@foreach (var segments in Model.ForPDSF)
{
<tr>
@for (int i = 0; i < segments.Length; i++)
{
<td>@(segments[i])</td>
}
</tr>
}
</table>
</div>
</body>
</html>
@section scripts {
<script>
$(function () {
console.log("ready!");
});
</script>
}

View File

@ -0,0 +1,49 @@
using APCViewer.Models.Stateless.Methods;
using IFX.Shared;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Serilog.Context;
using Shared;
using System.Text.Json;
namespace APCViewer.Pages;
public class TimePivotPage : PageModel, Models.Properties.ITimePivotPage, ITimePivotPage
{
protected List<string[]> _ForIPDSF;
protected List<string[]> _ForPDSF;
public List<string[]> ForIPDSF => _ForIPDSF;
public List<string[]> ForPDSF => _ForPDSF;
private readonly Serilog.ILogger _Log;
private readonly Singleton.Background _Background;
private readonly Models.Methods.IBackground _BackgroundMethods;
#nullable disable
public TimePivotPage(Singleton.Background background)
{
_Background = background;
_BackgroundMethods = background;
_Log = Serilog.Log.ForContext<TimePivotPage>();
}
#nullable enable
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
public void OnGet(bool is_gaN = false, bool is_Si = false)
{
string? methodName = IMethodName.GetActualAsyncMethodName();
using (LogContext.PushProperty("MethodName", methodName))
{
_Log.Debug("() => ...");
Tuple<List<string[]>, List<string[]>> tuple = _BackgroundMethods.GetTimePivot(isGaN: is_gaN, isSi: is_Si);
_ForIPDSF = tuple.Item1;
_ForPDSF = tuple.Item2;
}
}
}