Builds but needs tested

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

7292
APC Viewer/.vscode/format-report.json vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,12 +6,16 @@
<SccLocalPath>SAK</SccLocalPath> <SccLocalPath>SAK</SccLocalPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<LangVersion>9.0</LangVersion>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>APCViewer</RootNamespace>
<RuntimeFrameworkVersion>5.0.2</RuntimeFrameworkVersion>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel> <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> <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> <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> <IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
@ -27,23 +31,35 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" /> <PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" />
<PackageReference Include="Log4net" Version="2.0.12" /> </ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.5" /> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" /> <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" /> </ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" /> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" /> <PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" /> <PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.4" /> <PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.1.4" /> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.1.4" /> </ItemGroup>
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" /> <ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="wwwroot\images\" /> <Folder Include="wwwroot\images\" />
<Folder Include="wwwroot\js\html5shiv\3.7.2\" /> <Folder Include="wwwroot\js\html5shiv\3.7.2\" />
<Folder Include="wwwroot\js\respond\1.4.2\" /> <Folder Include="wwwroot\js\respond\1.4.2\" />
</ItemGroup> </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> </Project>

View 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;
}
}

View 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();
}
}
}

View File

@ -1,50 +1,39 @@
using APCViewer.Models; using APCViewer.Models;
using APCViewer.Models.Methods;
using APCViewer.Singleton; using APCViewer.Singleton;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Shared;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Text; using System.Text;
using System.Web; using System.Web;
namespace APCViewer.Controllers namespace APCViewer.Controllers;
public class HomeController : Controller, IHomeController
{ {
public class HomeController : Controller, IHomeController private readonly Serilog.ILogger _Log;
{ private readonly Background _Background;
private readonly IBackground _BackgroundMethods;
private readonly Log _Log; public HomeController(Background background)
private readonly Singleton.IBackground _Background;
private readonly IHttpContextAccessor _HttpContextAccessor;
public HomeController(ILogger<HomeController> logger, Singleton.IBackground background, IHttpContextAccessor httpContextAccessor)
{ {
_Log = new Log(logger);
_Background = background; _Background = background;
_HttpContextAccessor = httpContextAccessor; _BackgroundMethods = background;
_Log = Serilog.Log.ForContext<HomeController>();
} }
public ActionResult Index() public ActionResult Index() => View();
{
return View();
}
public ActionResult Privacy() public ActionResult Privacy() => View();
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public ActionResult Error() public ActionResult Error() => View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
public ActionResult Encode(string value = null) public ActionResult Encode(string value = "")
{ {
string result = string.Empty; string result = string.Empty;
if (!string.IsNullOrEmpty(value)) if (!string.IsNullOrEmpty(value))
@ -52,44 +41,23 @@ namespace APCViewer.Controllers
return Content(result, "text/plain"); 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(); ActionResult result;
if (message_clear.HasValue && message_clear.Value) try
_Background.ClearMessage();
if (exceptions_clear.HasValue && exceptions_clear.Value)
_Background.Exceptions.Clear();
if (set_is_primary_instance.HasValue)
{ {
if (set_is_primary_instance.Value) throw new Exception("This is a test");
_Background.SetIsPrimaryInstance();
else
_Background.ClearIsPrimaryInstance();
} }
if (logistics_clear.HasValue && logistics_clear.Value) catch (Exception ex)
_Background.LogisticsClear(); {
string message; result = Content(string.Concat(ex.Message, Environment.NewLine, Environment.NewLine, ex.StackTrace));
if (string.IsNullOrWhiteSpace(_Background.Message)) }
message = "N/A"; return result;
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();
} }
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.Files = tuple.Item1;
ViewBag.Grouped = tuple.Item2; ViewBag.Grouped = tuple.Item2;
ViewBag.Sorted = tuple.Item3; ViewBag.Sorted = tuple.Item3;
@ -97,14 +65,14 @@ namespace APCViewer.Controllers
return View(); return View();
} }
private StringBuilder GetPDSFHtml(string pdsfFile) private static StringBuilder GetPDSFHtml(string? pdsfFile)
{ {
StringBuilder result = new(); StringBuilder result = new();
result.AppendLine("<html><body><table border = '1'>"); _ = result.AppendLine("<html><body><table border = '1'>");
if (string.IsNullOrEmpty(pdsfFile)) if (string.IsNullOrEmpty(pdsfFile))
throw new Exception("<tr><td>Invalid input</td></tr>"); throw new Exception("<tr><td>Invalid input</td></tr>");
else if (!System.IO.File.Exists(pdsfFile)) 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 else
{ {
bool header = true; bool header = true;
@ -121,25 +89,25 @@ namespace APCViewer.Controllers
if (!logistics.Contains(logisticsSegment)) if (!logistics.Contains(logisticsSegment))
{ {
logistics.Add(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")) if (pdsfLine.StartsWith("NUM_DATA_ROWS") || pdsfLine.StartsWith("END_HEADER"))
{ {
body = false; body = false;
footer = true; footer = true;
result.AppendLine("</table><hr /><table border = '1'>"); _ = result.AppendLine("</table><hr /><table border = '1'>");
} }
if (header) if (header)
result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>"); _ = result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (body) else if (body)
result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>"); _ = result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (footer) else if (footer)
{ {
if (pdsfLine.StartsWith("DELIMITER")) if (pdsfLine.StartsWith("DELIMITER"))
result.Append("<tr><td>").Append(pdsfLine.Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>"); _ = result.Append("<tr><td>").Append(pdsfLine.Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else else
result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>"); _ = result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
} }
else else
throw new Exception(); throw new Exception();
@ -147,24 +115,24 @@ namespace APCViewer.Controllers
{ {
header = false; header = false;
body = true; 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; return result;
} }
public ContentResult ViewPDSF(string id = null) public ContentResult ViewPDSF(string? id = null)
{ {
string pdsfFile; string pdsfFile;
StringBuilder result = new(); StringBuilder result = new();
if (!id.Contains('_')) if (string.IsNullOrEmpty(id) || !id.Contains('_'))
result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>"); _ = result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>");
else else
{ {
if (!long.TryParse(id.Split('_')[1], out long sequence)) 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 else
{ {
pdsfFile = _Background.GetPDSF(sequence); pdsfFile = _Background.GetPDSF(sequence);
@ -174,10 +142,10 @@ namespace APCViewer.Controllers
return Content(result.ToString(), "text/html"); return Content(result.ToString(), "text/html");
} }
public ActionResult DownloadPDSF(string id = null) public ActionResult DownloadPDSF(string? id = null)
{ {
string pdsfFile; string pdsfFile;
if (!id.Contains('_')) if (string.IsNullOrEmpty(id) || !id.Contains('_'))
throw new Exception("A) Error: Invalid input"); throw new Exception("A) Error: Invalid input");
else else
{ {
@ -189,13 +157,13 @@ namespace APCViewer.Controllers
return File(pdsfFile, "text/plain", Path.GetFileName(pdsfFile)); 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); StringBuilder result = GetPDSFHtml(pdsf_file);
return Content(result.ToString(), "text/html"); 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)) if (string.IsNullOrEmpty(pdsf_file))
throw new Exception("Error: Invalid input"); throw new Exception("Error: Invalid input");
@ -204,9 +172,9 @@ namespace APCViewer.Controllers
return File(pdsf_file, "text/plain", Path.GetFileName(pdsf_file)); 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.Files = tuple.Item1;
ViewBag.Grouped = tuple.Item2; ViewBag.Grouped = tuple.Item2;
ViewBag.Sorted = tuple.Item3; ViewBag.Sorted = tuple.Item3;
@ -214,14 +182,14 @@ namespace APCViewer.Controllers
return View(); return View();
} }
private StringBuilder GetIPDSFHtml(string ipdsfFile) private static StringBuilder GetIPDSFHtml(string? ipdsfFile)
{ {
StringBuilder result = new(); StringBuilder result = new();
result.AppendLine("<html><body><table border = '1'>"); _ = result.AppendLine("<html><body><table border = '1'>");
if (string.IsNullOrEmpty(ipdsfFile)) if (string.IsNullOrEmpty(ipdsfFile))
throw new Exception("<tr><td>Invalid input</td></tr>"); throw new Exception("<tr><td>Invalid input</td></tr>");
else if (!System.IO.File.Exists(ipdsfFile)) 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 else
{ {
bool header = true; bool header = true;
@ -238,25 +206,25 @@ namespace APCViewer.Controllers
if (!logistics.Contains(logisticsSegment)) if (!logistics.Contains(logisticsSegment))
{ {
logistics.Add(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")) if (ipdsfLine.StartsWith("NUM_DATA_ROWS") || ipdsfLine.StartsWith("END_HEADER"))
{ {
body = false; body = false;
footer = true; footer = true;
result.AppendLine("</table><hr /><table border = '1'>"); _ = result.AppendLine("</table><hr /><table border = '1'>");
} }
if (header) if (header)
result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>"); _ = result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (body) else if (body)
result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>"); _ = result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (footer) else if (footer)
{ {
if (ipdsfLine.StartsWith("DELIMITER")) if (ipdsfLine.StartsWith("DELIMITER"))
result.Append("<tr><td>").Append(ipdsfLine.Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>"); _ = result.Append("<tr><td>").Append(ipdsfLine.Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else else
result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>"); _ = result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
} }
else else
throw new Exception(); throw new Exception();
@ -264,24 +232,24 @@ namespace APCViewer.Controllers
{ {
header = false; header = false;
body = true; 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; return result;
} }
public ContentResult ViewIPDSF(string id = null) public ContentResult ViewIPDSF(string? id = null)
{ {
string ipdsfFile; string ipdsfFile;
StringBuilder result = new(); StringBuilder result = new();
if (!id.Contains('_')) if (string.IsNullOrEmpty(id) || !id.Contains('_'))
result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>"); _ = result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>");
else else
{ {
if (!long.TryParse(id.Split('_')[1], out long sequence)) 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 else
{ {
ipdsfFile = _Background.GetIPDSF(sequence); ipdsfFile = _Background.GetIPDSF(sequence);
@ -291,10 +259,10 @@ namespace APCViewer.Controllers
return Content(result.ToString(), "text/html"); return Content(result.ToString(), "text/html");
} }
public ActionResult DownloadIPDSF(string id = null) public ActionResult DownloadIPDSF(string? id = null)
{ {
string ipdsfFile; string ipdsfFile;
if (!id.Contains('_')) if (string.IsNullOrEmpty(id) || !id.Contains('_'))
throw new Exception("A) Error: Invalid input"); throw new Exception("A) Error: Invalid input");
else else
{ {
@ -306,13 +274,13 @@ namespace APCViewer.Controllers
return File(ipdsfFile, "text/plain", Path.GetFileName(ipdsfFile)); 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); StringBuilder result = GetIPDSFHtml(ipdsf_file);
return Content(result.ToString(), "text/html"); 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)) if (string.IsNullOrEmpty(ipdsf_file))
throw new Exception("Error: Invalid input"); throw new Exception("Error: Invalid input");
@ -329,24 +297,4 @@ namespace APCViewer.Controllers
return View(); 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"

View File

@ -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")]

View File

@ -1,168 +1,168 @@
using APCViewer.Singleton; using APCViewer.Models.Methods;
using Microsoft.Extensions.Configuration; using APCViewer.Models.Stateless;
using Microsoft.Extensions.DependencyInjection; using APCViewer.Models.Stateless.Methods;
using Microsoft.Extensions.Hosting; using APCViewer.Singleton;
using Microsoft.Extensions.Logging; using IFX.Shared;
using System; using Serilog.Context;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
namespace APCViewer.HostedService namespace APCViewer.HostedService;
public class TimedHostedService : IHostedService
{ {
public class TimedHostedService : IHostedService, IDisposable private readonly Timer _APCDataTimer;
{ private readonly Timer _EDADataTimer;
private readonly Timer _EAFLogDataTimer;
private readonly int _ExecutionCount; private readonly int _ExecutionCount;
private readonly WebClient _WebClient; private readonly List<Timer> _Timers;
private readonly Serilog.ILogger _Log;
private readonly Background _Background; private readonly Background _Background;
private readonly IConfiguration _Configuration; private readonly IsEnvironment _IsEnvironment;
private readonly ILogger<TimedHostedService> _Log; private readonly IBackground _BackgroundMethods;
private Timer _APCDataTimer; public TimedHostedService(IsEnvironment isEnvironment, Background background)
private Timer _EDADataTimer;
private Timer _EAFLogDataTimer;
public TimedHostedService(Background background, IConfiguration configuration, IServiceProvider serviceProvider)
{ {
_Timers = new();
_ExecutionCount = 0; _ExecutionCount = 0;
_Background = background; _Background = background;
_Configuration = configuration; _IsEnvironment = isEnvironment;
_WebClient = serviceProvider.GetRequiredService<WebClient>(); _BackgroundMethods = background;
_Log = serviceProvider.GetRequiredService<ILogger<TimedHostedService>>(); _Log = Serilog.Log.ForContext<TimedHostedService>();
//_HttpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>(); _APCDataTimer = new Timer(APCDataCallback, null, Timeout.Infinite, Timeout.Infinite);
_WebClient = serviceProvider.GetRequiredService<WebClient>(); _EAFLogDataTimer = new Timer(EAFLogDataCallback, null, Timeout.Infinite, Timeout.Infinite);
_EDADataTimer = new Timer(EDADataCallback, null, Timeout.Infinite, Timeout.Infinite);
} }
public Task StartAsync(CancellationToken stoppingToken) public Task StartAsync(CancellationToken stoppingToken)
{ {
_Log.LogInformation(string.Concat("Timed Hosted Service: ", nameof(Background), ":", _Background.IsEnvironment.Profile, ":", Environment.ProcessId, " running.")); string? methodName = IMethodName.GetActualAsyncMethodName();
_Background.Update(_Log, _WebClient); using (LogContext.PushProperty("MethodName", methodName))
if (_Background.IsEnvironment.Development)
{ {
_Log.Info(string.Concat("Timed Hosted Service: ", _IsEnvironment.Profile, ":", Environment.ProcessId, " running."));
int milliSeconds = 3000; int milliSeconds = 3000;
if (_IsEnvironment.Development)
{
if (milliSeconds == 0) if (milliSeconds == 0)
{ } { }
} }
else if (_Background.IsEnvironment.Staging) else if (_IsEnvironment.Staging)
{ {
int milliSeconds = 3000; _ = _APCDataTimer.Change(milliSeconds, Timeout.Infinite);
_APCDataTimer = new Timer(APCDataCallback, null, milliSeconds, Timeout.Infinite); _Timers.Add(_APCDataTimer);
_Background.Timers.Add(_APCDataTimer);
milliSeconds += 2000; milliSeconds += 2000;
_EAFLogDataTimer = new Timer(EAFLogDataCallback, null, milliSeconds, Timeout.Infinite); _ = _EAFLogDataTimer.Change(milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_EAFLogDataTimer); _Timers.Add(_EAFLogDataTimer);
milliSeconds += 2000; milliSeconds += 2000;
_EDADataTimer = new Timer(EDADataCallback, null, milliSeconds, Timeout.Infinite); _ = _EDADataTimer.Change(milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_EDADataTimer); _Timers.Add(_EDADataTimer);
milliSeconds += 2000; milliSeconds += 2000;
} }
else if (_Background.IsEnvironment.Production) else if (_IsEnvironment.Production)
{ {
int milliSeconds = 3000; _ = _APCDataTimer.Change(milliSeconds, Timeout.Infinite);
_APCDataTimer = new Timer(APCDataCallback, null, milliSeconds, Timeout.Infinite); _Timers.Add(_APCDataTimer);
_Background.Timers.Add(_APCDataTimer);
milliSeconds += 2000; milliSeconds += 2000;
_EAFLogDataTimer = new Timer(EAFLogDataCallback, null, milliSeconds, Timeout.Infinite); _ = _EAFLogDataTimer.Change(milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_EAFLogDataTimer); _Timers.Add(_EAFLogDataTimer);
milliSeconds += 2000; milliSeconds += 2000;
_EDADataTimer = new Timer(EDADataCallback, null, milliSeconds, Timeout.Infinite); _ = _EDADataTimer.Change(milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_EDADataTimer); _Timers.Add(_EDADataTimer);
milliSeconds += 2000; milliSeconds += 2000;
} }
else else
throw new Exception(); 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; return Task.CompletedTask;
} }
public Task StopAsync(CancellationToken stoppingToken) public Task StopAsync(CancellationToken stoppingToken)
{ {
_Log.LogInformation(string.Concat("Timed Hosted Service: ", nameof(Background), ":", _Background.IsEnvironment.Profile, ":", Environment.ProcessId, " is stopping.")); string? methodName = IMethodName.GetActualAsyncMethodName();
_Background.Stop(immediate: true); 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++) for (short i = 0; i < short.MaxValue; i++)
{ {
Thread.Sleep(500); Thread.Sleep(500);
if (_ExecutionCount == 0) if (_ExecutionCount == 0)
break; break;
} }
}
return Task.CompletedTask; return Task.CompletedTask;
} }
public void Dispose() private void APCDataCallback(object? state)
{
_Background.Dispose();
}
private void APCDataCallback(object state)
{ {
try try
{ {
if (_Background.IsPrimaryInstance()) string? methodName = IMethodName.GetActualAsyncMethodName();
using (LogContext.PushProperty("MethodName", methodName))
{
if (_BackgroundMethods.IsPrimaryInstance())
_Background.APCDataCallback(); _Background.APCDataCallback();
} }
catch (Exception e) { _Background.Catch(e); } }
catch (Exception e) { _Log.Error(e, "Error: "); }
try try
{ {
TimeSpan timeSpan; TimeSpan timeSpan;
if (!_Background.IsPrimaryInstance()) if (!_BackgroundMethods.IsPrimaryInstance())
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks); timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks);
else else
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks); 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 try
{ {
if (_Background.IsPrimaryInstance()) string? methodName = IMethodName.GetActualAsyncMethodName();
using (LogContext.PushProperty("MethodName", methodName))
{
if (_BackgroundMethods.IsPrimaryInstance())
_Background.EDADataCallback(); _Background.EDADataCallback();
} }
catch (Exception e) { _Background.Catch(e); } }
catch (Exception e) { _Log.Error(e, "Error: "); }
try try
{ {
TimeSpan timeSpan; TimeSpan timeSpan;
if (!_Background.IsPrimaryInstance()) if (!_BackgroundMethods.IsPrimaryInstance())
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks); timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks);
else else
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks); 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 try
{ {
if (_Background.IsPrimaryInstance()) string? methodName = IMethodName.GetActualAsyncMethodName();
using (LogContext.PushProperty("MethodName", methodName))
{
if (_BackgroundMethods.IsPrimaryInstance())
_Background.EAFLogDataCallback(); _Background.EAFLogDataCallback();
} }
catch (Exception e) { _Background.Catch(e); } }
catch (Exception e) { _Log.Error(e, "Error: "); }
try try
{ {
TimeSpan timeSpan; TimeSpan timeSpan;
if (!_Background.IsPrimaryInstance()) if (!_BackgroundMethods.IsPrimaryInstance())
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks); timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks);
else else
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks); 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: "); }
}
} }
} }

View 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;
}
}

View 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;
}
}

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.Core namespace Library.Eaf.Core;
public class BackboneComponent
{ {
public class BackboneComponent
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.Core namespace Library.Eaf.Core;
public class BackboneStatusCache
{ {
public class BackboneStatusCache
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.Core namespace Library.Eaf.Core;
public interface ILoggingSetupManager
{ {
public interface ILoggingSetupManager
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.Core namespace Library.Eaf.Core;
public class StatusItem
{ {
public class StatusItem
{
}
} }

View File

@ -2,10 +2,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Library.Eaf.Core namespace Library.Eaf.Core;
public class Backbone
{ {
public class Backbone
{
public const string STATE_ERROR = "Error"; public const string STATE_ERROR = "Error";
public const string STATE_OFFLINE = "Offline"; public const string STATE_OFFLINE = "Offline";
public const string STATE_RUNNING = "Running"; public const string STATE_RUNNING = "Running";
@ -30,12 +30,12 @@ namespace Library.Eaf.Core
protected Dictionary<string, BackboneComponent> BackboneComponents { get; } protected Dictionary<string, BackboneComponent> BackboneComponents { get; }
public void AddBackboneComponent(BackboneComponent backboneComponent) { } 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.")] [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 List<StatusItem> GetAllStatuses() => throw new NotImplementedException();
public BackboneComponent GetBackboneComponentById(string id) { throw new NotImplementedException(); } public BackboneComponent GetBackboneComponentById(string id) => throw new NotImplementedException();
public List<T> GetBackboneComponentsOfType<T>() { throw new NotImplementedException(); } public List<T> GetBackboneComponentsOfType<T>() => throw new NotImplementedException();
public List<BackboneComponent> GetBackboneComponentsOfType(Type type) { throw new NotImplementedException(); } public List<BackboneComponent> GetBackboneComponentsOfType(Type type) => throw new NotImplementedException();
public void RegisterSubprocess(int pid) { } public void RegisterSubprocess(int pid) { }
[Obsolete("Use the capabilities exposed via the Status property -> SetValue. Will be removed with next major release.")] [Obsolete("Use the capabilities exposed via the Status property -> SetValue. Will be removed with next major release.")]
public void SetStatus(string statusName, string statusValue) { } public void SetStatus(string statusName, string statusValue) { }
@ -44,5 +44,4 @@ namespace Library.Eaf.Core
protected void CloseConnectionOfComponents(List<BackboneComponent> components) { } protected void CloseConnectionOfComponents(List<BackboneComponent> components) { }
protected virtual void StopAllComponents() { } protected virtual void StopAllComponents() { }
protected void StopComponents(List<BackboneComponent> components) { } protected void StopComponents(List<BackboneComponent> components) { }
}
} }

View File

@ -1,10 +1,9 @@
using System; using System;
namespace Library.Eaf.Core.Smtp namespace Library.Eaf.Core.Smtp;
{
public class EmailMessage public class EmailMessage
{ {
public EmailMessage() { } public EmailMessage() { }
public EmailMessage(string subject, string body, MailPriority priority = MailPriority.Normal) { } public EmailMessage(string subject, string body, MailPriority priority = MailPriority.Normal) { }
@ -12,13 +11,11 @@ namespace Library.Eaf.Core.Smtp
public MailPriority Priority { get; } public MailPriority Priority { get; }
public string Subject { get; } public string Subject { get; }
public EmailMessage PriorityHigh() { throw new NotImplementedException(); } public EmailMessage PriorityHigh() => throw new NotImplementedException();
public EmailMessage PriorityLow() { throw new NotImplementedException(); } public EmailMessage PriorityLow() => throw new NotImplementedException();
public EmailMessage PriorityNormal() { throw new NotImplementedException(); } public EmailMessage PriorityNormal() => throw new NotImplementedException();
public EmailMessage SetBody(string body) { throw new NotImplementedException(); } public EmailMessage SetBody(string body) => throw new NotImplementedException();
public EmailMessage SetPriority(MailPriority priority) { throw new NotImplementedException(); } public EmailMessage SetPriority(MailPriority priority) => throw new NotImplementedException();
public EmailMessage SetSubject(string subject) { throw new NotImplementedException(); } public EmailMessage SetSubject(string subject) => throw new NotImplementedException();
}
} }

View File

@ -1,9 +1,6 @@
namespace Library.Eaf.Core.Smtp namespace Library.Eaf.Core.Smtp;
public interface ISmtp
{ {
public interface ISmtp
{
void Send(EmailMessage message); void Send(EmailMessage message);
}
} }

View File

@ -1,11 +1,8 @@
namespace Library.Eaf.Core.Smtp namespace Library.Eaf.Core.Smtp;
{
public enum MailPriority public enum MailPriority
{ {
Low = 0, Low = 0,
Normal = 1, Normal = 1,
High = 2 High = 2
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public class ChangeDataCollectionHandler
{ {
public class ChangeDataCollectionHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public class DataCollectionRequest
{ {
public class DataCollectionRequest
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public class EquipmentEvent
{ {
public class EquipmentEvent
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public class EquipmentException
{ {
public class EquipmentException
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public class EquipmentSelfDescription
{ {
public class EquipmentSelfDescription
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public class GetParameterValuesHandler
{ {
public class GetParameterValuesHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface IConnectionControl
{ {
public interface IConnectionControl
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface IDataTracingHandler
{ {
public interface IDataTracingHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface IEquipmentCommandService
{ {
public interface IEquipmentCommandService
{
}
} }

View File

@ -1,9 +1,9 @@
using Library.PeerGroup.GCL.Annotations; using Library.PeerGroup.GCL.Annotations;
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface IEquipmentControl : IPackageSource
{ {
public interface IEquipmentControl : IPackageSource
{
[NotNull] [NotNull]
IEquipmentSelfDescriptionBuilder SelfDescriptionBuilder { get; } IEquipmentSelfDescriptionBuilder SelfDescriptionBuilder { get; }
[NotNull] [NotNull]
@ -12,5 +12,4 @@ namespace Library.Eaf.EquipmentCore.Control
IEquipmentCommandService Commands { get; } IEquipmentCommandService Commands { get; }
[NotNull] [NotNull]
IConnectionControl Connection { get; } IConnectionControl Connection { get; }
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface IEquipmentSelfDescriptionBuilder
{ {
public interface IEquipmentSelfDescriptionBuilder
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface IPackage
{ {
public interface IPackage
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface ISelfDescriptionLookup
{ {
public interface ISelfDescriptionLookup
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface IVirtualParameterValuesHandler
{ {
public interface IVirtualParameterValuesHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public class SetParameterValuesHandler
{ {
public class SetParameterValuesHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public class TraceRequest
{ {
public class TraceRequest
{
}
} }

View File

@ -3,10 +3,10 @@ using Library.Eaf.EquipmentCore.SelfDescription.ElementDescription;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface IEquipmentDataCollection
{ {
public interface IEquipmentDataCollection
{
IVirtualParameterValuesHandler VirtualParameterValuesHandler { get; } IVirtualParameterValuesHandler VirtualParameterValuesHandler { get; }
ISelfDescriptionLookup SelfDescriptionLookup { get; } ISelfDescriptionLookup SelfDescriptionLookup { get; }
EquipmentSelfDescription SelfDescription { get; } EquipmentSelfDescription SelfDescription { get; }
@ -35,5 +35,4 @@ namespace Library.Eaf.EquipmentCore.Control
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters); void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters);
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, IPackage sourcePackage); void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, DateTime equipmentTimeStamp); void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, DateTime equipmentTimeStamp);
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.EquipmentCore.Control namespace Library.Eaf.EquipmentCore.Control;
public interface IPackageSource
{ {
public interface IPackageSource
{
}
} }

View File

@ -2,10 +2,10 @@
using Library.PeerGroup.GCL.Annotations; using Library.PeerGroup.GCL.Annotations;
using System; using System;
namespace Library.Eaf.EquipmentCore.DataCollection.Reporting namespace Library.Eaf.EquipmentCore.DataCollection.Reporting;
public class ParameterValue
{ {
public class ParameterValue
{
public ParameterValue(EquipmentParameter definition, object value) { } public ParameterValue(EquipmentParameter definition, object value) { }
public ParameterValue(EquipmentParameter definition, object value, DateTime timestamp) { } public ParameterValue(EquipmentParameter definition, object value, DateTime timestamp) { }
@ -14,7 +14,6 @@ namespace Library.Eaf.EquipmentCore.DataCollection.Reporting
public EquipmentParameter Definition { get; } public EquipmentParameter Definition { get; }
public DateTime Timestamp { get; protected set; } public DateTime Timestamp { get; protected set; }
public virtual ParameterValue Clone(EquipmentParameter newDefinition) { throw new NotImplementedException(); } public virtual ParameterValue Clone(EquipmentParameter newDefinition) => throw new NotImplementedException();
public override string ToString() { return base.ToString(); } public override string ToString() => base.ToString();
}
} }

View File

@ -1,9 +1,9 @@
using Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes; using Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
namespace Library.Eaf.EquipmentCore.SelfDescription.ElementDescription namespace Library.Eaf.EquipmentCore.SelfDescription.ElementDescription;
public class EquipmentParameter
{ {
public class EquipmentParameter
{
public EquipmentParameter(EquipmentParameter source, ParameterTypeDefinition typeDefinition) { } public EquipmentParameter(EquipmentParameter source, ParameterTypeDefinition typeDefinition) { }
public EquipmentParameter(string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { } public EquipmentParameter(string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { }
public EquipmentParameter(string id, string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { } public EquipmentParameter(string id, string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { }
@ -17,8 +17,6 @@ namespace Library.Eaf.EquipmentCore.SelfDescription.ElementDescription
public bool IsTransient { get; } public bool IsTransient { get; }
public bool IsReadOnly { get; } public bool IsReadOnly { get; }
public override string ToString() { return base.ToString(); } public override string ToString() => base.ToString();
public string ToStringWithDetails() { return base.ToString(); } public string ToStringWithDetails() => base.ToString();
}
} }

View File

@ -1,12 +1,11 @@
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
public class Field
{ {
public class Field
{
public Field(string name, string description, bool canBeNull, ParameterTypeDefinition typeDefinition) { } public Field(string name, string description, bool canBeNull, ParameterTypeDefinition typeDefinition) { }
public string Name { get; } public string Name { get; }
public string Description { get; } public string Description { get; }
public ParameterTypeDefinition TypeDefinition { get; } public ParameterTypeDefinition TypeDefinition { get; }
public bool CanBeNull { get; } public bool CanBeNull { get; }
}
} }

View File

@ -1,12 +1,11 @@
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
public abstract class ParameterTypeDefinition
{ {
public abstract class ParameterTypeDefinition
{
public ParameterTypeDefinition(string name, string description) { } public ParameterTypeDefinition(string name, string description) { }
public string Name { get; } public string Name { get; }
public string Description { get; } public string Description { get; }
public override string ToString() { return base.ToString(); } public override string ToString() => base.ToString();
}
} }

View File

@ -1,12 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
public class StructuredType : ParameterTypeDefinition
{ {
public class StructuredType : ParameterTypeDefinition
{
public StructuredType(string name, string description, IList<Field> fields) : base(name, description) { } public StructuredType(string name, string description, IList<Field> fields) : base(name, description) { }
public IList<Field> Fields { get; } public IList<Field> Fields { get; }
}
} }

View File

@ -1,6 +1,5 @@
namespace Library.Eaf.Management.ConfigurationData.CellAutomation namespace Library.Eaf.Management.ConfigurationData.CellAutomation;
public interface IConfigurationObject
{ {
public interface IConfigurationObject
{
}
} }

View File

@ -1,10 +1,10 @@
using System; using System;
namespace Library.Eaf.Management.ConfigurationData.CellAutomation namespace Library.Eaf.Management.ConfigurationData.CellAutomation;
[System.Runtime.Serialization.DataContractAttribute(IsReference = true)]
public class ModelObjectParameterDefinition : IConfigurationObject
{ {
[System.Runtime.Serialization.DataContractAttribute(IsReference = true)]
public class ModelObjectParameterDefinition : IConfigurationObject
{
public ModelObjectParameterDefinition() { } public ModelObjectParameterDefinition() { }
public ModelObjectParameterDefinition(string name, ModelObjectParameterType valueType, object defaultValue) { } public ModelObjectParameterDefinition(string name, ModelObjectParameterType valueType, object defaultValue) { }
public ModelObjectParameterDefinition(string name, Type enumType, object defaultValue) { } public ModelObjectParameterDefinition(string name, Type enumType, object defaultValue) { }
@ -20,7 +20,6 @@ namespace Library.Eaf.Management.ConfigurationData.CellAutomation
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public virtual string EnumType { get; set; } public virtual string EnumType { get; set; }
public virtual ModelObjectParameterDefinition Clone() { return null; } public virtual ModelObjectParameterDefinition? Clone() => null;
public virtual bool IsValidValue(string value) { return false; } public virtual bool IsValidValue(string value) => false;
}
} }

View File

@ -1,7 +1,7 @@
namespace Library.Eaf.Management.ConfigurationData.CellAutomation namespace Library.Eaf.Management.ConfigurationData.CellAutomation;
public enum ModelObjectParameterType
{ {
public enum ModelObjectParameterType
{
String = 0, String = 0,
Bool = 1, Bool = 1,
Byte = 2, Byte = 2,
@ -13,5 +13,4 @@
Double = 8, Double = 8,
Float = 9, Float = 9,
Enum = 10 Enum = 10
}
} }

View File

@ -1,11 +1,11 @@
using Library.PeerGroup.GCL.SecsDriver; using Library.PeerGroup.GCL.SecsDriver;
using System; using System;
namespace Library.Eaf.Management.ConfigurationData.Semiconductor.CellInstances namespace Library.Eaf.Management.ConfigurationData.Semiconductor.CellInstances;
[System.Runtime.Serialization.DataContractAttribute]
public class SecsConnectionConfiguration
{ {
[System.Runtime.Serialization.DataContractAttribute]
public class SecsConnectionConfiguration
{
public SecsConnectionConfiguration() { } public SecsConnectionConfiguration() { }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
@ -40,5 +40,4 @@ namespace Library.Eaf.Management.ConfigurationData.Semiconductor.CellInstances
public virtual TimeSpan T7ConnectionIdle { get; set; } public virtual TimeSpan T7ConnectionIdle { get; set; }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T8NetworkIntercharacter { get; set; } public virtual TimeSpan T8NetworkIntercharacter { get; set; }
}
} }

View File

@ -1,13 +1,12 @@
namespace Library.Ifx.Eaf.Common.Configuration namespace Library.Ifx.Eaf.Common.Configuration;
[System.Runtime.Serialization.DataContractAttribute]
public class ConnectionSetting
{ {
[System.Runtime.Serialization.DataContractAttribute]
public class ConnectionSetting
{
public ConnectionSetting(string name, string value) { } public ConnectionSetting(string name, string value) { }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public string Name { get; set; } public string Name { get; set; }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public string Value { get; set; } public string Value { get; set; }
}
} }

View File

@ -1,19 +1,18 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Library.Ifx.Eaf.EquipmentConnector.File.Component namespace Library.Ifx.Eaf.EquipmentConnector.File.Component;
public class File
{ {
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 string Path { get; }
public DateTime TimeFound { get; } public DateTime TimeFound { get; }
public bool IsErrorFile { get; } public bool IsErrorFile { get; }
public Dictionary<string, string> ContentParameters { get; } public Dictionary<string, string> ContentParameters { get; }
public File UpdateContentParameters(Dictionary<string, string> contentParameters) { throw new NotImplementedException(); } public File UpdateContentParameters(Dictionary<string, string> contentParameters) => throw new NotImplementedException();
public File UpdateParsingStatus(bool isErrorFile) { throw new NotImplementedException(); } public File UpdateParsingStatus(bool isErrorFile) => throw new NotImplementedException();
}
} }

View File

@ -2,10 +2,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Library.Ifx.Eaf.EquipmentConnector.File.Component namespace Library.Ifx.Eaf.EquipmentConnector.File.Component;
public class FilePathGenerator
{ {
public class FilePathGenerator
{
public const char PLACEHOLDER_IDENTIFIER = '%'; public const char PLACEHOLDER_IDENTIFIER = '%';
public const char PLACEHOLDER_SEPARATOR = ':'; public const char PLACEHOLDER_SEPARATOR = ':';
public const string PLACEHOLDER_NOT_AVAILABLE = "NA"; public const string PLACEHOLDER_NOT_AVAILABLE = "NA";
@ -15,9 +15,9 @@ namespace Library.Ifx.Eaf.EquipmentConnector.File.Component
public const string PLACEHOLDER_SUB_FOLDER = "SubFolder"; public const string PLACEHOLDER_SUB_FOLDER = "SubFolder";
public const string PLACEHOLDER_CELL_NAME = "CellName"; public const string PLACEHOLDER_CELL_NAME = "CellName";
public FilePathGenerator(FileConnectorConfiguration config, 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, 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, string sourceFilePath, bool isErrorFile = false, Dictionary<string, string>? customPattern = null) => throw new NotImplementedException();
protected string SubFolderPath { get; } protected string SubFolderPath { get; }
protected FileConnectorConfiguration Configuration { get; } protected FileConnectorConfiguration Configuration { get; }
@ -25,11 +25,10 @@ namespace Library.Ifx.Eaf.EquipmentConnector.File.Component
protected bool IsErrorFile { get; } protected bool IsErrorFile { get; }
protected string DefaultPlaceHolderValue { get; } protected string DefaultPlaceHolderValue { get; }
public string GetFullTargetPath() { throw new NotImplementedException(); } public string GetFullTargetPath() => throw new NotImplementedException();
public virtual string GetTargetFileName() { throw new NotImplementedException(); } public virtual string GetTargetFileName() => throw new NotImplementedException();
public string GetTargetFolder(bool throwExceptionIfNotExist = true) { 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 GetSubFolder(string folderPattern, string subFolderPath) => throw new NotImplementedException();
protected virtual string PrepareFolderPath(string targetFolderPath, string subFolderPath) { throw new NotImplementedException(); } protected virtual string PrepareFolderPath(string targetFolderPath, string subFolderPath) => throw new NotImplementedException();
protected string ReplacePlaceholder(string inputPath) { throw new NotImplementedException(); } protected string ReplacePlaceholder(string inputPath) => throw new NotImplementedException();
}
} }

View File

@ -2,11 +2,11 @@
using System; using System;
using System.Collections.Generic; 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
{ {
[System.Runtime.Serialization.DataContractAttribute]
public class FileConnectorConfiguration
{
public const ulong IDLE_EVENT_WAIT_TIME_DEFAULT = 360; public const ulong IDLE_EVENT_WAIT_TIME_DEFAULT = 360;
public const ulong FILE_HANDLE_TIMEOUT_DEFAULT = 15; public const ulong FILE_HANDLE_TIMEOUT_DEFAULT = 15;
@ -85,7 +85,7 @@ namespace Library.Ifx.Eaf.EquipmentConnector.File.Configuration
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public string ErrorTargetFileName { get; set; } public string ErrorTargetFileName { get; set; }
public void Initialize() { throw new NotImplementedException(); } public void Initialize() => throw new NotImplementedException();
public enum PostProcessingModeEnum public enum PostProcessingModeEnum
{ {
@ -131,5 +131,4 @@ namespace Library.Ifx.Eaf.EquipmentConnector.File.Configuration
IgnoreNewer = 0, IgnoreNewer = 0,
IgnoreOlder = 1 IgnoreOlder = 1
} }
}
} }

View File

@ -2,13 +2,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Library.Ifx.Eaf.EquipmentConnector.File.SelfDescription namespace Library.Ifx.Eaf.EquipmentConnector.File.SelfDescription;
public class FileConnectorParameterTypeDefinitionProvider
{ {
public class FileConnectorParameterTypeDefinitionProvider
{
public FileConnectorParameterTypeDefinitionProvider() { } public FileConnectorParameterTypeDefinitionProvider() { }
public IEnumerable<ParameterTypeDefinition> GetAllParameterTypeDefinition() { return null; } public IEnumerable<ParameterTypeDefinition>? GetAllParameterTypeDefinition() => null;
public ParameterTypeDefinition GetParameterTypeDefinition(string name) { return null; } public ParameterTypeDefinition? GetParameterTypeDefinition(string name) => null;
}
} }

View File

@ -1,10 +1,9 @@
using System; 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
{ {
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.Delegate, AllowMultiple = false, Inherited = true)]
public sealed class NotNullAttribute : Attribute
{
public NotNullAttribute() { } public NotNullAttribute() { }
}
} }

View File

@ -1,8 +1,7 @@
namespace Library.PeerGroup.GCL.SecsDriver namespace Library.PeerGroup.GCL.SecsDriver;
public enum HsmsConnectionMode
{ {
public enum HsmsConnectionMode
{
Active = 0, Active = 0,
Passive = 1 Passive = 1
}
} }

View File

@ -1,8 +1,7 @@
namespace Library.PeerGroup.GCL.SecsDriver namespace Library.PeerGroup.GCL.SecsDriver;
public enum HsmsSessionMode
{ {
public enum HsmsSessionMode
{
MultiSession = 0, MultiSession = 0,
SingleSession = 1 SingleSession = 1
}
} }

View File

@ -1,8 +1,7 @@
namespace Library.PeerGroup.GCL.SecsDriver namespace Library.PeerGroup.GCL.SecsDriver;
public enum SecsTransportType
{ {
public enum SecsTransportType
{
HSMS = 0, HSMS = 0,
Serial = 1 Serial = 1
}
} }

View File

@ -1,7 +1,7 @@
namespace Library.PeerGroup.GCL.SecsDriver namespace Library.PeerGroup.GCL.SecsDriver;
public enum SerialBaudRate
{ {
public enum SerialBaudRate
{
Baud9600 = 0, Baud9600 = 0,
Baud19200 = 1, Baud19200 = 1,
Baud4800 = 2, Baud4800 = 2,
@ -12,5 +12,4 @@
Baud38400 = 7, Baud38400 = 7,
Baud57600 = 8, Baud57600 = 8,
Baud115200 = 9 Baud115200 = 9
}
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -1,25 +1,11 @@
using Microsoft.AspNetCore.Mvc; 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);
}
public interface IHomeController
{
ActionResult Encode(string value = "");
ActionResult Error();
ActionResult Index();
ActionResult Privacy();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,40 +1,90 @@
using Microsoft.AspNetCore.Hosting; using APCViewer.HostedService;
using Microsoft.Extensions.Configuration; using APCViewer.Models;
using Microsoft.Extensions.Hosting; using APCViewer.Models.Stateless.Methods;
using Shared; using IFX.Shared;
using System.Diagnostics; using Serilog;
using System.Reflection;
namespace APCViewer namespace APCViewer;
public class Program
{ {
public class Program public static int Main(string[] args)
{ {
LoggerConfiguration loggerConfiguration = new();
public static void Main(string[] args) // 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
{ {
CreateHostBuilder(args).Build().Run(); 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();
public static IHostBuilder CreateHostBuilder(string[] args) _ = webApplication.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "APC Viewer API V1"));
{
IHostBuilder result;
IsEnvironment isEnvironment = new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached);
result = Host.CreateDefaultBuilder(args)
.UseWindowsService()
.ConfigureAppConfiguration((context, configuration) =>
{
configuration
.AddEnvironmentVariables()
.AddCommandLine(args)
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
return result;
} }
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();
return 0;
}
catch (Exception ex)
{
log.Fatal(ex, "Host terminated unexpectedly");
return 1;
}
finally
{
Log.CloseAndFlush();
}
} }
} }

View File

@ -10,11 +10,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
namespace Shared namespace Shared;
{
public class Description public class Description
{ {
public enum RowColumn public enum RowColumn
{ {
@ -46,7 +45,6 @@ namespace Shared
internal const string FileFound = "FileFound"; internal const string FileFound = "FileFound";
public List<EquipmentParameter> EquipmentParameters { get; private set; } public List<EquipmentParameter> EquipmentParameters { get; private set; }
public List<ParameterTypeDefinition> ParameterTypeDefinitions { 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) 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; Enum param;
object value; object value;
Enum[] @params; Enum[] @params;
@ -112,7 +110,7 @@ namespace Shared
list.Add(new object[] { i, keyValuePair.Value[i].Item4 }); list.Add(new object[] { i, keyValuePair.Value[i].Item4 });
value = list; 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)); results.Add(new ParameterValue(equipmentParameter, value, DateTime.Now));
else else
results.Add(equipmentControl.DataCollection.CreateParameterValue(equipmentParameter, value)); results.Add(equipmentControl.DataCollection.CreateParameterValue(equipmentParameter, value));
@ -120,9 +118,9 @@ namespace Shared
return results; 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)) if (_UseCyclical && (i is null || i.Value > 0))
throw new Exception(); throw new Exception();
if (jsonElement.ValueKind != JsonValueKind.Array) if (jsonElement.ValueKind != JsonValueKind.Array)
@ -130,12 +128,12 @@ namespace Shared
Enum param; Enum param;
Tuple<Enum, string, string, object> tuple; Tuple<Enum, string, string, object> tuple;
JsonElement[] jsonElements = jsonElement.EnumerateArray().ToArray(); 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++) for (int r = i.Value; r < jsonElements.Length; r++)
{ {
foreach (JsonProperty jsonProperty in jsonElement[r].EnumerateObject()) 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; param = Param.StructuredType;
//jValue = jObject.Value<JValue>("Item1"); //jValue = jObject.Value<JValue>("Item1");
@ -143,25 +141,14 @@ namespace Shared
} }
else else
{ {
switch (jsonProperty.Value.ValueKind) param = jsonProperty.Value.ValueKind switch
{ {
case JsonValueKind.String: JsonValueKind.String => Param.String,
param = Param.String; JsonValueKind.Number => Param.Double,
break; JsonValueKind.True or JsonValueKind.False => Param.Boolean,
case JsonValueKind.Number: JsonValueKind.Null => Param.String,
param = Param.Double; _ => Param.StructuredType,
break; };
case JsonValueKind.True:
case JsonValueKind.False:
param = Param.Boolean;
break;
case JsonValueKind.Null:
param = Param.String;
break;
default:
param = Param.StructuredType;
break;
}
} }
tuple = new Tuple<Enum, string, string, object>(param, jsonProperty.Name, string.Empty, jsonProperty.Value.ToString()); tuple = new Tuple<Enum, string, string, object>(param, jsonProperty.Name, string.Empty, jsonProperty.Value.ToString());
if (!keyValuePairsCollection.ContainsKey(jsonProperty.Name)) if (!keyValuePairsCollection.ContainsKey(jsonProperty.Name))
@ -171,7 +158,7 @@ namespace Shared
if (!_UseCyclical) if (!_UseCyclical)
break; break;
} }
results = GetParameterValues(equipmentControl, keyValuePairsCollection); List<ParameterValue> results = GetParameterValues(equipmentControl, keyValuePairsCollection);
return results; return results;
} }
@ -187,6 +174,4 @@ namespace Shared
return result; return result;
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Shared namespace Shared;
{
public enum EquipmentType public enum EquipmentType
{ {
FileEquipment, FileEquipment,
SemiEquipment, SemiEquipment,
// //
@ -48,6 +47,4 @@
MET08XRDXPERTPROMRDXL_Monthly, MET08XRDXPERTPROMRDXL_Monthly,
MET08XRDXPERTPROMRDXL_Weekly, MET08XRDXPERTPROMRDXL_Weekly,
METBRXRAYJV7300L METBRXRAYJV7300L
}
} }

View File

@ -4,13 +4,11 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.Json; using System.Text.Json;
namespace Shared namespace Shared;
public interface IProcessData
{ {
public interface IProcessData
{
Tuple<string, JsonElement?, List<FileInfo>> GetResults(ILogic logic, ConfigDataBase configData, List<FileInfo> fileInfoCollection); Tuple<string, JsonElement?, List<FileInfo>> GetResults(ILogic logic, ConfigDataBase configData, List<FileInfo> fileInfoCollection);
}
} }

View File

@ -1,11 +1,10 @@
using Shared.Metrology; using Shared.Metrology;
using System.Collections.Generic; using System.Collections.Generic;
namespace Shared namespace Shared;
{
public interface IProcessDataDescription public interface IProcessDataDescription
{ {
int Test { get; set; } int Test { get; set; }
int Count { get; set; } int Count { get; set; }
@ -21,6 +20,4 @@ namespace Shared
List<string> GetParameterNames(ILogic logic, ConfigDataBase configDataBase); List<string> GetParameterNames(ILogic logic, ConfigDataBase configDataBase);
string GetEventDescription(); string GetEventDescription();
}
} }

View File

@ -1,10 +1,9 @@
using System; using System;
namespace Shared namespace Shared;
{
public interface IScopeInfo public interface IScopeInfo
{ {
Enum Enum { get; } Enum Enum { get; }
string HTML { get; } string HTML { get; }
@ -16,6 +15,4 @@ namespace Shared
string FileNameWithoutExtension { get; } string FileNameWithoutExtension { get; }
EquipmentType EquipmentType { get; } EquipmentType EquipmentType { get; }
}
} }

View File

@ -2,11 +2,10 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Shared namespace Shared;
{
public class IsEnvironment public class IsEnvironment
{ {
public enum Name public enum Name
{ {
@ -166,6 +165,4 @@ namespace Shared
return result; return result;
} }
}
} }

View File

@ -3,11 +3,10 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
namespace Shared namespace Shared;
{
public class Logistics public class Logistics
{ {
public object NullData { get; private set; } public object NullData { get; private set; }
public string JobID { get; private set; } //CellName public string JobID { get; private set; } //CellName
@ -54,7 +53,7 @@ namespace Shared
else else
{ {
string reportFullPathLower = fileInfo.FullName.ToLower(); 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)) if (reportFullPathLower.Contains(element.Key) || reportFullPathLower.Contains(element.Value))
{ {
@ -203,25 +202,13 @@ namespace Shared
} }
} }
public Logistics ShallowCopy() public Logistics ShallowCopy() => (Logistics)MemberwiseClone();
{
return (Logistics)MemberwiseClone();
}
private string DefaultMesEntity(DateTime dateTime) private string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
{
return string.Concat(dateTime.Ticks, "_MES_ENTITY");
}
internal string GetLotViaMostCommonMethod() internal string GetLotViaMostCommonMethod() => MID.Substring(0, MID.Length - 2);
{
return MID.Substring(0, MID.Length - 2);
}
internal string GetPocketNumberViaMostCommonMethod() internal string GetPocketNumberViaMostCommonMethod() => MID.Substring(MID.Length - 2);
{
return MID.Substring(MID.Length - 2);
}
internal void Update(string dateTime, string processJobID, string mid) internal void Update(string dateTime, string processJobID, string mid)
{ {
@ -240,6 +227,4 @@ namespace Shared
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>(); Logistics2 = new List<Logistics2>();
} }
}
} }

View File

@ -1,9 +1,9 @@
using System; using System;
namespace Shared namespace Shared;
public class Logistics2
{ {
public class Logistics2
{
public string MID { get; private set; } public string MID { get; private set; }
public string RunNumber { get; private set; } public string RunNumber { get; private set; }
@ -75,6 +75,4 @@ namespace Shared
} }
} }
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -7,11 +7,10 @@ using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace Shared.Metrology namespace Shared.Metrology;
{
public class ConfigDataBase public class ConfigDataBase
{ {
public bool UseCyclicalForDescription { get; protected set; } public bool UseCyclicalForDescription { get; protected set; }
public Dictionary<string, string> CellNames { get; protected set; } public Dictionary<string, string> CellNames { get; protected set; }
@ -54,27 +53,15 @@ namespace Shared.Metrology
_EquipmentConnection = null; _EquipmentConnection = null;
else else
_EquipmentConnection = equipmentTypeValue; _EquipmentConnection = equipmentTypeValue;
string suffix; string suffix = eventNameValue switch
switch (eventNameValue)
{ {
case EventName.FileRead: EventName.FileRead => string.Empty,
suffix = string.Empty; EventName.FileReadDaily => "_Daily",
break; EventName.FileReadWeekly => "_Weekly",
case EventName.FileReadDaily: EventName.FileReadMonthly => "_Monthly",
suffix = "_Daily"; EventName.FileReadVerification => "_Verification",
break; _ => throw new Exception(cellInstanceConnectionName),
case EventName.FileReadWeekly: };
suffix = "_Weekly";
break;
case EventName.FileReadMonthly:
suffix = "_Monthly";
break;
case EventName.FileReadVerification:
suffix = "_Verification";
break;
default:
throw new Exception(cellInstanceConnectionName);
}
string parameterizedModelObjectDefinitionTypeAppended = string.Concat(segments[0], suffix); string parameterizedModelObjectDefinitionTypeAppended = string.Concat(segments[0], suffix);
IsEvent = cellInstanceConnectionNameBase != parameterizedModelObjectDefinitionTypeAppended; IsEvent = cellInstanceConnectionNameBase != parameterizedModelObjectDefinitionTypeAppended;
_EventName = eventNameValue; _EventName = eventNameValue;
@ -182,7 +169,7 @@ namespace Shared.Metrology
public Dictionary<string, List<Tuple<Enum, string, string, object>>> GetParameterInfo(ILogic logic, bool allowNull) 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; string description;
Enum param; Enum param;
Tuple<Enum, string, string, object> tuple; Tuple<Enum, string, string, object> tuple;
@ -192,7 +179,7 @@ namespace Shared.Metrology
{ {
if (jsonProperty.Value.ValueKind == JsonValueKind.Null && !allowNull) if (jsonProperty.Value.ValueKind == JsonValueKind.Null && !allowNull)
throw new Exception(); 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; description = string.Empty;
param = Description.Param.StructuredType; param = Description.Param.StructuredType;
@ -201,25 +188,14 @@ namespace Shared.Metrology
} }
else else
{ {
switch (jsonProperty.Value.ValueKind) param = jsonProperty.Value.ValueKind switch
{ {
case JsonValueKind.String: JsonValueKind.String => Description.Param.String,
param = Description.Param.String; JsonValueKind.Number => Description.Param.Double,
break; JsonValueKind.True or JsonValueKind.False => Description.Param.Boolean,
case JsonValueKind.Number: JsonValueKind.Null => Description.Param.String,
param = Description.Param.Double; _ => Description.Param.StructuredType,
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;
}
} }
if (!keyValuePairs.ContainsKey(jsonProperty.Name)) if (!keyValuePairs.ContainsKey(jsonProperty.Name))
description = string.Empty; description = string.Empty;
@ -240,19 +216,19 @@ namespace Shared.Metrology
object value; object value;
Enum[] @params; Enum[] @params;
string description; string description;
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new();
string shareRoot = @"\\messv02ecc1.ec.local\EC_EDA"; string shareRoot = @"\\messv02ecc1.ec.local\EC_EDA";
string shareDirectory = string.Concat(shareRoot, @"\Staging\Pdsf\", cellName, @"\ExportAliases\", equipmentElementName); string shareDirectory = string.Concat(shareRoot, @"\Staging\Pdsf\", cellName, @"\ExportAliases\", equipmentElementName);
Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairs; Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairs;
if (!(logic is null)) if (logic is not null)
keyValuePairs = GetParameterInfo(logic, allowNull: false); keyValuePairs = GetParameterInfo(logic, allowNull: false);
else else
keyValuePairs = new Dictionary<string, List<Tuple<Enum, string, string, object>>>(); 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)) if (!Directory.Exists(shareRoot))
return; return;
if (!Directory.Exists(shareDirectory)) if (!Directory.Exists(shareDirectory))
Directory.CreateDirectory(shareDirectory); _ = Directory.CreateDirectory(shareDirectory);
string shareFile = string.Concat(shareDirectory, @"\", DateTime.Now.Ticks, ".csv"); string shareFile = string.Concat(shareDirectory, @"\", DateTime.Now.Ticks, ".csv");
foreach (KeyValuePair<string, List<Tuple<Enum, string, string, object>>> keyValuePair in keyValuePairs) 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) if (keyValuePair.Value[0].Item2 != keyValuePair.Key)
throw new Exception(); throw new Exception();
param = @params[0]; param = @params[0];
if (!(param is Description.Param.String)) if (param is not Description.Param.String)
stringBuilder.AppendLine($"\"{keyValuePair.Key}\";\"\";\"\";\"\";\"\";\"\";\"{i}\";\"{cellName}/{EquipmentElementName}/{keyValuePair.Key}\";\"\";\"{cellName}/{EquipmentElementName}/{EventName}\";\"\";\"True\""); _ = stringBuilder.AppendLine($"\"{keyValuePair.Key}\";\"\";\"\";\"\";\"\";\"\";\"{i}\";\"{cellName}/{EquipmentElementName}/{keyValuePair.Key}\";\"\";\"{cellName}/{EquipmentElementName}/{EventName}\";\"\";\"True\"");
else else
{ {
description = keyValuePair.Value[0].Item3.Split('|')[0]; description = keyValuePair.Value[0].Item3.Split('|')[0];
if (string.IsNullOrEmpty(description)) if (string.IsNullOrEmpty(description))
continue; continue;
value = keyValuePair.Value[0].Item4; 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()) if (keyValuePairs.Any())
@ -280,7 +256,7 @@ namespace Shared.Metrology
public Dictionary<string, string> GetDisplayNamesJsonElement(ILogic logic) 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); IProcessDataDescription processDataDescription = ProcessDataDescription.GetDisplayNames(logic, this);
string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType()); string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType());
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json); JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
@ -304,11 +280,11 @@ namespace Shared.Metrology
IProcessDataDescription processDataDescription = ProcessDataDescription.GetDisplayNames(logic, this); IProcessDataDescription processDataDescription = ProcessDataDescription.GetDisplayNames(logic, this);
string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType()); string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType());
object @object = JsonSerializer.Deserialize<object>(json); object @object = JsonSerializer.Deserialize<object>(json);
if (!(@object is JsonElement jsonElement)) if (@object is not JsonElement jsonElement)
throw new Exception(); throw new Exception();
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject()) 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(); throw new Exception();
value = jsonProperty.Value.ToString(); value = jsonProperty.Value.ToString();
if (!results.Contains(jsonProperty.Name) && pairedParameterNames.Contains(jsonProperty.Name) && (string.IsNullOrEmpty(value) || value[0] == '|')) 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; List<Duplicator.Description> results;
if (jsonElement.ValueKind != JsonValueKind.Array) if (jsonElement.ValueKind != JsonValueKind.Array)
throw new Exception(); 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); results = JsonSerializer.Deserialize<List<Duplicator.Description>>(jsonElement.ToString(), jsonSerializerOptions);
return results; return results;
} }
public Dictionary<Test, List<Duplicator.Description>> GetKeyValuePairs(List<Duplicator.Description> processDataDescriptions) 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; Test testKey;
for (int i = 0; i < processDataDescriptions.Count; i++) 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) 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; Test testKey;
if (jsonElement.ValueKind != JsonValueKind.Array) if (jsonElement.ValueKind != JsonValueKind.Array)
throw new Exception(); throw new Exception();
@ -358,7 +335,7 @@ namespace Shared.Metrology
continue; continue;
foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject()) 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(); throw new Exception();
if (!results.ContainsKey(jsonProperty.Name)) if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, new List<string>()); results.Add(jsonProperty.Name, new List<string>());
@ -379,7 +356,7 @@ namespace Shared.Metrology
{ {
if (jsonProperty.Value.ValueKind == JsonValueKind.Null && !allowNull) if (jsonProperty.Value.ValueKind == JsonValueKind.Null && !allowNull)
throw new Exception(); 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; description = string.Empty;
else else
description = keyValuePairs[jsonProperty.Name].Split('|')[0]; description = keyValuePairs[jsonProperty.Name].Split('|')[0];
@ -388,23 +365,22 @@ namespace Shared.Metrology
public List<IProcessDataDescription> GetIProcessDataDescriptions(JsonElement jsonElement) public List<IProcessDataDescription> GetIProcessDataDescriptions(JsonElement jsonElement)
{ {
List<IProcessDataDescription> results = new List<IProcessDataDescription>(); List<IProcessDataDescription> results = new();
if (jsonElement.ValueKind != JsonValueKind.Array) if (jsonElement.ValueKind != JsonValueKind.Array)
throw new Exception(); throw new Exception();
object @object; object @object;
Type type = ProcessDataDescription.GetType(); Type type = ProcessDataDescription.GetType();
JsonElement[] jsonElements = jsonElement.EnumerateArray().ToArray(); 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++) for (int i = 0; i < jsonElements.Length; i++)
{ {
@object = JsonSerializer.Deserialize(jsonElements[i].ToString(), type, jsonSerializerOptions); @object = JsonSerializer.Deserialize(jsonElements[i].ToString(), type, jsonSerializerOptions);
if (!(@object is IProcessDataDescription processDataDescription)) if (@object is not IProcessDataDescription processDataDescription)
continue; continue;
results.Add(processDataDescription); results.Add(processDataDescription);
} }
return results; return results;
} }
}
} }

View File

@ -1,13 +1,10 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public enum EventName public enum EventName
{ {
FileRead, FileRead,
FileReadDaily, FileReadDaily,
FileReadMonthly, FileReadMonthly,
FileReadVerification, FileReadVerification,
FileReadWeekly FileReadWeekly
}
} }

View File

@ -6,11 +6,10 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.Json; using System.Text.Json;
namespace Shared.Metrology namespace Shared.Metrology;
{
public interface ILogic public interface ILogic
{ {
ILogic ShallowCopy(); ILogic ShallowCopy();
Logistics Logistics { get; } Logistics Logistics { get; }
@ -28,7 +27,7 @@ namespace Shared.Metrology
object GetFilePathGeneratorInfo(string reportFullPath, bool isErrorFile); object GetFilePathGeneratorInfo(string reportFullPath, bool isErrorFile);
string GetReportFullPath(Dictionary<string, object> keyValuePairs); string GetReportFullPath(Dictionary<string, object> keyValuePairs);
string GetTarget2FileLocation(); 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); string ReExtract(string searchDirectory, string sourceFileFilter);
void ReflectionCreateSelfDescription(string equipmentElementName, int? input, string cellName, string debugConfig, string[] strings, bool[] booleans, long[] numbers, string[] enums); void ReflectionCreateSelfDescription(string equipmentElementName, int? input, string cellName, string debugConfig, string[] strings, bool[] booleans, long[] numbers, string[] enums);
ConfigDataBase ReflectionCreateSelfDescriptionV2(string json); ConfigDataBase ReflectionCreateSelfDescriptionV2(string json);
@ -43,6 +42,4 @@ namespace Shared.Metrology
void SetPlaceHolder(string reportFullPath, string key, string value); void SetPlaceHolder(string reportFullPath, string key, string value);
void SetTarget2FileLocation(string value); void SetTarget2FileLocation(string value);
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08AFMD3100 public class MET08AFMD3100
{ {
public enum Test public enum Test
{ {
AFMRoughness = Metrology.Test.AFMRoughness AFMRoughness = Metrology.Test.AFMRoughness
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08BVHGPROBE public class MET08BVHGPROBE
{ {
public enum Test public enum Test
{ {
@ -11,6 +10,4 @@
BreakdownVoltageMiddle8in = Metrology.Test.BreakdownVoltageMiddle8in BreakdownVoltageMiddle8in = Metrology.Test.BreakdownVoltageMiddle8in
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08CVHGPROBE802B150 public class MET08CVHGPROBE802B150
{ {
public enum Test public enum Test
{ {
@ -11,6 +10,4 @@
WeeklyCV = Metrology.Test.WeeklyCV WeeklyCV = Metrology.Test.WeeklyCV
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08DDINCAN8620 public class MET08DDINCAN8620
{ {
public enum Test public enum Test
{ {
@ -13,6 +12,4 @@
CandelaProdU = Metrology.Test.CandelaProdU CandelaProdU = Metrology.Test.CandelaProdU
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08DDUPSFS6420 public class MET08DDUPSFS6420
{ {
public enum Test public enum Test
{ {
Tencor = Metrology.Test.Tencor Tencor = Metrology.Test.Tencor
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08DDUPSP1TBI public class MET08DDUPSP1TBI
{ {
public enum Test public enum Test
{ {
SP1 = Metrology.Test.SP1 SP1 = Metrology.Test.SP1
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08EBEAMINTEGRITY26 public class MET08EBEAMINTEGRITY26
{ {
public enum Test public enum Test
{ {
Denton = Metrology.Test.Denton Denton = Metrology.Test.Denton
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08HALLHL5580 public class MET08HALLHL5580
{ {
public enum Test public enum Test
{ {
@ -11,6 +10,4 @@
WeeklyHall = Metrology.Test.WeeklyHall WeeklyHall = Metrology.Test.WeeklyHall
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08MESMICROSCOPE public class MET08MESMICROSCOPE
{ {
public enum Test public enum Test
{ {
Microscope = Metrology.Test.Microscope Microscope = Metrology.Test.Microscope
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08NDFRESIMAP151C public class MET08NDFRESIMAP151C
{ {
public enum Test public enum Test
{ {
@ -10,6 +9,4 @@
VerificationLehighton = Metrology.Test.VerificationLehighton VerificationLehighton = Metrology.Test.VerificationLehighton
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08PLMAPRPM public class MET08PLMAPRPM
{ {
public enum Test public enum Test
{ {
@ -15,6 +14,4 @@
VerificationRPM = Metrology.Test.VerificationRPM VerificationRPM = Metrology.Test.VerificationRPM
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08PRFUSB4000 public class MET08PRFUSB4000
{ {
public enum Test public enum Test
{ {
Photoreflectance = Metrology.Test.Photoreflectance Photoreflectance = Metrology.Test.Photoreflectance
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08RESIHGCV public class MET08RESIHGCV
{ {
public enum Test public enum Test
{ {
HgCV = Metrology.Test.HgCV HgCV = Metrology.Test.HgCV
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08RESIMAPCDE public class MET08RESIMAPCDE
{ {
public enum Test public enum Test
{ {
CDE = Metrology.Test.CDE CDE = Metrology.Test.CDE
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08THFTIRQS408M public class MET08THFTIRQS408M
{ {
public enum Test public enum Test
{ {
BioRadQS408M = Metrology.Test.BioRadQS408M BioRadQS408M = Metrology.Test.BioRadQS408M
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08THFTIRSTRATUS public class MET08THFTIRSTRATUS
{ {
public enum Test public enum Test
{ {
BioRadStratus = Metrology.Test.BioRadStratus BioRadStratus = Metrology.Test.BioRadStratus
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08UVH44GS100M public class MET08UVH44GS100M
{ {
public enum Test public enum Test
{ {
UV = Metrology.Test.UV UV = Metrology.Test.UV
} }
}
} }

View File

@ -1,14 +1,11 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08VPDSUBCON public class MET08VPDSUBCON
{ {
public enum Test public enum Test
{ {
VpdIcpmsAnalyte = Metrology.Test.VpdIcpmsAnalyte VpdIcpmsAnalyte = Metrology.Test.VpdIcpmsAnalyte
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Shared.Metrology namespace Shared.Metrology;
{
public class MET08WGEOMX203641Q public class MET08WGEOMX203641Q
{ {
public enum Test public enum Test
{ {
@ -10,6 +9,4 @@
VerificationWarpAndBow = Metrology.Test.VerificationWarpAndBow VerificationWarpAndBow = Metrology.Test.VerificationWarpAndBow
} }
}
} }

Some files were not shown because too many files have changed in this diff Show More