net6.0 Ready to test
This commit is contained in:
68
EDA Viewer/Pages/Background.cshtml
Normal file
68
EDA Viewer/Pages/Background.cshtml
Normal file
@ -0,0 +1,68 @@
|
||||
@page
|
||||
@model EDAViewer.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(EDAViewer)) -
|
||||
@(Model.IsPrimaryInstance) -
|
||||
@(Model.IsEnvironmentProfile) -
|
||||
@(Model.AppSettingsBuildNumber) -
|
||||
@(Model.AppSettingsGitCommitSeven) -
|
||||
@(Model.AppSettingsURLs)</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="/Index.txt">Index.txt</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> </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>
|
74
EDA Viewer/Pages/Background.cshtml.cs
Normal file
74
EDA Viewer/Pages/Background.cshtml.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using EDAViewer.Models.Stateless.Methods;
|
||||
using IFX.Shared;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Serilog.Context;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace EDAViewer.Pages;
|
||||
|
||||
public class BackgroundPage : PageModel, Models.Properties.IBackgroundPage, IBackgroundPage
|
||||
{
|
||||
|
||||
protected readonly string _AppSettingsBuildNumber;
|
||||
protected readonly string _AppSettingsGitCommitSeven;
|
||||
protected readonly string _AppSettingsURLs;
|
||||
protected readonly List<Exception> _Exceptions;
|
||||
protected readonly string _IsEnvironmentProfile;
|
||||
protected string _IsPrimaryInstance;
|
||||
protected readonly string _Message;
|
||||
protected readonly string _WorkingDirectory;
|
||||
public string AppSettingsBuildNumber => _AppSettingsBuildNumber;
|
||||
public string AppSettingsGitCommitSeven => _AppSettingsGitCommitSeven;
|
||||
public string AppSettingsURLs => _AppSettingsURLs;
|
||||
public List<Exception> Exceptions => _Exceptions;
|
||||
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)
|
||||
{
|
||||
_Message = background.Message;
|
||||
_BackgroundMethods = background;
|
||||
_AppSettingsURLs = appSettings.URLs;
|
||||
_Exceptions = background.Exceptions;
|
||||
_IsEnvironmentProfile = isEnvironment.Profile;
|
||||
_Log = Serilog.Log.ForContext<BackgroundPage>();
|
||||
_WorkingDirectory = background.WorkingDirectory;
|
||||
_AppSettingsBuildNumber = appSettings.BuildNumber;
|
||||
_AppSettingsGitCommitSeven = appSettings.GitCommitSeven;
|
||||
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();
|
||||
_IsPrimaryInstance = _BackgroundMethods.IsPrimaryInstance().ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
42
EDA Viewer/Pages/Error.cshtml
Normal file
42
EDA Viewer/Pages/Error.cshtml
Normal file
@ -0,0 +1,42 @@
|
||||
@page
|
||||
@model EDAViewer.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>
|
20
EDA Viewer/Pages/Error.cshtml.cs
Normal file
20
EDA Viewer/Pages/Error.cshtml.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace EDAViewer.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;
|
||||
}
|
Reference in New Issue
Block a user