Add MonIn Send Status
This commit is contained in:
parent
672b439864
commit
f36ad1ae5e
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -2,5 +2,6 @@
|
||||
"cSpell.enabled": false,
|
||||
"files.exclude": {
|
||||
"**/.git": false
|
||||
}
|
||||
},
|
||||
"coverage-gutters.coverageBaseDir": "../.vscode/TestResults/*"
|
||||
}
|
@ -29,6 +29,9 @@
|
||||
<PackageReference Include="jQuery" Version="3.6.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Infineon.Monitoring.MonA;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OI.Metrology.Archive.Models;
|
||||
@ -17,11 +18,13 @@ public class ExportController : Controller
|
||||
private readonly ILogger _Logger;
|
||||
private readonly bool _IsTestDatabase;
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly AppSettings _AppSettings;
|
||||
|
||||
public ExportController(AppSettings appSettings, ILogger<ExportController> logger, IMetrologyRepo repo)
|
||||
{
|
||||
_Repo = repo;
|
||||
_Logger = logger;
|
||||
_AppSettings = appSettings;
|
||||
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
@ -41,6 +44,8 @@ public class ExportController : Controller
|
||||
StartTime = DateTime.Now.AddMonths(-1),
|
||||
EndTime = DateTime.Now
|
||||
};
|
||||
MonIn monIn = MonIn.GetInstance();
|
||||
_ = monIn.SendStatus(_AppSettings.MonASite, _AppSettings.MonAResource, "Heartbeat", State.Up);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
@ -6,49 +6,38 @@ namespace OI.Metrology.Archive.Models;
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
protected string _ApiLoggingContentTypes;
|
||||
protected string _ApiLoggingPathPrefixes;
|
||||
protected string _ApiLogPath;
|
||||
protected string _AttachmentPath;
|
||||
protected string _BuildNumber;
|
||||
protected string _Company;
|
||||
protected string _ConnectionString;
|
||||
protected string _GitCommitSeven;
|
||||
protected string _InboundApiAllowedIPList;
|
||||
protected string _MonARessource;
|
||||
protected string _OIExportPath;
|
||||
protected string _URLs;
|
||||
protected string _WorkingDirectoryName;
|
||||
public string ApiLoggingContentTypes => _ApiLoggingContentTypes;
|
||||
public string ApiLoggingPathPrefixes => _ApiLoggingPathPrefixes;
|
||||
public string ApiLogPath => _ApiLogPath;
|
||||
public string AttachmentPath => _AttachmentPath;
|
||||
public string BuildNumber => _BuildNumber;
|
||||
public string Company => _Company;
|
||||
public string ConnectionString => _ConnectionString;
|
||||
public string GitCommitSeven => _GitCommitSeven;
|
||||
public string InboundApiAllowedIPList => _InboundApiAllowedIPList;
|
||||
public string MonARessource => _MonARessource;
|
||||
public string OIExportPath => _OIExportPath;
|
||||
public string URLs => _URLs;
|
||||
public string WorkingDirectoryName => _WorkingDirectoryName;
|
||||
public string ApiLoggingContentTypes { init; get; }
|
||||
public string ApiLoggingPathPrefixes { init; get; }
|
||||
public string ApiLogPath { init; get; }
|
||||
public string AttachmentPath { init; get; }
|
||||
public string BuildNumber { init; get; }
|
||||
public string Company { init; get; }
|
||||
public string ConnectionString { init; get; }
|
||||
public string GitCommitSeven { init; get; }
|
||||
public string InboundApiAllowedIPList { init; get; }
|
||||
public string MonAResource { init; get; }
|
||||
public string MonASite { init; get; }
|
||||
public string OIExportPath { init; get; }
|
||||
public string URLs { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string apiLoggingContentTypes, string apiLoggingPathPrefixes, string apiLogPath, string attachmentPath, string buildNumber, string company, string connectionString, string gitCommitSeven, string inboundApiAllowedIPList, string monARessource, string oiExportPath, string urls, string workingDirectoryName)
|
||||
public AppSettings(string apiLoggingContentTypes, string apiLoggingPathPrefixes, string apiLogPath, string attachmentPath, string buildNumber, string company, string connectionString, string gitCommitSeven, string inboundApiAllowedIPList, string monAResource, string monASite, string oiExportPath, string urls, string workingDirectoryName)
|
||||
{
|
||||
_ApiLoggingContentTypes = apiLoggingContentTypes;
|
||||
_ApiLoggingPathPrefixes = apiLoggingPathPrefixes;
|
||||
_ApiLogPath = apiLogPath;
|
||||
_AttachmentPath = attachmentPath;
|
||||
_BuildNumber = buildNumber;
|
||||
_Company = company;
|
||||
_ConnectionString = connectionString;
|
||||
_GitCommitSeven = gitCommitSeven;
|
||||
_InboundApiAllowedIPList = inboundApiAllowedIPList;
|
||||
_MonARessource = monARessource;
|
||||
_OIExportPath = oiExportPath;
|
||||
_URLs = urls;
|
||||
_WorkingDirectoryName = workingDirectoryName;
|
||||
ApiLoggingContentTypes = apiLoggingContentTypes;
|
||||
ApiLoggingPathPrefixes = apiLoggingPathPrefixes;
|
||||
ApiLogPath = apiLogPath;
|
||||
AttachmentPath = attachmentPath;
|
||||
BuildNumber = buildNumber;
|
||||
Company = company;
|
||||
ConnectionString = connectionString;
|
||||
GitCommitSeven = gitCommitSeven;
|
||||
InboundApiAllowedIPList = inboundApiAllowedIPList;
|
||||
MonAResource = monAResource;
|
||||
MonASite = monASite;
|
||||
OIExportPath = oiExportPath;
|
||||
URLs = urls;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@ -1,3 +1,4 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
@ -6,6 +7,8 @@ namespace OI.Metrology.Archive.Models.Binder;
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Display(Name = "Api Logging Content Types"), Required] public string ApiLoggingContentTypes { get; set; }
|
||||
[Display(Name = "Api Logging Path Prefixes"), Required] public string ApiLoggingPathPrefixes { get; set; }
|
||||
[Display(Name = "Api Log Path"), Required] public string ApiLogPath { get; set; }
|
||||
@ -15,27 +18,13 @@ public class AppSettings
|
||||
[Display(Name = "Connection String"), Required] public string ConnectionString { get; set; }
|
||||
[Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; }
|
||||
[Display(Name = "Inbound Api Allowed IP List"), Required] public string InboundApiAllowedIPList { get; set; }
|
||||
[Display(Name = "MonA Ressource"), Required] public string MonARessource { get; set; }
|
||||
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
||||
[Display(Name = "MonA Site"), Required] public string MonASite { get; set; }
|
||||
[Display(Name = "OI Export Path"), Required] public string OIExportPath { get; set; }
|
||||
[Display(Name = "URLs"), Required] public string URLs { get; set; }
|
||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||
|
||||
public AppSettings()
|
||||
{
|
||||
ApiLoggingContentTypes = string.Empty;
|
||||
ApiLoggingPathPrefixes = string.Empty;
|
||||
ApiLogPath = string.Empty;
|
||||
AttachmentPath = string.Empty;
|
||||
BuildNumber = string.Empty;
|
||||
Company = string.Empty;
|
||||
ConnectionString = string.Empty;
|
||||
GitCommitSeven = string.Empty;
|
||||
InboundApiAllowedIPList = string.Empty;
|
||||
MonARessource = string.Empty;
|
||||
OIExportPath = string.Empty;
|
||||
URLs = string.Empty;
|
||||
WorkingDirectoryName = string.Empty;
|
||||
}
|
||||
#nullable restore
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
@ -43,4 +32,33 @@ public class AppSettings
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Models.AppSettings Get(AppSettings appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
result = new(
|
||||
appSettings.ApiLoggingContentTypes,
|
||||
appSettings.ApiLoggingPathPrefixes,
|
||||
appSettings.ApiLogPath,
|
||||
appSettings.AttachmentPath,
|
||||
appSettings.BuildNumber,
|
||||
appSettings.Company,
|
||||
appSettings.ConnectionString,
|
||||
appSettings.GitCommitSeven,
|
||||
appSettings.InboundApiAllowedIPList,
|
||||
appSettings.MonAResource,
|
||||
appSettings.MonASite,
|
||||
appSettings.OIExportPath,
|
||||
appSettings.URLs,
|
||||
appSettings.WorkingDirectoryName);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
AppSettings appSettings = configurationRoot.Get<AppSettings>();
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace OI.Metrology.Archive.Models.Stateless;
|
||||
|
||||
public abstract class AppSettings
|
||||
{
|
||||
|
||||
#nullable enable
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings? result;
|
||||
Binder.AppSettings appSettings = configurationRoot.Get<Binder.AppSettings>();
|
||||
string json = JsonSerializer.Serialize(appSettings, new JsonSerializerOptions() { WriteIndented = true });
|
||||
result = JsonSerializer.Deserialize<Models.AppSettings>(json);
|
||||
if (result is null)
|
||||
throw new Exception(json);
|
||||
if (string.IsNullOrEmpty(result.Company))
|
||||
throw new Exception(json);
|
||||
string jsonThis = result.ToString();
|
||||
if (jsonThis != json)
|
||||
{
|
||||
int? check = null;
|
||||
int min = new int[] { json.Length, jsonThis.Length }.Min();
|
||||
for (int i = 0; i < min; i++)
|
||||
{
|
||||
if (json[i] == jsonThis[i])
|
||||
continue;
|
||||
check = i;
|
||||
break;
|
||||
}
|
||||
if (check is null)
|
||||
throw new Exception();
|
||||
string a = json[..check.Value].Split(',')[^1];
|
||||
string b = json[check.Value..].Split(',')[0];
|
||||
throw new Exception($"{a}{b}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -50,7 +50,7 @@ public class Program
|
||||
(string assemblyName, WebApplicationOptions _) = Get(args);
|
||||
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
|
||||
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
|
||||
AppSettings appSettings = Models.Stateless.AppSettings.Get(webApplicationBuilder.Configuration);
|
||||
AppSettings appSettings = Models.Binder.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);
|
||||
|
@ -17,6 +17,8 @@
|
||||
}
|
||||
},
|
||||
"InboundApiAllowedIPList": "",
|
||||
"MonAResource": "OI_Metrology_Archive_IFX",
|
||||
"MonASite": "sjc",
|
||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
|
@ -16,7 +16,9 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"MonAResource": "OI_Metrology_Archive_EC",
|
||||
"InboundApiAllowedIPList": "",
|
||||
"MonASite": "sjc",
|
||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
|
@ -27,3 +27,9 @@ Ouellette Jonathan (IFAM IT FI MES) created #315807, 7/25/2022
|
||||
## TFS / Azure DevOps - Pipelines
|
||||
* https://tfs.intra.infineon.com/tfs/manufacturingit/Mesa_FI/_build?definitionId=5439&_a=summary
|
||||
* https://tfs.intra.infineon.com/tfs/manufacturingit/Mesa_FI/_release?_a=releases&view=mine&definitionId=1
|
||||
|
||||
4c07c49f3b9daa69fecd9d5be64e047d0ad6be1d
|
||||
343ff2d792149c9eef1216f44dbdb73935cf6041
|
||||
|
||||
https://oi-metrology-viewer-prod.mes.infineon.com/
|
||||
https://oi-metrology-viewer-archive.mes.infineon.com/
|
@ -6,49 +6,38 @@ namespace OI.Metrology.Tests.Models;
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
protected string _ApiLoggingContentTypes;
|
||||
protected string _ApiLoggingPathPrefixes;
|
||||
protected string _ApiLogPath;
|
||||
protected string _AttachmentPath;
|
||||
protected string _BuildNumber;
|
||||
protected string _Company;
|
||||
protected string _ConnectionString;
|
||||
protected string _GitCommitSeven;
|
||||
protected string _InboundApiAllowedIPList;
|
||||
protected string _MonARessource;
|
||||
protected string _OIExportPath;
|
||||
protected string _URLs;
|
||||
protected string _WorkingDirectoryName;
|
||||
public string ApiLoggingContentTypes => _ApiLoggingContentTypes;
|
||||
public string ApiLoggingPathPrefixes => _ApiLoggingPathPrefixes;
|
||||
public string ApiLogPath => _ApiLogPath;
|
||||
public string AttachmentPath => _AttachmentPath;
|
||||
public string BuildNumber => _BuildNumber;
|
||||
public string Company => _Company;
|
||||
public string ConnectionString => _ConnectionString;
|
||||
public string GitCommitSeven => _GitCommitSeven;
|
||||
public string InboundApiAllowedIPList => _InboundApiAllowedIPList;
|
||||
public string MonARessource => _MonARessource;
|
||||
public string OIExportPath => _OIExportPath;
|
||||
public string URLs => _URLs;
|
||||
public string WorkingDirectoryName => _WorkingDirectoryName;
|
||||
public string ApiLoggingContentTypes { init; get; }
|
||||
public string ApiLoggingPathPrefixes { init; get; }
|
||||
public string ApiLogPath { init; get; }
|
||||
public string AttachmentPath { init; get; }
|
||||
public string BuildNumber { init; get; }
|
||||
public string Company { init; get; }
|
||||
public string ConnectionString { init; get; }
|
||||
public string GitCommitSeven { init; get; }
|
||||
public string InboundApiAllowedIPList { init; get; }
|
||||
public string MonAResource { init; get; }
|
||||
public string MonASite { init; get; }
|
||||
public string OIExportPath { init; get; }
|
||||
public string URLs { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string apiLoggingContentTypes, string apiLoggingPathPrefixes, string apiLogPath, string attachmentPath, string buildNumber, string company, string connectionString, string gitCommitSeven, string inboundApiAllowedIPList, string monARessource, string oiExportPath, string urls, string workingDirectoryName)
|
||||
public AppSettings(string apiLoggingContentTypes, string apiLoggingPathPrefixes, string apiLogPath, string attachmentPath, string buildNumber, string company, string connectionString, string gitCommitSeven, string inboundApiAllowedIPList, string monAResource, string monASite, string oiExportPath, string urls, string workingDirectoryName)
|
||||
{
|
||||
_ApiLoggingContentTypes = apiLoggingContentTypes;
|
||||
_ApiLoggingPathPrefixes = apiLoggingPathPrefixes;
|
||||
_ApiLogPath = apiLogPath;
|
||||
_AttachmentPath = attachmentPath;
|
||||
_BuildNumber = buildNumber;
|
||||
_Company = company;
|
||||
_ConnectionString = connectionString;
|
||||
_GitCommitSeven = gitCommitSeven;
|
||||
_InboundApiAllowedIPList = inboundApiAllowedIPList;
|
||||
_MonARessource = monARessource;
|
||||
_OIExportPath = oiExportPath;
|
||||
_URLs = urls;
|
||||
_WorkingDirectoryName = workingDirectoryName;
|
||||
ApiLoggingContentTypes = apiLoggingContentTypes;
|
||||
ApiLoggingPathPrefixes = apiLoggingPathPrefixes;
|
||||
ApiLogPath = apiLogPath;
|
||||
AttachmentPath = attachmentPath;
|
||||
BuildNumber = buildNumber;
|
||||
Company = company;
|
||||
ConnectionString = connectionString;
|
||||
GitCommitSeven = gitCommitSeven;
|
||||
InboundApiAllowedIPList = inboundApiAllowedIPList;
|
||||
MonAResource = monAResource;
|
||||
MonASite = monASite;
|
||||
OIExportPath = oiExportPath;
|
||||
URLs = urls;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@ -1,3 +1,4 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
@ -6,6 +7,8 @@ namespace OI.Metrology.Tests.Models.Binder;
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Display(Name = "Api Logging Content Types"), Required] public string ApiLoggingContentTypes { get; set; }
|
||||
[Display(Name = "Api Logging Path Prefixes"), Required] public string ApiLoggingPathPrefixes { get; set; }
|
||||
[Display(Name = "Api Log Path"), Required] public string ApiLogPath { get; set; }
|
||||
@ -15,27 +18,13 @@ public class AppSettings
|
||||
[Display(Name = "Connection String"), Required] public string ConnectionString { get; set; }
|
||||
[Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; }
|
||||
[Display(Name = "Inbound Api Allowed IP List"), Required] public string InboundApiAllowedIPList { get; set; }
|
||||
[Display(Name = "MonA Ressource"), Required] public string MonARessource { get; set; }
|
||||
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
||||
[Display(Name = "MonA Site"), Required] public string MonASite { get; set; }
|
||||
[Display(Name = "OI Export Path"), Required] public string OIExportPath { get; set; }
|
||||
[Display(Name = "URLs"), Required] public string URLs { get; set; }
|
||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||
|
||||
public AppSettings()
|
||||
{
|
||||
ApiLoggingContentTypes = string.Empty;
|
||||
ApiLoggingPathPrefixes = string.Empty;
|
||||
ApiLogPath = string.Empty;
|
||||
AttachmentPath = string.Empty;
|
||||
BuildNumber = string.Empty;
|
||||
Company = string.Empty;
|
||||
ConnectionString = string.Empty;
|
||||
GitCommitSeven = string.Empty;
|
||||
InboundApiAllowedIPList = string.Empty;
|
||||
MonARessource = string.Empty;
|
||||
OIExportPath = string.Empty;
|
||||
URLs = string.Empty;
|
||||
WorkingDirectoryName = string.Empty;
|
||||
}
|
||||
#nullable restore
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
@ -43,4 +32,33 @@ public class AppSettings
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Models.AppSettings Get(AppSettings appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
result = new(
|
||||
appSettings.ApiLoggingContentTypes,
|
||||
appSettings.ApiLoggingPathPrefixes,
|
||||
appSettings.ApiLogPath,
|
||||
appSettings.AttachmentPath,
|
||||
appSettings.BuildNumber,
|
||||
appSettings.Company,
|
||||
appSettings.ConnectionString,
|
||||
appSettings.GitCommitSeven,
|
||||
appSettings.InboundApiAllowedIPList,
|
||||
appSettings.MonAResource,
|
||||
appSettings.MonASite,
|
||||
appSettings.OIExportPath,
|
||||
appSettings.URLs,
|
||||
appSettings.WorkingDirectoryName);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
AppSettings appSettings = configurationRoot.Get<AppSettings>();
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace OI.Metrology.Tests.Models.Stateless;
|
||||
|
||||
public abstract class AppSettings
|
||||
{
|
||||
|
||||
#nullable enable
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings? result;
|
||||
Binder.AppSettings appSettings = configurationRoot.Get<Binder.AppSettings>();
|
||||
string json = JsonSerializer.Serialize(appSettings, new JsonSerializerOptions() { WriteIndented = true });
|
||||
result = JsonSerializer.Deserialize<Models.AppSettings>(json);
|
||||
if (result is null)
|
||||
throw new Exception(json);
|
||||
if (string.IsNullOrEmpty(result.Company))
|
||||
throw new Exception(json);
|
||||
string jsonThis = result.ToString();
|
||||
if (jsonThis != json)
|
||||
{
|
||||
int? check = null;
|
||||
int min = new int[] { json.Length, jsonThis.Length }.Min();
|
||||
for (int i = 0; i < min; i++)
|
||||
{
|
||||
if (json[i] == jsonThis[i])
|
||||
continue;
|
||||
check = i;
|
||||
break;
|
||||
}
|
||||
if (check is null)
|
||||
throw new Exception();
|
||||
string a = json[..check.Value].Split(',')[^1];
|
||||
string b = json[check.Value..].Split(',')[0];
|
||||
throw new Exception($"{a}{b}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,11 @@
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VSTestLogger>trx</VSTestLogger>
|
||||
<VSTestCollect>XPlat Code Coverage</VSTestCollect>
|
||||
<VSTestResultsDirectory>../.vscode/TestResults</VSTestResultsDirectory>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
|
||||
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
|
||||
|
@ -1,8 +1,8 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using OI.Metrology.Shared.Models;
|
||||
using OI.Metrology.Tests.Models;
|
||||
using Serilog;
|
||||
using System.Reflection;
|
||||
using OI.Metrology.Tests.Models;
|
||||
using OI.Metrology.Shared.Models;
|
||||
|
||||
namespace View_by_Distance.Tests;
|
||||
|
||||
@ -27,7 +27,7 @@ public class UnitTestArchive
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile("appsettings.Development.json");
|
||||
configurationRoot = configurationBuilder.Build();
|
||||
appSettings = OI.Metrology.Tests.Models.Stateless.AppSettings.Get(configurationRoot);
|
||||
appSettings = OI.Metrology.Tests.Models.Binder.AppSettings.Get(configurationRoot);
|
||||
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
|
||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
|
||||
|
@ -1,8 +1,8 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using OI.Metrology.Shared.Models;
|
||||
using OI.Metrology.Tests.Models;
|
||||
using Serilog;
|
||||
using System.Reflection;
|
||||
using OI.Metrology.Tests.Models;
|
||||
using OI.Metrology.Shared.Models;
|
||||
|
||||
namespace View_by_Distance.Tests;
|
||||
|
||||
@ -27,7 +27,7 @@ public class UnitTestExample
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile("appsettings.Development.json");
|
||||
configurationRoot = configurationBuilder.Build();
|
||||
appSettings = OI.Metrology.Tests.Models.Stateless.AppSettings.Get(configurationRoot);
|
||||
appSettings = OI.Metrology.Tests.Models.Binder.AppSettings.Get(configurationRoot);
|
||||
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
|
||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
|
||||
|
@ -17,6 +17,7 @@
|
||||
}
|
||||
},
|
||||
"InboundApiAllowedIPList": "",
|
||||
"MonASite": "sjc",
|
||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
|
@ -17,6 +17,7 @@
|
||||
}
|
||||
},
|
||||
"InboundApiAllowedIPList": "",
|
||||
"MonASite": "sjc",
|
||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Infineon.Monitoring.MonA;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
@ -17,11 +18,13 @@ public class ExportController : Controller
|
||||
private readonly ILogger _Logger;
|
||||
private readonly bool _IsTestDatabase;
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly AppSettings _AppSettings;
|
||||
|
||||
public ExportController(AppSettings appSettings, ILogger<ExportController> logger, IMetrologyRepo repo)
|
||||
{
|
||||
_Repo = repo;
|
||||
_Logger = logger;
|
||||
_AppSettings = appSettings;
|
||||
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
@ -40,6 +43,8 @@ public class ExportController : Controller
|
||||
StartTime = DateTime.Now.AddMonths(-1),
|
||||
EndTime = DateTime.Now
|
||||
};
|
||||
MonIn monIn = MonIn.GetInstance();
|
||||
_ = monIn.SendStatus(_AppSettings.MonASite, _AppSettings.MonAResource, "Heartbeat", State.Up);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
@ -6,49 +6,38 @@ namespace OI.Metrology.Viewer.Models;
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
protected string _ApiLoggingContentTypes;
|
||||
protected string _ApiLoggingPathPrefixes;
|
||||
protected string _ApiLogPath;
|
||||
protected string _AttachmentPath;
|
||||
protected string _BuildNumber;
|
||||
protected string _Company;
|
||||
protected string _ConnectionString;
|
||||
protected string _GitCommitSeven;
|
||||
protected string _InboundApiAllowedIPList;
|
||||
protected string _MonARessource;
|
||||
protected string _OIExportPath;
|
||||
protected string _URLs;
|
||||
protected string _WorkingDirectoryName;
|
||||
public string ApiLoggingContentTypes => _ApiLoggingContentTypes;
|
||||
public string ApiLoggingPathPrefixes => _ApiLoggingPathPrefixes;
|
||||
public string ApiLogPath => _ApiLogPath;
|
||||
public string AttachmentPath => _AttachmentPath;
|
||||
public string BuildNumber => _BuildNumber;
|
||||
public string Company => _Company;
|
||||
public string ConnectionString => _ConnectionString;
|
||||
public string GitCommitSeven => _GitCommitSeven;
|
||||
public string InboundApiAllowedIPList => _InboundApiAllowedIPList;
|
||||
public string MonARessource => _MonARessource;
|
||||
public string OIExportPath => _OIExportPath;
|
||||
public string URLs => _URLs;
|
||||
public string WorkingDirectoryName => _WorkingDirectoryName;
|
||||
public string ApiLoggingContentTypes { init; get; }
|
||||
public string ApiLoggingPathPrefixes { init; get; }
|
||||
public string ApiLogPath { init; get; }
|
||||
public string AttachmentPath { init; get; }
|
||||
public string BuildNumber { init; get; }
|
||||
public string Company { init; get; }
|
||||
public string ConnectionString { init; get; }
|
||||
public string GitCommitSeven { init; get; }
|
||||
public string InboundApiAllowedIPList { init; get; }
|
||||
public string MonAResource { init; get; }
|
||||
public string MonASite { init; get; }
|
||||
public string OIExportPath { init; get; }
|
||||
public string URLs { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string apiLoggingContentTypes, string apiLoggingPathPrefixes, string apiLogPath, string attachmentPath, string buildNumber, string company, string connectionString, string gitCommitSeven, string inboundApiAllowedIPList, string monARessource, string oiExportPath, string urls, string workingDirectoryName)
|
||||
public AppSettings(string apiLoggingContentTypes, string apiLoggingPathPrefixes, string apiLogPath, string attachmentPath, string buildNumber, string company, string connectionString, string gitCommitSeven, string inboundApiAllowedIPList, string monAResource, string monASite, string oiExportPath, string urls, string workingDirectoryName)
|
||||
{
|
||||
_ApiLoggingContentTypes = apiLoggingContentTypes;
|
||||
_ApiLoggingPathPrefixes = apiLoggingPathPrefixes;
|
||||
_ApiLogPath = apiLogPath;
|
||||
_AttachmentPath = attachmentPath;
|
||||
_BuildNumber = buildNumber;
|
||||
_Company = company;
|
||||
_ConnectionString = connectionString;
|
||||
_GitCommitSeven = gitCommitSeven;
|
||||
_InboundApiAllowedIPList = inboundApiAllowedIPList;
|
||||
_MonARessource = monARessource;
|
||||
_OIExportPath = oiExportPath;
|
||||
_URLs = urls;
|
||||
_WorkingDirectoryName = workingDirectoryName;
|
||||
ApiLoggingContentTypes = apiLoggingContentTypes;
|
||||
ApiLoggingPathPrefixes = apiLoggingPathPrefixes;
|
||||
ApiLogPath = apiLogPath;
|
||||
AttachmentPath = attachmentPath;
|
||||
BuildNumber = buildNumber;
|
||||
Company = company;
|
||||
ConnectionString = connectionString;
|
||||
GitCommitSeven = gitCommitSeven;
|
||||
InboundApiAllowedIPList = inboundApiAllowedIPList;
|
||||
MonAResource = monAResource;
|
||||
MonASite = monASite;
|
||||
OIExportPath = oiExportPath;
|
||||
URLs = urls;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@ -1,3 +1,4 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
@ -6,6 +7,8 @@ namespace OI.Metrology.Viewer.Models.Binder;
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Display(Name = "Api Logging Content Types"), Required] public string ApiLoggingContentTypes { get; set; }
|
||||
[Display(Name = "Api Logging Path Prefixes"), Required] public string ApiLoggingPathPrefixes { get; set; }
|
||||
[Display(Name = "Api Log Path"), Required] public string ApiLogPath { get; set; }
|
||||
@ -15,27 +18,13 @@ public class AppSettings
|
||||
[Display(Name = "Connection String"), Required] public string ConnectionString { get; set; }
|
||||
[Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; }
|
||||
[Display(Name = "Inbound Api Allowed IP List"), Required] public string InboundApiAllowedIPList { get; set; }
|
||||
[Display(Name = "MonA Ressource"), Required] public string MonARessource { get; set; }
|
||||
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
||||
[Display(Name = "MonA Site"), Required] public string MonASite { get; set; }
|
||||
[Display(Name = "OI Export Path"), Required] public string OIExportPath { get; set; }
|
||||
[Display(Name = "URLs"), Required] public string URLs { get; set; }
|
||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||
|
||||
public AppSettings()
|
||||
{
|
||||
ApiLoggingContentTypes = string.Empty;
|
||||
ApiLoggingPathPrefixes = string.Empty;
|
||||
ApiLogPath = string.Empty;
|
||||
AttachmentPath = string.Empty;
|
||||
BuildNumber = string.Empty;
|
||||
Company = string.Empty;
|
||||
ConnectionString = string.Empty;
|
||||
GitCommitSeven = string.Empty;
|
||||
InboundApiAllowedIPList = string.Empty;
|
||||
MonARessource = string.Empty;
|
||||
OIExportPath = string.Empty;
|
||||
URLs = string.Empty;
|
||||
WorkingDirectoryName = string.Empty;
|
||||
}
|
||||
#nullable restore
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
@ -43,4 +32,33 @@ public class AppSettings
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Models.AppSettings Get(AppSettings appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
result = new(
|
||||
appSettings.ApiLoggingContentTypes,
|
||||
appSettings.ApiLoggingPathPrefixes,
|
||||
appSettings.ApiLogPath,
|
||||
appSettings.AttachmentPath,
|
||||
appSettings.BuildNumber,
|
||||
appSettings.Company,
|
||||
appSettings.ConnectionString,
|
||||
appSettings.GitCommitSeven,
|
||||
appSettings.InboundApiAllowedIPList,
|
||||
appSettings.MonAResource,
|
||||
appSettings.MonASite,
|
||||
appSettings.OIExportPath,
|
||||
appSettings.URLs,
|
||||
appSettings.WorkingDirectoryName);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
AppSettings appSettings = configurationRoot.Get<AppSettings>();
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace OI.Metrology.Viewer.Models.Stateless;
|
||||
|
||||
public abstract class AppSettings
|
||||
{
|
||||
|
||||
#nullable enable
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings? result;
|
||||
Binder.AppSettings appSettings = configurationRoot.Get<Binder.AppSettings>();
|
||||
string json = JsonSerializer.Serialize(appSettings, new JsonSerializerOptions() { WriteIndented = true });
|
||||
result = JsonSerializer.Deserialize<Models.AppSettings>(json);
|
||||
if (result is null)
|
||||
throw new Exception(json);
|
||||
if (string.IsNullOrEmpty(result.Company))
|
||||
throw new Exception(json);
|
||||
string jsonThis = result.ToString();
|
||||
if (jsonThis != json)
|
||||
{
|
||||
int? check = null;
|
||||
int min = new int[] { json.Length, jsonThis.Length }.Min();
|
||||
for (int i = 0; i < min; i++)
|
||||
{
|
||||
if (json[i] == jsonThis[i])
|
||||
continue;
|
||||
check = i;
|
||||
break;
|
||||
}
|
||||
if (check is null)
|
||||
throw new Exception();
|
||||
string a = json[..check.Value].Split(',')[^1];
|
||||
string b = json[check.Value..].Split(',')[0];
|
||||
throw new Exception($"{a}{b}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -50,7 +50,7 @@ public class Program
|
||||
(string assemblyName, WebApplicationOptions _) = Get(args);
|
||||
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
|
||||
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
|
||||
AppSettings appSettings = Models.Stateless.AppSettings.Get(webApplicationBuilder.Configuration);
|
||||
AppSettings appSettings = Models.Binder.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);
|
||||
|
@ -35,6 +35,9 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" />
|
||||
|
@ -70,7 +70,7 @@
|
||||
<li>@Html.ActionLink("Run Information", "RunInfo", "Pages", new { area = "" }, null)</li>
|
||||
<li>@Html.ActionLink("Run Headers", "RunHeaders", "Pages", new { area = "" }, null)</li>
|
||||
<li>@Html.ActionLink("Export", "Index", "Export", new { area = "" }, null)</li>
|
||||
<li><a href="http://oi-metrology-viewer-archive.mes.infineon.com/" target="_blank">Archive</a></li>
|
||||
<li><a href="https://oi-metrology-viewer-archive.mes.infineon.com/" target="_blank">Archive</a></li>
|
||||
</ul>
|
||||
<p class="navbar-text navbar-right">
|
||||
@User.Identity.Name
|
||||
|
@ -17,6 +17,8 @@
|
||||
}
|
||||
},
|
||||
"InboundApiAllowedIPList": "",
|
||||
"MonAResource": "OI_Metrology_Viewer_IFX",
|
||||
"MonASite": "sjc",
|
||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
|
@ -17,6 +17,8 @@
|
||||
}
|
||||
},
|
||||
"InboundApiAllowedIPList": "",
|
||||
"MonAResource": "OI_Metrology_Viewer_EC",
|
||||
"MonASite": "sjc",
|
||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user