net6.0 Ready to test
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user