Builds but needs tested
This commit is contained in:
parent
a6abe8fdbd
commit
1f607cbbed
7292
APC Viewer/.vscode/format-report.json
vendored
Normal file
7292
APC Viewer/.vscode/format-report.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -6,12 +6,16 @@
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>APCViewer</RootNamespace>
|
||||
<RuntimeFrameworkVersion>5.0.2</RuntimeFrameworkVersion>
|
||||
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
|
||||
<UserSecretsId>d71a673c-be39-45b5-ae5f-4c22639be045</UserSecretsId>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>APCViewer</RootNamespace>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
|
||||
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
|
||||
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
|
||||
@ -27,23 +31,35 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" />
|
||||
<PackageReference Include="Log4net" Version="2.0.12" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.1.4" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\images\" />
|
||||
<Folder Include="wwwroot\js\html5shiv\3.7.2\" />
|
||||
<Folder Include="wwwroot\js\respond\1.4.2\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="appsettings.Staging.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="appsettings.Development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
16
APC Viewer/Blazor/Counter.razor
Normal file
16
APC Viewer/Blazor/Counter.razor
Normal file
@ -0,0 +1,16 @@
|
||||
<h3>Counter</h3>
|
||||
|
||||
<p>
|
||||
Current Count: @i
|
||||
</p>
|
||||
|
||||
<button @onclick="IncrementCounter" class="btn btn-primary">Click Me</button>
|
||||
|
||||
@code {
|
||||
int i = 0;
|
||||
|
||||
private void IncrementCounter()
|
||||
{
|
||||
i += 1;
|
||||
}
|
||||
}
|
83
APC Viewer/Controllers/BackgroundController.cs
Normal file
83
APC Viewer/Controllers/BackgroundController.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using APCViewer.Models.Stateless.Methods;
|
||||
using IFX.Shared;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serilog.Context;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace APCViewer.Controllers;
|
||||
|
||||
public class BackgroundController : Controller, Models.Properties.IBackgroundController, IBackgroundController
|
||||
{
|
||||
|
||||
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 BackgroundController(IsEnvironment isEnvironment, Models.AppSettings appSettings, Singleton.Background background)
|
||||
{
|
||||
_Message = background.Message;
|
||||
_BackgroundMethods = background;
|
||||
_AppSettingsURLs = appSettings.URLs;
|
||||
_Exceptions = background.Exceptions;
|
||||
_IsEnvironmentProfile = isEnvironment.Profile;
|
||||
_WorkingDirectory = background.WorkingDirectory;
|
||||
_Log = Serilog.Log.ForContext<BackgroundController>();
|
||||
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 ActionResult Index(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();
|
||||
}
|
||||
string message;
|
||||
if (string.IsNullOrWhiteSpace(_Message))
|
||||
message = "N/A";
|
||||
else
|
||||
message = _Message;
|
||||
List<Exception> exceptions = new();
|
||||
foreach (Exception exception in _Exceptions)
|
||||
exceptions.Add(exception);
|
||||
ViewBag.Message = message;
|
||||
ViewBag.Exceptions = exceptions;
|
||||
ViewBag.URLs = _AppSettingsURLs;
|
||||
ViewBag.Profile = _IsEnvironmentProfile;
|
||||
ViewBag.WorkingDirectory = _WorkingDirectory;
|
||||
ViewBag.IsPrimaryInstance = _IsPrimaryInstance;
|
||||
ViewBag.ExceptionsCount = string.Concat("Exception(s) - ", exceptions.Count);
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +1,39 @@
|
||||
using APCViewer.Models;
|
||||
using APCViewer.Models.Methods;
|
||||
using APCViewer.Singleton;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace APCViewer.Controllers
|
||||
{
|
||||
namespace APCViewer.Controllers;
|
||||
|
||||
public class HomeController : Controller, IHomeController
|
||||
{
|
||||
|
||||
private readonly Log _Log;
|
||||
private readonly Singleton.IBackground _Background;
|
||||
private readonly IHttpContextAccessor _HttpContextAccessor;
|
||||
private readonly Serilog.ILogger _Log;
|
||||
private readonly Background _Background;
|
||||
private readonly IBackground _BackgroundMethods;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger, Singleton.IBackground background, IHttpContextAccessor httpContextAccessor)
|
||||
public HomeController(Background background)
|
||||
{
|
||||
_Log = new Log(logger);
|
||||
_Background = background;
|
||||
_HttpContextAccessor = httpContextAccessor;
|
||||
_BackgroundMethods = background;
|
||||
_Log = Serilog.Log.ForContext<HomeController>();
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public ActionResult Index() => View();
|
||||
|
||||
public ActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public ActionResult Privacy() => View();
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public ActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
public ActionResult Error() => View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
|
||||
public ActionResult Encode(string value = null)
|
||||
public ActionResult Encode(string value = "")
|
||||
{
|
||||
string result = string.Empty;
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
@ -52,44 +41,23 @@ namespace APCViewer.Controllers
|
||||
return Content(result, "text/plain");
|
||||
}
|
||||
|
||||
public ActionResult Background(bool? message_clear = null, bool? exceptions_clear = null, bool? set_is_primary_instance = null, bool? logistics_clear = null)
|
||||
public ActionResult TestTry()
|
||||
{
|
||||
_Background.SendStatusOk();
|
||||
if (message_clear.HasValue && message_clear.Value)
|
||||
_Background.ClearMessage();
|
||||
if (exceptions_clear.HasValue && exceptions_clear.Value)
|
||||
_Background.Exceptions.Clear();
|
||||
if (set_is_primary_instance.HasValue)
|
||||
ActionResult result;
|
||||
try
|
||||
{
|
||||
if (set_is_primary_instance.Value)
|
||||
_Background.SetIsPrimaryInstance();
|
||||
else
|
||||
_Background.ClearIsPrimaryInstance();
|
||||
throw new Exception("This is a test");
|
||||
}
|
||||
if (logistics_clear.HasValue && logistics_clear.Value)
|
||||
_Background.LogisticsClear();
|
||||
string message;
|
||||
if (string.IsNullOrWhiteSpace(_Background.Message))
|
||||
message = "N/A";
|
||||
else
|
||||
message = _Background.Message;
|
||||
//Response.AppendToLog(_Background.Message);
|
||||
List<Exception> exceptions = new();
|
||||
foreach (Exception exception in _Background.Exceptions)
|
||||
exceptions.Add(exception);
|
||||
ViewBag.Message = message;
|
||||
ViewBag.Exceptions = exceptions;
|
||||
ViewBag.URLs = _Background.AppSettings.URLs;
|
||||
ViewBag.Profile = _Background.IsEnvironment.Profile;
|
||||
ViewBag.WorkingDirectory = _Background.WorkingDirectory;
|
||||
ViewBag.IsPrimaryInstance = _Background.IsPrimaryInstance();
|
||||
ViewBag.ExceptionsCount = string.Concat("Exception(s) - ", exceptions.Count);
|
||||
return View();
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = Content(string.Concat(ex.Message, Environment.NewLine, Environment.NewLine, ex.StackTrace));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ActionResult PDSF(string directory = null, string filter = null, bool is_gaN = false, bool is_Si = false)
|
||||
public ActionResult PDSF(string? directory = null, string? filter = null, bool is_gaN = false, bool is_Si = false)
|
||||
{
|
||||
Tuple<int, object, object, string> tuple = _Background.SetViewBag(directory, filter, isGaN: is_gaN, isSi: is_Si, forPDSF: true);
|
||||
Tuple<int, object, object, string?> tuple = _Background.SetViewBag(directory, filter, isGaN: is_gaN, isSi: is_Si, forPDSF: true);
|
||||
ViewBag.Files = tuple.Item1;
|
||||
ViewBag.Grouped = tuple.Item2;
|
||||
ViewBag.Sorted = tuple.Item3;
|
||||
@ -97,14 +65,14 @@ namespace APCViewer.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
private StringBuilder GetPDSFHtml(string pdsfFile)
|
||||
private static StringBuilder GetPDSFHtml(string? pdsfFile)
|
||||
{
|
||||
StringBuilder result = new();
|
||||
result.AppendLine("<html><body><table border = '1'>");
|
||||
_ = 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>");
|
||||
_ = result.AppendLine("<tr><td>File doesn't exist!</td></tr>");
|
||||
else
|
||||
{
|
||||
bool header = true;
|
||||
@ -121,25 +89,25 @@ namespace APCViewer.Controllers
|
||||
if (!logistics.Contains(logisticsSegment))
|
||||
{
|
||||
logistics.Add(logisticsSegment);
|
||||
result.AppendLine("</table><hr /><table border = '1'>");
|
||||
_ = 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'>");
|
||||
_ = result.AppendLine("</table><hr /><table border = '1'>");
|
||||
}
|
||||
if (header)
|
||||
result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine(" </td></tr>");
|
||||
_ = result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine(" </td></tr>");
|
||||
else if (body)
|
||||
result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine(" </td></tr>");
|
||||
_ = result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine(" </td></tr>");
|
||||
else if (footer)
|
||||
{
|
||||
if (pdsfLine.StartsWith("DELIMITER"))
|
||||
result.Append("<tr><td>").Append(pdsfLine.Replace(";", "</td><td>")).AppendLine(" </td></tr>");
|
||||
_ = result.Append("<tr><td>").Append(pdsfLine.Replace(";", "</td><td>")).AppendLine(" </td></tr>");
|
||||
else
|
||||
result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine(" </td></tr>");
|
||||
_ = result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine(" </td></tr>");
|
||||
}
|
||||
else
|
||||
throw new Exception();
|
||||
@ -147,24 +115,24 @@ namespace APCViewer.Controllers
|
||||
{
|
||||
header = false;
|
||||
body = true;
|
||||
result.AppendLine("</table><hr /><table border = '1'>");
|
||||
_ = result.AppendLine("</table><hr /><table border = '1'>");
|
||||
}
|
||||
}
|
||||
}
|
||||
result.AppendLine("</table></body>");
|
||||
_ = result.AppendLine("</table></body>");
|
||||
return result;
|
||||
}
|
||||
|
||||
public ContentResult ViewPDSF(string id = null)
|
||||
public ContentResult ViewPDSF(string? id = null)
|
||||
{
|
||||
string pdsfFile;
|
||||
StringBuilder result = new();
|
||||
if (!id.Contains('_'))
|
||||
result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>");
|
||||
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>");
|
||||
_ = result.AppendLine("<html><body><table border = '1'><tr><td>B) Error: Invalid input</td></tr></table></body>");
|
||||
else
|
||||
{
|
||||
pdsfFile = _Background.GetPDSF(sequence);
|
||||
@ -174,10 +142,10 @@ namespace APCViewer.Controllers
|
||||
return Content(result.ToString(), "text/html");
|
||||
}
|
||||
|
||||
public ActionResult DownloadPDSF(string id = null)
|
||||
public ActionResult DownloadPDSF(string? id = null)
|
||||
{
|
||||
string pdsfFile;
|
||||
if (!id.Contains('_'))
|
||||
if (string.IsNullOrEmpty(id) || !id.Contains('_'))
|
||||
throw new Exception("A) Error: Invalid input");
|
||||
else
|
||||
{
|
||||
@ -189,13 +157,13 @@ namespace APCViewer.Controllers
|
||||
return File(pdsfFile, "text/plain", Path.GetFileName(pdsfFile));
|
||||
}
|
||||
|
||||
public ContentResult ViewCustomPDSF(string pdsf_file = null)
|
||||
public ContentResult ViewCustomPDSF(string? pdsf_file = null)
|
||||
{
|
||||
StringBuilder result = GetPDSFHtml(pdsf_file);
|
||||
return Content(result.ToString(), "text/html");
|
||||
}
|
||||
|
||||
public ActionResult DownloadCustomPDSF(string pdsf_file = null)
|
||||
public ActionResult DownloadCustomPDSF(string? pdsf_file = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pdsf_file))
|
||||
throw new Exception("Error: Invalid input");
|
||||
@ -204,9 +172,9 @@ namespace APCViewer.Controllers
|
||||
return File(pdsf_file, "text/plain", Path.GetFileName(pdsf_file));
|
||||
}
|
||||
|
||||
public ActionResult IPDSF(string directory = null, string filter = null, bool is_gaN = false, bool is_Si = false)
|
||||
public ActionResult IPDSF(string? directory = null, string? filter = null, bool is_gaN = false, bool is_Si = false)
|
||||
{
|
||||
Tuple<int, object, object, string> tuple = _Background.SetViewBag(directory, filter, isGaN: is_gaN, isSi: is_Si, forIPDSF: true);
|
||||
Tuple<int, object, object, string?> tuple = _Background.SetViewBag(directory, filter, isGaN: is_gaN, isSi: is_Si, forIPDSF: true);
|
||||
ViewBag.Files = tuple.Item1;
|
||||
ViewBag.Grouped = tuple.Item2;
|
||||
ViewBag.Sorted = tuple.Item3;
|
||||
@ -214,14 +182,14 @@ namespace APCViewer.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
private StringBuilder GetIPDSFHtml(string ipdsfFile)
|
||||
private static StringBuilder GetIPDSFHtml(string? ipdsfFile)
|
||||
{
|
||||
StringBuilder result = new();
|
||||
result.AppendLine("<html><body><table border = '1'>");
|
||||
_ = 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>");
|
||||
_ = result.AppendLine("<tr><td>File doesn't exist!</td></tr>");
|
||||
else
|
||||
{
|
||||
bool header = true;
|
||||
@ -238,25 +206,25 @@ namespace APCViewer.Controllers
|
||||
if (!logistics.Contains(logisticsSegment))
|
||||
{
|
||||
logistics.Add(logisticsSegment);
|
||||
result.AppendLine("</table><hr /><table border = '1'>");
|
||||
_ = 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'>");
|
||||
_ = result.AppendLine("</table><hr /><table border = '1'>");
|
||||
}
|
||||
if (header)
|
||||
result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine(" </td></tr>");
|
||||
_ = result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine(" </td></tr>");
|
||||
else if (body)
|
||||
result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine(" </td></tr>");
|
||||
_ = result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine(" </td></tr>");
|
||||
else if (footer)
|
||||
{
|
||||
if (ipdsfLine.StartsWith("DELIMITER"))
|
||||
result.Append("<tr><td>").Append(ipdsfLine.Replace(";", "</td><td>")).AppendLine(" </td></tr>");
|
||||
_ = result.Append("<tr><td>").Append(ipdsfLine.Replace(";", "</td><td>")).AppendLine(" </td></tr>");
|
||||
else
|
||||
result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine(" </td></tr>");
|
||||
_ = result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine(" </td></tr>");
|
||||
}
|
||||
else
|
||||
throw new Exception();
|
||||
@ -264,24 +232,24 @@ namespace APCViewer.Controllers
|
||||
{
|
||||
header = false;
|
||||
body = true;
|
||||
result.AppendLine("</table><hr /><table border = '1'>");
|
||||
_ = result.AppendLine("</table><hr /><table border = '1'>");
|
||||
}
|
||||
}
|
||||
}
|
||||
result.AppendLine("</table></body>");
|
||||
_ = result.AppendLine("</table></body>");
|
||||
return result;
|
||||
}
|
||||
|
||||
public ContentResult ViewIPDSF(string id = null)
|
||||
public ContentResult ViewIPDSF(string? id = null)
|
||||
{
|
||||
string ipdsfFile;
|
||||
StringBuilder result = new();
|
||||
if (!id.Contains('_'))
|
||||
result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>");
|
||||
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>");
|
||||
_ = result.AppendLine("<html><body><table border = '1'><tr><td>B) Error: Invalid input</td></tr></table></body>");
|
||||
else
|
||||
{
|
||||
ipdsfFile = _Background.GetIPDSF(sequence);
|
||||
@ -291,10 +259,10 @@ namespace APCViewer.Controllers
|
||||
return Content(result.ToString(), "text/html");
|
||||
}
|
||||
|
||||
public ActionResult DownloadIPDSF(string id = null)
|
||||
public ActionResult DownloadIPDSF(string? id = null)
|
||||
{
|
||||
string ipdsfFile;
|
||||
if (!id.Contains('_'))
|
||||
if (string.IsNullOrEmpty(id) || !id.Contains('_'))
|
||||
throw new Exception("A) Error: Invalid input");
|
||||
else
|
||||
{
|
||||
@ -306,13 +274,13 @@ namespace APCViewer.Controllers
|
||||
return File(ipdsfFile, "text/plain", Path.GetFileName(ipdsfFile));
|
||||
}
|
||||
|
||||
public ContentResult ViewCustomIPDSF(string ipdsf_file = null)
|
||||
public ContentResult ViewCustomIPDSF(string? ipdsf_file = null)
|
||||
{
|
||||
StringBuilder result = GetIPDSFHtml(ipdsf_file);
|
||||
return Content(result.ToString(), "text/html");
|
||||
}
|
||||
|
||||
public ActionResult DownloadCustomIPDSF(string ipdsf_file = null)
|
||||
public ActionResult DownloadCustomIPDSF(string? ipdsf_file = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ipdsf_file))
|
||||
throw new Exception("Error: Invalid input");
|
||||
@ -329,24 +297,4 @@ namespace APCViewer.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
IActionResult IHomeController.Background(bool? message_clear, bool? exceptions_clear, bool? set_is_primary_instance, bool? logistics_clear) => throw new NotImplementedException();
|
||||
IActionResult IHomeController.DownloadCustomIPDSF(string ipdsf_file) => throw new NotImplementedException();
|
||||
IActionResult IHomeController.DownloadCustomPDSF(string pdsf_file) => throw new NotImplementedException();
|
||||
IActionResult IHomeController.DownloadIPDSF(string id) => throw new NotImplementedException();
|
||||
IActionResult IHomeController.DownloadPDSF(string id) => throw new NotImplementedException();
|
||||
IActionResult IHomeController.Encode(string value) => throw new NotImplementedException();
|
||||
IActionResult IHomeController.Error() => throw new NotImplementedException();
|
||||
IActionResult IHomeController.Index() => throw new NotImplementedException();
|
||||
IActionResult IHomeController.IPDSF(string directory, string filter, bool is_gaN, bool is_Si) => throw new NotImplementedException();
|
||||
IActionResult IHomeController.PDSF(string directory, string filter, bool is_gaN, bool is_Si) => throw new NotImplementedException();
|
||||
IActionResult IHomeController.Privacy() => throw new NotImplementedException();
|
||||
IActionResult IHomeController.TimePivot(bool is_gaN, bool is_Si) => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
// dotnet publish --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o "L:\net5.0\APCViewer"
|
||||
// dotnet publish --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o "D:\net5.0\APCViewer"
|
||||
// dotnet publish --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o "D:\.jenkins\publish\manual-Mesa-0\APCViewer"
|
||||
//http://mestsa005.infineon.com:8080/job/Mesa/buildWithParameters?token=DotnetRules&projectName=APC%20Viewer
|
||||
// http://mestsa02ec.ec.local:8080/job/Mesa/buildWithParameters?token=DotnetRules&projectName=APC%20Viewer
|
||||
//sc create APCViewer_5003 binPath="D:\.jenkins\publish\manual-Mesa-0\APCViewer\APC Viewer.exe"
|
@ -1,9 +0,0 @@
|
||||
// This file is used by Code Analysis to maintain SuppressMessage
|
||||
// attributes that are applied to this project.
|
||||
// Project-level suppressions either have no target or are given
|
||||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~M:APCViewer.Controllers.HomeController.GetPDSFHtml(System.String)~System.Text.StringBuilder")]
|
||||
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~M:APCViewer.Controllers.HomeController.GetIPDSFHtml(System.String)~System.Text.StringBuilder")]
|
@ -1,168 +1,168 @@
|
||||
using APCViewer.Singleton;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using APCViewer.Models.Methods;
|
||||
using APCViewer.Models.Stateless;
|
||||
using APCViewer.Models.Stateless.Methods;
|
||||
using APCViewer.Singleton;
|
||||
using IFX.Shared;
|
||||
using Serilog.Context;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace APCViewer.HostedService
|
||||
{
|
||||
|
||||
public class TimedHostedService : IHostedService, IDisposable
|
||||
namespace APCViewer.HostedService;
|
||||
|
||||
public class TimedHostedService : IHostedService
|
||||
{
|
||||
|
||||
private readonly Timer _APCDataTimer;
|
||||
private readonly Timer _EDADataTimer;
|
||||
private readonly Timer _EAFLogDataTimer;
|
||||
private readonly int _ExecutionCount;
|
||||
private readonly WebClient _WebClient;
|
||||
private readonly List<Timer> _Timers;
|
||||
private readonly Serilog.ILogger _Log;
|
||||
private readonly Background _Background;
|
||||
private readonly IConfiguration _Configuration;
|
||||
private readonly ILogger<TimedHostedService> _Log;
|
||||
private readonly IsEnvironment _IsEnvironment;
|
||||
private readonly IBackground _BackgroundMethods;
|
||||
|
||||
private Timer _APCDataTimer;
|
||||
private Timer _EDADataTimer;
|
||||
private Timer _EAFLogDataTimer;
|
||||
|
||||
public TimedHostedService(Background background, IConfiguration configuration, IServiceProvider serviceProvider)
|
||||
public TimedHostedService(IsEnvironment isEnvironment, Background background)
|
||||
{
|
||||
_Timers = new();
|
||||
_ExecutionCount = 0;
|
||||
_Background = background;
|
||||
_Configuration = configuration;
|
||||
_WebClient = serviceProvider.GetRequiredService<WebClient>();
|
||||
_Log = serviceProvider.GetRequiredService<ILogger<TimedHostedService>>();
|
||||
//_HttpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
|
||||
_WebClient = serviceProvider.GetRequiredService<WebClient>();
|
||||
_IsEnvironment = isEnvironment;
|
||||
_BackgroundMethods = background;
|
||||
_Log = Serilog.Log.ForContext<TimedHostedService>();
|
||||
_APCDataTimer = new Timer(APCDataCallback, null, Timeout.Infinite, Timeout.Infinite);
|
||||
_EAFLogDataTimer = new Timer(EAFLogDataCallback, null, Timeout.Infinite, Timeout.Infinite);
|
||||
_EDADataTimer = new Timer(EDADataCallback, null, Timeout.Infinite, Timeout.Infinite);
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
_Log.LogInformation(string.Concat("Timed Hosted Service: ", nameof(Background), ":", _Background.IsEnvironment.Profile, ":", Environment.ProcessId, " running."));
|
||||
_Background.Update(_Log, _WebClient);
|
||||
if (_Background.IsEnvironment.Development)
|
||||
string? methodName = IMethodName.GetActualAsyncMethodName();
|
||||
using (LogContext.PushProperty("MethodName", methodName))
|
||||
{
|
||||
_Log.Info(string.Concat("Timed Hosted Service: ", _IsEnvironment.Profile, ":", Environment.ProcessId, " running."));
|
||||
int milliSeconds = 3000;
|
||||
if (_IsEnvironment.Development)
|
||||
{
|
||||
if (milliSeconds == 0)
|
||||
{ }
|
||||
}
|
||||
else if (_Background.IsEnvironment.Staging)
|
||||
else if (_IsEnvironment.Staging)
|
||||
{
|
||||
int milliSeconds = 3000;
|
||||
_APCDataTimer = new Timer(APCDataCallback, null, milliSeconds, Timeout.Infinite);
|
||||
_Background.Timers.Add(_APCDataTimer);
|
||||
_ = _APCDataTimer.Change(milliSeconds, Timeout.Infinite);
|
||||
_Timers.Add(_APCDataTimer);
|
||||
milliSeconds += 2000;
|
||||
_EAFLogDataTimer = new Timer(EAFLogDataCallback, null, milliSeconds, Timeout.Infinite);
|
||||
_Background.Timers.Add(_EAFLogDataTimer);
|
||||
_ = _EAFLogDataTimer.Change(milliSeconds, Timeout.Infinite);
|
||||
_Timers.Add(_EAFLogDataTimer);
|
||||
milliSeconds += 2000;
|
||||
_EDADataTimer = new Timer(EDADataCallback, null, milliSeconds, Timeout.Infinite);
|
||||
_Background.Timers.Add(_EDADataTimer);
|
||||
_ = _EDADataTimer.Change(milliSeconds, Timeout.Infinite);
|
||||
_Timers.Add(_EDADataTimer);
|
||||
milliSeconds += 2000;
|
||||
}
|
||||
else if (_Background.IsEnvironment.Production)
|
||||
else if (_IsEnvironment.Production)
|
||||
{
|
||||
int milliSeconds = 3000;
|
||||
_APCDataTimer = new Timer(APCDataCallback, null, milliSeconds, Timeout.Infinite);
|
||||
_Background.Timers.Add(_APCDataTimer);
|
||||
_ = _APCDataTimer.Change(milliSeconds, Timeout.Infinite);
|
||||
_Timers.Add(_APCDataTimer);
|
||||
milliSeconds += 2000;
|
||||
_EAFLogDataTimer = new Timer(EAFLogDataCallback, null, milliSeconds, Timeout.Infinite);
|
||||
_Background.Timers.Add(_EAFLogDataTimer);
|
||||
_ = _EAFLogDataTimer.Change(milliSeconds, Timeout.Infinite);
|
||||
_Timers.Add(_EAFLogDataTimer);
|
||||
milliSeconds += 2000;
|
||||
_EDADataTimer = new Timer(EDADataCallback, null, milliSeconds, Timeout.Infinite);
|
||||
_Background.Timers.Add(_EDADataTimer);
|
||||
_ = _EDADataTimer.Change(milliSeconds, Timeout.Infinite);
|
||||
_Timers.Add(_EDADataTimer);
|
||||
milliSeconds += 2000;
|
||||
}
|
||||
else
|
||||
throw new Exception();
|
||||
if (_Background.IsEnvironment.Staging || _Background.IsEnvironment.Production)
|
||||
{
|
||||
string countDirectory = _Background.GetCountDirectory("Start");
|
||||
string checkDirectory = Path.GetPathRoot(countDirectory);
|
||||
if (Directory.Exists(checkDirectory))
|
||||
Directory.CreateDirectory(countDirectory);
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
_Log.LogInformation(string.Concat("Timed Hosted Service: ", nameof(Background), ":", _Background.IsEnvironment.Profile, ":", Environment.ProcessId, " is stopping."));
|
||||
_Background.Stop(immediate: true);
|
||||
string? methodName = IMethodName.GetActualAsyncMethodName();
|
||||
using (LogContext.PushProperty("MethodName", methodName))
|
||||
{
|
||||
_Log.Info(string.Concat("Timed Hosted Service: ", _IsEnvironment.Profile, ":", Environment.ProcessId, " is stopping."));
|
||||
_BackgroundMethods.Stop(immediate: true);
|
||||
for (short i = 0; i < short.MaxValue; i++)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
if (_ExecutionCount == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_Background.Dispose();
|
||||
}
|
||||
|
||||
private void APCDataCallback(object state)
|
||||
private void APCDataCallback(object? state)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_Background.IsPrimaryInstance())
|
||||
string? methodName = IMethodName.GetActualAsyncMethodName();
|
||||
using (LogContext.PushProperty("MethodName", methodName))
|
||||
{
|
||||
if (_BackgroundMethods.IsPrimaryInstance())
|
||||
_Background.APCDataCallback();
|
||||
}
|
||||
catch (Exception e) { _Background.Catch(e); }
|
||||
}
|
||||
catch (Exception e) { _Log.Error(e, "Error: "); }
|
||||
try
|
||||
{
|
||||
TimeSpan timeSpan;
|
||||
if (!_Background.IsPrimaryInstance())
|
||||
if (!_BackgroundMethods.IsPrimaryInstance())
|
||||
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks);
|
||||
else
|
||||
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks);
|
||||
_APCDataTimer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
_ = _APCDataTimer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
}
|
||||
catch (Exception e) { _Background.Catch(e); }
|
||||
catch (Exception e) { _Log.Error(e, "Error: "); }
|
||||
}
|
||||
|
||||
private void EDADataCallback(object state)
|
||||
private void EDADataCallback(object? state)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_Background.IsPrimaryInstance())
|
||||
string? methodName = IMethodName.GetActualAsyncMethodName();
|
||||
using (LogContext.PushProperty("MethodName", methodName))
|
||||
{
|
||||
if (_BackgroundMethods.IsPrimaryInstance())
|
||||
_Background.EDADataCallback();
|
||||
}
|
||||
catch (Exception e) { _Background.Catch(e); }
|
||||
}
|
||||
catch (Exception e) { _Log.Error(e, "Error: "); }
|
||||
try
|
||||
{
|
||||
TimeSpan timeSpan;
|
||||
if (!_Background.IsPrimaryInstance())
|
||||
if (!_BackgroundMethods.IsPrimaryInstance())
|
||||
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks);
|
||||
else
|
||||
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks);
|
||||
_EDADataTimer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
_ = _EDADataTimer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
}
|
||||
catch (Exception e) { _Background.Catch(e); }
|
||||
catch (Exception e) { _Log.Error(e, "Error: "); }
|
||||
}
|
||||
|
||||
private void EAFLogDataCallback(object state)
|
||||
private void EAFLogDataCallback(object? state)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_Background.IsPrimaryInstance())
|
||||
string? methodName = IMethodName.GetActualAsyncMethodName();
|
||||
using (LogContext.PushProperty("MethodName", methodName))
|
||||
{
|
||||
if (_BackgroundMethods.IsPrimaryInstance())
|
||||
_Background.EAFLogDataCallback();
|
||||
}
|
||||
catch (Exception e) { _Background.Catch(e); }
|
||||
}
|
||||
catch (Exception e) { _Log.Error(e, "Error: "); }
|
||||
try
|
||||
{
|
||||
TimeSpan timeSpan;
|
||||
if (!_Background.IsPrimaryInstance())
|
||||
if (!_BackgroundMethods.IsPrimaryInstance())
|
||||
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks);
|
||||
else
|
||||
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks);
|
||||
_EAFLogDataTimer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
_ = _EAFLogDataTimer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
}
|
||||
catch (Exception e) { _Background.Catch(e); }
|
||||
}
|
||||
|
||||
catch (Exception e) { _Log.Error(e, "Error: "); }
|
||||
}
|
||||
|
||||
}
|
167
APC Viewer/IFX/Shared/IsEnvironment.cs
Normal file
167
APC Viewer/IFX/Shared/IsEnvironment.cs
Normal file
@ -0,0 +1,167 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace IFX.Shared;
|
||||
|
||||
public class IsEnvironment
|
||||
{
|
||||
|
||||
public enum Name
|
||||
{
|
||||
LinuxDevelopment,
|
||||
LinuxProduction,
|
||||
LinuxStaging,
|
||||
OSXDevelopment,
|
||||
OSXProduction,
|
||||
OSXStaging,
|
||||
WindowsDevelopment,
|
||||
WindowsProduction,
|
||||
WindowsStaging
|
||||
}
|
||||
|
||||
public bool DebuggerWasAttachedDuringConstructor { get; private set; }
|
||||
public bool Development { get; private set; }
|
||||
public bool Linux { get; private set; }
|
||||
public bool OSX { get; private set; }
|
||||
public bool Production { get; private set; }
|
||||
public bool Staging { get; private set; }
|
||||
public bool Windows { get; private set; }
|
||||
public string Profile { get; private set; }
|
||||
public string AppSettingsFileName { get; private set; }
|
||||
public string? ASPNetCoreEnvironment { get; private set; }
|
||||
|
||||
public IsEnvironment(string testCategory)
|
||||
{
|
||||
if (testCategory.EndsWith(".json"))
|
||||
{
|
||||
Production = testCategory == "appsettings.json";
|
||||
Staging = testCategory.EndsWith(nameof(Staging));
|
||||
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
Development = testCategory.EndsWith(nameof(Development));
|
||||
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
|
||||
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
}
|
||||
else
|
||||
{
|
||||
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
|
||||
OSX = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(OSX));
|
||||
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
Linux = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Linux));
|
||||
Staging = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Staging));
|
||||
Windows = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Windows));
|
||||
Production = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Production));
|
||||
Development = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Development));
|
||||
}
|
||||
Profile = GetProfile();
|
||||
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
|
||||
}
|
||||
|
||||
public IsEnvironment(bool isDevelopment, bool isStaging, bool isProduction)
|
||||
{
|
||||
Staging = isStaging;
|
||||
Production = isProduction;
|
||||
Development = isDevelopment;
|
||||
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
|
||||
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
Profile = GetProfile();
|
||||
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
|
||||
}
|
||||
|
||||
public IsEnvironment(int? processesCount, bool nullASPNetCoreEnvironmentIsDevelopment, bool nullASPNetCoreEnvironmentIsProduction)
|
||||
{
|
||||
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
|
||||
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
if (nullASPNetCoreEnvironmentIsDevelopment && nullASPNetCoreEnvironmentIsProduction)
|
||||
throw new Exception();
|
||||
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsProduction)
|
||||
Production = true;
|
||||
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsDevelopment)
|
||||
Development = true;
|
||||
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && !nullASPNetCoreEnvironmentIsDevelopment && !nullASPNetCoreEnvironmentIsProduction)
|
||||
throw new Exception();
|
||||
else
|
||||
{
|
||||
Staging = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Staging));
|
||||
Production = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Production));
|
||||
Development = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Development));
|
||||
}
|
||||
Profile = GetProfile();
|
||||
AppSettingsFileName = GetAppSettingsFileName(processesCount);
|
||||
}
|
||||
|
||||
private string GetProfile()
|
||||
{
|
||||
string result;
|
||||
if (Windows && Production)
|
||||
result = nameof(Production);
|
||||
else if (Windows && Staging)
|
||||
result = nameof(Staging);
|
||||
else if (Windows && Development)
|
||||
result = nameof(Development);
|
||||
else if (Linux && Production)
|
||||
result = nameof(Name.LinuxProduction);
|
||||
else if (Linux && Staging)
|
||||
result = nameof(Name.LinuxStaging);
|
||||
else if (Linux && Development)
|
||||
result = nameof(Name.LinuxDevelopment);
|
||||
else if (OSX && Production)
|
||||
result = nameof(Name.OSXProduction);
|
||||
else if (OSX && Staging)
|
||||
result = nameof(Name.OSXStaging);
|
||||
else if (OSX && Development)
|
||||
result = nameof(Name.OSXDevelopment);
|
||||
else
|
||||
throw new Exception();
|
||||
return result;
|
||||
}
|
||||
|
||||
private string GetAppSettingsFileName(int? processesCount)
|
||||
{
|
||||
string result;
|
||||
if (Production)
|
||||
{
|
||||
if (processesCount is null)
|
||||
result = "appsettings.json";
|
||||
else
|
||||
result = $"appsettings.{processesCount}.json";
|
||||
}
|
||||
else
|
||||
{
|
||||
string environment;
|
||||
if (Staging)
|
||||
environment = nameof(Staging);
|
||||
else if (Development)
|
||||
environment = nameof(Development);
|
||||
else
|
||||
throw new Exception();
|
||||
if (processesCount is null)
|
||||
result = $"appsettings.{environment}.json";
|
||||
else
|
||||
result = $"appsettings.{environment}.{processesCount}.json";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string GetEnvironmentName(IsEnvironment isEnvironment)
|
||||
{
|
||||
string result;
|
||||
if (isEnvironment.Windows)
|
||||
result = nameof(IsEnvironment.Windows);
|
||||
else if (isEnvironment.Linux)
|
||||
result = nameof(IsEnvironment.Linux);
|
||||
else if (isEnvironment.OSX)
|
||||
result = nameof(IsEnvironment.OSX);
|
||||
else
|
||||
throw new Exception();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
93
APC Viewer/IFX/Shared/RijndaelEncryption.cs
Normal file
93
APC Viewer/IFX/Shared/RijndaelEncryption.cs
Normal file
@ -0,0 +1,93 @@
|
||||
#pragma warning disable SYSLIB0022
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace IFX.Shared;
|
||||
|
||||
public static class RijndaelEncryption
|
||||
{
|
||||
/// <summary>
|
||||
/// Change the Inputkey GUID when you use this code in your own program.
|
||||
/// Keep this inputkey very safe and prevent someone from decoding it some way!!
|
||||
/// Generated 2021-08-10
|
||||
/// </summary>
|
||||
internal const string _Inputkey = "970CCEF6-4307-4F6A-9AC8-377DADB889BD";
|
||||
|
||||
/// <summary>
|
||||
/// Encrypt the given text and give the byte array back as a BASE64 string
|
||||
/// </summary>
|
||||
/// <param name="text">The text to encrypt</param>
|
||||
/// <param name="salt">The pasword salt</param>
|
||||
/// <returns>The encrypted text</returns>
|
||||
public static string Encrypt(string text, string salt)
|
||||
{
|
||||
string result;
|
||||
if (string.IsNullOrEmpty(text))
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
RijndaelManaged aesAlg = NewRijndaelManaged(salt);
|
||||
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
|
||||
MemoryStream msEncrypt = new();
|
||||
using (CryptoStream csEncrypt = new(msEncrypt, encryptor, CryptoStreamMode.Write))
|
||||
using (StreamWriter swEncrypt = new(csEncrypt))
|
||||
swEncrypt.Write(text);
|
||||
result = Convert.ToBase64String(msEncrypt.ToArray());
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a string is base64 encoded
|
||||
/// </summary>
|
||||
/// <param name="base64String">The base64 encoded string</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsBase64String(string base64String)
|
||||
{
|
||||
bool result;
|
||||
base64String = base64String.Trim();
|
||||
result = (base64String.Length % 4 == 0) && Regex.IsMatch(base64String, @"^[a-zA-Z0-9\+/]*={0,3}$", RegexOptions.None);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decrypts the given text
|
||||
/// </summary>
|
||||
/// <param name="cipherText">The encrypted BASE64 text</param>
|
||||
/// <param name="salt">The pasword salt</param>
|
||||
/// <returns>De gedecrypte text</returns>
|
||||
public static string Decrypt(string cipherText, string salt)
|
||||
{
|
||||
if (string.IsNullOrEmpty(cipherText))
|
||||
throw new ArgumentNullException(nameof(cipherText));
|
||||
if (!IsBase64String(cipherText))
|
||||
throw new Exception("The cipherText input parameter is not base64 encoded");
|
||||
string text;
|
||||
RijndaelManaged aesAlg = NewRijndaelManaged(salt);
|
||||
ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
|
||||
byte[] cipher = Convert.FromBase64String(cipherText);
|
||||
using (MemoryStream msDecrypt = new(cipher))
|
||||
{
|
||||
using CryptoStream csDecrypt = new(msDecrypt, decryptor, CryptoStreamMode.Read);
|
||||
using StreamReader srDecrypt = new(csDecrypt);
|
||||
text = srDecrypt.ReadToEnd();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new RijndaelManaged class and initialize it
|
||||
/// </summary>
|
||||
/// <param name="salt">The pasword salt</param>
|
||||
/// <returns></returns>
|
||||
private static RijndaelManaged NewRijndaelManaged(string salt)
|
||||
{
|
||||
if (salt == null)
|
||||
throw new ArgumentNullException(nameof(salt));
|
||||
byte[] saltBytes = Encoding.ASCII.GetBytes(salt);
|
||||
Rfc2898DeriveBytes key = new(_Inputkey, saltBytes);
|
||||
RijndaelManaged aesAlg = new();
|
||||
aesAlg.Key = key.GetBytes(aesAlg.KeySize / 8);
|
||||
aesAlg.IV = key.GetBytes(aesAlg.BlockSize / 8);
|
||||
return aesAlg;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.Core
|
||||
{
|
||||
namespace Library.Eaf.Core;
|
||||
|
||||
public class BackboneComponent
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.Core
|
||||
{
|
||||
namespace Library.Eaf.Core;
|
||||
|
||||
public class BackboneStatusCache
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.Core
|
||||
{
|
||||
namespace Library.Eaf.Core;
|
||||
|
||||
public interface ILoggingSetupManager
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.Core
|
||||
{
|
||||
namespace Library.Eaf.Core;
|
||||
|
||||
public class StatusItem
|
||||
{
|
||||
}
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Library.Eaf.Core
|
||||
{
|
||||
namespace Library.Eaf.Core;
|
||||
|
||||
public class Backbone
|
||||
{
|
||||
public const string STATE_ERROR = "Error";
|
||||
@ -30,12 +30,12 @@ namespace Library.Eaf.Core
|
||||
protected Dictionary<string, BackboneComponent> BackboneComponents { get; }
|
||||
|
||||
public void AddBackboneComponent(BackboneComponent backboneComponent) { }
|
||||
public bool ContainsBackboneComponent(string id) { throw new NotImplementedException(); }
|
||||
public bool ContainsBackboneComponent(string id) => throw new NotImplementedException();
|
||||
[Obsolete("Use the capabilities exposed via the Status property -> GetAll. Will be removed with next major release.")]
|
||||
public List<StatusItem> GetAllStatuses() { throw new NotImplementedException(); }
|
||||
public BackboneComponent GetBackboneComponentById(string id) { throw new NotImplementedException(); }
|
||||
public List<T> GetBackboneComponentsOfType<T>() { throw new NotImplementedException(); }
|
||||
public List<BackboneComponent> GetBackboneComponentsOfType(Type type) { throw new NotImplementedException(); }
|
||||
public List<StatusItem> GetAllStatuses() => throw new NotImplementedException();
|
||||
public BackboneComponent GetBackboneComponentById(string id) => throw new NotImplementedException();
|
||||
public List<T> GetBackboneComponentsOfType<T>() => throw new NotImplementedException();
|
||||
public List<BackboneComponent> GetBackboneComponentsOfType(Type type) => throw new NotImplementedException();
|
||||
public void RegisterSubprocess(int pid) { }
|
||||
[Obsolete("Use the capabilities exposed via the Status property -> SetValue. Will be removed with next major release.")]
|
||||
public void SetStatus(string statusName, string statusValue) { }
|
||||
@ -45,4 +45,3 @@ namespace Library.Eaf.Core
|
||||
protected virtual void StopAllComponents() { }
|
||||
protected void StopComponents(List<BackboneComponent> components) { }
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Library.Eaf.Core.Smtp
|
||||
{
|
||||
namespace Library.Eaf.Core.Smtp;
|
||||
|
||||
public class EmailMessage
|
||||
{
|
||||
@ -12,13 +11,11 @@ namespace Library.Eaf.Core.Smtp
|
||||
public MailPriority Priority { get; }
|
||||
public string Subject { get; }
|
||||
|
||||
public EmailMessage PriorityHigh() { throw new NotImplementedException(); }
|
||||
public EmailMessage PriorityLow() { throw new NotImplementedException(); }
|
||||
public EmailMessage PriorityNormal() { throw new NotImplementedException(); }
|
||||
public EmailMessage SetBody(string body) { throw new NotImplementedException(); }
|
||||
public EmailMessage SetPriority(MailPriority priority) { throw new NotImplementedException(); }
|
||||
public EmailMessage SetSubject(string subject) { throw new NotImplementedException(); }
|
||||
|
||||
}
|
||||
public EmailMessage PriorityHigh() => throw new NotImplementedException();
|
||||
public EmailMessage PriorityLow() => throw new NotImplementedException();
|
||||
public EmailMessage PriorityNormal() => throw new NotImplementedException();
|
||||
public EmailMessage SetBody(string body) => throw new NotImplementedException();
|
||||
public EmailMessage SetPriority(MailPriority priority) => throw new NotImplementedException();
|
||||
public EmailMessage SetSubject(string subject) => throw new NotImplementedException();
|
||||
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
namespace Library.Eaf.Core.Smtp
|
||||
{
|
||||
namespace Library.Eaf.Core.Smtp;
|
||||
|
||||
public interface ISmtp
|
||||
{
|
||||
void Send(EmailMessage message);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Library.Eaf.Core.Smtp
|
||||
{
|
||||
namespace Library.Eaf.Core.Smtp;
|
||||
|
||||
public enum MailPriority
|
||||
{
|
||||
@ -7,5 +6,3 @@
|
||||
Normal = 1,
|
||||
High = 2
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public class ChangeDataCollectionHandler
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public class DataCollectionRequest
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public class EquipmentEvent
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public class EquipmentException
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public class EquipmentSelfDescription
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public class GetParameterValuesHandler
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface IConnectionControl
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface IDataTracingHandler
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface IEquipmentCommandService
|
||||
{
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using Library.PeerGroup.GCL.Annotations;
|
||||
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface IEquipmentControl : IPackageSource
|
||||
{
|
||||
[NotNull]
|
||||
@ -13,4 +13,3 @@ namespace Library.Eaf.EquipmentCore.Control
|
||||
[NotNull]
|
||||
IConnectionControl Connection { get; }
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface IEquipmentSelfDescriptionBuilder
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface IPackage
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface ISelfDescriptionLookup
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface IVirtualParameterValuesHandler
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public class SetParameterValuesHandler
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public class TraceRequest
|
||||
{
|
||||
}
|
||||
}
|
@ -3,8 +3,8 @@ using Library.Eaf.EquipmentCore.SelfDescription.ElementDescription;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface IEquipmentDataCollection
|
||||
{
|
||||
IVirtualParameterValuesHandler VirtualParameterValuesHandler { get; }
|
||||
@ -36,4 +36,3 @@ namespace Library.Eaf.EquipmentCore.Control
|
||||
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
|
||||
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, DateTime equipmentTimeStamp);
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.Control
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.Control;
|
||||
|
||||
public interface IPackageSource
|
||||
{
|
||||
}
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
using Library.PeerGroup.GCL.Annotations;
|
||||
using System;
|
||||
|
||||
namespace Library.Eaf.EquipmentCore.DataCollection.Reporting
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.DataCollection.Reporting;
|
||||
|
||||
public class ParameterValue
|
||||
{
|
||||
public ParameterValue(EquipmentParameter definition, object value) { }
|
||||
@ -14,7 +14,6 @@ namespace Library.Eaf.EquipmentCore.DataCollection.Reporting
|
||||
public EquipmentParameter Definition { get; }
|
||||
public DateTime Timestamp { get; protected set; }
|
||||
|
||||
public virtual ParameterValue Clone(EquipmentParameter newDefinition) { throw new NotImplementedException(); }
|
||||
public override string ToString() { return base.ToString(); }
|
||||
}
|
||||
public virtual ParameterValue Clone(EquipmentParameter newDefinition) => throw new NotImplementedException();
|
||||
public override string ToString() => base.ToString();
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
|
||||
|
||||
namespace Library.Eaf.EquipmentCore.SelfDescription.ElementDescription
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.SelfDescription.ElementDescription;
|
||||
|
||||
public class EquipmentParameter
|
||||
{
|
||||
public EquipmentParameter(EquipmentParameter source, ParameterTypeDefinition typeDefinition) { }
|
||||
@ -17,8 +17,6 @@ namespace Library.Eaf.EquipmentCore.SelfDescription.ElementDescription
|
||||
public bool IsTransient { get; }
|
||||
public bool IsReadOnly { get; }
|
||||
|
||||
public override string ToString() { return base.ToString(); }
|
||||
public string ToStringWithDetails() { return base.ToString(); }
|
||||
}
|
||||
|
||||
public override string ToString() => base.ToString();
|
||||
public string ToStringWithDetails() => base.ToString();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
|
||||
|
||||
public class Field
|
||||
{
|
||||
public Field(string name, string description, bool canBeNull, ParameterTypeDefinition typeDefinition) { }
|
||||
@ -9,4 +9,3 @@
|
||||
public ParameterTypeDefinition TypeDefinition { get; }
|
||||
public bool CanBeNull { get; }
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
|
||||
|
||||
public abstract class ParameterTypeDefinition
|
||||
{
|
||||
public ParameterTypeDefinition(string name, string description) { }
|
||||
@ -7,6 +7,5 @@
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
|
||||
public override string ToString() { return base.ToString(); }
|
||||
}
|
||||
public override string ToString() => base.ToString();
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes
|
||||
{
|
||||
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
|
||||
|
||||
public class StructuredType : ParameterTypeDefinition
|
||||
{
|
||||
|
||||
@ -9,4 +9,3 @@ namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes
|
||||
|
||||
public IList<Field> Fields { get; }
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
namespace Library.Eaf.Management.ConfigurationData.CellAutomation
|
||||
{
|
||||
namespace Library.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
|
||||
public interface IConfigurationObject
|
||||
{
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Library.Eaf.Management.ConfigurationData.CellAutomation
|
||||
{
|
||||
namespace Library.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
|
||||
[System.Runtime.Serialization.DataContractAttribute(IsReference = true)]
|
||||
public class ModelObjectParameterDefinition : IConfigurationObject
|
||||
{
|
||||
@ -20,7 +20,6 @@ namespace Library.Eaf.Management.ConfigurationData.CellAutomation
|
||||
[System.Runtime.Serialization.DataMemberAttribute]
|
||||
public virtual string EnumType { get; set; }
|
||||
|
||||
public virtual ModelObjectParameterDefinition Clone() { return null; }
|
||||
public virtual bool IsValidValue(string value) { return false; }
|
||||
}
|
||||
public virtual ModelObjectParameterDefinition? Clone() => null;
|
||||
public virtual bool IsValidValue(string value) => false;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
namespace Library.Eaf.Management.ConfigurationData.CellAutomation
|
||||
{
|
||||
namespace Library.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
|
||||
public enum ModelObjectParameterType
|
||||
{
|
||||
String = 0,
|
||||
@ -14,4 +14,3 @@
|
||||
Float = 9,
|
||||
Enum = 10
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
using Library.PeerGroup.GCL.SecsDriver;
|
||||
using System;
|
||||
|
||||
namespace Library.Eaf.Management.ConfigurationData.Semiconductor.CellInstances
|
||||
{
|
||||
namespace Library.Eaf.Management.ConfigurationData.Semiconductor.CellInstances;
|
||||
|
||||
[System.Runtime.Serialization.DataContractAttribute]
|
||||
public class SecsConnectionConfiguration
|
||||
{
|
||||
@ -41,4 +41,3 @@ namespace Library.Eaf.Management.ConfigurationData.Semiconductor.CellInstances
|
||||
[System.Runtime.Serialization.DataMemberAttribute]
|
||||
public virtual TimeSpan T8NetworkIntercharacter { get; set; }
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
namespace Library.Ifx.Eaf.Common.Configuration
|
||||
{
|
||||
namespace Library.Ifx.Eaf.Common.Configuration;
|
||||
|
||||
[System.Runtime.Serialization.DataContractAttribute]
|
||||
public class ConnectionSetting
|
||||
{
|
||||
@ -10,4 +10,3 @@
|
||||
[System.Runtime.Serialization.DataMemberAttribute]
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
@ -1,19 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Library.Ifx.Eaf.EquipmentConnector.File.Component
|
||||
{
|
||||
namespace Library.Ifx.Eaf.EquipmentConnector.File.Component;
|
||||
|
||||
public class File
|
||||
{
|
||||
public File(string filePath) { throw new NotImplementedException(); }
|
||||
public File(string filePath, DateTime timeFileFound) { throw new NotImplementedException(); }
|
||||
public File(string filePath) => throw new NotImplementedException();
|
||||
public File(string filePath, DateTime timeFileFound) => throw new NotImplementedException();
|
||||
|
||||
public string Path { get; }
|
||||
public DateTime TimeFound { get; }
|
||||
public bool IsErrorFile { get; }
|
||||
public Dictionary<string, string> ContentParameters { get; }
|
||||
|
||||
public File UpdateContentParameters(Dictionary<string, string> contentParameters) { throw new NotImplementedException(); }
|
||||
public File UpdateParsingStatus(bool isErrorFile) { throw new NotImplementedException(); }
|
||||
}
|
||||
public File UpdateContentParameters(Dictionary<string, string> contentParameters) => throw new NotImplementedException();
|
||||
public File UpdateParsingStatus(bool isErrorFile) => throw new NotImplementedException();
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Library.Ifx.Eaf.EquipmentConnector.File.Component
|
||||
{
|
||||
namespace Library.Ifx.Eaf.EquipmentConnector.File.Component;
|
||||
|
||||
public class FilePathGenerator
|
||||
{
|
||||
public const char PLACEHOLDER_IDENTIFIER = '%';
|
||||
@ -15,9 +15,9 @@ namespace Library.Ifx.Eaf.EquipmentConnector.File.Component
|
||||
public const string PLACEHOLDER_SUB_FOLDER = "SubFolder";
|
||||
public const string PLACEHOLDER_CELL_NAME = "CellName";
|
||||
|
||||
public FilePathGenerator(FileConnectorConfiguration config, Dictionary<string, string> customPattern = null) { throw new NotImplementedException(); }
|
||||
public FilePathGenerator(FileConnectorConfiguration config, File file, bool isErrorFile = false, Dictionary<string, string> customPattern = null) { throw new NotImplementedException(); }
|
||||
public FilePathGenerator(FileConnectorConfiguration config, string sourceFilePath, bool isErrorFile = false, Dictionary<string, string> customPattern = null) { throw new NotImplementedException(); }
|
||||
public FilePathGenerator(FileConnectorConfiguration config, Dictionary<string, string>? customPattern = null) => throw new NotImplementedException();
|
||||
public FilePathGenerator(FileConnectorConfiguration config, File file, bool isErrorFile = false, Dictionary<string, string>? customPattern = null) => throw new NotImplementedException();
|
||||
public FilePathGenerator(FileConnectorConfiguration config, string sourceFilePath, bool isErrorFile = false, Dictionary<string, string>? customPattern = null) => throw new NotImplementedException();
|
||||
|
||||
protected string SubFolderPath { get; }
|
||||
protected FileConnectorConfiguration Configuration { get; }
|
||||
@ -25,11 +25,10 @@ namespace Library.Ifx.Eaf.EquipmentConnector.File.Component
|
||||
protected bool IsErrorFile { get; }
|
||||
protected string DefaultPlaceHolderValue { get; }
|
||||
|
||||
public string GetFullTargetPath() { throw new NotImplementedException(); }
|
||||
public virtual string GetTargetFileName() { throw new NotImplementedException(); }
|
||||
public string GetTargetFolder(bool throwExceptionIfNotExist = true) { throw new NotImplementedException(); }
|
||||
protected virtual string GetSubFolder(string folderPattern, string subFolderPath) { throw new NotImplementedException(); }
|
||||
protected virtual string PrepareFolderPath(string targetFolderPath, string subFolderPath) { throw new NotImplementedException(); }
|
||||
protected string ReplacePlaceholder(string inputPath) { throw new NotImplementedException(); }
|
||||
}
|
||||
public string GetFullTargetPath() => throw new NotImplementedException();
|
||||
public virtual string GetTargetFileName() => throw new NotImplementedException();
|
||||
public string GetTargetFolder(bool throwExceptionIfNotExist = true) => throw new NotImplementedException();
|
||||
protected virtual string GetSubFolder(string folderPattern, string subFolderPath) => throw new NotImplementedException();
|
||||
protected virtual string PrepareFolderPath(string targetFolderPath, string subFolderPath) => throw new NotImplementedException();
|
||||
protected string ReplacePlaceholder(string inputPath) => throw new NotImplementedException();
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Library.Ifx.Eaf.EquipmentConnector.File.Configuration
|
||||
{
|
||||
namespace Library.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
|
||||
[System.Runtime.Serialization.DataContractAttribute]
|
||||
public class FileConnectorConfiguration
|
||||
{
|
||||
@ -85,7 +85,7 @@ namespace Library.Ifx.Eaf.EquipmentConnector.File.Configuration
|
||||
[System.Runtime.Serialization.DataMemberAttribute]
|
||||
public string ErrorTargetFileName { get; set; }
|
||||
|
||||
public void Initialize() { throw new NotImplementedException(); }
|
||||
public void Initialize() => throw new NotImplementedException();
|
||||
|
||||
public enum PostProcessingModeEnum
|
||||
{
|
||||
@ -132,4 +132,3 @@ namespace Library.Ifx.Eaf.EquipmentConnector.File.Configuration
|
||||
IgnoreOlder = 1
|
||||
}
|
||||
}
|
||||
}
|
@ -2,13 +2,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Library.Ifx.Eaf.EquipmentConnector.File.SelfDescription
|
||||
{
|
||||
namespace Library.Ifx.Eaf.EquipmentConnector.File.SelfDescription;
|
||||
|
||||
public class FileConnectorParameterTypeDefinitionProvider
|
||||
{
|
||||
public FileConnectorParameterTypeDefinitionProvider() { }
|
||||
|
||||
public IEnumerable<ParameterTypeDefinition> GetAllParameterTypeDefinition() { return null; }
|
||||
public ParameterTypeDefinition GetParameterTypeDefinition(string name) { return null; }
|
||||
}
|
||||
public IEnumerable<ParameterTypeDefinition>? GetAllParameterTypeDefinition() => null;
|
||||
public ParameterTypeDefinition? GetParameterTypeDefinition(string name) => null;
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Library.PeerGroup.GCL.Annotations
|
||||
{
|
||||
namespace Library.PeerGroup.GCL.Annotations;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.Delegate, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class NotNullAttribute : Attribute
|
||||
{
|
||||
public NotNullAttribute() { }
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
namespace Library.PeerGroup.GCL.SecsDriver
|
||||
{
|
||||
namespace Library.PeerGroup.GCL.SecsDriver;
|
||||
|
||||
public enum HsmsConnectionMode
|
||||
{
|
||||
Active = 0,
|
||||
Passive = 1
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
namespace Library.PeerGroup.GCL.SecsDriver
|
||||
{
|
||||
namespace Library.PeerGroup.GCL.SecsDriver;
|
||||
|
||||
public enum HsmsSessionMode
|
||||
{
|
||||
MultiSession = 0,
|
||||
SingleSession = 1
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
namespace Library.PeerGroup.GCL.SecsDriver
|
||||
{
|
||||
namespace Library.PeerGroup.GCL.SecsDriver;
|
||||
|
||||
public enum SecsTransportType
|
||||
{
|
||||
HSMS = 0,
|
||||
Serial = 1
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
namespace Library.PeerGroup.GCL.SecsDriver
|
||||
{
|
||||
namespace Library.PeerGroup.GCL.SecsDriver;
|
||||
|
||||
public enum SerialBaudRate
|
||||
{
|
||||
Baud9600 = 0,
|
||||
@ -13,4 +13,3 @@
|
||||
Baud57600 = 8,
|
||||
Baud115200 = 9
|
||||
}
|
||||
}
|
@ -1,12 +1,46 @@
|
||||
namespace APCViewer.Models
|
||||
{
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace APCViewer.Models;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
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; }
|
||||
|
||||
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)
|
||||
{
|
||||
_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;
|
||||
}
|
||||
|
||||
}
|
34
APC Viewer/Models/Binder/AppSettings.cs
Normal file
34
APC Viewer/Models/Binder/AppSettings.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
namespace APCViewer.Models
|
||||
{
|
||||
namespace APCViewer.Models;
|
||||
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string RequestId { get; set; }
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
@ -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);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace APCViewer.Models
|
||||
{
|
||||
namespace APCViewer.Controllers;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
ActionResult Encode(string value = "");
|
||||
ActionResult Error();
|
||||
ActionResult Index();
|
||||
ActionResult Privacy();
|
||||
}
|
19
APC Viewer/Models/Methods/IBackground.cs
Normal file
19
APC Viewer/Models/Methods/IBackground.cs
Normal 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);
|
||||
|
||||
}
|
6
APC Viewer/Models/Properties/IBackground.cs
Normal file
6
APC Viewer/Models/Properties/IBackground.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace APCViewer.Models.Properties;
|
||||
|
||||
public interface IBackground
|
||||
{
|
||||
|
||||
}
|
10
APC Viewer/Models/Properties/IBackgroundPage.cs
Normal file
10
APC Viewer/Models/Properties/IBackgroundPage.cs
Normal 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; }
|
||||
|
||||
}
|
24
APC Viewer/Models/Stateless/AppSettings.cs
Normal file
24
APC Viewer/Models/Stateless/AppSettings.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
12
APC Viewer/Models/Stateless/Methods/IBackgroundController.cs
Normal file
12
APC Viewer/Models/Stateless/Methods/IBackgroundController.cs
Normal 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..];
|
||||
|
||||
}
|
10
APC Viewer/Models/Stateless/Methods/IMethodName.cs
Normal file
10
APC Viewer/Models/Stateless/Methods/IMethodName.cs
Normal 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;
|
||||
|
||||
}
|
8
APC Viewer/Models/Stateless/Methods/IWorkingDirectory.cs
Normal file
8
APC Viewer/Models/Stateless/Methods/IWorkingDirectory.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace APCViewer.Models.Stateless.Methods;
|
||||
|
||||
public interface IWorkingDirectory
|
||||
{
|
||||
|
||||
static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName) => WorkingDirectory.GetWorkingDirectory(executingAssemblyName, subDirectoryName);
|
||||
|
||||
}
|
50
APC Viewer/Models/Stateless/Methods/WorkingDirectory.cs
Normal file
50
APC Viewer/Models/Stateless/Methods/WorkingDirectory.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
10
APC Viewer/Models/Stateless/SerilogExtensionMethods.cs
Normal file
10
APC Viewer/Models/Stateless/SerilogExtensionMethods.cs
Normal 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);
|
||||
|
||||
}
|
@ -1,40 +1,90 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Shared;
|
||||
using System.Diagnostics;
|
||||
using APCViewer.HostedService;
|
||||
using APCViewer.Models;
|
||||
using APCViewer.Models.Stateless.Methods;
|
||||
using IFX.Shared;
|
||||
using Serilog;
|
||||
using System.Reflection;
|
||||
|
||||
namespace APCViewer
|
||||
{
|
||||
namespace APCViewer;
|
||||
|
||||
public class Program
|
||||
{
|
||||
|
||||
public static void Main(string[] args)
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
LoggerConfiguration loggerConfiguration = new();
|
||||
// ConsoleLoggerConfigurationExtensions.Console(loggerConfiguration.WriteTo);
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
string? assemblyName = assembly.GetName()?.Name;
|
||||
if (string.IsNullOrEmpty(assemblyName))
|
||||
throw new Exception();
|
||||
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
|
||||
AppSettings appSettings = Models.Stateless.AppSettings.Get(webApplicationBuilder.Configuration);
|
||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||
throw new Exception("Working directory name must have a value!");
|
||||
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assemblyName, appSettings.WorkingDirectoryName);
|
||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, webApplicationBuilder.Configuration);
|
||||
_ = SerilogHostBuilderExtensions.UseSerilog(webApplicationBuilder.Host);
|
||||
Log.Logger = loggerConfiguration.CreateLogger();
|
||||
Serilog.ILogger log = Log.ForContext<Program>();
|
||||
try
|
||||
{
|
||||
IsEnvironment isEnvironment = new(webApplicationBuilder.Environment.IsDevelopment(), webApplicationBuilder.Environment.IsStaging(), webApplicationBuilder.Environment.IsProduction());
|
||||
Singleton.Background background = new(isEnvironment, appSettings, workingDirectory);
|
||||
if (isEnvironment.Development && !string.IsNullOrEmpty("storage.UrlRoot"))
|
||||
throw new Exception();
|
||||
_ = webApplicationBuilder.Services.AddControllersWithViews();
|
||||
// _ = webApplicationBuilder.Services.AddRazorPages(configure => configure.Conventions.AuthorizeFolder("/Admin").AddPageRoute("/index", "{*url}"));
|
||||
_ = webApplicationBuilder.Services.AddRazorPages();
|
||||
_ = webApplicationBuilder.Services.AddSingleton<AppSettings, AppSettings>(_ => appSettings);
|
||||
_ = webApplicationBuilder.Services.AddSingleton<IsEnvironment, IsEnvironment>(_ => isEnvironment);
|
||||
_ = webApplicationBuilder.Services.AddSingleton<Singleton.Background, Singleton.Background>(_ => background);
|
||||
_ = webApplicationBuilder.Services.AddHostedService(t => new TimedHostedService(isEnvironment, background));
|
||||
_ = webApplicationBuilder.Services.AddSwaggerGen();
|
||||
WebApplication webApplication = webApplicationBuilder.Build();
|
||||
if (isEnvironment.Development)
|
||||
{
|
||||
webApplication.UseWebAssemblyDebugging();
|
||||
if (!string.IsNullOrEmpty("storage.UrlRoot"))
|
||||
{
|
||||
Environment.ExitCode = -1;
|
||||
webApplication.Lifetime.StopApplication();
|
||||
}
|
||||
_ = webApplication.UseSwagger();
|
||||
_ = webApplication.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "APC Viewer API V1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = webApplication.UseExceptionHandler("/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
_ = webApplication.UseHsts();
|
||||
}
|
||||
_ = webApplication.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush);
|
||||
_ = ApplicationBuilderSerilogClientExtensions.UseSerilogIngestion(webApplication);
|
||||
_ = SerilogApplicationBuilderExtensions.UseSerilogRequestLogging(webApplication);
|
||||
_ = webApplication.UseDeveloperExceptionPage();
|
||||
_ = webApplication.UseHttpsRedirection();
|
||||
_ = webApplication.UseBlazorFrameworkFiles();
|
||||
_ = webApplication.UseStaticFiles();
|
||||
_ = webApplication.UseRouting();
|
||||
_ = webApplication.MapRazorPages();
|
||||
_ = webApplication.MapControllers();
|
||||
_ = webApplication.MapFallbackToFile("index.html");
|
||||
log.Information("Starting Web Application");
|
||||
webApplication.Run();
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args)
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
IHostBuilder result;
|
||||
IsEnvironment isEnvironment = new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached);
|
||||
result = Host.CreateDefaultBuilder(args)
|
||||
.UseWindowsService()
|
||||
.ConfigureAppConfiguration((context, configuration) =>
|
||||
log.Fatal(ex, "Host terminated unexpectedly");
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
configuration
|
||||
.AddEnvironmentVariables()
|
||||
.AddCommandLine(args)
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
||||
})
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,8 +10,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
namespace Shared;
|
||||
|
||||
public class Description
|
||||
{
|
||||
@ -46,7 +45,6 @@ namespace Shared
|
||||
|
||||
internal const string FileFound = "FileFound";
|
||||
|
||||
|
||||
public List<EquipmentParameter> EquipmentParameters { get; private set; }
|
||||
public List<ParameterTypeDefinition> ParameterTypeDefinitions { get; private set; }
|
||||
|
||||
@ -71,7 +69,7 @@ namespace Shared
|
||||
|
||||
private List<ParameterValue> GetParameterValues(IEquipmentControl equipmentControl, Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairsCollection)
|
||||
{
|
||||
List<ParameterValue> results = new List<ParameterValue>();
|
||||
List<ParameterValue> results = new();
|
||||
Enum param;
|
||||
object value;
|
||||
Enum[] @params;
|
||||
@ -112,7 +110,7 @@ namespace Shared
|
||||
list.Add(new object[] { i, keyValuePair.Value[i].Item4 });
|
||||
value = list;
|
||||
}
|
||||
if (equipmentControl is null || !(param is Param.StructuredType))
|
||||
if (equipmentControl is null || param is not Param.StructuredType)
|
||||
results.Add(new ParameterValue(equipmentParameter, value, DateTime.Now));
|
||||
else
|
||||
results.Add(equipmentControl.DataCollection.CreateParameterValue(equipmentParameter, value));
|
||||
@ -120,9 +118,9 @@ namespace Shared
|
||||
return results;
|
||||
}
|
||||
|
||||
public List<ParameterValue> GetParameterValues(ILogic logic, IEquipmentControl equipmentControl, JsonElement jsonElement, int? i = null, Dictionary<string, object> keyValuePairs = null)
|
||||
public List<ParameterValue> GetParameterValues(ILogic logic, IEquipmentControl equipmentControl, JsonElement jsonElement, int? i = null, Dictionary<string, object>? keyValuePairs = null)
|
||||
{
|
||||
List<ParameterValue> results = new List<ParameterValue>();
|
||||
_ = new List<ParameterValue>();
|
||||
if (_UseCyclical && (i is null || i.Value > 0))
|
||||
throw new Exception();
|
||||
if (jsonElement.ValueKind != JsonValueKind.Array)
|
||||
@ -130,12 +128,12 @@ namespace Shared
|
||||
Enum param;
|
||||
Tuple<Enum, string, string, object> tuple;
|
||||
JsonElement[] jsonElements = jsonElement.EnumerateArray().ToArray();
|
||||
Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairsCollection = new Dictionary<string, List<Tuple<Enum, string, string, object>>>();
|
||||
Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairsCollection = new();
|
||||
for (int r = i.Value; r < jsonElements.Length; r++)
|
||||
{
|
||||
foreach (JsonProperty jsonProperty in jsonElement[r].EnumerateObject())
|
||||
{
|
||||
if (jsonProperty.Value.ValueKind == JsonValueKind.Object || jsonProperty.Value.ValueKind == JsonValueKind.Array)
|
||||
if (jsonProperty.Value.ValueKind is JsonValueKind.Object or JsonValueKind.Array)
|
||||
{
|
||||
param = Param.StructuredType;
|
||||
//jValue = jObject.Value<JValue>("Item1");
|
||||
@ -143,25 +141,14 @@ namespace Shared
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (jsonProperty.Value.ValueKind)
|
||||
param = jsonProperty.Value.ValueKind switch
|
||||
{
|
||||
case JsonValueKind.String:
|
||||
param = Param.String;
|
||||
break;
|
||||
case JsonValueKind.Number:
|
||||
param = Param.Double;
|
||||
break;
|
||||
case JsonValueKind.True:
|
||||
case JsonValueKind.False:
|
||||
param = Param.Boolean;
|
||||
break;
|
||||
case JsonValueKind.Null:
|
||||
param = Param.String;
|
||||
break;
|
||||
default:
|
||||
param = Param.StructuredType;
|
||||
break;
|
||||
}
|
||||
JsonValueKind.String => Param.String,
|
||||
JsonValueKind.Number => Param.Double,
|
||||
JsonValueKind.True or JsonValueKind.False => Param.Boolean,
|
||||
JsonValueKind.Null => Param.String,
|
||||
_ => Param.StructuredType,
|
||||
};
|
||||
}
|
||||
tuple = new Tuple<Enum, string, string, object>(param, jsonProperty.Name, string.Empty, jsonProperty.Value.ToString());
|
||||
if (!keyValuePairsCollection.ContainsKey(jsonProperty.Name))
|
||||
@ -171,7 +158,7 @@ namespace Shared
|
||||
if (!_UseCyclical)
|
||||
break;
|
||||
}
|
||||
results = GetParameterValues(equipmentControl, keyValuePairsCollection);
|
||||
List<ParameterValue> results = GetParameterValues(equipmentControl, keyValuePairsCollection);
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -188,5 +175,3 @@ namespace Shared
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared
|
||||
{
|
||||
namespace Shared;
|
||||
|
||||
public enum EquipmentType
|
||||
{
|
||||
@ -49,5 +48,3 @@
|
||||
MET08XRDXPERTPROMRDXL_Weekly,
|
||||
METBRXRAYJV7300L
|
||||
}
|
||||
|
||||
}
|
@ -4,13 +4,11 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
namespace Shared;
|
||||
|
||||
public interface IProcessData
|
||||
{
|
||||
|
||||
Tuple<string, JsonElement?, List<FileInfo>> GetResults(ILogic logic, ConfigDataBase configData, List<FileInfo> fileInfoCollection);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
using Shared.Metrology;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
namespace Shared;
|
||||
|
||||
public interface IProcessDataDescription
|
||||
{
|
||||
@ -22,5 +21,3 @@ namespace Shared
|
||||
string GetEventDescription();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
namespace Shared;
|
||||
|
||||
public interface IScopeInfo
|
||||
{
|
||||
@ -17,5 +16,3 @@ namespace Shared
|
||||
EquipmentType EquipmentType { get; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,7 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
namespace Shared;
|
||||
|
||||
public class IsEnvironment
|
||||
{
|
||||
@ -167,5 +166,3 @@ namespace Shared
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -3,8 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
namespace Shared;
|
||||
|
||||
public class Logistics
|
||||
{
|
||||
@ -54,7 +53,7 @@ namespace Shared
|
||||
else
|
||||
{
|
||||
string reportFullPathLower = fileInfo.FullName.ToLower();
|
||||
foreach (var element in cellNames)
|
||||
foreach (KeyValuePair<string, string> element in cellNames)
|
||||
{
|
||||
if (reportFullPathLower.Contains(element.Key) || reportFullPathLower.Contains(element.Value))
|
||||
{
|
||||
@ -203,25 +202,13 @@ namespace Shared
|
||||
}
|
||||
}
|
||||
|
||||
public Logistics ShallowCopy()
|
||||
{
|
||||
return (Logistics)MemberwiseClone();
|
||||
}
|
||||
public Logistics ShallowCopy() => (Logistics)MemberwiseClone();
|
||||
|
||||
private string DefaultMesEntity(DateTime dateTime)
|
||||
{
|
||||
return string.Concat(dateTime.Ticks, "_MES_ENTITY");
|
||||
}
|
||||
private string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
|
||||
|
||||
internal string GetLotViaMostCommonMethod()
|
||||
{
|
||||
return MID.Substring(0, MID.Length - 2);
|
||||
}
|
||||
internal string GetLotViaMostCommonMethod() => MID.Substring(0, MID.Length - 2);
|
||||
|
||||
internal string GetPocketNumberViaMostCommonMethod()
|
||||
{
|
||||
return MID.Substring(MID.Length - 2);
|
||||
}
|
||||
internal string GetPocketNumberViaMostCommonMethod() => MID.Substring(MID.Length - 2);
|
||||
|
||||
internal void Update(string dateTime, string processJobID, string mid)
|
||||
{
|
||||
@ -241,5 +228,3 @@ namespace Shared
|
||||
Logistics2 = new List<Logistics2>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
namespace Shared;
|
||||
|
||||
public class Logistics2
|
||||
{
|
||||
|
||||
@ -76,5 +76,3 @@ namespace Shared
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -7,8 +7,7 @@ using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class ConfigDataBase
|
||||
{
|
||||
@ -54,27 +53,15 @@ namespace Shared.Metrology
|
||||
_EquipmentConnection = null;
|
||||
else
|
||||
_EquipmentConnection = equipmentTypeValue;
|
||||
string suffix;
|
||||
switch (eventNameValue)
|
||||
string suffix = eventNameValue switch
|
||||
{
|
||||
case EventName.FileRead:
|
||||
suffix = string.Empty;
|
||||
break;
|
||||
case EventName.FileReadDaily:
|
||||
suffix = "_Daily";
|
||||
break;
|
||||
case EventName.FileReadWeekly:
|
||||
suffix = "_Weekly";
|
||||
break;
|
||||
case EventName.FileReadMonthly:
|
||||
suffix = "_Monthly";
|
||||
break;
|
||||
case EventName.FileReadVerification:
|
||||
suffix = "_Verification";
|
||||
break;
|
||||
default:
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
}
|
||||
EventName.FileRead => string.Empty,
|
||||
EventName.FileReadDaily => "_Daily",
|
||||
EventName.FileReadWeekly => "_Weekly",
|
||||
EventName.FileReadMonthly => "_Monthly",
|
||||
EventName.FileReadVerification => "_Verification",
|
||||
_ => throw new Exception(cellInstanceConnectionName),
|
||||
};
|
||||
string parameterizedModelObjectDefinitionTypeAppended = string.Concat(segments[0], suffix);
|
||||
IsEvent = cellInstanceConnectionNameBase != parameterizedModelObjectDefinitionTypeAppended;
|
||||
_EventName = eventNameValue;
|
||||
@ -182,7 +169,7 @@ namespace Shared.Metrology
|
||||
|
||||
public Dictionary<string, List<Tuple<Enum, string, string, object>>> GetParameterInfo(ILogic logic, bool allowNull)
|
||||
{
|
||||
Dictionary<string, List<Tuple<Enum, string, string, object>>> results = new Dictionary<string, List<Tuple<Enum, string, string, object>>>();
|
||||
Dictionary<string, List<Tuple<Enum, string, string, object>>> results = new();
|
||||
string description;
|
||||
Enum param;
|
||||
Tuple<Enum, string, string, object> tuple;
|
||||
@ -192,7 +179,7 @@ namespace Shared.Metrology
|
||||
{
|
||||
if (jsonProperty.Value.ValueKind == JsonValueKind.Null && !allowNull)
|
||||
throw new Exception();
|
||||
if (jsonProperty.Value.ValueKind == JsonValueKind.Object || jsonProperty.Value.ValueKind == JsonValueKind.Array)
|
||||
if (jsonProperty.Value.ValueKind is JsonValueKind.Object or JsonValueKind.Array)
|
||||
{
|
||||
description = string.Empty;
|
||||
param = Description.Param.StructuredType;
|
||||
@ -201,25 +188,14 @@ namespace Shared.Metrology
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (jsonProperty.Value.ValueKind)
|
||||
param = jsonProperty.Value.ValueKind switch
|
||||
{
|
||||
case JsonValueKind.String:
|
||||
param = Description.Param.String;
|
||||
break;
|
||||
case JsonValueKind.Number:
|
||||
param = Description.Param.Double;
|
||||
break;
|
||||
case JsonValueKind.True:
|
||||
case JsonValueKind.False:
|
||||
param = Description.Param.Boolean;
|
||||
break;
|
||||
case JsonValueKind.Null:
|
||||
param = Description.Param.String;
|
||||
break;
|
||||
default:
|
||||
param = Description.Param.StructuredType;
|
||||
break;
|
||||
}
|
||||
JsonValueKind.String => Description.Param.String,
|
||||
JsonValueKind.Number => Description.Param.Double,
|
||||
JsonValueKind.True or JsonValueKind.False => Description.Param.Boolean,
|
||||
JsonValueKind.Null => Description.Param.String,
|
||||
_ => Description.Param.StructuredType,
|
||||
};
|
||||
}
|
||||
if (!keyValuePairs.ContainsKey(jsonProperty.Name))
|
||||
description = string.Empty;
|
||||
@ -240,19 +216,19 @@ namespace Shared.Metrology
|
||||
object value;
|
||||
Enum[] @params;
|
||||
string description;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
StringBuilder stringBuilder = new();
|
||||
string shareRoot = @"\\messv02ecc1.ec.local\EC_EDA";
|
||||
string shareDirectory = string.Concat(shareRoot, @"\Staging\Pdsf\", cellName, @"\ExportAliases\", equipmentElementName);
|
||||
Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairs;
|
||||
if (!(logic is null))
|
||||
if (logic is not null)
|
||||
keyValuePairs = GetParameterInfo(logic, allowNull: false);
|
||||
else
|
||||
keyValuePairs = new Dictionary<string, List<Tuple<Enum, string, string, object>>>();
|
||||
stringBuilder.AppendLine("\"AliasName\";\"Condition\";\"EventId\";\"ExceptionId\";\"Formula\";\"HardwareId\";\"OrderId\";\"ParameterName\";\"Remark\";\"ReportName\";\"SourceId\";\"Use\"");
|
||||
_ = stringBuilder.AppendLine("\"AliasName\";\"Condition\";\"EventId\";\"ExceptionId\";\"Formula\";\"HardwareId\";\"OrderId\";\"ParameterName\";\"Remark\";\"ReportName\";\"SourceId\";\"Use\"");
|
||||
if (!Directory.Exists(shareRoot))
|
||||
return;
|
||||
if (!Directory.Exists(shareDirectory))
|
||||
Directory.CreateDirectory(shareDirectory);
|
||||
_ = Directory.CreateDirectory(shareDirectory);
|
||||
string shareFile = string.Concat(shareDirectory, @"\", DateTime.Now.Ticks, ".csv");
|
||||
foreach (KeyValuePair<string, List<Tuple<Enum, string, string, object>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
@ -263,15 +239,15 @@ namespace Shared.Metrology
|
||||
if (keyValuePair.Value[0].Item2 != keyValuePair.Key)
|
||||
throw new Exception();
|
||||
param = @params[0];
|
||||
if (!(param is Description.Param.String))
|
||||
stringBuilder.AppendLine($"\"{keyValuePair.Key}\";\"\";\"\";\"\";\"\";\"\";\"{i}\";\"{cellName}/{EquipmentElementName}/{keyValuePair.Key}\";\"\";\"{cellName}/{EquipmentElementName}/{EventName}\";\"\";\"True\"");
|
||||
if (param is not Description.Param.String)
|
||||
_ = stringBuilder.AppendLine($"\"{keyValuePair.Key}\";\"\";\"\";\"\";\"\";\"\";\"{i}\";\"{cellName}/{EquipmentElementName}/{keyValuePair.Key}\";\"\";\"{cellName}/{EquipmentElementName}/{EventName}\";\"\";\"True\"");
|
||||
else
|
||||
{
|
||||
description = keyValuePair.Value[0].Item3.Split('|')[0];
|
||||
if (string.IsNullOrEmpty(description))
|
||||
continue;
|
||||
value = keyValuePair.Value[0].Item4;
|
||||
stringBuilder.AppendLine($"\"'{description}'\";\"\";\"\";\"\";\"\";\"\";\"{i}\";\"{cellName}/{EquipmentElementName}/{value}\";\"\";\"{cellName}/{EquipmentElementName}/{EventName}\";\"\";\"True\"");
|
||||
_ = stringBuilder.AppendLine($"\"'{description}'\";\"\";\"\";\"\";\"\";\"\";\"{i}\";\"{cellName}/{EquipmentElementName}/{value}\";\"\";\"{cellName}/{EquipmentElementName}/{EventName}\";\"\";\"True\"");
|
||||
}
|
||||
}
|
||||
if (keyValuePairs.Any())
|
||||
@ -280,7 +256,7 @@ namespace Shared.Metrology
|
||||
|
||||
public Dictionary<string, string> GetDisplayNamesJsonElement(ILogic logic)
|
||||
{
|
||||
Dictionary<string, string> results = new Dictionary<string, string>();
|
||||
Dictionary<string, string> results = new();
|
||||
IProcessDataDescription processDataDescription = ProcessDataDescription.GetDisplayNames(logic, this);
|
||||
string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType());
|
||||
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
|
||||
@ -304,11 +280,11 @@ namespace Shared.Metrology
|
||||
IProcessDataDescription processDataDescription = ProcessDataDescription.GetDisplayNames(logic, this);
|
||||
string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType());
|
||||
object @object = JsonSerializer.Deserialize<object>(json);
|
||||
if (!(@object is JsonElement jsonElement))
|
||||
if (@object is not JsonElement jsonElement)
|
||||
throw new Exception();
|
||||
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
|
||||
{
|
||||
if (jsonProperty.Value.ValueKind == JsonValueKind.Object || jsonProperty.Value.ValueKind == JsonValueKind.Array)
|
||||
if (jsonProperty.Value.ValueKind is JsonValueKind.Object or JsonValueKind.Array)
|
||||
throw new Exception();
|
||||
value = jsonProperty.Value.ToString();
|
||||
if (!results.Contains(jsonProperty.Name) && pairedParameterNames.Contains(jsonProperty.Name) && (string.IsNullOrEmpty(value) || value[0] == '|'))
|
||||
@ -323,14 +299,15 @@ namespace Shared.Metrology
|
||||
List<Duplicator.Description> results;
|
||||
if (jsonElement.ValueKind != JsonValueKind.Array)
|
||||
throw new Exception();
|
||||
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
|
||||
JsonSerializerOptions jsonSerializerOptions = new()
|
||||
{ NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
|
||||
results = JsonSerializer.Deserialize<List<Duplicator.Description>>(jsonElement.ToString(), jsonSerializerOptions);
|
||||
return results;
|
||||
}
|
||||
|
||||
public Dictionary<Test, List<Duplicator.Description>> GetKeyValuePairs(List<Duplicator.Description> processDataDescriptions)
|
||||
{
|
||||
Dictionary<Test, List<Duplicator.Description>> results = new Dictionary<Test, List<Duplicator.Description>>();
|
||||
Dictionary<Test, List<Duplicator.Description>> results = new();
|
||||
Test testKey;
|
||||
for (int i = 0; i < processDataDescriptions.Count; i++)
|
||||
{
|
||||
@ -344,7 +321,7 @@ namespace Shared.Metrology
|
||||
|
||||
public Dictionary<string, List<string>> GetKeyValuePairs(JsonElement jsonElement, List<Duplicator.Description> processDataDescriptions, Test test)
|
||||
{
|
||||
Dictionary<string, List<string>> results = new Dictionary<string, List<string>>();
|
||||
Dictionary<string, List<string>> results = new();
|
||||
Test testKey;
|
||||
if (jsonElement.ValueKind != JsonValueKind.Array)
|
||||
throw new Exception();
|
||||
@ -358,7 +335,7 @@ namespace Shared.Metrology
|
||||
continue;
|
||||
foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject())
|
||||
{
|
||||
if (jsonProperty.Value.ValueKind == JsonValueKind.Object || jsonProperty.Value.ValueKind == JsonValueKind.Array)
|
||||
if (jsonProperty.Value.ValueKind is JsonValueKind.Object or JsonValueKind.Array)
|
||||
throw new Exception();
|
||||
if (!results.ContainsKey(jsonProperty.Name))
|
||||
results.Add(jsonProperty.Name, new List<string>());
|
||||
@ -379,7 +356,7 @@ namespace Shared.Metrology
|
||||
{
|
||||
if (jsonProperty.Value.ValueKind == JsonValueKind.Null && !allowNull)
|
||||
throw new Exception();
|
||||
if (!(jsonProperty.Value.ValueKind is JsonValueKind.String) || !keyValuePairs.ContainsKey(jsonProperty.Name))
|
||||
if (jsonProperty.Value.ValueKind is not JsonValueKind.String || !keyValuePairs.ContainsKey(jsonProperty.Name))
|
||||
description = string.Empty;
|
||||
else
|
||||
description = keyValuePairs[jsonProperty.Name].Split('|')[0];
|
||||
@ -388,17 +365,18 @@ namespace Shared.Metrology
|
||||
|
||||
public List<IProcessDataDescription> GetIProcessDataDescriptions(JsonElement jsonElement)
|
||||
{
|
||||
List<IProcessDataDescription> results = new List<IProcessDataDescription>();
|
||||
List<IProcessDataDescription> results = new();
|
||||
if (jsonElement.ValueKind != JsonValueKind.Array)
|
||||
throw new Exception();
|
||||
object @object;
|
||||
Type type = ProcessDataDescription.GetType();
|
||||
JsonElement[] jsonElements = jsonElement.EnumerateArray().ToArray();
|
||||
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
|
||||
JsonSerializerOptions jsonSerializerOptions = new()
|
||||
{ NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
|
||||
for (int i = 0; i < jsonElements.Length; i++)
|
||||
{
|
||||
@object = JsonSerializer.Deserialize(jsonElements[i].ToString(), type, jsonSerializerOptions);
|
||||
if (!(@object is IProcessDataDescription processDataDescription))
|
||||
if (@object is not IProcessDataDescription processDataDescription)
|
||||
continue;
|
||||
results.Add(processDataDescription);
|
||||
}
|
||||
@ -406,5 +384,3 @@ namespace Shared.Metrology
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public enum EventName
|
||||
{
|
||||
@ -9,5 +8,3 @@
|
||||
FileReadVerification,
|
||||
FileReadWeekly
|
||||
}
|
||||
|
||||
}
|
@ -6,8 +6,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public interface ILogic
|
||||
{
|
||||
@ -28,7 +27,7 @@ namespace Shared.Metrology
|
||||
object GetFilePathGeneratorInfo(string reportFullPath, bool isErrorFile);
|
||||
string GetReportFullPath(Dictionary<string, object> keyValuePairs);
|
||||
string GetTarget2FileLocation();
|
||||
void Move(string reportFullPath, Tuple<string, JsonElement?, List<FileInfo>> extractResults, Exception exception = null);
|
||||
void Move(string reportFullPath, Tuple<string, JsonElement?, List<FileInfo>> extractResults, Exception? exception = null);
|
||||
string ReExtract(string searchDirectory, string sourceFileFilter);
|
||||
void ReflectionCreateSelfDescription(string equipmentElementName, int? input, string cellName, string debugConfig, string[] strings, bool[] booleans, long[] numbers, string[] enums);
|
||||
ConfigDataBase ReflectionCreateSelfDescriptionV2(string json);
|
||||
@ -44,5 +43,3 @@ namespace Shared.Metrology
|
||||
void SetTarget2FileLocation(string value);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08AFMD3100
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08BVHGPROBE
|
||||
{
|
||||
@ -12,5 +11,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08CVHGPROBE802B150
|
||||
{
|
||||
@ -12,5 +11,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08DDINCAN8620
|
||||
{
|
||||
@ -14,5 +13,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08DDUPSFS6420
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08DDUPSP1TBI
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08EBEAMINTEGRITY26
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08HALLHL5580
|
||||
{
|
||||
@ -12,5 +11,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08MESMICROSCOPE
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08NDFRESIMAP151C
|
||||
{
|
||||
@ -11,5 +10,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08PLMAPRPM
|
||||
{
|
||||
@ -16,5 +15,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08PRFUSB4000
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08RESIHGCV
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08RESIMAPCDE
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08THFTIRQS408M
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08THFTIRSTRATUS
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08UVH44GS100M
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08VPDSUBCON
|
||||
{
|
||||
@ -10,5 +9,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
namespace Shared.Metrology
|
||||
{
|
||||
namespace Shared.Metrology;
|
||||
|
||||
public class MET08WGEOMX203641Q
|
||||
{
|
||||
@ -11,5 +10,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user