sjc => auc and switch to code
over reference for MonIn
This commit is contained in:
parent
f36ad1ae5e
commit
1e834360ae
@ -80,9 +80,11 @@ dotnet_diagnostic.CA1825.severity = warning # CA1823: Avoid zero-length array al
|
|||||||
dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available
|
dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available
|
||||||
dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable
|
dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable
|
||||||
dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name
|
dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name
|
||||||
|
dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant.
|
||||||
dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2");
|
dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2");
|
||||||
dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary
|
dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary
|
||||||
dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed
|
dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed
|
||||||
|
dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049)
|
||||||
dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter
|
dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter
|
||||||
dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning
|
dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning
|
||||||
dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case
|
dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case
|
||||||
@ -215,7 +217,7 @@ dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
|
|||||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
|
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
|
||||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
|
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
|
||||||
dotnet_style_predefined_type_for_locals_parameters_members = true
|
dotnet_style_predefined_type_for_locals_parameters_members = true
|
||||||
dotnet_style_predefined_type_for_member_access = true
|
dotnet_style_predefined_type_for_member_access = true:warning
|
||||||
dotnet_style_prefer_auto_properties = true:warning
|
dotnet_style_prefer_auto_properties = true:warning
|
||||||
dotnet_style_prefer_compound_assignment = true:warning
|
dotnet_style_prefer_compound_assignment = true:warning
|
||||||
dotnet_style_prefer_conditional_expression_over_assignment = false
|
dotnet_style_prefer_conditional_expression_over_assignment = false
|
||||||
|
@ -29,9 +29,6 @@
|
|||||||
<PackageReference Include="jQuery" Version="3.6.0" />
|
<PackageReference Include="jQuery" Version="3.6.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
|
||||||
@ -60,4 +57,12 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="compilerconfig.json" />
|
<None Include="compilerconfig.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="appsettings.Development.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -48,7 +48,7 @@ public class Program
|
|||||||
{
|
{
|
||||||
LoggerConfiguration loggerConfiguration = new();
|
LoggerConfiguration loggerConfiguration = new();
|
||||||
(string assemblyName, WebApplicationOptions _) = Get(args);
|
(string assemblyName, WebApplicationOptions _) = Get(args);
|
||||||
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
|
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
|
||||||
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
|
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
|
||||||
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration);
|
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration);
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
"InboundApiAllowedIPList": "",
|
"InboundApiAllowedIPList": "",
|
||||||
"MonAResource": "OI_Metrology_Archive_IFX",
|
"MonAResource": "OI_Metrology_Archive_IFX",
|
||||||
"MonASite": "sjc",
|
"MonASite": "auc",
|
||||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
"MonAResource": "OI_Metrology_Archive_EC",
|
"MonAResource": "OI_Metrology_Archive_EC",
|
||||||
"InboundApiAllowedIPList": "",
|
"InboundApiAllowedIPList": "",
|
||||||
"MonASite": "sjc",
|
"MonASite": "auc",
|
||||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
|
19
Shared/Infineon/Monitoring/MonA/ExtWebClient.cs
Normal file
19
Shared/Infineon/Monitoring/MonA/ExtWebClient.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace Infineon.Monitoring.MonA;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
#pragma warning disable SYSLIB0014
|
||||||
|
|
||||||
|
public class ExtWebClient : WebClient
|
||||||
|
{
|
||||||
|
protected override WebRequest GetWebRequest(Uri address)
|
||||||
|
{
|
||||||
|
WebRequest webRequest = base.GetWebRequest(address);
|
||||||
|
if (webRequest != null)
|
||||||
|
webRequest.PreAuthenticate = PreAuthenticate;
|
||||||
|
return webRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool PreAuthenticate { get; set; }
|
||||||
|
}
|
165
Shared/Infineon/Monitoring/MonA/IMonIn.cs
Normal file
165
Shared/Infineon/Monitoring/MonA/IMonIn.cs
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
namespace Infineon.Monitoring.MonA;
|
||||||
|
|
||||||
|
public interface IMonIn
|
||||||
|
{
|
||||||
|
string SendStatus(string site, string resource, string stateName, State state);
|
||||||
|
|
||||||
|
string SendStatus(
|
||||||
|
string site,
|
||||||
|
DateTime timeStamp,
|
||||||
|
string resource,
|
||||||
|
string stateName,
|
||||||
|
State state);
|
||||||
|
|
||||||
|
string SendStatus(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string stateName,
|
||||||
|
State state,
|
||||||
|
string description);
|
||||||
|
|
||||||
|
string SendStatus(
|
||||||
|
string site,
|
||||||
|
DateTime timeStamp,
|
||||||
|
string resource,
|
||||||
|
string stateName,
|
||||||
|
State state,
|
||||||
|
string description);
|
||||||
|
|
||||||
|
string SendStatus(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string stateName,
|
||||||
|
State state);
|
||||||
|
|
||||||
|
string SendStatus(
|
||||||
|
string site,
|
||||||
|
DateTime timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string stateName,
|
||||||
|
State state);
|
||||||
|
|
||||||
|
string SendStatus(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string stateName,
|
||||||
|
State state,
|
||||||
|
string description);
|
||||||
|
|
||||||
|
string SendStatus(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string stateName,
|
||||||
|
State state,
|
||||||
|
string description);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string description);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string description);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
int? interval);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string unit);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string unit,
|
||||||
|
int? interval);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string description);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
int? interval);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string unit);
|
||||||
|
|
||||||
|
string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string description,
|
||||||
|
string unit,
|
||||||
|
int? interval);
|
||||||
|
}
|
290
Shared/Infineon/Monitoring/MonA/MonIn.cs
Normal file
290
Shared/Infineon/Monitoring/MonA/MonIn.cs
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Infineon.Monitoring.MonA;
|
||||||
|
|
||||||
|
public class MonIn : IMonIn, IDisposable
|
||||||
|
{
|
||||||
|
private static readonly DateTime _Utc1970DateTime = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||||
|
public const string MonInUrl = "http://moninhttp.{0}.infineon.com/input/text";
|
||||||
|
private static readonly Dictionary<string, MonIn> _Instances = new();
|
||||||
|
private readonly ExtWebClient _WebClient;
|
||||||
|
private readonly string _MonInUrl;
|
||||||
|
private static CultureInfo? _CultureInfo;
|
||||||
|
|
||||||
|
public static MonIn GetInstance(string url = "http://moninhttp.{0}.infineon.com/input/text")
|
||||||
|
{
|
||||||
|
MonIn instance;
|
||||||
|
if (_Instances.ContainsKey(url))
|
||||||
|
{
|
||||||
|
instance = _Instances[url];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lock (_Instances)
|
||||||
|
{
|
||||||
|
if (!_Instances.ContainsKey(url))
|
||||||
|
{
|
||||||
|
instance = new MonIn(url);
|
||||||
|
_Instances.Add(url, instance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
instance = _Instances[url];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MonIn(string url)
|
||||||
|
{
|
||||||
|
_WebClient = new ExtWebClient();
|
||||||
|
_WebClient.Headers[HttpRequestHeader.ContentType] = "application/text";
|
||||||
|
_WebClient.Encoding = Encoding.UTF8;
|
||||||
|
_CultureInfo = new CultureInfo("en-US");
|
||||||
|
_MonInUrl = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetBasicAuthentication(string username, string password)
|
||||||
|
{
|
||||||
|
_WebClient.PreAuthenticate = true;
|
||||||
|
_WebClient.Headers[HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SendStatus(string site, string resource, string stateName, State state) => SendStatus(site, new DateTime?(), resource, string.Empty, stateName, state, string.Empty);
|
||||||
|
|
||||||
|
public string SendStatus(
|
||||||
|
string site,
|
||||||
|
DateTime timeStamp,
|
||||||
|
string resource,
|
||||||
|
string stateName,
|
||||||
|
State state) => SendStatus(site, new DateTime?(timeStamp), resource, string.Empty, stateName, state, string.Empty);
|
||||||
|
|
||||||
|
public string SendStatus(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string stateName,
|
||||||
|
State state,
|
||||||
|
string description) => SendStatus(site, new DateTime?(), resource, string.Empty, stateName, state, description);
|
||||||
|
|
||||||
|
public string SendStatus(
|
||||||
|
string site,
|
||||||
|
DateTime timeStamp,
|
||||||
|
string resource,
|
||||||
|
string stateName,
|
||||||
|
State state,
|
||||||
|
string description) => SendStatus(site, new DateTime?(timeStamp), resource, string.Empty, stateName, state, description);
|
||||||
|
|
||||||
|
public string SendStatus(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string stateName,
|
||||||
|
State state) => SendStatus(site, new DateTime?(), resource, subresource, stateName, state, string.Empty);
|
||||||
|
|
||||||
|
public string SendStatus(
|
||||||
|
string site,
|
||||||
|
DateTime timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string stateName,
|
||||||
|
State state) => SendStatus(site, new DateTime?(timeStamp), resource, subresource, stateName, state, string.Empty);
|
||||||
|
|
||||||
|
public string SendStatus(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string stateName,
|
||||||
|
State state,
|
||||||
|
string description) => SendStatus(site, new DateTime?(), resource, subresource, stateName, state, description);
|
||||||
|
|
||||||
|
public string SendStatus(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string stateName,
|
||||||
|
State state,
|
||||||
|
string description)
|
||||||
|
{
|
||||||
|
string statusMessage = CreateStatusMessage(site, timeStamp, resource, subresource, stateName, state.ToString(), description);
|
||||||
|
lock (_WebClient)
|
||||||
|
return _WebClient.UploadString(string.Format(_MonInUrl, site), statusMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value) => SendPerformanceMessage(site, new DateTime?(), resource, string.Empty, performanceName, value, string.Empty, string.Empty, new int?());
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, string.Empty, string.Empty, new int?());
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string description) => SendPerformanceMessage(site, new DateTime?(), resource, string.Empty, performanceName, value, description, string.Empty, new int?());
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string description) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, description, string.Empty, new int?());
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
int? interval) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, string.Empty, string.Empty, interval);
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string unit) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, string.Empty, unit, new int?());
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string unit,
|
||||||
|
int? interval) => SendPerformanceMessage(site, timeStamp, resource, string.Empty, performanceName, value, string.Empty, unit, interval);
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value) => SendPerformanceMessage(site, new DateTime?(), resource, subresource, performanceName, value, string.Empty, string.Empty, new int?());
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value) => SendPerformanceMessage(site, timeStamp, resource, subresource, performanceName, value, string.Empty, string.Empty, new int?());
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string description) => SendPerformanceMessage(site, new DateTime?(), resource, subresource, performanceName, value, description, string.Empty, new int?());
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
int? interval) => SendPerformanceMessage(site, timeStamp, resource, subresource, performanceName, value, string.Empty, string.Empty, interval);
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string unit) => SendPerformanceMessage(site, timeStamp, resource, subresource, performanceName, value, string.Empty, unit, new int?());
|
||||||
|
|
||||||
|
public string SendPerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string description,
|
||||||
|
string unit,
|
||||||
|
int? interval)
|
||||||
|
{
|
||||||
|
string performanceMessage = CreatePerformanceMessage(site, timeStamp, resource, subresource, performanceName, value, description, unit, interval);
|
||||||
|
lock (_WebClient)
|
||||||
|
return _WebClient.UploadString(string.Format(_MonInUrl, site), performanceMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string CreateStatusMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string stateName,
|
||||||
|
string state,
|
||||||
|
string description)
|
||||||
|
{
|
||||||
|
StringBuilder stringBuilder = new();
|
||||||
|
if (string.IsNullOrEmpty(subresource))
|
||||||
|
_ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" {4} \n{5}", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), stateName.Trim(), state.Trim(), description.Trim());
|
||||||
|
else
|
||||||
|
_ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" \"{4}\" {5} \n{6}", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), subresource.Trim(), stateName.Trim(), state.Trim(), description.Trim());
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string CreatePerformanceMessage(
|
||||||
|
string site,
|
||||||
|
DateTime? timeStamp,
|
||||||
|
string resource,
|
||||||
|
string subresource,
|
||||||
|
string performanceName,
|
||||||
|
double value,
|
||||||
|
string description,
|
||||||
|
string unit,
|
||||||
|
int? interval)
|
||||||
|
{
|
||||||
|
StringBuilder stringBuilder = new();
|
||||||
|
if (string.IsNullOrEmpty(subresource))
|
||||||
|
{
|
||||||
|
if (unit.Equals(string.Empty) && !interval.HasValue)
|
||||||
|
_ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" {4} \n{5}", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), performanceName.Trim(), value, description.Trim());
|
||||||
|
else
|
||||||
|
_ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" {4} {5} {{interval={6}, unit={7}}}\n", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), performanceName.Trim(), value, description.Trim(), interval.HasValue ? interval.Value.ToString() : (object)string.Empty, unit.Trim());
|
||||||
|
}
|
||||||
|
else if (unit.Equals(string.Empty) && !interval.HasValue)
|
||||||
|
_ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" \"{4}\" {5} \n{6}", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), subresource.Trim(), performanceName.Trim(), value, description.Trim());
|
||||||
|
else
|
||||||
|
_ = stringBuilder.AppendFormat(_CultureInfo, "> {0} {1} \"{2}\" \"{3}\" \"{4}\" {5} {6} {{interval={7}, unit={8}}}\n", site.Trim(), timeStamp.HasValue ? GetDateTimeNowAsPosix(timeStamp.Value) : (object)"now", resource.Trim(), subresource.Trim(), performanceName.Trim(), value, description.Trim(), interval.HasValue ? interval.Value.ToString() : (object)string.Empty, unit.Trim());
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetDateTimeNowAsPosix(DateTime timeStamp)
|
||||||
|
{
|
||||||
|
if (timeStamp > DateTime.Now)
|
||||||
|
timeStamp = DateTime.Now;
|
||||||
|
return ((int)timeStamp.ToUniversalTime().Subtract(_Utc1970DateTime).TotalSeconds).ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
KeyValuePair<string, MonIn> keyValuePair = new();
|
||||||
|
foreach (KeyValuePair<string, MonIn> instance in _Instances)
|
||||||
|
{
|
||||||
|
if (instance.Value == this)
|
||||||
|
{
|
||||||
|
keyValuePair = instance;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ = _Instances.Remove(keyValuePair.Key);
|
||||||
|
_WebClient?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
11
Shared/Infineon/Monitoring/MonA/State.cs
Normal file
11
Shared/Infineon/Monitoring/MonA/State.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace Infineon.Monitoring.MonA;
|
||||||
|
|
||||||
|
public enum State
|
||||||
|
{
|
||||||
|
Up,
|
||||||
|
Ok,
|
||||||
|
Warning,
|
||||||
|
Critical,
|
||||||
|
Down,
|
||||||
|
Unknown,
|
||||||
|
}
|
@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"InboundApiAllowedIPList": "",
|
"InboundApiAllowedIPList": "",
|
||||||
"MonASite": "sjc",
|
"MonASite": "auc",
|
||||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"InboundApiAllowedIPList": "",
|
"InboundApiAllowedIPList": "",
|
||||||
"MonASite": "sjc",
|
"MonASite": "auc",
|
||||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
|
@ -48,7 +48,7 @@ public class Program
|
|||||||
{
|
{
|
||||||
LoggerConfiguration loggerConfiguration = new();
|
LoggerConfiguration loggerConfiguration = new();
|
||||||
(string assemblyName, WebApplicationOptions _) = Get(args);
|
(string assemblyName, WebApplicationOptions _) = Get(args);
|
||||||
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
|
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
|
||||||
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
|
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
|
||||||
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration);
|
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration);
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||||
|
@ -35,9 +35,6 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" />
|
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" />
|
||||||
@ -60,4 +57,12 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="compilerconfig.json" />
|
<None Include="compilerconfig.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="appsettings.Development.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -18,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
"InboundApiAllowedIPList": "",
|
"InboundApiAllowedIPList": "",
|
||||||
"MonAResource": "OI_Metrology_Viewer_IFX",
|
"MonAResource": "OI_Metrology_Viewer_IFX",
|
||||||
"MonASite": "sjc",
|
"MonASite": "auc",
|
||||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
"InboundApiAllowedIPList": "",
|
"InboundApiAllowedIPList": "",
|
||||||
"MonAResource": "OI_Metrology_Viewer_EC",
|
"MonAResource": "OI_Metrology_Viewer_EC",
|
||||||
"MonASite": "sjc",
|
"MonASite": "auc",
|
||||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user