Builds but needs tested

This commit is contained in:
2022-03-25 18:13:23 -07:00
parent a6abe8fdbd
commit 1f607cbbed
113 changed files with 12922 additions and 5993 deletions

View File

@ -1,12 +1,46 @@
namespace APCViewer.Models
using System.Text.Json;
using System.Text.Json.Serialization;
namespace APCViewer.Models;
public class AppSettings
{
public class AppSettings
protected string _Company;
protected string _EncryptedPassword;
protected string _MonARessource;
protected string _Server;
protected string _ServiceUser;
protected string _URLs;
protected string _WorkingDirectoryName;
public string Company => _Company;
public string EncryptedPassword => _EncryptedPassword;
public string MonARessource => _MonARessource;
public string Server => _Server;
public string ServiceUser => _ServiceUser;
public string URLs => _URLs;
public string WorkingDirectoryName => _WorkingDirectoryName;
// public AppSettings()
// {
// }
[JsonConstructor]
public AppSettings(string company, string encryptedPassword, string monARessource, string server, string serviceUser, string urls, string workingDirectoryName)
{
public string Company { get; set; }
public string EncryptedPassword { get; set; }
public string MonARessource { get; set; }
public string Server { get; set; }
public string ServiceUser { get; set; }
public string URLs { get; set; }
_Company = company;
_EncryptedPassword = encryptedPassword;
_MonARessource = monARessource;
_Server = server;
_ServiceUser = serviceUser;
_URLs = urls;
_WorkingDirectoryName = workingDirectoryName;
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
}

View File

@ -0,0 +1,34 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json;
namespace APCViewer.Models.Binder;
public class AppSettings
{
[Display(Name = "Company"), Required] public string Company { get; set; }
[Display(Name = "Encrypted Password"), Required] public string EncryptedPassword { get; set; }
[Display(Name = "MonARessource"), Required] public string MonARessource { get; set; }
[Display(Name = "Server"), Required] public string Server { get; set; }
[Display(Name = "Service User"), Required] public string ServiceUser { get; set; }
[Display(Name = "URLs"), Required] public string URLs { get; set; }
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
public AppSettings()
{
Company = string.Empty;
EncryptedPassword = string.Empty;
MonARessource = string.Empty;
Server = string.Empty;
ServiceUser = string.Empty;
URLs = string.Empty;
WorkingDirectoryName = string.Empty;
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
}

View File

@ -1,9 +1,8 @@
namespace APCViewer.Models
{
public class ErrorViewModel
{
public string RequestId { get; set; }
namespace APCViewer.Models;
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
public class ErrorViewModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}

View File

@ -1,91 +0,0 @@
namespace APCViewer.Models
{
public interface IBackground
{
void APCDataCallback();
// public void DataForApc(string workingDirectory, bool isGaN = false, bool isSi = false)
// {
// long ticks = DateTime.Now.Ticks;
// string server = GetServer(debugIsNotEC: false);
// Logic2019Q2 logic2019Q2 = new Logic2019Q2(_Log);
// Logic2020Q3 logic2020Q3 = new Logic2020Q3(_Log);
// string[] equipmentTypes = GetEquipmentTypes(isGaN, isSi);
// Dictionary<string, string> pdsfFiles = new Dictionary<string, string>();
// Dictionary<string, object> apcLogistics = new Dictionary<string, object>();
// Dictionary<string, object> edaLogistics = new Dictionary<string, object>();
// Dictionary<string, object> eafLogLogistics = new Dictionary<string, object>();
// logic2019Q2.Data(server, equipmentTypes, apcLogistics, pdsfFiles, isAPC: true);
// Tuple<int, object, object, string> tuple = logic2020Q3.SetViewBag(apcLogistics, edaLogistics, eafLogLogistics, directory: null, filter: null, forPDSF: true, forIPDSF: false);
// if (tuple is null) { }
// List<string[]> timePivot = logic2020Q3.GetTimePivot(equipmentTypes, apcLogistics, edaLogistics, eafLogLogistics, forPDSF: true, forIPDSF: false);
// _Log.Debug(string.Concat("Took ", new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds, " second(s)"));
// List<string> list = new List<string>();
// StringBuilder stringBuilder = new StringBuilder();
// foreach (string[] segments in timePivot)
// {
// foreach (string segment in segments)
// stringBuilder.Append(segment).Append('\t');
// list.Add(stringBuilder.ToString());
// stringBuilder.Clear();
// }
// ShowWindow(workingDirectory, ShowWindowCommand.ShowMaximized, list);
// }
void EAFLogDataCallback();
// public void DataForEafLog(string workingDirectory, bool isGaN = false, bool isSi = false)
// {
// long ticks = DateTime.Now.Ticks;
// string server = GetServer(debugIsNotEC: false);
// Logic2019Q2 logic2019Q2 = new Logic2019Q2(_Log);
// Logic2020Q3 logic2020Q3 = new Logic2020Q3(_Log);
// string[] equipmentTypes = GetEquipmentTypes(isGaN, isSi);
// Dictionary<string, string> pdsfFiles = new Dictionary<string, string>();
// Dictionary<string, object> apcLogistics = new Dictionary<string, object>();
// Dictionary<string, object> edaLogistics = new Dictionary<string, object>();
// Dictionary<string, object> eafLogLogistics = new Dictionary<string, object>();
// logic2019Q2.Data(server, equipmentTypes, eafLogLogistics, pdsfFiles, isEAFLog: true);
// Tuple<int, object, object, string> tuple = logic2020Q3.SetViewBag(apcLogistics, edaLogistics, eafLogLogistics, directory: null, filter: null, forPDSF: false, forIPDSF: true);
// if (tuple is null) { }
// List<string[]> timePivot = logic2020Q3.GetTimePivot(equipmentTypes, apcLogistics, edaLogistics, eafLogLogistics, forPDSF: false, forIPDSF: true);
// _Log.Debug(string.Concat("Took ", new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds, " second(s)"));
// List<string> list = new List<string>();
// StringBuilder stringBuilder = new StringBuilder();
// foreach (string[] segments in timePivot)
// {
// foreach (string segment in segments)
// stringBuilder.Append(segment).Append('\t');
// list.Add(stringBuilder.ToString());
// stringBuilder.Clear();
// }
// ShowWindow(workingDirectory, ShowWindowCommand.ShowMaximized, list);
// }
void EDADataCallback();
// public void DataForEda(string workingDirectory, bool isGaN = false, bool isSi = false)
// {
// long ticks = DateTime.Now.Ticks;
// string server = GetServer(debugIsNotEC: true);
// Logic2019Q2 logic2019Q2 = new Logic2019Q2(_Log);
// Logic2020Q3 logic2020Q3 = new Logic2020Q3(_Log);
// string[] equipmentTypes = GetEquipmentTypes(isGaN, isSi);
// Dictionary<string, string> pdsfFiles = new Dictionary<string, string>();
// Dictionary<string, object> apcLogistics = new Dictionary<string, object>();
// Dictionary<string, object> edaLogistics = new Dictionary<string, object>();
// Dictionary<string, object> eafLogLogistics = new Dictionary<string, object>();
// logic2019Q2.Data(server, equipmentTypes, edaLogistics, pdsfFiles, isEDA: true);
// Tuple<int, object, object, string> tuple = logic2020Q3.SetViewBag(apcLogistics, edaLogistics, eafLogLogistics, directory: null, filter: null, forPDSF: true, forIPDSF: false);
// if (tuple is null) { }
// List<string[]> timePivot = logic2020Q3.GetTimePivot(equipmentTypes, apcLogistics, edaLogistics, eafLogLogistics, forPDSF: true, forIPDSF: false);
// _Log.Debug(string.Concat("Took ", new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds, " second(s)"));
// List<string> list = new List<string>();
// StringBuilder stringBuilder = new StringBuilder();
// foreach (string[] segments in timePivot)
// {
// foreach (string segment in segments)
// stringBuilder.Append(segment).Append('\t');
// list.Add(stringBuilder.ToString());
// stringBuilder.Clear();
// }
// ShowWindow(workingDirectory, ShowWindowCommand.ShowMaximized, list);
// }
}
}

View File

@ -1,25 +1,11 @@
using Microsoft.AspNetCore.Mvc;
namespace APCViewer.Models
{
public interface IHomeController
{
IActionResult Background(bool? message_clear = null, bool? exceptions_clear = null, bool? set_is_primary_instance = null, bool? logistics_clear = null);
IActionResult DownloadCustomIPDSF(string ipdsf_file = null);
IActionResult DownloadCustomPDSF(string pdsf_file = null);
IActionResult DownloadIPDSF(string id = null);
IActionResult DownloadPDSF(string id = null);
IActionResult Encode(string value = null);
IActionResult Error();
IActionResult Index();
IActionResult IPDSF(string directory = null, string filter = null, bool is_gaN = false, bool is_Si = false);
IActionResult PDSF(string directory = null, string filter = null, bool is_gaN = false, bool is_Si = false);
IActionResult Privacy();
IActionResult TimePivot(bool is_gaN = false, bool is_Si = false);
ContentResult ViewCustomIPDSF(string ipdsf_file = null);
ContentResult ViewCustomPDSF(string pdsf_file = null);
ContentResult ViewIPDSF(string id = null);
ContentResult ViewPDSF(string id = null);
}
namespace APCViewer.Controllers;
public interface IHomeController
{
ActionResult Encode(string value = "");
ActionResult Error();
ActionResult Index();
ActionResult Privacy();
}

View File

@ -0,0 +1,19 @@
namespace APCViewer.Models.Methods;
public interface IBackground
{
void Update();
void ClearMessage();
List<string> DoBackup();
bool IsPrimaryInstance();
void Stop(bool immediate);
void SetIsPrimaryInstance();
string GetPDSF(long Sequence);
void ClearIsPrimaryInstance();
string GetIPDSF(long Sequence);
void Catch(Exception exception);
Tuple<List<string[]>, List<string[]>> GetTimePivot(bool isGaN = false, bool isSi = false);
Tuple<int, object, object, string> SetViewBag(string directory, string filter, bool isGaN = false, bool isSi = false, bool forPDSF = false, bool forIPDSF = false);
}

View File

@ -0,0 +1,6 @@
namespace APCViewer.Models.Properties;
public interface IBackground
{
}

View File

@ -0,0 +1,10 @@
namespace APCViewer.Models.Properties;
public interface IBackgroundController
{
public List<Exception> Exceptions { get; }
public string Message { get; }
public string WorkingDirectory { get; }
}

View File

@ -0,0 +1,24 @@
using System.Text.Json;
namespace APCViewer.Models.Stateless;
public abstract class AppSettings
{
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{
Models.AppSettings? result;
Models.Binder.AppSettings appSettings = configurationRoot.Get<Models.Binder.AppSettings>();
string json = JsonSerializer.Serialize(appSettings, new JsonSerializerOptions() { WriteIndented = true });
result = JsonSerializer.Deserialize<Models.AppSettings>(json);
if (result is null)
throw new Exception(json);
if (string.IsNullOrEmpty(result.Company))
throw new Exception(json);
string jsonThis = result.ToString();
if (jsonThis != json)
throw new Exception(json);
return result;
}
}

View File

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
namespace APCViewer.Models.Stateless.Methods;
public interface IBackgroundController
{
ActionResult Index(bool? message_clear = null, bool? exceptions_clear = null, bool? set_is_primary_instance = null);
static string GetRouteName() => nameof(IBackgroundController).Replace("Controller", string.Empty)[1..];
}

View File

@ -0,0 +1,10 @@
using System.Runtime.CompilerServices;
namespace APCViewer.Models.Stateless.Methods;
public interface IMethodName
{
static string? GetActualAsyncMethodName([CallerMemberName] string? name = null) => name;
}

View File

@ -0,0 +1,8 @@
namespace APCViewer.Models.Stateless.Methods;
public interface IWorkingDirectory
{
static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName) => WorkingDirectory.GetWorkingDirectory(executingAssemblyName, subDirectoryName);
}

View File

@ -0,0 +1,50 @@
namespace APCViewer.Models.Stateless.Methods;
internal abstract class WorkingDirectory
{
internal static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName)
{
string result = string.Empty;
if (executingAssemblyName is null)
throw new Exception();
string traceFile;
List<string> directories = new();
Environment.SpecialFolder[] specialFolders = new Environment.SpecialFolder[]
{
Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolder.ApplicationData,
Environment.SpecialFolder.History,
Environment.SpecialFolder.CommonApplicationData,
Environment.SpecialFolder.InternetCache
};
foreach (Environment.SpecialFolder specialFolder in specialFolders)
directories.Add(Path.Combine(Environment.GetFolderPath(specialFolder), subDirectoryName, executingAssemblyName));
foreach (string directory in directories)
{
for (int i = 1; i < 3; i++)
{
if (i == 1)
result = directory;
else
result = string.Concat("D", directory[1..]);
try
{
if (!Directory.Exists(result))
_ = Directory.CreateDirectory(result);
traceFile = string.Concat(result, @"\", DateTime.Now.Ticks, ".txt");
File.WriteAllText(traceFile, traceFile);
File.Delete(traceFile);
break;
}
catch (Exception) { result = string.Empty; }
}
if (!string.IsNullOrEmpty(result))
break;
}
if (string.IsNullOrEmpty(result))
throw new Exception("Unable to set working directory!");
return result;
}
}

View File

@ -0,0 +1,10 @@
namespace APCViewer.Models.Stateless;
public static class SerilogExtensionMethods
{
internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
}