-
- @if (!liveUpdate)
- {
-
- }
- else
- {
-
- }
+
+
+
+
+ @if (!liveUpdate)
+ {
+
+ }
+ else
+ {
+
+ }
+
+
+
+ @if (selMacchina != "*")
+ {
+
+ }
+
+
+
@if (showEditPar)
{
-
+
-
-
-
-
-
+
+
@@ -62,34 +76,37 @@
}
else
{
-
+
}
-
-
-
- @if (ListMacchine != null)
- {
- foreach (var item in ListMacchine)
+
+
+
+
+
+ @if (ListMacchine != null)
{
-
+ foreach (var item in ListMacchine)
+ {
+
+ }
}
- }
-
-
-
-
-
- @if (ListFlux != null)
- {
- foreach (var item in ListFlux)
+
+
+
+
+ @if (ListFlux != null)
{
-
+ foreach (var item in ListFlux)
+ {
+
+ }
}
- }
-
+
+
+
diff --git a/MP.SPEC/Components/ParamsFilter.razor.cs b/MP.SPEC/Components/ParamsFilter.razor.cs
index ed1ef126..a715db76 100644
--- a/MP.SPEC/Components/ParamsFilter.razor.cs
+++ b/MP.SPEC/Components/ParamsFilter.razor.cs
@@ -17,7 +17,11 @@ namespace MP.SPEC.Components
#region Protected Fields
- protected string lastUpdate = "-";
+ protected string lastUpdate
+ {
+ get => SelFilter.lastUpdate;
+ set => SelFilter.lastUpdate = value;
+ }
#endregion Protected Fields
@@ -145,6 +149,14 @@ namespace MP.SPEC.Components
}
}
+ protected async Task takeSnapshot()
+ {
+ // fermo udpate
+ liveUpdate = false;
+ await MDService.DossiersTakeParamsSnapshot(selMacchina, 10);
+ lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
+ }
+
#endregion Protected Methods
#region Private Fields
diff --git a/MP.SPEC/Data/MessageService.cs b/MP.SPEC/Data/MessageService.cs
index 79ca19ff..02a690b2 100644
--- a/MP.SPEC/Data/MessageService.cs
+++ b/MP.SPEC/Data/MessageService.cs
@@ -150,7 +150,7 @@
private string searchVal = "";
private bool showSearch;
private string stateSel = "*";
- private string tipoSearch = "*";
+ private string tipoSearch = "";
#endregion Private Fields
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs
index 2c864fec..64e95ba8 100644
--- a/MP.SPEC/Data/MpDataService.cs
+++ b/MP.SPEC/Data/MpDataService.cs
@@ -1,6 +1,7 @@
using MP.Data;
using MP.Data.Conf;
using MP.Data.DatabaseModels;
+using MP.Data.DTO;
using Newtonsoft.Json;
using NLog;
using StackExchange.Redis;
@@ -20,8 +21,12 @@ namespace MP.SPEC.Data
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
+ redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin"));
redisDb = redisConn.GetDatabase();
+ // leggo cache lungo periodo
+ int.TryParse(_configuration.GetValue
("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
+
_logger.LogInformation("Redis INIT");
// setup canali pub/sub
@@ -62,7 +67,6 @@ namespace MP.SPEC.Data
public async Task> AnagStatiComm()
{
- int maxAgeConfig = 5;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
List? result = new List();
@@ -80,7 +84,7 @@ namespace MP.SPEC.Data
result = await Task.FromResult(dbController.AnagStatiComm());
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(redisStatoCom, rawData, getRandTOut(maxAgeConfig));
+ await redisDb.StringSetAsync(redisStatoCom, rawData, getRandTOut(redisLongTimeCache));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AnagStatiComm Read from DB: {ts.TotalMilliseconds}ms");
@@ -94,7 +98,6 @@ namespace MP.SPEC.Data
public async Task> AnagTipoArtLV()
{
- int maxAgeConfig = 5;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
List? result = new List();
@@ -112,7 +115,7 @@ namespace MP.SPEC.Data
result = await Task.FromResult(dbController.AnagTipoArtLV());
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(redisTipoArt, rawData, getRandTOut(maxAgeConfig));
+ await redisDb.StringSetAsync(redisTipoArt, rawData, getRandTOut(redisLongTimeCache));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AnagTipoArtLV Read from DB: {ts.TotalMilliseconds}ms");
@@ -224,7 +227,6 @@ namespace MP.SPEC.Data
public async Task> ConfigGetAll()
{
- int maxAgeConfig = 5;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
List? result = new List();
@@ -242,7 +244,7 @@ namespace MP.SPEC.Data
result = await Task.FromResult(dbController.ConfigGetAll());
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(redisConfKey, rawData, getRandTOut(maxAgeConfig));
+ await redisDb.StringSetAsync(redisConfKey, rawData, getRandTOut(redisLongTimeCache));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ConfigGetAll Read from DB: {ts.TotalMilliseconds}ms");
@@ -272,6 +274,14 @@ namespace MP.SPEC.Data
return await Task.FromResult(dbController.ConfigUpdate(updRec));
}
+ public List convertToFluxLog(string Valore)
+ {
+ //string valStriped = Valore.Substring(7, Valore.Length - 8);
+ //var result = JsonConvert.DeserializeObject>(valStriped);
+ var result = JsonConvert.DeserializeObject(Valore);
+ return result.ODL;
+ }
+
public void Dispose()
{
// Clear database controller
@@ -279,6 +289,65 @@ namespace MP.SPEC.Data
redisConn.Dispose();
}
+ ///
+ /// Elenco ultimi n record DOssiers (che contengono ad esempio "salvataggi" di FLuxLog) dato
+ /// macchina (ordinato x data registrazione)
+ ///
+ /// * = tutte, altrimenti solo x una data macchina
+ /// Data di riferimento (Massima) per estrazione records
+ /// numero massimo record da restituire
+ ///
+ public async Task> DossiersGetLastFilt(string IdxMacchina, DateTime DtRef, int MaxRec)
+ {
+ List? result = new List();
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string readType = "DB";
+ string currKey = $"{redisDossByMac}:{IdxMacchina}";
+ // cerco in redis dato valore sel macchina...
+ RedisValue rawData = redisDb.StringGet(currKey);
+ if (rawData.HasValue)
+ {
+ result = JsonConvert.DeserializeObject>($"{rawData}");
+ readType = "REDIS";
+ }
+ else
+ {
+ result = await Task.FromResult(dbController.DossiersGetLastFilt(IdxMacchina, DtRef, MaxRec));
+ // serializzp e salvo...
+ rawData = JsonConvert.SerializeObject(result);
+ redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache / 5));
+ }
+ if (result == null)
+ {
+ result = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DossiersGetLastFilt | Read from {readType}: {ts.TotalMilliseconds}ms");
+ return result;
+ }
+
+ ///
+ /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis
+ ///
+ /// macchina
+ /// NUm massimo secondi per recuperare dati correnti
+ ///
+ public async Task DossiersTakeParamsSnapshot(string IdxMacchina, int MaxSec)
+ {
+ bool answ = false;
+ await Task.Delay(1);
+ // chiamo stored x salvare parametri
+ dbController.DossiersTakeParamsSnapshot(IdxMacchina, MaxSec);
+ // svuoto cache redis x macchina
+ string currKey = $"{redisDossByMac}:{IdxMacchina}";
+ redisDb.StringSet(currKey, "", TimeSpan.FromSeconds(1));
+ currKey = $"{redisDossByMac}:*";
+ redisDb.StringSet(currKey, "", TimeSpan.FromSeconds(1));
+ return answ;
+ }
+
///
/// Restitusice elenco aziende
///
@@ -302,6 +371,27 @@ namespace MP.SPEC.Data
return Task.FromResult(dbController.ElencoLink());
}
+ public async Task FlushRedisCache()
+ {
+ await Task.Delay(1);
+ bool answ = false;
+ var listEndpoints = redisConnAdmin.GetEndPoints();
+ var server = redisConnAdmin.GetServer(listEndpoints[0]);
+ RedisValue pattern = new RedisValue($"{redisBaseAddr}*");
+ if (server != null)
+ {
+ var keyList = server.Keys(redisDb.Database, pattern);
+ foreach (var item in keyList)
+ {
+ await redisDb.KeyDeleteAsync(item);
+ }
+ // brutalmente rimuovo intero contenuto DB... DANGER
+ //await server.FlushDatabaseAsync();
+ answ = true;
+ }
+ return answ;
+ }
+
///
/// Elenco ultimi n record flux log dato macchina e flusso (ordinato x data registrazione)
///
@@ -379,8 +469,6 @@ namespace MP.SPEC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- // 5 minuti valore cache
- int maxAgeMin = 5;
string currKey = redisMacList;
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
@@ -394,7 +482,7 @@ namespace MP.SPEC.Data
result = await Task.FromResult(dbController.MacchineGetAll());
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(maxAgeMin));
+ redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
}
if (result == null)
{
@@ -416,8 +504,6 @@ namespace MP.SPEC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- // 5 minuti valore cache
- int maxAgeMin = 5;
string currKey = redisMacByFlux;
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
@@ -431,7 +517,7 @@ namespace MP.SPEC.Data
result = await Task.FromResult(dbController.MacchineWithFlux());
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(maxAgeMin));
+ redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
}
if (result == null)
{
@@ -454,8 +540,6 @@ namespace MP.SPEC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- // 5 minuti valore cache
- int maxAgeMin = 5;
string currKey = $"{redisFluxByMac}:{IdxMacchina}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
@@ -469,7 +553,7 @@ namespace MP.SPEC.Data
result = await Task.FromResult(dbController.ParametriGetFilt(IdxMacchina));
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(maxAgeMin));
+ redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
}
if (result == null)
{
@@ -526,16 +610,16 @@ namespace MP.SPEC.Data
#region Private Fields
- private const string redisConfKey = "MP:SPEC:Cache:Config";
- private const string redisFluxByMac = "MP:SPEC:Cache:FluxByMac";
- private const string redisMacByFlux = "MP:SPEC:Cache:MacByFlux";
- private const string redisMacList = "MP:SPEC:Cache:MacList";
- private const string redisStatoCom = "MP:SPEC:Cache:StatoCom";
- private const string redisTipoArt = "MP:SPEC:Cache:TipoArt";
+ private const string redisBaseAddr = "MP:";
+ private const string redisConfKey = redisBaseAddr + "SPEC:Cache:Config";
+ private const string redisDossByMac = redisBaseAddr + "SPEC:Cache:DossByMac";
+ private const string redisFluxByMac = redisBaseAddr + "SPEC:Cache:FluxByMac";
+ private const string redisMacByFlux = redisBaseAddr + "SPEC:Cache:MacByFlux";
+ private const string redisMacList = redisBaseAddr + "SPEC:Cache:MacList";
+ private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom";
+ private const string redisTipoArt = redisBaseAddr + "SPEC:Cache:TipoArt";
private static IConfiguration _configuration = null!;
-
private static ILogger _logger = null!;
-
private static Logger Log = LogManager.GetCurrentClassLogger();
///
@@ -543,11 +627,18 @@ namespace MP.SPEC.Data
///
private ConnectionMultiplexer redisConn = null!;
+ ///
+ /// Oggetto per connessione a REDIS modalità admin (ex flux dati)
+ ///
+ private ConnectionMultiplexer redisConnAdmin = null!;
+
///
/// Oggetto DB redis da impiegare x chiamate R/W
///
private IDatabase redisDb = null!;
+ private int redisLongTimeCache = 5;
+
#endregion Private Fields
}
}
\ No newline at end of file
diff --git a/MP.SPEC/Data/SelectDossierParams.cs b/MP.SPEC/Data/SelectDossierParams.cs
new file mode 100644
index 00000000..ebcf3928
--- /dev/null
+++ b/MP.SPEC/Data/SelectDossierParams.cs
@@ -0,0 +1,68 @@
+namespace MP.SPEC.Data
+{
+ public class SelectDossierParams
+ {
+ #region Public Constructors
+
+ public SelectDossierParams()
+ { }
+
+ #endregion Public Constructors
+
+ #region Public Properties
+
+ ///
+ /// Inizializzazione con periodo e arrotondamento
+ ///
+ ///
+ ///
+ ///
+ public static DateTime Init(int minRound)
+ {
+ TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today);
+ int minDay = (int)Math.Ceiling((double)(DayElapsed.TotalMinutes / minRound)) * minRound;
+ DateTime endRounded = DateTime.Today.AddMinutes(minDay);
+ return endRounded;
+ }
+
+ public string IdxMacchina { get; set; } = "*";
+
+ public int MaxRecord { get; set; } = 100;
+ public DateTime DtRef { get; set; } = Init(5);
+ public int CurrPage { get; set; } = 1;
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ public override bool Equals(object obj)
+ {
+ if (!(obj is SelectDossierParams item))
+ return false;
+
+ if (IdxMacchina != item.IdxMacchina)
+ return false;
+
+ if (MaxRecord != item.MaxRecord)
+ return false;
+
+ if (DtRef != item.DtRef)
+ return false;
+
+ if (CurrPage != item.CurrPage)
+ return false;
+
+ //if (lastUpdate != item.lastUpdate)
+ // return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode();
+ }
+
+ #endregion Public Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.SPEC/Data/SelectFluxParams.cs b/MP.SPEC/Data/SelectFluxParams.cs
index 685d046b..92559e14 100644
--- a/MP.SPEC/Data/SelectFluxParams.cs
+++ b/MP.SPEC/Data/SelectFluxParams.cs
@@ -18,6 +18,7 @@
public int MaxRecord { get; set; } = 100;
public int TempoAgg { get; set; } = 2000;
public int CurrPage { get; set; } = 1;
+ public string lastUpdate { get; set; } = "-";
#endregion Public Properties
@@ -46,6 +47,9 @@
if (CurrPage != item.CurrPage)
return false;
+ if (lastUpdate != item.lastUpdate)
+ return false;
+
return true;
}
diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj
index 45d1f9ee..55d5b54d 100644
--- a/MP.SPEC/MP.SPEC.csproj
+++ b/MP.SPEC/MP.SPEC.csproj
@@ -5,6 +5,7 @@
enable
enable
MP.SPEC
+ 6.16.2209.2110
@@ -38,6 +39,12 @@
Always
+
+ Always
+
+
+
+
diff --git a/MP.SPEC/Pages/Articoli.razor b/MP.SPEC/Pages/Articoli.razor
index f4c1a9ff..d6e4522f 100644
--- a/MP.SPEC/Pages/Articoli.razor
+++ b/MP.SPEC/Pages/Articoli.razor
@@ -17,15 +17,18 @@
-
- @if (ListAziende != null)
- {
- foreach (var item in ListAziende)
+
+
+
+ @if (ListAziende != null)
{
-
+ foreach (var item in ListAziende)
+ {
+
+ }
}
- }
-
+
+
@if (currRecord != null)
@@ -119,11 +122,11 @@
|
-
Articolo |
-
Disegno |
-
Descrizione |
-
Tipo |
-
Azienda |
+
Articolo |
+
Disegno |
+
Descrizione |
+
Tipo |
+
Azienda |
|
diff --git a/MP.SPEC/Pages/DOSS.razor b/MP.SPEC/Pages/DOSS.razor
new file mode 100644
index 00000000..0b62dd06
--- /dev/null
+++ b/MP.SPEC/Pages/DOSS.razor
@@ -0,0 +1,37 @@
+@page "/DOSS"
+
+
+
+
+ @if (isLoading)
+ {
+
+ }
+ else
+ {
+
+ }
+
+
+
+
+
diff --git a/MP.SPEC/Pages/DOSS.razor.cs b/MP.SPEC/Pages/DOSS.razor.cs
new file mode 100644
index 00000000..2038917f
--- /dev/null
+++ b/MP.SPEC/Pages/DOSS.razor.cs
@@ -0,0 +1,91 @@
+using Microsoft.AspNetCore.Components;
+using MP.SPEC.Components;
+using MP.SPEC.Data;
+
+namespace MP.SPEC.Pages
+{
+ public partial class DOSS
+ {
+ #region Protected Fields
+
+ protected DataPager pagerODL = null!;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ [Inject]
+ protected MessageService MsgService { get; set; } = null!;
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ protected void ForceReload(int newNum)
+ {
+ numRecord = newNum;
+ }
+
+ protected override async Task OnInitializedAsync()
+ {
+ isLoading = true;
+ isFiltering = true;
+ // disabilito ricerca...
+ MsgService.SearchVal = "";
+ MsgService.ShowSearch = false;
+ // fix pagina
+ await Task.Delay(1);
+ var modFilter = currFilter;
+ modFilter.CurrPage = 1;
+ currFilter = modFilter;
+ await Task.Delay(1);
+ isFiltering = false;
+ }
+
+ protected void updateTotal(int newTotCount)
+ {
+ totalCount = newTotCount;
+ }
+
+ #endregion Protected Methods
+
+ #region Private Properties
+
+ private SelectDossierParams currFilter { get; set; } = new SelectDossierParams();
+
+ private int currPage
+ {
+ get => MsgService.currPage;
+ set => MsgService.currPage = value;
+ }
+
+ private bool isFiltering { get; set; } = false;
+ private bool isLoading { get; set; } = true;
+
+ private int numRecord
+ {
+ get => MsgService.numRecord;
+ set => MsgService.numRecord = value;
+ }
+
+ private int totalCount { get; set; } = 0;
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ private async Task updateFilter(SelectDossierParams newParams)
+ {
+ isFiltering = false;
+ isLoading = true;
+ await Task.Delay(1);
+ currPage = 1;
+ await Task.Delay(1);
+ await InvokeAsync(() => StateHasChanged());
+ currFilter = newParams;
+ isLoading = false;
+ }
+
+ #endregion Private Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.SPEC/Pages/Index.razor b/MP.SPEC/Pages/Index.razor
index b3173e20..0616f89b 100644
--- a/MP.SPEC/Pages/Index.razor
+++ b/MP.SPEC/Pages/Index.razor
@@ -18,9 +18,7 @@
-
MAPO MES Custom Pages
-
-
+
@if (ElencoLink == null)
@@ -46,7 +44,16 @@
-
Custom pages azienda @currAzienda
+
diff --git a/MP.SPEC/Pages/ODL.razor b/MP.SPEC/Pages/ODL.razor
index c99f8b4d..10b5550c 100644
--- a/MP.SPEC/Pages/ODL.razor
+++ b/MP.SPEC/Pages/ODL.razor
@@ -2,223 +2,29 @@