diff --git a/MP-TAB-SERV/Shared/MainLayout.razor b/MP-TAB-SERV/Shared/MainLayout.razor
index fabf02f0..99fc2a41 100644
--- a/MP-TAB-SERV/Shared/MainLayout.razor
+++ b/MP-TAB-SERV/Shared/MainLayout.razor
@@ -4,6 +4,7 @@
@inject NavigationManager NavMan
@inject ListSelectDataSrv MDataService
@inject SharedMemService MStor
+@inject MessageService MServ
MP-TAB-SERV
@@ -91,11 +92,6 @@
{
CurrMenuItems = MStor.DictMenu[CurrLevel];
}
- // else
- // {
- // CurrMenuItems = await MDataService.ListLinkFilt(CurrLevel);
- // MStor.DictMenu.Add(CurrLevel, CurrMenuItems);
- // }
await Task.Delay(1);
}
@@ -106,11 +102,17 @@
Log.Info("Start ForceReload");
ResetClass = "btn-warning";
await InvokeAsync(StateHasChanged);
- await MDataService.FlushCache();
+ await MServ.ClearLocalStor();
+ await MServ.ClearSessionStor();
MStor.ResetCache();
- await Task.Delay(200);
+ await MDataService.FlushCache();
+ var allData = await MDataService.ListLinkAll();
+ MStor.SetupMenu(allData);
+ await Task.Delay(300);
ResetClass = "btn-primary";
- await InvokeAsync(StateHasChanged);
+ // await InvokeAsync(StateHasChanged);
+ // ricarica pagina!
+ NavMan.NavigateTo("/", true);
Log.Info("END ForceReload");
}
diff --git a/MP.Data/Services/MessageService.cs b/MP.Data/Services/MessageService.cs
index 26afdf92..13fbc465 100644
--- a/MP.Data/Services/MessageService.cs
+++ b/MP.Data/Services/MessageService.cs
@@ -1,13 +1,9 @@
using Blazored.LocalStorage;
using Blazored.SessionStorage;
-using MongoDB.Bson.IO;
-using MongoDB.Driver.Core.Servers;
using MP.Data.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
@@ -29,29 +25,25 @@ namespace MP.Data.Services
sessionStore = sessStore;
}
-
#endregion Public Constructors
#region Public Events
-
public event Action EA_OperUpdated = null!;
public event Action EA_PageUpdated = null!;
+ #endregion Public Events
+
#if false
public event Action EA_DateChanged = null!;
public event Action EA_CalModeChanged = null!;
- public event Action EA_TimbUpd = null!;
+ public event Action EA_TimbUpd = null!;
#endif
- #endregion Public Events
-
- #region Public Properties
-
#if false
- public RegAttivitaModel? clonedRA { get; set; } = null;
+ public RegAttivitaModel? clonedRA { get; set; } = null;
///
/// Calcola HASH del codice impiego = payload utente
@@ -68,20 +60,7 @@ namespace MP.Data.Services
}
#endif
- public int MatrOpr
- {
- get
- {
- int answ = 102;
- //int answ = -1;
- if (_rigaOper != null)
- {
- answ = _rigaOper.MatrOpr;
- }
- return answ;
- }
- }
-
+ #region Public Properties
///
/// Dizionario macchine
@@ -107,6 +86,96 @@ namespace MP.Data.Services
pUpd.Wait();
}
}
+
+ public int MatrOpr
+ {
+ get
+ {
+ int answ = 102;
+ //int answ = -1;
+ if (_rigaOper != null)
+ {
+ answ = _rigaOper.MatrOpr;
+ }
+ return answ;
+ }
+ }
+
+ public AnagOperatoriModel? RigaOper
+ {
+ get => _rigaOper;
+ set
+ {
+ // salvo
+ _rigaOper = value;
+ if (EA_OperUpdated != null)
+ {
+ EA_OperUpdated?.Invoke();
+ }
+ }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ public async Task ClearLocalStor()
+ {
+ await localStorage.ClearAsync();
+ }
+
+ public async Task ClearSessionStor()
+ {
+ await sessionStore.ClearAsync();
+ }
+
+ ///
+ /// Restituisce il valore Ipv4 del Device da localstorage
+ ///
+ ///
+ public async Task getDevIpAsync()
+ {
+ string answ = "";
+ var result = await localStorage.GetItemAsync(KeyDevIp4);
+ if (result != null)
+ {
+ answ = result;
+ }
+ return answ;
+ }
+
+ ///
+ /// Restituisce il valore di DeviceSecret da localstorage
+ ///
+ ///
+ public async Task getDevSecretAsync()
+ {
+ string answ = "";
+ var result = await localStorage.GetItemAsync(KeyDevSec);
+ if (result != null)
+ {
+ answ = result;
+ }
+ return answ;
+ }
+
+ ///
+ /// Recupero dati MSE x macchina
+ ///
+ ///
+ ///
+ public async Task GetMachineMse(string idxMacchina)
+ {
+ MappaStatoExpl answ = new MappaStatoExpl();
+ //answ = await localStorage.GetItemAsync(machineMse(idxMacchina));
+ string tryString = await localStorage.GetItemAsync(machineMse(idxMacchina));
+ if (tryString != "")
+ {
+ answ = JsonSerializer.Deserialize(tryString);
+ }
+ return answ;
+ }
+
///
/// Macchine attualmente selezionata
///
@@ -139,7 +208,7 @@ namespace MP.Data.Services
public bool isRicTimb { get; set; } = false;
- public CalendarModeEnum.modoControllo modoCal { get; set; } = CalendarModeEnum.modoControllo.showCalendar;
+ public CalendarModeEnum.modoControllo modoCal { get; set; } = CalendarModeEnum.modoControllo.showCalendar;
#endif
#if false
@@ -184,7 +253,7 @@ namespace MP.Data.Services
ReportPageUpd();
}
}
- }
+ }
public string PageName
{
@@ -200,23 +269,8 @@ namespace MP.Data.Services
}
public bool PayloadOk { get; set; } = false;
- public RegAttivitaModel? recordRA { get; set; } = null;
+ public RegAttivitaModel? recordRA { get; set; } = null;
#endif
-
- public AnagOperatoriModel? RigaOper
- {
- get => _rigaOper;
- set
- {
- // salvo
- _rigaOper = value;
- if (EA_OperUpdated != null)
- {
- EA_OperUpdated?.Invoke();
- }
- }
- }
-
#if false
public string SearchVal
{
@@ -251,45 +305,74 @@ namespace MP.Data.Services
}
public DateTime targetDate { get; set; } = DateTime.Today;
- public DateTime targetDateMancTimb { get; set; }
+ public DateTime targetDateMancTimb { get; set; }
#endif
- #endregion Public Properties
-
- protected const string KeyMacDict = "MachineDict";
- protected const string KeyDevSec = "DevSec";
- protected const string KeyDevIp4 = "DevIpv4";
-
- #region Public Methods
-
- ///
- /// Restituisce il valore di DeviceSecret da localstorage
- ///
- ///
- public async Task getDevSecretAsync()
- {
- string answ = "";
- var result = await localStorage.GetItemAsync(KeyDevSec);
- if (result != null)
+ ///
+ /// Effettua salvataggio in localstorage dei dati MSE correnti
+ ///
+ ///
+ ///
+ ///
+ public async Task SaveMse(List currListMSE)
{
- answ = result;
+ foreach (var item in currListMSE)
+ {
+ string serVal = JsonSerializer.Serialize(item);
+ await localStorage.SetItemAsync(machineMse(item.IdxMacchina), serVal);
+ }
}
- return answ;
- }
- ///
- /// Restituisce il valore Ipv4 del Device da localstorage
- ///
- ///
- public async Task getDevIpAsync()
- {
- string answ = "";
- var result = await localStorage.GetItemAsync(KeyDevIp4);
- if (result != null)
+
+ ///
+ /// Scrive il valore di IPV4 del device nel localstoragee
+ ///
+ ///
+ ///
+ public async Task setDevIpv4Async(string newVal)
{
- answ = result;
+ bool answ = false;
+ try
+ {
+ await localStorage.SetItemAsync(KeyDevIp4, newVal);
+ answ = true;
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Eccezione in setDevIpv4Async{Environment.NewLine}{ex}");
+ }
+ return answ;
}
- return answ;
- }
+
+ ///
+ /// Scrive il valore di DeviceSecret nel localstoragee
+ ///
+ ///
+ ///
+ public async Task setDevSecretAsync(string newVal)
+ {
+ bool answ = false;
+ try
+ {
+ await localStorage.SetItemAsync(KeyDevSec, newVal);
+ answ = true;
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Eccezione in setDevSecretAsync{Environment.NewLine}{ex}");
+ }
+ return answ;
+ }
+
+ #endregion Public Methods
+
+ #region Protected Fields
+
+ protected const string KeyDevIp4 = "DevIpv4";
+ protected const string KeyDevSec = "DevSec";
+ protected const string KeyMacDict = "MachineDict";
+
+ #endregion Protected Fields
+
#if false
public void ReportDateChange()
@@ -300,7 +383,6 @@ namespace MP.Data.Services
}
}
-
public void setModeCalendar()
{
modoCal = CalendarModeEnum.modoControllo.showCalendar;
@@ -356,126 +438,48 @@ namespace MP.Data.Services
{
EA_TimbUpd?.Invoke();
}
- }
+ }
#endif
- ///
- /// Scrive il valore di DeviceSecret nel localstoragee
- ///
- ///
- ///
- public async Task setDevSecretAsync(string newVal)
- {
- bool answ = false;
- try
+ #region Protected Properties
+
+ protected ILocalStorageService localStorage { get; set; } = null!;
+
+ protected ISessionStorageService sessionStore { get; set; } = null!;
+
+ #endregion Protected Properties
+
+ #region Private Fields
+
+ private AnagOperatoriModel? _rigaOper;
+
+ private Logger Log = LogManager.GetCurrentClassLogger();
+
+ #endregion Private Fields
+
+ #region Private Methods
+
+ private string machineMse(string idxMacc)
{
- await localStorage.SetItemAsync(KeyDevSec, newVal);
- answ = true;
+ return $"MSE_{idxMacc}";
}
- catch (Exception ex)
- {
- Log.Error($"Eccezione in setDevSecretAsync{Environment.NewLine}{ex}");
- }
- return answ;
- }
- ///
- /// Scrive il valore di IPV4 del device nel localstoragee
- ///
- ///
- ///
- public async Task setDevIpv4Async(string newVal)
- {
- bool answ = false;
- try
- {
- await localStorage.SetItemAsync(KeyDevIp4, newVal);
- answ = true;
- }
- catch (Exception ex)
- {
- Log.Error($"Eccezione in setDevIpv4Async{Environment.NewLine}{ex}");
- }
- return answ;
- }
- private string machineMse(string idxMacc)
- {
- return $"MSE_{idxMacc}";
- }
-
- ///
- /// Effettua salvataggio in localstorage dei dati MSE correnti
- ///
- ///
- ///
- ///
- public async Task SaveMse(List currListMSE)
- {
- foreach (var item in currListMSE)
- {
- string serVal = JsonSerializer.Serialize(item);
- await localStorage.SetItemAsync(machineMse(item.IdxMacchina), serVal);
- }
- }
-
- ///
- /// Recupero dati MSE x macchina
- ///
- ///
- ///
- public async Task GetMachineMse(string idxMacchina)
- {
- MappaStatoExpl answ = new MappaStatoExpl();
- //answ = await localStorage.GetItemAsync(machineMse(idxMacchina));
- string tryString = await localStorage.GetItemAsync(machineMse(idxMacchina));
- if (tryString != "")
- {
- answ = JsonSerializer.Deserialize(tryString);
- }
- return answ;
- }
-
- #endregion Public Methods
-
- #region Protected Properties
-
- protected ILocalStorageService localStorage { get; set; } = null!;
-
- protected ISessionStorageService sessionStore { get; set; } = null!;
-
- #endregion Protected Properties
-
- #region Private Fields
+ #endregion Private Methods
#if false
private string _pageIcon = "";
- private string _pageName = "";
+ private string _pageName = "";
#endif
-
- private AnagOperatoriModel? _rigaOper;
-
-
- private Logger Log = LogManager.GetCurrentClassLogger();
-
#if false
private string _searchVal = "";
- private bool showSearch;
+ private bool showSearch;
#endif
- #endregion Private Fields
-
- #region Private Properties
-
-
#if false
private string lastAction { get; set; } = "";
- private bool nextIsEntrata { get; set; } = true;
+ private bool nextIsEntrata { get; set; } = true;
#endif
- #endregion Private Properties
-
- #region Private Methods
-
#if false
private void ReportPageUpd()
{
@@ -491,9 +495,7 @@ namespace MP.Data.Services
{
EA_DipUpdated?.Invoke();
}
- }
+ }
#endif
-
- #endregion Private Methods
-}
-}
+ }
+}
\ No newline at end of file