diff --git a/.editorconfig b/.editorconfig
index 046ef9f..3856cdf 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -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.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable
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.IDE0005.severity = warning # Using directive is unnecessary
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_naming_rule.abstract_method_should_be_pascal_case.severity = warning
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_relational_binary_operators = always_for_clarity
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_compound_assignment = true:warning
dotnet_style_prefer_conditional_expression_over_assignment = false
diff --git a/Archive/Archive.csproj b/Archive/Archive.csproj
index f681582..7baedc6 100644
--- a/Archive/Archive.csproj
+++ b/Archive/Archive.csproj
@@ -29,9 +29,6 @@
-
-
-
@@ -60,4 +57,12 @@
+
+
+ Always
+
+
+ Always
+
+
\ No newline at end of file
diff --git a/Archive/Program.cs b/Archive/Program.cs
index bc46126..064a011 100644
--- a/Archive/Program.cs
+++ b/Archive/Program.cs
@@ -48,7 +48,7 @@ public class Program
{
LoggerConfiguration loggerConfiguration = new();
(string assemblyName, WebApplicationOptions _) = Get(args);
- WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
+ WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
_ = webApplicationBuilder.Configuration.AddUserSecrets();
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration);
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
diff --git a/Archive/appsettings.Development.json b/Archive/appsettings.Development.json
index 1a83359..c74d050 100644
--- a/Archive/appsettings.Development.json
+++ b/Archive/appsettings.Development.json
@@ -18,7 +18,7 @@
},
"InboundApiAllowedIPList": "",
"MonAResource": "OI_Metrology_Archive_IFX",
- "MonASite": "sjc",
+ "MonASite": "auc",
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
"Serilog": {
"Using": [
diff --git a/Archive/appsettings.json b/Archive/appsettings.json
index 9c0dcdd..77d7513 100644
--- a/Archive/appsettings.json
+++ b/Archive/appsettings.json
@@ -18,7 +18,7 @@
},
"MonAResource": "OI_Metrology_Archive_EC",
"InboundApiAllowedIPList": "",
- "MonASite": "sjc",
+ "MonASite": "auc",
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
"Serilog": {
"Using": [
diff --git a/Shared/Infineon/Monitoring/MonA/ExtWebClient.cs b/Shared/Infineon/Monitoring/MonA/ExtWebClient.cs
new file mode 100644
index 0000000..37bfafb
--- /dev/null
+++ b/Shared/Infineon/Monitoring/MonA/ExtWebClient.cs
@@ -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; }
+}
\ No newline at end of file
diff --git a/Shared/Infineon/Monitoring/MonA/IMonIn.cs b/Shared/Infineon/Monitoring/MonA/IMonIn.cs
new file mode 100644
index 0000000..3c0b153
--- /dev/null
+++ b/Shared/Infineon/Monitoring/MonA/IMonIn.cs
@@ -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);
+}
\ No newline at end of file
diff --git a/Shared/Infineon/Monitoring/MonA/MonIn.cs b/Shared/Infineon/Monitoring/MonA/MonIn.cs
new file mode 100644
index 0000000..57b310e
--- /dev/null
+++ b/Shared/Infineon/Monitoring/MonA/MonIn.cs
@@ -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 _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 keyValuePair = new();
+ foreach (KeyValuePair instance in _Instances)
+ {
+ if (instance.Value == this)
+ {
+ keyValuePair = instance;
+ break;
+ }
+ }
+ _ = _Instances.Remove(keyValuePair.Key);
+ _WebClient?.Dispose();
+ }
+
+}
\ No newline at end of file
diff --git a/Shared/Infineon/Monitoring/MonA/State.cs b/Shared/Infineon/Monitoring/MonA/State.cs
new file mode 100644
index 0000000..d6bface
--- /dev/null
+++ b/Shared/Infineon/Monitoring/MonA/State.cs
@@ -0,0 +1,11 @@
+namespace Infineon.Monitoring.MonA;
+
+public enum State
+{
+ Up,
+ Ok,
+ Warning,
+ Critical,
+ Down,
+ Unknown,
+}
\ No newline at end of file
diff --git a/Tests/appsettings.Development.json b/Tests/appsettings.Development.json
index 1b69385..c7a5540 100644
--- a/Tests/appsettings.Development.json
+++ b/Tests/appsettings.Development.json
@@ -17,7 +17,7 @@
}
},
"InboundApiAllowedIPList": "",
- "MonASite": "sjc",
+ "MonASite": "auc",
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
"Serilog": {
"Using": [
diff --git a/Tests/appsettings.json b/Tests/appsettings.json
index 301bde9..341b245 100644
--- a/Tests/appsettings.json
+++ b/Tests/appsettings.json
@@ -17,7 +17,7 @@
}
},
"InboundApiAllowedIPList": "",
- "MonASite": "sjc",
+ "MonASite": "auc",
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
"Serilog": {
"Using": [
diff --git a/Viewer/Program.cs b/Viewer/Program.cs
index 58e78f6..2a0c2ac 100644
--- a/Viewer/Program.cs
+++ b/Viewer/Program.cs
@@ -48,7 +48,7 @@ public class Program
{
LoggerConfiguration loggerConfiguration = new();
(string assemblyName, WebApplicationOptions _) = Get(args);
- WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
+ WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
_ = webApplicationBuilder.Configuration.AddUserSecrets();
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration);
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
diff --git a/Viewer/Viewer.csproj b/Viewer/Viewer.csproj
index 4c4b784..7baedc6 100644
--- a/Viewer/Viewer.csproj
+++ b/Viewer/Viewer.csproj
@@ -35,9 +35,6 @@
-
-
-
@@ -60,4 +57,12 @@
+
+
+ Always
+
+
+ Always
+
+
\ No newline at end of file
diff --git a/Viewer/appsettings.Development.json b/Viewer/appsettings.Development.json
index 9dabcb1..b27f8b2 100644
--- a/Viewer/appsettings.Development.json
+++ b/Viewer/appsettings.Development.json
@@ -18,7 +18,7 @@
},
"InboundApiAllowedIPList": "",
"MonAResource": "OI_Metrology_Viewer_IFX",
- "MonASite": "sjc",
+ "MonASite": "auc",
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
"Serilog": {
"Using": [
diff --git a/Viewer/appsettings.json b/Viewer/appsettings.json
index 3f54f1f..dbf0a14 100644
--- a/Viewer/appsettings.json
+++ b/Viewer/appsettings.json
@@ -18,7 +18,7 @@
},
"InboundApiAllowedIPList": "",
"MonAResource": "OI_Metrology_Viewer_EC",
- "MonASite": "sjc",
+ "MonASite": "auc",
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
"Serilog": {
"Using": [