diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html
index 6d14fa4..c38c545 100644
--- a/Resources/ChangeLog.html
+++ b/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
WebDoorCreator - Egalware
- Version: 0.9.2404.2316
+ Version: 0.9.2404.2317
Release note:
-
diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt
index 27860b9..e4a6ced 100644
--- a/Resources/VersNum.txt
+++ b/Resources/VersNum.txt
@@ -1 +1 @@
-0.9.2404.2316
+0.9.2404.2317
diff --git a/Resources/manifest.xml b/Resources/manifest.xml
index 5b83be9..439962a 100644
--- a/Resources/manifest.xml
+++ b/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 0.9.2404.2316
+ 0.9.2404.2317
http://nexus.steamware.net/repository/SWS/WDC/stable/WDC.UI.zip
http://nexus.steamware.net/repository/SWS/WDC/stable/ChangeLog.html
false
diff --git a/WebDoorCreator.UI/Health/Checks.cs b/WebDoorCreator.UI/Health/Checks.cs
index d08cd70..b1ead81 100644
--- a/WebDoorCreator.UI/Health/Checks.cs
+++ b/WebDoorCreator.UI/Health/Checks.cs
@@ -1,106 +1,76 @@
using Microsoft.Extensions.Diagnostics.HealthChecks;
using NLog;
using System.Net.NetworkInformation;
+using WebDoorCreator.Data;
+using WebDoorCreator.UI.Components.Users;
namespace WebDoorCreator.UI.Health
{
public class Checks
{
- #region Private Fields
-
- private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
-
- #endregion Private Fields
-
#region Public Methods
- public static async Task DbIdentity(string dbName)
+ public static async Task ConfigCount(IConfiguration _config)
{
- string description = "Try check Table IdentityUsers";
+ string description = "Try check Config table";
var healthCheckData = new Dictionary();
-#if false
- using (var appDb = new UserIdentityDbContext())
+ using (WDCDataContext localDbCtx = new WDCDataContext(_config))
{
- List recordList = new List();
- try
+ var dbCount = localDbCtx
+ .DbSetConfig
+ .Count();
+ if (dbCount > 0)
{
- string sqlQuery = $"SELECT 'AspNetUsers' AS TableName, COUNT(*) AS Count FROM information_schema.tables WHERE table_schema = '{dbName}' AND table_name = 'AspNetUsers' LIMIT 1;";
- var table = await Task.FromResult(appDb.DbSetCounts.FromSqlRaw(sqlQuery).ToList());
-
- // provo a controllare se ho tab utenti
- if (table != null && table.Count > 0)
- {
- // controllo valore
- if (table[0].Count > 0)
- {
- description = $"Check IdentityUsers table, found!";
- return HealthCheckResult.Healthy(description, healthCheckData);
- }
- }
- }
- catch (Exception exc)
- {
- Log.Error(exc, "Errore in esecuzione DbIdentity");
- }
- }
-#endif
-
- return HealthCheckResult.Degraded(description + $" {dbName}", null, healthCheckData);
- }
-
- public static async Task DbPlantTable(string dbName)
- {
- string description = "Try check Table PlantLog";
- var healthCheckData = new Dictionary();
-#if false
- using (var appDb = new GWMSContext())
- {
- List recordList = new List();
- try
- {
- // provo a controllare se ho tab utenti
- recordList = await Task.FromResult(appDb.DbSetPlant.ToList()).ConfigureAwait(false);
- if (recordList.Count > 0)
- {
- description = $"Check PlantDetail table, found {recordList.Count} records";
+ description = $"Check Config table, found {dbCount} records";
+ healthCheckData.Add("Count", dbCount);
return HealthCheckResult.Healthy(description, healthCheckData);
}
}
- catch (Exception exc)
- {
- Log.Error(exc, "Errore in esecuzione PlantDetail Table");
- }
- }
-#endif
- return HealthCheckResult.Degraded(description + $" {dbName}", null, healthCheckData);
+
+ await Task.Delay(1);
+ return HealthCheckResult.Unhealthy(description + $" NO RECORD found", null, healthCheckData);
}
- public static async Task DbUserRoot(string dbName)
+ public static async Task DoorsCount(IConfiguration _config)
{
- string description = "Try check MySql User table";
+ string description = "Try check DOOR table";
var healthCheckData = new Dictionary();
-#if false
- using (var adminDb = new AdminContext())
- {
- List userList = new List();
- try
+ using (WDCDataContext localDbCtx = new WDCDataContext(_config))
{
- // provo a controllare se ho tab utenti
- userList = await Task.FromResult(adminDb.UserList.ToList()).ConfigureAwait(false);
- if (userList.Count > 0)
+ var dbCount = localDbCtx
+ .DbSetDoor
+ .Count();
+ if (dbCount > 0)
{
- description = $"Check MySql User table, found {userList.Count} records";
+ description = $"Check DOOR table, found {dbCount} records";
+ healthCheckData.Add("Count", dbCount);
return HealthCheckResult.Healthy(description, healthCheckData);
}
}
- catch (Exception exc)
- {
- Log.Error(exc, "Errore in esecuzione DbUserRoot");
- }
- }
-#endif
- return HealthCheckResult.Unhealthy(description + $" {dbName}", null, healthCheckData);
+ await Task.Delay(1);
+ return HealthCheckResult.Unhealthy(description + $" NO RECORD found", null, healthCheckData);
+ }
+
+ public static async Task OrdersCount(IConfiguration _config)
+ {
+ string description = "Try check ORDER table";
+ var healthCheckData = new Dictionary();
+ using (WDCDataContext localDbCtx = new WDCDataContext(_config))
+ {
+ var dbCount = localDbCtx
+ .DbSetOrders
+ .Count();
+ if (dbCount > 0)
+ {
+ description = $"Check ORDER table, found {dbCount} records";
+ healthCheckData.Add("Count", dbCount);
+ return HealthCheckResult.Healthy(description, healthCheckData);
+ }
+ }
+
+ await Task.Delay(1);
+ return HealthCheckResult.Unhealthy(description + $" NO RECORD found", null, healthCheckData);
}
public static async Task PingCheck(string hostName)
@@ -117,11 +87,16 @@ namespace WebDoorCreator.UI.Health
description += $" - {pingResult.RoundtripTime}ms";
return HealthCheckResult.Healthy(description, healthCheckData);
}
-
}
return HealthCheckResult.Unhealthy(description + $" {hostName}", null, healthCheckData);
}
#endregion Public Methods
+
+ #region Private Fields
+
+ private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
+
+ #endregion Private Fields
}
-}
+}
\ No newline at end of file
diff --git a/WebDoorCreator.UI/Program.cs b/WebDoorCreator.UI/Program.cs
index 5a4bb4d..5f17f1c 100644
--- a/WebDoorCreator.UI/Program.cs
+++ b/WebDoorCreator.UI/Program.cs
@@ -28,7 +28,7 @@ var builder = WebApplication.CreateBuilder(args);
Microsoft.Extensions.Configuration.ConfigurationManager configuration = builder.Configuration;
// AspNetCore Identity setup
-var connectionString = builder.Configuration.GetConnectionString("Identity.DB");
+var connectionString = configuration.GetConnectionString("Identity.DB");
// REDIS setup
string connStringRedis = configuration.GetConnectionString("Redis");
@@ -62,14 +62,15 @@ if (connectionString.Contains("Server"))
}
// healthchecks
builder.Services.AddHealthChecks()
- .AddSqlServer(connectionString, healthQuery: "SELECT 1;", name: "sql", failureStatus: HealthStatus.Degraded, tags: new string[] { "DB", "MsSql" })
+ .AddSqlServer(connectionString, healthQuery: "SELECT 1;", name: "SqlServer", failureStatus: HealthStatus.Degraded, tags: new string[] { "DB", "MsSql" })
.AddAsyncCheck($"DB PING ({dbServerAddr})", () => WebDoorCreator.UI.Health.Checks.PingCheck(dbServerAddr))
.AddAsyncCheck($"Redis PING ({redisSrvAddr})", () => WebDoorCreator.UI.Health.Checks.PingCheck(redisSrvAddr))
- //.AddProcessAllocatedMemoryHealthCheck(512, "Max Process memory (<512MB)", failureStatus: HealthStatus.Degraded) // 512 MB max allocated memory
+ // 512 MB max allocated memory
+ .AddProcessAllocatedMemoryHealthCheck(512, "Max Process memory (<512MB)", failureStatus: HealthStatus.Degraded)
.AddRedis(connStringRedis, "Redis", failureStatus: HealthStatus.Degraded)
- //.AddAsyncCheck($"MsSql Root User", () => WebDoorCreator.UI.Health.Checks.DbUserRoot("MsSql"))
- //.AddAsyncCheck($"MsSql Identity", () => WebDoorCreator.UI.Health.Checks.DbIdentity(DbConfig.DATABASE_NAME))
- //.AddAsyncCheck($"MsSql PlantLog", () => WebDoorCreator.UI.Health.Checks.DbPlantTable(DbConfig.DATABASE_NAME))
+ .AddAsyncCheck($"Config Table", () => WebDoorCreator.UI.Health.Checks.ConfigCount(configuration))
+ .AddAsyncCheck($"Orders Table", () => WebDoorCreator.UI.Health.Checks.OrdersCount(configuration))
+ .AddAsyncCheck($"Doors Table", () => WebDoorCreator.UI.Health.Checks.DoorsCount(configuration))
;
builder.Services
diff --git a/WebDoorCreator.UI/WebDoorCreator.UI.csproj b/WebDoorCreator.UI/WebDoorCreator.UI.csproj
index 6a25632..ec2ff54 100644
--- a/WebDoorCreator.UI/WebDoorCreator.UI.csproj
+++ b/WebDoorCreator.UI/WebDoorCreator.UI.csproj
@@ -3,7 +3,7 @@
net6.0
enable
- 0.9.2404.2316
+ 0.9.2404.2317
enable
aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608
@@ -39,6 +39,7 @@
+