Fix MessageService
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
using EgwCoreLib.Utils;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.DatabaseModels;
|
||||
@@ -27,6 +28,54 @@ namespace MP.Data.Services
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected const string KeyDevIp4 = "DevIpv4";
|
||||
|
||||
protected const string KeyDevSec = "DevSec";
|
||||
|
||||
protected const string KeyMacDict = "MachineDict";
|
||||
|
||||
protected static IConfiguration _configuration = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
protected ConnectionMultiplexer redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
protected IDatabase redisDb = null!;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private AnagOperatoriModel? _rigaOper;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
private string lastIdxMacc = "";
|
||||
|
||||
private DateTime lastUserUpd = DateTime.Now;
|
||||
|
||||
private Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private string redisBaseKey = "MP:TAB:User";
|
||||
|
||||
private Random rnd = new Random();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MessageService(IConfiguration configuration, ILocalStorageService genLocalStorage, ISessionStorageService sessStore, TabDataService tdService, SharedMemService smServ)
|
||||
@@ -98,7 +147,6 @@ namespace MP.Data.Services
|
||||
}
|
||||
|
||||
public DateTime dtLastAction { get; set; } = DateTime.Now;
|
||||
|
||||
public DateTime dtLastSave { get; set; } = DateTime.Now;
|
||||
|
||||
public string LastIdxMacchina
|
||||
@@ -115,6 +163,28 @@ namespace MP.Data.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cache elenco macchine abilitate all'utente, vuoto se scaduto reload
|
||||
/// </summary>
|
||||
public List<Macchine>? ListMachineEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Macchine>? answ = userListMachine;
|
||||
if (DateTime.Now.Subtract(lastUserUpd).TotalSeconds > 30)
|
||||
{
|
||||
answ = new List<Macchine>();
|
||||
Log.Debug("ListMachineEnabled unvalidated");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
lastUserUpd = DateTime.Now;
|
||||
userListMachine = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int MatrOpr
|
||||
{
|
||||
get
|
||||
@@ -184,6 +254,23 @@ namespace MP.Data.Services
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected int expDays { get; set; } = 0;
|
||||
protected ILocalStorageService localStorage { get; set; } = null!;
|
||||
protected ISessionStorageService sessionStore { get; set; } = null!;
|
||||
protected SharedMemService SMService { get; set; } = null!;
|
||||
protected TabDataService TDService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private List<Macchine>? userListMachine { get; set; } = null;
|
||||
private Dictionary<string, string> UserPrefs { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task ClearLocalStor()
|
||||
@@ -612,62 +699,6 @@ namespace MP.Data.Services
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected const string KeyDevIp4 = "DevIpv4";
|
||||
protected const string KeyDevSec = "DevSec";
|
||||
protected const string KeyMacDict = "MachineDict";
|
||||
protected static IConfiguration _configuration = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
protected ConnectionMultiplexer redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
protected IDatabase redisDb = null!;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected int expDays { get; set; } = 0;
|
||||
protected ILocalStorageService localStorage { get; set; } = null!;
|
||||
protected ISessionStorageService sessionStore { get; set; } = null!;
|
||||
protected SharedMemService SMService { get; set; } = null!;
|
||||
protected TabDataService TDService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private AnagOperatoriModel? _rigaOper;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlLong = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache breve IN SECONDI
|
||||
/// </summary>
|
||||
private int cacheTtlShort = 60 * 1;
|
||||
|
||||
private string lastIdxMacc = "";
|
||||
private Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private string redisBaseKey = "MP:TAB:User";
|
||||
private Random rnd = new Random();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private Dictionary<string, string> UserPrefs { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string machineMse(string idxMacc)
|
||||
|
||||
Reference in New Issue
Block a user