net6.0 Ready to test

This commit is contained in:
2022-05-09 16:48:57 -07:00
parent 053c873d6b
commit 6c8ad46064
171 changed files with 6547 additions and 48515 deletions

View File

@ -1,15 +1,52 @@
namespace EDAViewer.Models
using System.Text.Json;
using System.Text.Json.Serialization;
namespace EDAViewer.Models;
public class AppSettings
{
public class AppSettings
protected string _BuildNumber;
protected string _Company;
protected string _ECEDADatabasePassword;
protected string _GitCommitSeven;
protected string _IFXEDADatabasePassword;
protected string _MonARessource;
protected string _Server;
protected string _URLs;
protected string _WorkingDirectoryName;
public string BuildNumber => _BuildNumber;
public string Company => _Company;
public string ECEDADatabasePassword => _ECEDADatabasePassword;
public string GitCommitSeven => _GitCommitSeven;
public string IFXEDADatabasePassword => _IFXEDADatabasePassword;
public string MonARessource => _MonARessource;
public string Server => _Server;
public string URLs => _URLs;
public string WorkingDirectoryName => _WorkingDirectoryName;
// public AppSettings()
// {
// }
[JsonConstructor]
public AppSettings(string buildNumber, string company, string ecEDADatabasePassword, string gitCommitSeven, string ifxEDADatabasePassword, string monARessource, string server, string urls, string workingDirectoryName)
{
public string Company { get; set; }
public string ECEDADatabasePassword { get; set; }
public string EncryptedPassword { get; set; }
public string IFXEDADatabasePassword { get; set; }
public string MonARessource { get; set; }
public string Server { get; set; }
public string ServiceUser { get; set; }
public string URLs { get; set; }
public string WorkingDirectoryName { get; set; }
_BuildNumber = buildNumber;
_Company = company;
_ECEDADatabasePassword = ecEDADatabasePassword;
_GitCommitSeven = gitCommitSeven;
_IFXEDADatabasePassword = ifxEDADatabasePassword;
_MonARessource = monARessource;
_Server = server;
_URLs = urls;
_WorkingDirectoryName = workingDirectoryName;
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
}

View File

@ -0,0 +1,38 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json;
namespace EDAViewer.Models.Binder;
public class AppSettings
{
[Display(Name = "Build Number"), Required] public string BuildNumber { get; set; }
[Display(Name = "Company"), Required] public string Company { get; set; }
[Display(Name = "EC EDA Database Password"), Required] public string ECEDADatabasePassword { get; set; }
[Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; }
[Display(Name = "IFX EDA Database Password"), Required] public string IFXEDADatabasePassword { get; set; }
[Display(Name = "MonA Ressource"), Required] public string MonARessource { get; set; }
[Display(Name = "Server"), Required] public string Server { get; set; }
[Display(Name = "URLs"), Required] public string URLs { get; set; }
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
public AppSettings()
{
BuildNumber = string.Empty;
Company = string.Empty;
ECEDADatabasePassword = string.Empty;
GitCommitSeven = string.Empty;
IFXEDADatabasePassword = string.Empty;
MonARessource = string.Empty;
Server = 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,52 +0,0 @@
using EDAViewer.Models;
using System;
using System.ComponentModel.DataAnnotations;
namespace EDAViewer.Models
{
public class EdaHtmlDiff : WithEnvironment
{
public string Paths { get; set; }
public string CurrentPath { get; set; }
public string PathAndFileName { get; set; }
[Display(Name = "FileName")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[Required(ErrorMessage = "Please select an file name", AllowEmptyStrings = false)]
public string FileName { get; set; }
public EdaHtmlDiff()
{
Common(path: string.Empty);
}
public EdaHtmlDiff(WithEnvironment withEnvironment, string path)
{
Common(path);
if (string.IsNullOrEmpty(withEnvironment.user_name))
user_name = "AUTO";
else
user_name = withEnvironment.user_name;
if (string.IsNullOrEmpty(withEnvironment.machine_name))
machine_name = "IFX";
else
machine_name = withEnvironment.machine_name;
if (withEnvironment.now_ticks == 0)
now_ticks = DateTime.Now.Ticks;
else
now_ticks = withEnvironment.now_ticks;
message = withEnvironment.message;
}
private void Common(string path)
{
Paths = string.Empty;
CurrentPath = path;
FileName = string.Empty;
}
}
}

View File

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

View File

@ -1,46 +0,0 @@
namespace EDAViewer.Models
{
public interface IBackground
{
void EdaDataCollectionPlansCallback();
// public void EdaDataCollectionPlans()
// {
// long ticks = DateTime.Now.Ticks;
// Logic2021Q1 logic2021Q1 = new Logic2021Q1(_Log);
// string server = GetServer(debugIsNotEC: false);
// string cSharpFormat = "yyyy-MM-dd_hh:mm:ss tt";
// string oracleFormat = "yyyy-MM-dd_hh:mi:ss AM";
// string edaDataCollectionPlansLastRun = "2020-07-02_10:45:01 AM";
// logic2021Q1.EdaDataCollectionPlans(server, server.Contains("_ec_"), edaDataCollectionPlansLastRun, cSharpFormat, oracleFormat);
// _Log.Debug(string.Concat("Took ", new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds, " second(s)"));
// }
void EDAOutputArchiveCallback();
// public void EDAOutputArchive()
// {
// long ticks = DateTime.Now.Ticks;
// string server = GetServer(debugIsNotEC: true);
// string sourceDirectory = string.Concat(@"\\", server, @"\ec_eda\Staging\Traces");
// if (!Directory.Exists(sourceDirectory))
// _Log.Debug(string.Concat("// Source directory <", sourceDirectory, "> doesn't exist."));
// else
// {
// Logic2019Q4 logic2019Q4 = new Logic2019Q4(_Log);
// logic2019Q4.EDAOutputArchive(sourceDirectory);
// }
// _Log.Debug(string.Concat("Took ", new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds, " second(s)"));
// }
void LogPathCleanUpByWeekCallback();
// public void LogPathCleanUpByWeek()
// {
// long ticks = DateTime.Now.Ticks;
// string server = GetServer(debugIsNotEC: true);
// Logic2019Q3 logic2019Q3 = new Logic2019Q3(_Log);
// logic2019Q3.LogPathCleanUpByWeek(server, isEDA: true);
// logic2019Q3.LogPathCleanUpByWeek(server, isEAFLog: true);
// _Log.Debug(string.Concat("Took ", new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds, " second(s)"));
// }
}
}

View File

@ -1,17 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using System.Collections.Generic;
namespace EDAViewer.Models
{
public interface IHomeController
{
IActionResult Background(bool? message_clear = null, bool? exceptions_clear = null, bool? set_is_primary_instance = null, int? invoke_eda_dcp = null);
IActionResult Encode(string value = null);
IActionResult Error();
IActionResult Index();
IActionResult Privacy();
IActionResult ViewEdaHtmlDiff(WithEnvironment withEnvironment = null);
ActionResult<IEnumerable<SelectListItem>> GetDirectoriesOrFiles(string path = null, bool? upDirectory = null, string filter = null);
}
}

View File

@ -0,0 +1,20 @@
namespace EDAViewer.Models.Methods;
public interface IBackground
{
void Catch(Exception exception);
void ClearIsPrimaryInstance();
void ClearMessage();
void Dispose();
bool IsPrimaryInstance();
void SetIsPrimaryInstance();
void Stop(bool immediate);
void Update(int milliSeconds);
string GetCountDirectory(string verb);
void EDAOutputArchiveCallback();
void EdaDataCollectionPlansCallback();
void LogPathCleanUpByWeekCallback();
}

View File

@ -0,0 +1,8 @@
namespace EDAViewer.Models.Properties;
public interface IBackground
{
public List<Timer> Timers { get; }
}

View File

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

View File

@ -0,0 +1,39 @@
using System.Text.Json;
namespace EDAViewer.Models.Stateless;
public abstract class AppSettings
{
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{
Models.AppSettings? result;
Binder.AppSettings appSettings = configurationRoot.Get<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)
{
int? check = null;
int min = new int[] { json.Length, jsonThis.Length }.Min();
for (int i = 0; i < min; i++)
{
if (json[i] == jsonThis[i])
continue;
check = i;
break;
}
if (check is null)
throw new Exception();
string a = json[..check.Value].Split(',')[^1];
string b = json[check.Value..].Split(',')[0];
throw new Exception($"{a}{b}");
}
return result;
}
}

View File

@ -0,0 +1,10 @@
namespace EDAViewer.Models.Stateless.Methods;
public interface IBackgroundPage
{
void OnGet(bool? message_clear = null, bool? exceptions_clear = null, bool? set_is_primary_instance = null);
static string GetRouteName() => nameof(IBackgroundPage).Replace("Page", string.Empty)[1..];
}

View File

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

View File

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

View File

@ -0,0 +1,50 @@
namespace EDAViewer.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 EDAViewer.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);
}

View File

@ -1,14 +0,0 @@
namespace EDAViewer.Models
{
public class WithEnvironment
{
public string message { get; set; }
public string user_name { get; set; }
public string machine_name { get; set; }
public long now_ticks { get; set; }
}
}