diff --git a/MP.Data/Constants.cs b/MP.Data/Constants.cs
index 4c988efc..6f31223c 100644
--- a/MP.Data/Constants.cs
+++ b/MP.Data/Constants.cs
@@ -19,6 +19,7 @@
+ public static string redisMacchine = "MP:MON:Cache:Macchine";
public static string redisMseKey = "MP:MON:Cache:MSE";
public static string redisMseKeySingle = "MP:MON:Cache:MseSingle";
diff --git a/MP.Data/Controllers/MpMonController.cs b/MP.Data/Controllers/MpMonController.cs
index 4d13053b..512fb20e 100644
--- a/MP.Data/Controllers/MpMonController.cs
+++ b/MP.Data/Controllers/MpMonController.cs
@@ -1,6 +1,7 @@
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
+using MP.Data.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
@@ -84,6 +85,49 @@ namespace MP.Data.Controllers
return dbResult;
}
+ ///
+ /// Elenco da tabella Macchine
+ ///
+ ///
+ ///
+ public List MacchineGetFilt(string codGruppo)
+ {
+ List dbResult = new List();
+ try
+ {
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ if (codGruppo == "*")
+ {
+ dbResult = dbCtx
+ .DbSetMacchine
+ .AsNoTracking()
+ .OrderBy(x => x.IdxMacchina)
+ .ToList();
+ }
+ else
+ {
+ dbResult = dbCtx
+ .DbSetGrp2Macc
+ .Where(g => g.CodGruppo == codGruppo)
+ .Join(dbCtx.DbSetMacchine,
+ g => g.IdxMacchina,
+ m => m.IdxMacchina,
+ (g, m) => m
+ )
+ .AsNoTracking()
+ .OrderBy(x => x.IdxMacchina)
+ .ToList();
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in MacchineGetFilt{Environment.NewLine}{exc}");
+ }
+ return dbResult;
+ }
+
///
/// Elenco da tabella MappaStatoExpl
///
diff --git a/MP.Data/Services/StatusData.cs b/MP.Data/Services/StatusData.cs
index 365c88f2..3f89c3d4 100644
--- a/MP.Data/Services/StatusData.cs
+++ b/MP.Data/Services/StatusData.cs
@@ -51,6 +51,10 @@ namespace MP.Data.Services
maxAge = _configuration.GetValue("OptConf:msRefresh");
}
+ // sistemo i timespan
+ LongCache = TimeSpan.FromSeconds(300);
+ FastCache = TimeSpan.FromMilliseconds(maxAge);
+
// setup conf IOB da dizionario
tryLoadIobTags();
}
@@ -110,9 +114,66 @@ namespace MP.Data.Services
return outVal;
}
- public Task> MacchineGetAll()
+ public async Task> MacchineGetAll()
{
- return Task.FromResult(dbController.MacchineGetAll());
+ Stopwatch sw = new Stopwatch();
+ string source = "DB";
+ sw.Start();
+ List? result = new List();
+ // cerco in redis...
+ string currKey = $"{Constants.redisMacchine}:ALL";
+ RedisValue rawData = redisDb.StringGet(currKey);
+ if (rawData.HasValue)
+ {
+ result = JsonConvert.DeserializeObject>($"{rawData}");
+ source = "REDIS";
+ }
+ else
+ {
+ result = await Task.FromResult(dbController.MacchineGetAll());
+ // serializzo e salvo...
+ rawData = JsonConvert.SerializeObject(result);
+ await redisDb.StringSetAsync(currKey, rawData, LongCache);
+ }
+ if (result == null)
+ {
+ result = new List();
+ }
+ sw.Stop();
+ Log.Debug($"MacchineGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
+ return result;
+ //return Task.FromResult(dbController.MacchineGetAll());
+ }
+
+ public async Task> MacchineGetByGruppo(string CodGruppo)
+ {
+ Stopwatch sw = new Stopwatch();
+ string source = "DB";
+ sw.Start();
+ List? result = new List();
+ // cerco in redis...
+ string currKey = $"{Constants.redisMacchine}:{CodGruppo}";
+ RedisValue rawData = redisDb.StringGet(currKey);
+ if (rawData.HasValue)
+ {
+ result = JsonConvert.DeserializeObject>($"{rawData}");
+ source = "REDIS";
+ }
+ else
+ {
+ result = await Task.FromResult(dbController.MacchineGetFilt(CodGruppo));
+ //result = dbController.MacchineGetFilt(CodGruppo);
+ // serializzo e salvo...
+ rawData = JsonConvert.SerializeObject(result);
+ await redisDb.StringSetAsync(currKey, rawData, LongCache);
+ }
+ if (result == null)
+ {
+ result = new List();
+ }
+ sw.Stop();
+ Log.Debug($"MacchineGetByGruppo | {source} | {sw.Elapsed.TotalMilliseconds}ms");
+ return result;
}
///
@@ -205,7 +266,7 @@ namespace MP.Data.Services
result = await Task.FromResult(dbController.MseGetAll(maxAge));
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(Constants.redisMseKey, rawData, TimeSpan.FromMilliseconds(maxAge));
+ await redisDb.StringSetAsync(Constants.redisMseKey, rawData, FastCache);
}
if (result == null)
{
@@ -236,7 +297,19 @@ namespace MP.Data.Services
#region Private Fields
private static IConfiguration _configuration = null!;
+
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
+
+ ///
+ /// Cache breve durata
+ ///
+ private TimeSpan FastCache = TimeSpan.FromSeconds(5);
+
+ ///
+ /// Cache lunga durata
+ ///
+ private TimeSpan LongCache = TimeSpan.FromSeconds(60);
+
private int maxAge = 2000;
#endregion Private Fields
diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs
index e565156f..4e84afe1 100644
--- a/MP.Data/Services/TabDataService.cs
+++ b/MP.Data/Services/TabDataService.cs
@@ -2419,6 +2419,7 @@ namespace MP.Data.Services
answ = dbTabController.RicalcMse(idxMacchina, maxAgeSec);
await FlushOdlCache();
await FlushCache(Constants.redisMseKey);
+ await FlushCache(Constants.redisMacchine);
return answ;
}
diff --git a/MP.Mon/MP.Mon.csproj b/MP.Mon/MP.Mon.csproj
index 80b4093d..82a11624 100644
--- a/MP.Mon/MP.Mon.csproj
+++ b/MP.Mon/MP.Mon.csproj
@@ -4,7 +4,7 @@
net6.0
enable
enable
- 6.16.2402.1919
+ 6.16.2402.2312
@@ -33,8 +33,11 @@
+
+
+
diff --git a/MP.Mon/Pages/Index.razor.cs b/MP.Mon/Pages/Index.razor.cs
index 57701ac4..5c6f56d2 100644
--- a/MP.Mon/Pages/Index.razor.cs
+++ b/MP.Mon/Pages/Index.razor.cs
@@ -5,6 +5,8 @@ using MP.Data.DatabaseModels;
using MP.Data.Services;
using Newtonsoft.Json;
using NLog;
+using System;
+using EgwCoreLib.Razor;
namespace MP.Mon.Pages
{
@@ -25,8 +27,8 @@ namespace MP.Mon.Pages
// dispongo i vari timers...
disposeTimers();
await Task.Delay(10);
- // reload pagina
- NavManager.NavigateTo(NavManager.Uri);
+ // reload pagina intera
+ NavManager.NavigateTo(NavManager.Uri, true);
}
public void StartTimer()
@@ -154,6 +156,8 @@ namespace MP.Mon.Pages
return answ;
}
+ private string CodGruppo = "";
+
protected override async Task OnInitializedAsync()
{
await setupConf();
@@ -175,6 +179,7 @@ namespace MP.Mon.Pages
private List? CurrConfig = null;
private bool doBlink = false;
private List? listMSE = null;
+ private List listMacchine = new List();
private Random rnd = new Random();
#endregion Private Fields
@@ -218,9 +223,24 @@ namespace MP.Mon.Pages
{
try
{
- var dataList = JsonConvert.DeserializeObject>(currArgs.newMessage);
+ List? dataList = JsonConvert.DeserializeObject>(currArgs.newMessage);
if (dataList != null)
{
+ // se ho filtro macchine --> tengo solo quelle che mi tornano...
+ if (listMacchine != null && listMacchine.Count > 0)
+ {
+ List listaFilt = new List();
+ foreach (var item in listMacchine)
+ {
+ var rigaFilt = dataList.FirstOrDefault(x => x.IdxMacchina == item.IdxMacchina);
+ if (rigaFilt != null)
+ {
+ listaFilt.Add(rigaFilt);
+ }
+ }
+ dataList = listaFilt;
+ }
+
#if DEBUG
// hack: legge 3 volte i dati x stressare sistema
var singleData = dataList;
@@ -272,8 +292,17 @@ namespace MP.Mon.Pages
Log.Info($"setupConf | Effettuato setup parametri | keepAlive: {keepAliveMin} | MaxCol: {maxCol} | doAnimate: {doAnimate} | slowRefreshSec: {slowRefreshSec} | fastRefreshMs: {fastRefreshMs}");
}
+ // verifico se ho richiesta filtro x codGruppo...
+ CodGruppo = NavMan.ExtractQueryStringByKey("CodGruppo");
+ if (!string.IsNullOrEmpty(CodGruppo))
+ {
+ listMacchine = await MMDataService.MacchineGetByGruppo(CodGruppo);
+ }
}
+ [Inject]
+ protected NavigationManager NavMan { get; set; } = null!;
+
#endregion Private Methods
}
}
\ No newline at end of file
diff --git a/MP.Mon/Resources/ChangeLog.html b/MP.Mon/Resources/ChangeLog.html
index 0cd6a0d4..ea073e0d 100644
--- a/MP.Mon/Resources/ChangeLog.html
+++ b/MP.Mon/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MON MAPO
- Versione: 6.16.2402.1919
+ Versione: 6.16.2402.2312
Note di rilascio:
-
diff --git a/MP.Mon/Resources/VersNum.txt b/MP.Mon/Resources/VersNum.txt
index dad8f7b3..3d88ebaa 100644
--- a/MP.Mon/Resources/VersNum.txt
+++ b/MP.Mon/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2402.1919
+6.16.2402.2312
diff --git a/MP.Mon/Resources/manifest.xml b/MP.Mon/Resources/manifest.xml
index f722befa..95c9183b 100644
--- a/MP.Mon/Resources/manifest.xml
+++ b/MP.Mon/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2402.1919
+ 6.16.2402.2312
https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.Mon.zip
https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html
false