diff --git a/LiMan.Api/Data/ApiDataService.cs b/LiMan.Api/Data/ApiDataService.cs index cb7d378..9f48f0a 100644 --- a/LiMan.Api/Data/ApiDataService.cs +++ b/LiMan.Api/Data/ApiDataService.cs @@ -47,7 +47,6 @@ namespace LiMan.APi.Data /// /// public ApiDataService(IConfiguration configuration, ILogger logger, IEmailSender emailSender, IRedisCacheClient redisCacheClient, IConnectionMultiplexer redisConnMult) - //public ApiDataService(IConfiguration configuration, ILogger logger, IDistributedCache distributedCache, IEmailSender emailSender, IRedisCacheClient redisCacheClient) { _logger = logger; _configuration = configuration; @@ -1733,7 +1732,6 @@ namespace LiMan.APi.Data private readonly IEmailSender _emailSender; - //private readonly IDistributedCache distributedCache; private readonly IRedisCacheClient _redisCacheClient; /// diff --git a/LiMan.Api/Resources/ChangeLog.html b/LiMan.Api/Resources/ChangeLog.html index 5bdadfc..30894b2 100644 --- a/LiMan.Api/Resources/ChangeLog.html +++ b/LiMan.Api/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

Versione: 2.1.2501.2907

+

Versione: 2.1.2501.2910


Note di rilascio:
  • diff --git a/LiMan.Api/Resources/VersNum.txt b/LiMan.Api/Resources/VersNum.txt index 1e22251..83dfcaa 100644 --- a/LiMan.Api/Resources/VersNum.txt +++ b/LiMan.Api/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.2907 +2.1.2501.2910 diff --git a/LiMan.Api/Resources/manifest.xml b/LiMan.Api/Resources/manifest.xml index 8cc3a19..dba703e 100644 --- a/LiMan.Api/Resources/manifest.xml +++ b/LiMan.Api/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.2907 + 2.1.2501.2910 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false diff --git a/LiMan.DB/Services/CommonDataServices.cs b/LiMan.DB/Services/CommonDataServices.cs index 9c9b7cc..8e1a95a 100644 --- a/LiMan.DB/Services/CommonDataServices.cs +++ b/LiMan.DB/Services/CommonDataServices.cs @@ -618,6 +618,136 @@ namespace LiMan.DB.Services return answ; } + /// + /// Recupera licenza dato IDX + /// + /// + /// + public LicenzaModel LicenzaNextGetByIdx(int IdxLic) + { + Stopwatch sw = new Stopwatch(); + LicenzaModel dbResult = new LicenzaModel(); + sw.Start(); + dbResult = dbControllerNext.GetLicenza(IdxLic); + sw.Stop(); + TimeSpan ts = sw.Elapsed; + Log.Trace($"Effettuata lettura da DB per LicenzeNextGetByIdx: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + public async Task ReleaseDelete(ReleaseModel rec2del) + { + bool fatto = dbControllerNext.ReleaseDelete(rec2del); + await FlushRedisCache(); + return fatto; + } + + /// + /// Elenco Release dato Applicativo + /// + /// Codice Applicazione + /// + public async Task> ReleaseGetByApp(string CodApp) + { + string source = "DB"; + List? dbResult = new List(); + try + { + string currKey = $"{Const.rKeyConfig}:App:AllRel:{CodApp}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbControllerNext.ReleaseGetByApp(CodApp); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + // per evitare loopback uso deserialize... + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult != null) + { + dbResult = tempResult; + } + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ReleaseGetByApp | {source} in: {ts.TotalMilliseconds} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during ReleaseGetByApp:{Environment.NewLine}{exc}"); + } + return dbResult; + } + + /// + /// Elenco Release dato Applicativo + versione minima + /// + /// Codice Applicazione + /// Versione minima richiesta + /// + public async Task> ReleaseGetByAppVers(string CodApp, string VersMin) + { + await Task.Delay(1); + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbControllerNext.ReleaseGetByAppVers(CodApp, VersMin); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per ReleaseGetByAppVers | {CodApp} | vers >= {VersMin} | {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Ultima Release dato Applicativo VALIDA (= rilasciata) + /// + /// Codice Applicazione + /// + public async Task ReleaseLastGetByApp(string CodApp) + { + string answ = ""; + RedisKey currKey = $"{Const.rKeyConfig}:App:CurrRel"; + var rawVal = await redisDb.HashGetAsync(currKey, CodApp); + if (rawVal.HasValue) + { + answ = $"{rawVal}"; + } + else + { + var rawList = await ReleaseGetByApp(CodApp); + if (rawList != null) + { + var lastRel = rawList + .Where(x => x.IsReleased) + .OrderByDescending(x => x.VersVal) + .ThenByDescending(x => x.ReleaseDate) + .FirstOrDefault() ?? new ReleaseModel() { CodApp = CodApp }; + answ = lastRel.VersNum; + // salvo su redis tab... + await redisDb.HashSetAsync(currKey, CodApp, answ); + } + } + return answ; + } + /// /// Restituisce i task associati ad un dato EgwACC in stato DONE /// @@ -901,21 +1031,11 @@ namespace LiMan.DB.Services return answ; } - #endregion Protected Methods - - #region Private Fields - - private Dictionary UserClaimsLUT = new Dictionary(); - - #endregion Private Fields - - #region Private Methods - /// /// Eliminazione di un HashSet Redis /// /// Chiave del dizionario - private bool redisHashDictDelete(RedisKey dictKey) + protected bool redisHashDictDelete(RedisKey dictKey) { bool fatto = false; try @@ -940,7 +1060,7 @@ namespace LiMan.DB.Services ///
/// Chiave del dizionario /// Dizionario valori salvato - private Dictionary redisHashDictGet(RedisKey dictKey) + protected Dictionary redisHashDictGet(RedisKey dictKey) { Dictionary answ = new Dictionary(); try @@ -961,7 +1081,7 @@ namespace LiMan.DB.Services /// /// Chiave del dizionario /// Valore Dizionario da salvare - private bool redisHashDictSet(RedisKey dictKey, Dictionary dict) + protected bool redisHashDictSet(RedisKey dictKey, Dictionary dict) { // ove non indicato expiry è 0 = MAI return redisHashDictSet(dictKey, dict, 0); @@ -973,7 +1093,7 @@ namespace LiMan.DB.Services /// Chiave del dizionario /// Valore Dizionario da salvare /// Expiry in minuti del valore, se 0 = mai - private bool redisHashDictSet(RedisKey dictKey, Dictionary dict, double expireMin) + protected bool redisHashDictSet(RedisKey dictKey, Dictionary dict, double expireMin) { bool fatto = false; try @@ -1006,7 +1126,7 @@ namespace LiMan.DB.Services /// /// Chiave del dizionario /// Chiave del valore da eliminare (singolo record) - private bool redisHashKeyDelete(RedisKey dictKey, string recKey) + protected bool redisHashKeyDelete(RedisKey dictKey, string recKey) { bool fatto = false; try @@ -1021,13 +1141,24 @@ namespace LiMan.DB.Services return fatto; } + /// + /// recupero un singolo valore in HashSet Redis + /// + /// Chiave del dizionario + /// Chiave valore da recuperare + protected string redisHashKeyGet(RedisKey dictKey, string recKey) + { + string answ = redisDb.HashGet(dictKey, (RedisValue)recKey); + return answ; + } + /// /// Salvataggio di un singolo valore in HashSet Redis, con expiry NON gestito (0 = mai) /// /// Chiave del dizionario /// Chiave valore da salvare /// Valore da salvare - private bool redisHashKeySet(RedisKey dictKey, string recKey, string recVal) + protected bool redisHashKeySet(RedisKey dictKey, string recKey, string recVal) { // ove non indicato expiry è 0 = MAI return redisHashKeySet(dictKey, recKey, recVal, 0); @@ -1040,7 +1171,7 @@ namespace LiMan.DB.Services /// Chiave valore da salvare /// Valore da salvare /// Expiry in minuti del valore, se 0 = mai - private bool redisHashKeySet(RedisKey dictKey, string recKey, string recVal, double expireMin) + protected bool redisHashKeySet(RedisKey dictKey, string recKey, string recVal, double expireMin) { bool fatto = false; try @@ -1063,6 +1194,12 @@ namespace LiMan.DB.Services return fatto; } - #endregion Private Methods + #endregion Protected Methods + + #region Private Fields + + private Dictionary UserClaimsLUT = new Dictionary(); + + #endregion Private Fields } } \ No newline at end of file diff --git a/LiMan.Transfer/Resources/ChangeLog.html b/LiMan.Transfer/Resources/ChangeLog.html index 0d1d222..6501505 100644 --- a/LiMan.Transfer/Resources/ChangeLog.html +++ b/LiMan.Transfer/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

Versione: 2.1.2501.2907

+

Versione: 2.1.2501.2910


Note di rilascio:
    diff --git a/LiMan.Transfer/Resources/VersNum.txt b/LiMan.Transfer/Resources/VersNum.txt index 1e22251..83dfcaa 100644 --- a/LiMan.Transfer/Resources/VersNum.txt +++ b/LiMan.Transfer/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.2907 +2.1.2501.2910 diff --git a/LiMan.Transfer/Resources/manifest.xml b/LiMan.Transfer/Resources/manifest.xml index 012d1cd..2d49877 100644 --- a/LiMan.Transfer/Resources/manifest.xml +++ b/LiMan.Transfer/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.2907 + 2.1.2501.2910 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.Transfer.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false diff --git a/LiMan.UI/Components/Activations.razor.cs b/LiMan.UI/Components/Activations.razor.cs index 1d6a42f..01786e7 100644 --- a/LiMan.UI/Components/Activations.razor.cs +++ b/LiMan.UI/Components/Activations.razor.cs @@ -179,7 +179,7 @@ namespace LiMan.UI.Components private async Task fullReload() { - await DataService.InvalidateAllCache(); + await DataService.FlushRedisCache(); await ReloadAllData(); } diff --git a/LiMan.UI/Components/ListApplicazioni.razor.cs b/LiMan.UI/Components/ListApplicazioni.razor.cs index 920c85a..f722fb1 100644 --- a/LiMan.UI/Components/ListApplicazioni.razor.cs +++ b/LiMan.UI/Components/ListApplicazioni.razor.cs @@ -281,7 +281,7 @@ namespace LiMan.UI.Components { recordEdit = null; recordSel = null; - await DataService.InvalidateAllCache(); + await DataService.FlushRedisCache(); await ReloadAllData(); } diff --git a/LiMan.UI/Components/ListApplicazioniGLS.razor.cs b/LiMan.UI/Components/ListApplicazioniGLS.razor.cs index 8efdc1c..cec8fa0 100644 --- a/LiMan.UI/Components/ListApplicazioniGLS.razor.cs +++ b/LiMan.UI/Components/ListApplicazioniGLS.razor.cs @@ -11,6 +11,91 @@ namespace LiMan.UI.Components { public partial class ListApplicazioniGLS : ComponentBase, IDisposable { + #region Public Methods + + public string checkSelect(string Applicativo) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.Applicativo == Applicativo) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + public void Dispose() + { + } + + #endregion Public Methods + + #region Protected Fields + + protected int totalCount = 0; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected MessageService AppMService { get; set; } + + [Inject] + protected LiManDataService DataService { get; set; } + + [Inject] + protected IJSRuntime JSRuntime { get; set; } + + [Inject] + protected NavigationManager NavManager { get; set; } + + protected bool showCamera { get; set; } = false; + + #endregion Protected Properties + + #region Protected Methods + + protected void Edit(AnagApplicazioni selRecord) + { + currRecord = selRecord; + } + + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + protected async Task PagerReloadNum(int newNum) + { + numRecord = newNum; + await ReloadAllData(); + isLoading = false; + } + + protected async Task PagerReloadPage(int newNum) + { + currPage = newNum; + await ReloadAllData(); + isLoading = false; + } + + protected async Task ResetData() + { + await FullReload(); + } + + protected async Task UpdateData() + { + await FullReload(); + } + + #endregion Protected Methods + #region Private Fields private AnagApplicazioni currRecord = null; @@ -19,12 +104,6 @@ namespace LiMan.UI.Components #endregion Private Fields - #region Protected Fields - - protected int totalCount = 0; - - #endregion Protected Fields - #region Private Properties private int currPage @@ -55,30 +134,12 @@ namespace LiMan.UI.Components #endregion Private Properties - #region Protected Properties - - [Inject] - protected MessageService AppMService { get; set; } - - [Inject] - protected LiManDataService DataService { get; set; } - - [Inject] - protected IJSRuntime JSRuntime { get; set; } - - [Inject] - protected NavigationManager NavManager { get; set; } - - protected bool showCamera { get; set; } = false; - - #endregion Protected Properties - #region Private Methods - private async Task fullReload() + private async Task FullReload() { currRecord = null; - await DataService.InvalidateAllCache(); + await DataService.FlushRedisCache(); await ReloadAllData(); } @@ -94,66 +155,5 @@ namespace LiMan.UI.Components } #endregion Private Methods - - #region Protected Methods - - protected void Edit(AnagApplicazioni selRecord) - { - currRecord = selRecord; - } - - protected override async Task OnInitializedAsync() - { - await ReloadAllData(); - } - - protected async Task PagerReloadNum(int newNum) - { - numRecord = newNum; - await ReloadAllData(); - isLoading = false; - } - - protected async Task PagerReloadPage(int newNum) - { - currPage = newNum; - await ReloadAllData(); - isLoading = false; - } - - protected async Task ResetData() - { - await fullReload(); - } - - protected async Task UpdateData() - { - await fullReload(); - } - - #endregion Protected Methods - - #region Public Methods - - public string checkSelect(string Applicativo) - { - string answ = ""; - if (currRecord != null) - { - try - { - answ = (currRecord.Applicativo == Applicativo) ? "table-info" : ""; - } - catch - { } - } - return answ; - } - - public void Dispose() - { - } - - #endregion Public Methods } } \ No newline at end of file diff --git a/LiMan.UI/Components/ListAttach.razor.cs b/LiMan.UI/Components/ListAttach.razor.cs index 5e4bd97..46f8087 100644 --- a/LiMan.UI/Components/ListAttach.razor.cs +++ b/LiMan.UI/Components/ListAttach.razor.cs @@ -1,10 +1,7 @@ -using Core; using LiMan.DB.DBModels; -using LiMan.DB.DTO; using LiMan.UI.Data; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -13,29 +10,51 @@ namespace LiMan.UI.Components { public partial class ListAttach { - private List ListRecords; + #region Public Properties + + [Parameter] + public EventCallback DataReset { get; set; } + + #endregion Public Properties + + #region Protected Fields + protected int totalCount = 0; + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected LiManDataService DataService { get; set; } + + #endregion Protected Properties + + #region Private Fields + + private List ListRecords; + + #endregion Private Fields + //protected override async Task OnInitializedAsync() //{ // await ReloadAllData(); //} + #region Private Properties + private bool isLoading { get; set; } = false; [Inject] private IJSRuntime JSRuntime { get; set; } - [Inject] - protected LiManDataService DataService { get; set; } + #endregion Private Properties + #region Private Methods - [Parameter] - public EventCallback DataReset { get; set; } - - private async Task fullReload() + private async Task FullReload() { - await DataService.InvalidateAllCache(); + await DataService.FlushRedisCache(); await ReloadAllData(); } @@ -50,5 +69,7 @@ namespace LiMan.UI.Components totalCount = ListRecords.Count(); //isLoading = false; } + + #endregion Private Methods } } \ No newline at end of file diff --git a/LiMan.UI/Components/ListInstallazioni.razor.cs b/LiMan.UI/Components/ListInstallazioni.razor.cs index 4c8dced..291cce3 100644 --- a/LiMan.UI/Components/ListInstallazioni.razor.cs +++ b/LiMan.UI/Components/ListInstallazioni.razor.cs @@ -11,13 +11,28 @@ namespace LiMan.UI.Components { public partial class ListInstallazioni : ComponentBase, IDisposable { - #region Private Fields + #region Public Methods - private InstallazioneModel currRecord = null; - private List ListRecords; - private List SearchRecords; + public string checkSelect(string CodInst) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.CodInst == CodInst) ? "table-info" : ""; + } + catch + { } + } + return answ; + } - #endregion Private Fields + public void Dispose() + { + } + + #endregion Public Methods #region Protected Fields @@ -25,36 +40,6 @@ namespace LiMan.UI.Components #endregion Protected Fields - #region Private Properties - - private int currPage - { - get - { - return AppMService.PageNum; - } - set - { - AppMService.PageNum = value; - } - } - - private bool isLoading { get; set; } = false; - - private int numRecord - { - get - { - return AppMService.PageSize; - } - set - { - AppMService.PageSize = value; - } - } - - #endregion Private Properties - #region Protected Properties [Inject] @@ -73,28 +58,6 @@ namespace LiMan.UI.Components #endregion Protected Properties - #region Private Methods - - private async Task fullReload() - { - currRecord = null; - await DataService.InvalidateAllCache(); - await ReloadAllData(); - } - - private async Task ReloadAllData() - { - isLoading = true; - await Task.Delay(1); - //SearchRecords = null; - SearchRecords = await DataService.InstallazioniNextGetAll(); - totalCount = SearchRecords.Count(); - ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); - isLoading = false; - } - - #endregion Private Methods - #region Protected Methods protected void AddNew() @@ -135,37 +98,74 @@ namespace LiMan.UI.Components protected async Task ResetData() { - await fullReload(); + await FullReload(); } protected async Task UpdateData() { - await fullReload(); + await FullReload(); } #endregion Protected Methods - #region Public Methods + #region Private Fields - public string checkSelect(string CodInst) + private InstallazioneModel currRecord = null; + private List ListRecords; + private List SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private int currPage { - string answ = ""; - if (currRecord != null) + get { - try - { - answ = (currRecord.CodInst == CodInst) ? "table-info" : ""; - } - catch - { } + return AppMService.PageNum; + } + set + { + AppMService.PageNum = value; } - return answ; } - public void Dispose() + private bool isLoading { get; set; } = false; + + private int numRecord { + get + { + return AppMService.PageSize; + } + set + { + AppMService.PageSize = value; + } } - #endregion Public Methods + #endregion Private Properties + + #region Private Methods + + private async Task FullReload() + { + currRecord = null; + await DataService.FlushRedisCache(); + await ReloadAllData(); + } + + private async Task ReloadAllData() + { + isLoading = true; + await Task.Delay(1); + //SearchRecords = null; + SearchRecords = await DataService.InstallazioniNextGetAll(); + totalCount = SearchRecords.Count(); + ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + isLoading = false; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/LiMan.UI/Components/ListInstallazioniGLS.razor.cs b/LiMan.UI/Components/ListInstallazioniGLS.razor.cs index 53a702d..f29306b 100644 --- a/LiMan.UI/Components/ListInstallazioniGLS.razor.cs +++ b/LiMan.UI/Components/ListInstallazioniGLS.razor.cs @@ -11,13 +11,28 @@ namespace LiMan.UI.Components { public partial class ListInstallazioniGLS : ComponentBase, IDisposable { - #region Private Fields + #region Public Methods - private AnagInstallazioni currRecord = null; - private List ListRecords; - private List SearchRecords; + public string checkSelect(string Installazione) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.Installazione == Installazione) ? "table-info" : ""; + } + catch + { } + } + return answ; + } - #endregion Private Fields + public void Dispose() + { + } + + #endregion Public Methods #region Protected Fields @@ -25,36 +40,6 @@ namespace LiMan.UI.Components #endregion Protected Fields - #region Private Properties - - private int currPage - { - get - { - return AppMService.PageNum; - } - set - { - AppMService.PageNum = value; - } - } - - private bool isLoading { get; set; } = false; - - private int numRecord - { - get - { - return AppMService.PageSize; - } - set - { - AppMService.PageSize = value; - } - } - - #endregion Private Properties - #region Protected Properties [Inject] @@ -73,28 +58,6 @@ namespace LiMan.UI.Components #endregion Protected Properties - #region Private Methods - - private async Task fullReload() - { - currRecord = null; - await DataService.InvalidateAllCache(); - await ReloadAllData(); - } - - private async Task ReloadAllData() - { - isLoading = true; - await Task.Delay(1); - //SearchRecords = null; - SearchRecords = await DataService.InstallazioniGLSGetAll(); - totalCount = SearchRecords.Count(); - ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); - isLoading = false; - } - - #endregion Private Methods - #region Protected Methods protected void Edit(AnagInstallazioni selRecord) @@ -126,37 +89,74 @@ namespace LiMan.UI.Components protected async Task ResetData() { - await fullReload(); + await FullReload(); } protected async Task UpdateData() { - await fullReload(); + await FullReload(); } #endregion Protected Methods - #region Public Methods + #region Private Fields - public string checkSelect(string Installazione) + private AnagInstallazioni currRecord = null; + private List ListRecords; + private List SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private int currPage { - string answ = ""; - if (currRecord != null) + get { - try - { - answ = (currRecord.Installazione == Installazione) ? "table-info" : ""; - } - catch - { } + return AppMService.PageNum; + } + set + { + AppMService.PageNum = value; } - return answ; } - public void Dispose() + private bool isLoading { get; set; } = false; + + private int numRecord { + get + { + return AppMService.PageSize; + } + set + { + AppMService.PageSize = value; + } } - #endregion Public Methods + #endregion Private Properties + + #region Private Methods + + private async Task FullReload() + { + currRecord = null; + await DataService.FlushRedisCache(); + await ReloadAllData(); + } + + private async Task ReloadAllData() + { + isLoading = true; + await Task.Delay(1); + //SearchRecords = null; + SearchRecords = await DataService.InstallazioniGLSGetAll(); + totalCount = SearchRecords.Count(); + ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + isLoading = false; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/LiMan.UI/Components/ListLicenze.razor.cs b/LiMan.UI/Components/ListLicenze.razor.cs index 8e3499e..2037c18 100644 --- a/LiMan.UI/Components/ListLicenze.razor.cs +++ b/LiMan.UI/Components/ListLicenze.razor.cs @@ -60,8 +60,6 @@ namespace LiMan.UI.Components aTimer.Start(); } - private bool UserCanEdit { get; set; } = false; - #endregion Public Methods #region Protected Fields @@ -191,7 +189,7 @@ namespace LiMan.UI.Components protected async Task ResetData() { - await fullReload(); + await FullReload(); } protected void resetShowDetail() @@ -223,7 +221,7 @@ namespace LiMan.UI.Components protected async Task UpdateActivData() { int idxLic = currRecord.IdxLic; - await fullReload(); + await FullReload(); currRecord = ListRecords.Where(x => x.IdxLic == idxLic).FirstOrDefault(); resetShowDetail(); showActivations = true; @@ -232,7 +230,7 @@ namespace LiMan.UI.Components protected async Task UpdateTicketData() { int idxLic = currRecord.IdxLic; - await fullReload(); + await FullReload(); currRecord = ListRecords.Where(x => x.IdxLic == idxLic).FirstOrDefault(); resetShowDetail(); showTickets = true; @@ -256,7 +254,6 @@ namespace LiMan.UI.Components private bool showActivations = false; private bool showTickets = false; private Dictionary UserClaimsLUT = new Dictionary(); - private string userName = ""; #endregion Private Fields @@ -365,6 +362,8 @@ namespace LiMan.UI.Components } } + private bool UserCanEdit { get; set; } = false; + #endregion Private Properties #region Private Methods @@ -376,11 +375,11 @@ namespace LiMan.UI.Components pUpd.Wait(); } - private async Task fullReload() + private async Task FullReload() { currRecord = null; resetShowDetail(); - await DataService.InvalidateAllCache(); + await DataService.FlushRedisCache(); await ReloadAllData(); } diff --git a/LiMan.UI/Components/ListLicenzeGLS.razor.cs b/LiMan.UI/Components/ListLicenzeGLS.razor.cs index b33fcb7..f8d2e78 100644 --- a/LiMan.UI/Components/ListLicenzeGLS.razor.cs +++ b/LiMan.UI/Components/ListLicenzeGLS.razor.cs @@ -11,6 +11,119 @@ namespace LiMan.UI.Components { public partial class ListLicenzeGLS : ComponentBase, IDisposable { + #region Public Methods + + public string checkSelect(int IdxLic) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.IdxLic == IdxLic) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + public void Dispose() + { + } + + #endregion Public Methods + + #region Protected Fields + + protected int totalCount = 0; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected MessageService AppMService { get; set; } + + [Inject] + protected LiManDataService DataService { get; set; } + + [Inject] + protected IJSRuntime JSRuntime { get; set; } + + [Inject] + protected NavigationManager NavManager { get; set; } + + protected bool showCamera { get; set; } = false; + + #endregion Protected Properties + + #region Protected Methods + + /// + /// formatta testo secondo scadenza: + /// scadenza > 60gg --> verde + /// 0 < scadenza < 60 gg --> giallo + /// scadenza < 0 --> rosso + /// + /// + /// + protected string cssScadenza(DateTime scadenza) + { + string answ = "text-dark"; + double periodo = scadenza.Subtract(DateTime.Today).TotalDays; + if (periodo > 60) + { + answ = "text-success"; + } + else if (periodo > 0) + { + answ = "text-warning"; + } + else + { + answ = "text-danger"; + } + + return answ; + } + + protected void Edit(LicenzeAttive selRecord) + { + currRecord = selRecord; + } + + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + protected async Task PagerReloadNum(int newNum) + { + numRecord = newNum; + await ReloadAllData(); + isLoading = false; + } + + protected async Task PagerReloadPage(int newNum) + { + currPage = newNum; + await ReloadAllData(); + isLoading = false; + } + + protected async Task ResetData() + { + await FullReload(); + } + + protected async Task UpdateData() + { + await FullReload(); + } + + #endregion Protected Methods + #region Private Fields private LicenzeAttive currRecord = null; @@ -22,12 +135,6 @@ namespace LiMan.UI.Components #endregion Private Fields - #region Protected Fields - - protected int totalCount = 0; - - #endregion Protected Fields - #region Private Properties private int currPage @@ -146,30 +253,12 @@ namespace LiMan.UI.Components #endregion Private Properties - #region Protected Properties - - [Inject] - protected MessageService AppMService { get; set; } - - [Inject] - protected LiManDataService DataService { get; set; } - - [Inject] - protected IJSRuntime JSRuntime { get; set; } - - [Inject] - protected NavigationManager NavManager { get; set; } - - protected bool showCamera { get; set; } = false; - - #endregion Protected Properties - #region Private Methods - private async Task fullReload() + private async Task FullReload() { currRecord = null; - await DataService.InvalidateAllCache(); + await DataService.FlushRedisCache(); await ReloadAllData(); } @@ -187,94 +276,5 @@ namespace LiMan.UI.Components } #endregion Private Methods - - #region Protected Methods - - /// - /// formatta testo secondo scadenza: - /// scadenza > 60gg --> verde - /// 0 < scadenza < 60 gg --> giallo - /// scadenza < 0 --> rosso - /// - /// - /// - protected string cssScadenza(DateTime scadenza) - { - string answ = "text-dark"; - double periodo = scadenza.Subtract(DateTime.Today).TotalDays; - if (periodo > 60) - { - answ = "text-success"; - } - else if (periodo > 0) - { - answ = "text-warning"; - } - else - { - answ = "text-danger"; - } - - return answ; - } - - protected void Edit(LicenzeAttive selRecord) - { - currRecord = selRecord; - } - - protected override async Task OnInitializedAsync() - { - await ReloadAllData(); - } - - protected async Task PagerReloadNum(int newNum) - { - numRecord = newNum; - await ReloadAllData(); - isLoading = false; - } - - protected async Task PagerReloadPage(int newNum) - { - currPage = newNum; - await ReloadAllData(); - isLoading = false; - } - - protected async Task ResetData() - { - await fullReload(); - } - - protected async Task UpdateData() - { - await fullReload(); - } - - #endregion Protected Methods - - #region Public Methods - - public string checkSelect(int IdxLic) - { - string answ = ""; - if (currRecord != null) - { - try - { - answ = (currRecord.IdxLic == IdxLic) ? "table-info" : ""; - } - catch - { } - } - return answ; - } - - public void Dispose() - { - } - - #endregion Public Methods } } \ No newline at end of file diff --git a/LiMan.UI/Components/StatsCallList.razor b/LiMan.UI/Components/StatsCallList.razor index f42dd52..e640395 100644 --- a/LiMan.UI/Components/StatsCallList.razor +++ b/LiMan.UI/Components/StatsCallList.razor @@ -37,7 +37,7 @@ - + Anno Codice diff --git a/LiMan.UI/Components/StatsCallList.razor.cs b/LiMan.UI/Components/StatsCallList.razor.cs index f9ece43..686ebe4 100644 --- a/LiMan.UI/Components/StatsCallList.razor.cs +++ b/LiMan.UI/Components/StatsCallList.razor.cs @@ -69,7 +69,7 @@ namespace LiMan.UI.Components protected async Task ResetData() { - await fullReload(); + await FullReload(); } protected void Select(StatsCallModel selRecord) @@ -79,7 +79,7 @@ namespace LiMan.UI.Components protected async Task UpdateData() { - await fullReload(); + await FullReload(); } #endregion Protected Methods @@ -162,15 +162,15 @@ namespace LiMan.UI.Components { var pUpd = Task.Run(async () => { - await fullReload(); + await FullReload(); }); pUpd.Wait(); } - private async Task fullReload() + private async Task FullReload() { currRecord = null; - await DataService.InvalidateAllCache(); + await DataService.FlushRedisCache(); await ReloadAllData(); } diff --git a/LiMan.UI/Components/Tickets.razor.cs b/LiMan.UI/Components/Tickets.razor.cs index a4477fb..e7a0c60 100644 --- a/LiMan.UI/Components/Tickets.razor.cs +++ b/LiMan.UI/Components/Tickets.razor.cs @@ -15,212 +15,80 @@ namespace LiMan.UI.Components { public partial class Tickets { - #region Private Fields + #region Public Methods - private List ListRecords; - private List SearchRecords; - private List ListInstall; - private List ListActivations; - private List ListApp; - protected int totalCount = 0; + public string checkSelect(int IdxSubLic) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.IdxSubLic == IdxSubLic) ? "table-info" : ""; + } + catch + { } + } + return answ; + } - protected TipologiaTicket currTipo = TipologiaTicket.ND; + public string decryptAuthKey(string authKey) + { + string answ = authKey; + try + { + answ = SteamCrypto.DecryptString(authKey, "AuthGPW"); + } + catch + { } + return answ; + } - private List FileAttached; + public string selTick(int idxTicket) + { + string answ = " "; - private bool showTickets = false; + if (idxTicketSel == idxTicket) + { + answ = "table-primary"; + } + return answ; + } - #endregion Private Fields + #endregion Public Methods #region Protected Fields protected SubLicenzaModel _currRecord = new SubLicenzaModel(); - protected LicenzaModel _masterLic = new LicenzaModel(); - + protected TipologiaTicket currTipo = TipologiaTicket.ND; protected int idxTicketSel = 0; - - protected StatoRichiesta StatusSel = StatoRichiesta.ND; - protected bool showKey = false; + protected StatoRichiesta StatusSel = StatoRichiesta.ND; + protected int totalCount = 0; #endregion Protected Fields - #region Private Properties - - private SubLicenzaModel currRecord - { - get - { - return _currRecord; - } - set - { - _currRecord = value; - } - } - - protected override async Task OnInitializedAsync() - { - await ReloadAllData(); - } - - private bool isLoading { get; set; } = false; - - [Inject] - private IJSRuntime JSRuntime { get; set; } - - #endregion Private Properties - #region Protected Properties - [Inject] - protected LiManDataService DataService { get; set; } - - #endregion Protected Properties - - #region Public Properties - - //[Parameter] - //public EventCallback DataReset { get; set; } - - //[Parameter] - //public EventCallback DataUpdated { get; set; } - - //[Parameter] - //public LicenzaModel MasterLicence - //{ - // get - // { - // return _masterLic; - // } - // set - // { - // _masterLic = value; - // var pUpd = Task.Run(async () => await ReloadAllData()); - // pUpd.Wait(); - // } - //} - - #endregion Public Properties - - #region Private Methods - [Inject] protected MessageService AppMService { get; set; } - private async Task fullReload() - { - await DataService.InvalidateAllCache(); - await ReloadAllData(); - } + [Inject] + protected LiManDataService DataService { get; set; } protected string mainCss { get => idxTicketSel == 0 ? "col-12" : "col-8"; } - private async Task ReloadAllData() + #endregion Protected Properties + + #region Protected Methods + + protected async void closeDet() { - isLoading = true; - idxTicketSel = 0; - await Task.Delay(1); - showTickets = false; - ListApp = await DataService.ApplicazioniNextGetAll(); - ListInstall = await DataService.InstallazioniNextGetAll(); - //bool StatoRichiesta = true; - //SearchRecords = await LMDService.LicenzeNextGetFilt(AppMServ.DetailDBFilter); - SearchRecords = await DataService.TicketsGetFilt(true, SelApp, SelInst); - //totalCount = SearchRecords.Count(); - //SearchRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); - - //SearchRecords = await LMDService.TicketsGetAll(); - ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); - - totalCount = SearchRecords.Count(); - isLoading = false; - } - - private string SelInst - { - get - { - string answ = ""; - if (AppMService.DetailDBFilter != null) - { - answ = AppMService.DetailDBFilter.InstallazioneSel; - } - return answ; - } - set - { - if (!AppMService.DetailDBFilter.InstallazioneSel.Equals(value)) - { - AppMService.DetailDBFilter.InstallazioneSel = value; - var pUpd = Task.Run(async () => await ReloadAllData()); - pUpd.Wait(); - } - } - } - - private string SelApp - { - get - { - string answ = ""; - if (AppMService.DetailDBFilter != null) - { - answ = AppMService.DetailDBFilter.ApplicazioneSel; - } - return answ; - } - set - { - if (!AppMService.DetailDBFilter.ApplicazioneSel.Equals(value)) - { - AppMService.DetailDBFilter.ApplicazioneSel = value; - var pUpd = Task.Run(async () => await ReloadAllData()); - pUpd.Wait(); - } - } - } - - private int numRecord - { - get - { - return AppMService.PageSize; - } - set - { - AppMService.PageSize = value; - } - } - - private int currPage - { - get - { - return AppMService.PageNum; - } - set - { - AppMService.PageNum = value; - } - } - - protected async Task PagerReloadNum(int newNum) - { - numRecord = newNum; await ReloadAllData(); - isLoading = false; - } - - protected async Task PagerReloadPage(int newNum) - { - currPage = newNum; - await ReloadAllData(); - isLoading = false; } //private async void DownloadFileFromURL(string fileName, string rawUrl) @@ -231,16 +99,6 @@ namespace LiMan.UI.Components // //var fileName = FileAttached; // await JS.InvokeVoidAsync("triggerFileDownload", fileName, fileURL); //} - - #endregion Private Methods - - #region Protected Methods - - protected async void closeDet() - { - await ReloadAllData(); - } - /// /// formatta testo secondo scadenza: /// scadenza < oggi --> verde @@ -264,9 +122,28 @@ namespace LiMan.UI.Components return answ; } + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + protected async Task PagerReloadNum(int newNum) + { + numRecord = newNum; + await ReloadAllData(); + isLoading = false; + } + + protected async Task PagerReloadPage(int newNum) + { + currPage = newNum; + await ReloadAllData(); + isLoading = false; + } + protected async Task ResetData() { - await fullReload(); + await FullReload(); } protected void showDecrypt() @@ -316,46 +193,156 @@ namespace LiMan.UI.Components #endregion Protected Methods - #region Public Methods + #region Private Fields - public string checkSelect(int IdxSubLic) + private List FileAttached; + private List ListActivations; + private List ListApp; + private List ListInstall; + private List ListRecords; + private List SearchRecords; + private bool showTickets = false; + + #endregion Private Fields + + #region Private Properties + + private int currPage { - string answ = ""; - if (currRecord != null) + get { - try + return AppMService.PageNum; + } + set + { + AppMService.PageNum = value; + } + } + + private SubLicenzaModel currRecord + { + get + { + return _currRecord; + } + set + { + _currRecord = value; + } + } + + private bool isLoading { get; set; } = false; + + [Inject] + private IJSRuntime JSRuntime { get; set; } + + //[Parameter] + //public EventCallback DataReset { get; set; } + + //[Parameter] + //public EventCallback DataUpdated { get; set; } + + private int numRecord + { + get + { + return AppMService.PageSize; + } + set + { + AppMService.PageSize = value; + } + } + + private string SelApp + { + get + { + string answ = ""; + if (AppMService.DetailDBFilter != null) { - answ = (currRecord.IdxSubLic == IdxSubLic) ? "table-info" : ""; + answ = AppMService.DetailDBFilter.ApplicazioneSel; } - catch - { } + return answ; } - return answ; - } - - public string decryptAuthKey(string authKey) - { - string answ = authKey; - try + set { - answ = SteamCrypto.DecryptString(authKey, "AuthGPW"); + if (!AppMService.DetailDBFilter.ApplicazioneSel.Equals(value)) + { + AppMService.DetailDBFilter.ApplicazioneSel = value; + var pUpd = Task.Run(async () => await ReloadAllData()); + pUpd.Wait(); + } } - catch - { } - return answ; } - public string selTick(int idxTicket) + private string SelInst { - string answ = " "; - - if (idxTicketSel == idxTicket) + get { - answ = "table-primary"; + string answ = ""; + if (AppMService.DetailDBFilter != null) + { + answ = AppMService.DetailDBFilter.InstallazioneSel; + } + return answ; + } + set + { + if (!AppMService.DetailDBFilter.InstallazioneSel.Equals(value)) + { + AppMService.DetailDBFilter.InstallazioneSel = value; + var pUpd = Task.Run(async () => await ReloadAllData()); + pUpd.Wait(); + } } - return answ; } - #endregion Public Methods + #endregion Private Properties + + #region Private Methods + + //[Parameter] + //public LicenzaModel MasterLicence + //{ + // get + // { + // return _masterLic; + // } + // set + // { + // _masterLic = value; + // var pUpd = Task.Run(async () => await ReloadAllData()); + // pUpd.Wait(); + // } + //} + private async Task FullReload() + { + await DataService.FlushRedisCache(); + await ReloadAllData(); + } + + private async Task ReloadAllData() + { + isLoading = true; + idxTicketSel = 0; + await Task.Delay(1); + showTickets = false; + ListApp = await DataService.ApplicazioniNextGetAll(); + ListInstall = await DataService.InstallazioniNextGetAll(); + //bool StatoRichiesta = true; + //SearchRecords = await LMDService.LicenzeNextGetFilt(AppMServ.DetailDBFilter); + SearchRecords = await DataService.TicketsGetFilt(true, SelApp, SelInst); + //totalCount = SearchRecords.Count(); + //SearchRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + + //SearchRecords = await LMDService.TicketsGetAll(); + ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + + totalCount = SearchRecords.Count(); + isLoading = false; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/LiMan.UI/Components/TicketsHP.razor.cs b/LiMan.UI/Components/TicketsHP.razor.cs index 456ac6a..9b74445 100644 --- a/LiMan.UI/Components/TicketsHP.razor.cs +++ b/LiMan.UI/Components/TicketsHP.razor.cs @@ -10,69 +10,10 @@ using System.Linq; using System.Threading.Tasks; using static Core.Enum; - namespace LiMan.UI.Components { public partial class TicketsHP { - #region Private Fields - - private List ListActivations; - private List ListRecords; - - #endregion Private Fields - - #region Protected Fields - - protected SubLicenzaModel _currRecord = new SubLicenzaModel(); - - protected LicenzaModel _masterLic = new LicenzaModel(); - - private List FileAttached; - - protected int idxTicketSel = 0; - - protected TipologiaTicket currTipo = TipologiaTicket.ND; - - protected StatoRichiesta StatusSel = StatoRichiesta.ND; - - protected bool showKey = false; - - [Inject] - protected LiManDataService DataService { get; set; } - - #endregion Protected Fields - - #region Private Properties - - private SubLicenzaModel currRecord - { - get - { - return _currRecord; - } - set - { - _currRecord = value; - } - } - - protected override async Task OnInitializedAsync() - { - await ReloadAllData(); - } - - private bool isLoading { get; set; } = false; - - [Inject] - private IJSRuntime JSRuntime { get; set; } - - #endregion Private Properties - - #region Protected Properties - - #endregion Protected Properties - #region Public Properties [Parameter] @@ -98,129 +39,6 @@ namespace LiMan.UI.Components #endregion Public Properties - #region Private Methods - - private async Task fullReload() - { - await DataService.InvalidateAllCache(); - await ReloadAllData(); - } - - private async Task ReloadAllData() - { - isLoading = true; - ListActivations = null; - idxTicketSel = 0; - await Task.Delay(1); - ListRecords = MasterLicence.Tickets.ToList(); - isLoading = false; - } - - #endregion Private Methods - - #region Protected Methods - - protected async void close() - { - await DataReset.InvokeAsync(0); - } - - protected async void closeDet() - { - await ReloadAllData(); - } - - //protected string rowsel = "background:red"; - - /// - /// formatta testo secondo scadenza: - /// scadenza < oggi --> verde - /// scadenza > oggi --> rosso - /// - /// - /// - protected string cssScadenza(DateTime scadenza) - { - string answ = "text-dark"; - double periodo = scadenza.Subtract(DateTime.Today).TotalDays; - if (periodo <= 0) - { - answ = "text-success"; - } - else - { - answ = "text-danger"; - } - - return answ; - } - - protected async Task ResetData() - { - await fullReload(); - } - - protected void showDecrypt() - { - showKey = !showKey; - } - - //protected void showDet(TicketModel currTicket) - //{ - // // salvo ticket sel - // idxTicketSel = currTicket.IdxTicket; - // StatusSel = currTicket.Status; - // currTipo = currTicket.TType; - // FileAttached = await LMDService.FileGetFilt(idxTicketSel); - // // mostro SOLO le attivazioni di cui ho ticket attivi... - // ListActivations = MasterLicence - // .Attivazioni - // .Where(a => a.IdxSubLic == currTicket.IdxSubLic) - // .ToList(); - //} - - protected async Task showDet(TicketModel currTicket) - { - // salvo ticket sel - idxTicketSel = currTicket.IdxTicket; - StatusSel = currTicket.Status; - currTipo = currTicket.TType; - FileAttached = await DataService.FileGetFilt(idxTicketSel); - //rowsel = "background-color:red"; - // mostro SOLO le attivazioni di cui ho ticket attivi... - ListActivations = MasterLicence - .Attivazioni - .Where(a => a.IdxSubLic == currTicket.IdxSubLic) - .ToList(); - } - - protected async Task UnLock(SubLicenzaModel selRecord) - { - if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il blocco? la data di scadenza verrà impostata a ieri liberando la licenza per cancellazioni o rimozioni.")) - return; - - // chiamo procedura sblocco... - await DataService.AttivazioneUnlock(selRecord.IdxSubLic); - await DataUpdated.InvokeAsync(0); - } - - protected async void updateStato(StatoRichiesta nuovoStato) - { - if (nuovoStato == StatoRichiesta.Approvata || nuovoStato == StatoRichiesta.Rifiutata) - { - if (!await JSRuntime.InvokeAsync("confirm", "Confermi l'azione richiesta? Ricorda che in caso di approvazione/rifiuto va modificato preventivamente il record dell'Attivazione coinvolta.")) - return; - } - if (idxTicketSel > 0) - { - // salvo presa in carico ticket - await DataService.TicketUpdateState(idxTicketSel, nuovoStato); - await DataUpdated.InvokeAsync(0); - } - } - - #endregion Protected Methods - #region Public Methods public string checkSelect(int IdxSubLic) @@ -266,5 +84,178 @@ namespace LiMan.UI.Components } #endregion Public Methods + + #region Protected Fields + + protected SubLicenzaModel _currRecord = new SubLicenzaModel(); + protected LicenzaModel _masterLic = new LicenzaModel(); + protected TipologiaTicket currTipo = TipologiaTicket.ND; + protected int idxTicketSel = 0; + protected bool showKey = false; + protected StatoRichiesta StatusSel = StatoRichiesta.ND; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected LiManDataService DataService { get; set; } + + #endregion Protected Properties + + #region Protected Methods + + protected async void close() + { + await DataReset.InvokeAsync(0); + } + + protected async void closeDet() + { + await ReloadAllData(); + } + + /// + /// formatta testo secondo scadenza: + /// scadenza < oggi --> verde + /// scadenza > oggi --> rosso + /// + /// + /// + protected string cssScadenza(DateTime scadenza) + { + string answ = "text-dark"; + double periodo = scadenza.Subtract(DateTime.Today).TotalDays; + if (periodo <= 0) + { + answ = "text-success"; + } + else + { + answ = "text-danger"; + } + + return answ; + } + + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + //protected string rowsel = "background:red"; + protected async Task ResetData() + { + await FullReload(); + } + + protected void showDecrypt() + { + showKey = !showKey; + } + + protected async Task showDet(TicketModel currTicket) + { + // salvo ticket sel + idxTicketSel = currTicket.IdxTicket; + StatusSel = currTicket.Status; + currTipo = currTicket.TType; + FileAttached = await DataService.FileGetFilt(idxTicketSel); + //rowsel = "background-color:red"; + // mostro SOLO le attivazioni di cui ho ticket attivi... + ListActivations = MasterLicence + .Attivazioni + .Where(a => a.IdxSubLic == currTicket.IdxSubLic) + .ToList(); + } + + //protected void showDet(TicketModel currTicket) + //{ + // // salvo ticket sel + // idxTicketSel = currTicket.IdxTicket; + // StatusSel = currTicket.Status; + // currTipo = currTicket.TType; + // FileAttached = await LMDService.FileGetFilt(idxTicketSel); + // // mostro SOLO le attivazioni di cui ho ticket attivi... + // ListActivations = MasterLicence + // .Attivazioni + // .Where(a => a.IdxSubLic == currTicket.IdxSubLic) + // .ToList(); + //} + protected async Task UnLock(SubLicenzaModel selRecord) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il blocco? la data di scadenza verrà impostata a ieri liberando la licenza per cancellazioni o rimozioni.")) + return; + + // chiamo procedura sblocco... + await DataService.AttivazioneUnlock(selRecord.IdxSubLic); + await DataUpdated.InvokeAsync(0); + } + + protected async void updateStato(StatoRichiesta nuovoStato) + { + if (nuovoStato == StatoRichiesta.Approvata || nuovoStato == StatoRichiesta.Rifiutata) + { + if (!await JSRuntime.InvokeAsync("confirm", "Confermi l'azione richiesta? Ricorda che in caso di approvazione/rifiuto va modificato preventivamente il record dell'Attivazione coinvolta.")) + return; + } + if (idxTicketSel > 0) + { + // salvo presa in carico ticket + await DataService.TicketUpdateState(idxTicketSel, nuovoStato); + await DataUpdated.InvokeAsync(0); + } + } + + #endregion Protected Methods + + #region Private Fields + + private List FileAttached; + private List ListActivations; + private List ListRecords; + + #endregion Private Fields + + #region Private Properties + + private SubLicenzaModel currRecord + { + get + { + return _currRecord; + } + set + { + _currRecord = value; + } + } + + private bool isLoading { get; set; } = false; + + [Inject] + private IJSRuntime JSRuntime { get; set; } + + #endregion Private Properties + + #region Private Methods + + private async Task FullReload() + { + await DataService.FlushRedisCache(); + await ReloadAllData(); + } + + private async Task ReloadAllData() + { + isLoading = true; + ListActivations = null; + idxTicketSel = 0; + await Task.Delay(1); + ListRecords = MasterLicence.Tickets.ToList(); + isLoading = false; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/LiMan.UI/Data/LiManDataService.cs b/LiMan.UI/Data/LiManDataService.cs index d53fe9f..5a97d60 100644 --- a/LiMan.UI/Data/LiManDataService.cs +++ b/LiMan.UI/Data/LiManDataService.cs @@ -39,11 +39,8 @@ namespace LiMan.UI.Data #region Public Constructors - public LiManDataService(IConfiguration configuration, IMemoryCache memoryCache, IDistributedCache distributedCache, IConnectionMultiplexer redisConnMult, IEmailSender emailSender) : base(configuration, redisConnMult, emailSender) + public LiManDataService(IConfiguration configuration, IConnectionMultiplexer redisConnMult, IEmailSender emailSender) : base(configuration, redisConnMult, emailSender) { - // conf cache - this.memoryCache = memoryCache; - this.distributedCache = distributedCache; // conf DB string connStrGLS = _configuration.GetConnectionString("LiMan.GLS"); if (string.IsNullOrEmpty(connStrGLS)) @@ -63,28 +60,45 @@ namespace LiMan.UI.Data public async Task> ApplicazioniGLSGetAll() { - List dbResult = new List(); - string cacheKey = mHash("GLS:Applicazioni"); - string rawData; - var redisDataList = await distributedCache.GetAsync(cacheKey); - if (redisDataList != null) + string source = "DB"; + List? dbResult = new List(); + try { - rawData = Encoding.UTF8.GetString(redisDataList); - dbResult = JsonConvert.DeserializeObject>(rawData); + string currKey = $"{Const.rKeyConfig}:GLS:Applicazioni"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbControllerGLS.GetApplicazioni(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + sw.Stop(); + Log.Debug($"ApplicazioniGLSGetAll | {source} in: {sw.Elapsed.TotalMilliseconds:N2} ms"); } - else + catch (Exception exc) { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbControllerGLS.GetApplicazioni(); - rawData = JsonConvert.SerializeObject(dbResult); - redisDataList = Encoding.UTF8.GetBytes(rawData); - await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB + caching per ApplicazioniGLSGetAll: {ts.TotalMilliseconds} ms"); + Log.Error($"Error during ApplicazioniGLSGetAll:{Environment.NewLine}{exc}"); } - return await Task.FromResult(dbResult); + return dbResult; } public async Task ApplicazioniGLSUpdate(GLS.DatabaseModels.AnagApplicazioni currItem) @@ -93,7 +107,7 @@ namespace LiMan.UI.Data try { done = dbControllerGLS.UpdateApplicazioni(currItem); - await InvalidateAllCache(); + await FlushRedisCache(); } catch (Exception exc) { @@ -104,28 +118,34 @@ namespace LiMan.UI.Data public async Task ApplicazioniHasChild(string CodApp) { + string source = "DB"; bool dbResult = false; - string cacheKey = mHash($"Next:Applicazioni:hasChild:{CodApp}"); - string rawData; - var redisDataList = await distributedCache.GetAsync(cacheKey); - if (redisDataList != null) + try { - rawData = Encoding.UTF8.GetString(redisDataList); - dbResult = JsonConvert.DeserializeObject(rawData); + string currKey = $"{Const.rKeyConfig}:Next:Applicazioni:HasChild"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + string rawData = redisHashKeyGet(currKey, CodApp); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + dbResult = JsonConvert.DeserializeObject(rawData); + } + else + { + dbResult = dbControllerNext.ApplicazioniHasChild(CodApp); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + redisHashKeySet(currKey, CodApp, rawData, UltraLongCache.Minutes); + } + sw.Stop(); + Log.Debug($"ApplicazioniHasChild | {source} in: {sw.Elapsed.TotalMilliseconds:N2} ms"); } - else + catch (Exception exc) { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbControllerNext.ApplicazioniHasChild(CodApp); - rawData = JsonConvert.SerializeObject(dbResult); - redisDataList = Encoding.UTF8.GetBytes(rawData); - await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB + caching per ApplicazioniHasChild: {ts.TotalMilliseconds} ms"); + Log.Error($"Error during ApplicazioniHasChild:{Environment.NewLine}{exc}"); } - return await Task.FromResult(dbResult); + await Task.Delay(0); + return dbResult; } /// @@ -143,7 +163,7 @@ namespace LiMan.UI.Data if (!hasCHild) { done = dbControllerNext.ApplicazioniNextDelete(currItem); - await InvalidateAllCache(); + await FlushRedisCache(); } } catch (Exception exc) @@ -155,28 +175,45 @@ namespace LiMan.UI.Data public async Task> ApplicazioniNextGetAll() { + string source = "DB"; List dbResult = new List(); - string cacheKey = mHash("Next:Applicazioni"); - string rawData; - var redisDataList = await distributedCache.GetAsync(cacheKey); - if (redisDataList != null) + try { - rawData = Encoding.UTF8.GetString(redisDataList); - dbResult = JsonConvert.DeserializeObject>(rawData); + string currKey = $"{Const.rKeyConfig}:Next:Applicazioni:List"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbControllerNext.GetApplicazioni(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + sw.Stop(); + Log.Debug($"ApplicazioniNextGetAll | {source} in: {sw.Elapsed.TotalMilliseconds:N2} ms"); } - else + catch (Exception exc) { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbControllerNext.GetApplicazioni(); - rawData = JsonConvert.SerializeObject(dbResult); - redisDataList = Encoding.UTF8.GetBytes(rawData); - await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB + caching per ApplicazioniNextGetAll: {ts.TotalMilliseconds} ms"); + Log.Error($"Error during ApplicazioniNextGetAll:{Environment.NewLine}{exc}"); } - return await Task.FromResult(dbResult); + return dbResult; } public async Task ApplicazioniNextUpdate(ApplicativoModel currItem) @@ -185,7 +222,7 @@ namespace LiMan.UI.Data try { done = dbControllerNext.ApplicazioniNextUpdate(currItem); - await InvalidateAllCache(); + await FlushRedisCache(); } catch (Exception exc) { @@ -213,13 +250,12 @@ namespace LiMan.UI.Data /// public async Task> AttivazioniGetByLic(int IdxLic) { - Stopwatch stopWatch = new Stopwatch(); + Stopwatch sw = new Stopwatch(); List dbResult = new List(); - stopWatch.Start(); + sw.Start(); dbResult = dbControllerNext.AttivazioniGetByLic(IdxLic); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per AttivazioniGetByLic: {ts.TotalMilliseconds} ms"); + sw.Stop(); + Log.Trace($"Effettuata lettura da DB per AttivazioniGetByLic: {sw.Elapsed.TotalMilliseconds} ms"); return await Task.FromResult(dbResult); } @@ -243,17 +279,57 @@ namespace LiMan.UI.Data public async Task> FileGetFilt(int idxTicket) { List dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); + Stopwatch sw = new Stopwatch(); + sw.Start(); dbResult = dbControllerNext.FileGetFilt(idxTicket); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per FileGetFilt: {ts.TotalMilliseconds} ms"); + sw.Stop(); + Log.Trace($"Effettuata lettura da DB per FileGetFilt: {sw.Elapsed.TotalMilliseconds} ms"); return await Task.FromResult(dbResult); } public async Task> InstallazioniGLSGetAll() { + string source = "DB"; + List dbResult = new List(); + try + { + string currKey = $"{Const.rKeyConfig}:GLS:Installazioni:List"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbControllerGLS.GetInstallazioni(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + sw.Stop(); + Log.Debug($"InstallazioniGLSGetAll | {source} in: {sw.Elapsed.TotalMilliseconds:N2} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during InstallazioniGLSGetAll:{Environment.NewLine}{exc}"); + } + return dbResult; + +#if false List dbResult = new List(); string cacheKey = mHash("GLS:Installazioni"); string rawData; @@ -276,6 +352,7 @@ namespace LiMan.UI.Data Log.Trace($"Effettuata lettura da DB + caching per InstallazioniGLSGetAll: {ts.TotalMilliseconds} ms"); } return await Task.FromResult(dbResult); +#endif } public async Task InstallazioniGLSUpdate(GLS.DatabaseModels.AnagInstallazioni currItem) @@ -284,7 +361,7 @@ namespace LiMan.UI.Data try { done = dbControllerGLS.UpdateInstallazioni(currItem); - await InvalidateAllCache(); + await FlushRedisCache(); } catch (Exception exc) { @@ -295,6 +372,47 @@ namespace LiMan.UI.Data public async Task> InstallazioniNextGetAll() { + string source = "DB"; + List dbResult = new List(); + try + { + string currKey = $"{Const.rKeyConfig}:Next:Installazioni:List"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + string rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbControllerNext.GetInstallazioni(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + sw.Stop(); + Log.Debug($"InstallazioniNextGetAll | {source} in: {sw.Elapsed.TotalMilliseconds:N2} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during InstallazioniNextGetAll:{Environment.NewLine}{exc}"); + } + return dbResult; + +#if false List dbResult = new List(); string cacheKey = mHash("Next:Installazioni"); string rawData; @@ -317,6 +435,7 @@ namespace LiMan.UI.Data Log.Trace($"Effettuata lettura da DB + caching per InstallazioniNextGetAll: {ts.TotalMilliseconds} ms"); } return await Task.FromResult(dbResult); +#endif } public async Task InstallazioniNextUpdate(InstallazioneModel currItem) @@ -325,7 +444,7 @@ namespace LiMan.UI.Data try { done = dbControllerNext.UpsertInstallazione(currItem); - await InvalidateAllCache(); + await FlushRedisCache(); } catch (Exception exc) { @@ -377,8 +496,7 @@ namespace LiMan.UI.Data dbResult = new InstallStatusDTO(); } sw.Stop(); - TimeSpan ts = sw.Elapsed; - Log.Debug($"InstallStatusGetInfo | {source} in: {ts.TotalMilliseconds} ms"); + Log.Debug($"InstallStatusGetInfo | {source} in: {sw.Elapsed.TotalMilliseconds} ms"); } catch (Exception exc) { @@ -387,23 +505,6 @@ namespace LiMan.UI.Data return dbResult; } - /// - /// invalida tutta la cache in caso di update - /// - /// - public async Task InvalidateAllCache() - { - await distributedCache.RemoveAsync(mHash("GLS:Applicazioni")); - await distributedCache.RemoveAsync(mHash("Next:Applicazioni")); - await distributedCache.RemoveAsync(mHash("GLS:Installazioni")); - await distributedCache.RemoveAsync(mHash("Next:Installazioni")); - await distributedCache.RemoveAsync(mHash("GLS:Licenze")); - await distributedCache.RemoveAsync(mHash("Next:Licenze")); - //await distributedCache.RemoveAsync(mHash("SUPPL:List")); - //await distributedCache.RemoveAsync(mHash("TRANSP:List")); - //await distributedCache.RemoveAsync(mHash("WEEKPLAN:List")); - } - /// /// Trasferisce una licenza da GLS a Next come LOG di una licenza scaduta /// @@ -438,23 +539,6 @@ namespace LiMan.UI.Data return await Task.FromResult(done); } - /// - /// Recupera licenza dato IDX - /// - /// - /// - public LicenzaModel LicenzaNextGetByIdx(int IdxLic) - { - Stopwatch sw = new Stopwatch(); - LicenzaModel dbResult = new LicenzaModel(); - sw.Start(); - dbResult = dbControllerNext.GetLicenza(IdxLic); - sw.Stop(); - TimeSpan ts = sw.Elapsed; - Log.Trace($"Effettuata lettura da DB per LicenzeNextGetByIdx: {ts.TotalMilliseconds} ms"); - return dbResult; - } - /// /// Trasferisce una licenza da GLS a Next /// @@ -509,6 +593,47 @@ namespace LiMan.UI.Data public async Task> LicenzeGLSGetAll() { + string source = "DB"; + List dbResult = new List(); + try + { + string currKey = $"{Const.rKeyConfig}:GLS:Licenze:List"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + string rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbControllerGLS.GetLicenze(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + sw.Stop(); + Log.Debug($"LicenzeGLSGetAll | {source} in: {sw.Elapsed.TotalMilliseconds:N2} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during LicenzeGLSGetAll:{Environment.NewLine}{exc}"); + } + return dbResult; + +#if false List dbResult = new List(); string cacheKey = mHash("GLS:Licenze"); string rawData; @@ -531,6 +656,7 @@ namespace LiMan.UI.Data Log.Trace($"Effettuata lettura da DB + caching per LicenzeGLSGetAll: {ts.TotalMilliseconds} ms"); } return await Task.FromResult(dbResult); +#endif } /// @@ -540,13 +666,12 @@ namespace LiMan.UI.Data /// public async Task> LicenzeGLSGetFilt(SelectGLS CurrFilter) { - Stopwatch stopWatch = new Stopwatch(); + Stopwatch sw = new Stopwatch(); List dbResult = new List(); - stopWatch.Start(); + sw.Start(); dbResult = dbControllerGLS.GetLicenzeFilt(CurrFilter.OnlyActive, CurrFilter.OnlyUnlock, CurrFilter.ApplicazioneSel, CurrFilter.InstallazioneSel); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per LicenzeGLSGetFilt: {ts.TotalMilliseconds} ms"); + sw.Stop(); + Log.Trace($"Effettuata lettura da DB per LicenzeGLSGetFilt: {sw.Elapsed.TotalMilliseconds} ms"); return await Task.FromResult(dbResult); } @@ -569,6 +694,47 @@ namespace LiMan.UI.Data public async Task> LicenzeNextGetAll() { + string source = "DB"; + List dbResult = new List(); + try + { + string currKey = $"{Const.rKeyConfig}:Next:Licenze:List"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbControllerNext.GetLicenze(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + sw.Stop(); + Log.Debug($"LicenzeNextGetAll | {source} in: {sw.Elapsed.TotalMilliseconds:N2} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during LicenzeNextGetAll:{Environment.NewLine}{exc}"); + } + return dbResult; + +#if false List dbResult = new List(); string cacheKey = mHash("Next:Licenze"); string rawData; @@ -591,6 +757,7 @@ namespace LiMan.UI.Data Log.Trace($"Effettuata lettura da DB + caching per LicenzeNextGetAll: {ts.TotalMilliseconds} ms"); } return await Task.FromResult(dbResult); +#endif } /// @@ -600,13 +767,12 @@ namespace LiMan.UI.Data /// public async Task> LicenzeNextGetFilt(SelectNext CurrFilter) { - Stopwatch stopWatch = new Stopwatch(); + Stopwatch sw = new Stopwatch(); List dbResult = new List(); - stopWatch.Start(); + sw.Start(); dbResult = dbControllerNext.GetLicenzeFilt(CurrFilter.OnlyActive, CurrFilter.ApplicazioneSel, CurrFilter.InstallazioneSel); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per LicenzeNextGetFilt: {ts.TotalMilliseconds} ms"); + sw.Stop(); + Log.Trace($"Effettuata lettura da DB per LicenzeNextGetFilt: {sw.Elapsed.TotalMilliseconds} ms"); return await Task.FromResult(dbResult); } @@ -618,7 +784,7 @@ namespace LiMan.UI.Data try { done = dbControllerNext.UpsertLicenza(currItem); - await InvalidateAllCache(); + await FlushRedisCache(); } catch (Exception exc) { @@ -627,131 +793,6 @@ namespace LiMan.UI.Data return await Task.FromResult(done); } - public async Task ReleaseDelete(ReleaseModel rec2del) - { - bool fatto = dbControllerNext.ReleaseDelete(rec2del); - await FlushRedisCache(); - return fatto; - } - - /// - /// Elenco Release dato Applicativo - /// - /// Codice Applicazione - /// - public async Task> ReleaseGetByApp(string CodApp) - { - string source = "DB"; - List? dbResult = new List(); - try - { - string currKey = $"{Const.rKeyConfig}:App:AllRel:{CodApp}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbControllerNext.ReleaseGetByApp(CodApp); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, LongCache); - // per evitare loopback uso deserialize... - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult != null) - { - dbResult = tempResult; - } - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ReleaseGetByApp | {source} in: {ts.TotalMilliseconds} ms"); - } - catch (Exception exc) - { - Log.Error($"Error during ReleaseGetByApp:{Environment.NewLine}{exc}"); - } - return dbResult; - -#if false - await Task.Delay(1); - List dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbControllerNext.ReleaseGetByApp(CodApp); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per ReleaseGetByApp | {CodApp} | {ts.TotalMilliseconds} ms"); - return dbResult; -#endif - } - - /// - /// Elenco Release dato Applicativo + versione minima - /// - /// Codice Applicazione - /// Versione minima richiesta - /// - public async Task> ReleaseGetByAppVers(string CodApp, string VersMin) - { - await Task.Delay(1); - List dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbControllerNext.ReleaseGetByAppVers(CodApp, VersMin); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per ReleaseGetByAppVers | {CodApp} | vers >= {VersMin} | {ts.TotalMilliseconds} ms"); - return dbResult; - } - - /// - /// Ultima Release dato Applicativo VALIDA (= rilasciata) - /// - /// Codice Applicazione - /// - public async Task ReleaseLastGetByApp(string CodApp) - { - string answ = ""; - RedisKey currKey = $"{Const.rKeyConfig}:App:CurrRel"; - var rawVal = await redisDb.HashGetAsync(currKey, CodApp); - if (rawVal.HasValue) - { - answ = $"{rawVal}"; - } - else - { - var rawList = await ReleaseGetByApp(CodApp); - if (rawList != null) - { - var lastRel = rawList - .Where(x => x.IsReleased) - .OrderByDescending(x => x.VersVal) - .ThenByDescending(x => x.ReleaseDate) - .FirstOrDefault() ?? new ReleaseModel() { CodApp = CodApp }; - answ = lastRel.VersNum; - // salvo su redis tab... - await redisDb.HashSetAsync(currKey, CodApp, answ); - } - } - return answ; - } - /// /// Upsert record Release applicazione /// @@ -763,7 +804,6 @@ namespace LiMan.UI.Data try { done = await dbControllerNext.ReleaseUpsert(currItem); - await InvalidateAllCache(); await FlushRedisCache(); } catch (Exception exc) @@ -801,6 +841,55 @@ namespace LiMan.UI.Data /// public async Task> StatsLogCallGetFilt(DateTime DateFrom, DateTime DateTo, string SearchVal = "") { + string source = "DB"; + List dbResult = new List(); + try + { + string currKey = $"{Const.rKeyConfig}:StatslogCall:{DateFrom:yyyyMMdd}:{DateTo:yyyyMMdd}"; + if (!string.IsNullOrEmpty(SearchVal)) + { + currKey += $":{SearchVal}"; + } + Stopwatch sw = new Stopwatch(); + sw.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + var rawResult = dbControllerNext.StatsLogCallGetFilt(DateFrom, DateTo, SearchVal); + dbResult = rawResult + .OrderByDescending(x => x.YearRef) + .ThenByDescending(x => x.TotCall) + .ToList(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + sw.Stop(); + Log.Debug($"StatsLogCallGetFilt | {source} in: {sw.Elapsed.TotalMilliseconds:N2} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during StatsLogCallGetFilt:{Environment.NewLine}{exc}"); + } + return dbResult; + +#if false List dbResult = new List(); string cacheKey = mHash($"StatslogCall:{DateFrom:yyyyMMdd}:{DateTo:yyyyMMdd}"); if (!string.IsNullOrEmpty(SearchVal)) @@ -831,6 +920,7 @@ namespace LiMan.UI.Data Log.Trace($"Effettuata lettura da DB + caching per StatsLogCallGetFilt: {ts.TotalMilliseconds} ms"); } return await Task.FromResult(dbResult); +#endif } /// @@ -840,12 +930,12 @@ namespace LiMan.UI.Data /// public async Task> TicketsGetAll() { - Stopwatch stopWatch = new Stopwatch(); + Stopwatch sw = new Stopwatch(); List dbResult = new List(); - stopWatch.Start(); + sw.Start(); dbResult = dbControllerNext.TicketGetAll(false, 1000); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; + sw.Stop(); + TimeSpan ts = sw.Elapsed; Log.Trace($"Effettuata lettura da DB per TicketsGetAll: {ts.TotalMilliseconds} ms"); return await Task.FromResult(dbResult); } @@ -857,12 +947,12 @@ namespace LiMan.UI.Data /// public async Task> TicketsGetFilt(SelectNext CurrFilter) { - Stopwatch stopWatch = new Stopwatch(); + Stopwatch sw = new Stopwatch(); List dbResult = new List(); - stopWatch.Start(); + sw.Start(); dbResult = dbControllerNext.TicketGetFiltAllLic(CurrFilter.OnlyActive, Core.Enum.TipologiaTicket.ND, CurrFilter.ApplicazioneSel, CurrFilter.InstallazioneSel, 1000); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; + sw.Stop(); + TimeSpan ts = sw.Elapsed; Log.Trace($"Effettuata lettura da DB per TicketsGetFilt: {ts.TotalMilliseconds} ms"); return await Task.FromResult(dbResult); } @@ -876,12 +966,12 @@ namespace LiMan.UI.Data /// public async Task> TicketsGetFilt(bool onlyOpen, string CodApp, string CodInst) { - Stopwatch stopWatch = new Stopwatch(); + Stopwatch sw = new Stopwatch(); List dbResult = new List(); - stopWatch.Start(); + sw.Start(); dbResult = dbControllerNext.TicketGetFilt(onlyOpen, CodApp, CodInst); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; + sw.Stop(); + TimeSpan ts = sw.Elapsed; Log.Trace($"Effettuata lettura da DB per TicketsGetFilt: {ts.TotalMilliseconds} ms"); return await Task.FromResult(dbResult); } @@ -896,11 +986,11 @@ namespace LiMan.UI.Data { bool fatto = false; // inserimento! - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); + Stopwatch sw = new Stopwatch(); + sw.Start(); fatto = dbControllerNext.TicketUpdateState(IdxTicket, NewStatus); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; + sw.Stop(); + TimeSpan ts = sw.Elapsed; Log.Trace($"Effettuata update con TicketUpdateState: {ts.TotalMilliseconds} ms"); // restituisce elenco @@ -925,6 +1015,12 @@ namespace LiMan.UI.Data #endregion Internal Methods + #region Protected Fields + + protected new static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Protected Fields + #region Protected Methods protected string getCacheKey(string TableName, SelectData CurrFilter) @@ -934,45 +1030,5 @@ namespace LiMan.UI.Data } #endregion Protected Methods - - #region Private Fields - - private readonly IDistributedCache distributedCache; - private readonly IMemoryCache memoryCache; - - /// - /// Durata assoluta massima della cache IN SECONDI - /// - private int chAbsExp = 60 * 5; - - /// - /// Durata della cache IN SECONDI in modalità inattiva (non acceduta) prima di venire - /// rimossa NON estende oltre il tempo massimo di validità della cache (chAbsExp) - /// - private int chSliExp = 60 * 1; - - #endregion Private Fields - - #region Private Methods - - /// - /// Hash Redis contenente i dati MP di una specifico TYPE (es StatusMacchina, - /// StateMachineIngressi, ...) - /// - /// - /// - private static string mHash(string dataType) - { - return $"DATA:{dataType}"; - } - - private DistributedCacheEntryOptions cacheOpt(bool fastCache) - { - var numSecAbsExp = fastCache ? chAbsExp : chAbsExp * 10; - var numSecSliExp = fastCache ? chSliExp : chSliExp * 10; - return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp)); - } - - #endregion Private Methods } } \ No newline at end of file diff --git a/LiMan.UI/LiMan.UI.csproj b/LiMan.UI/LiMan.UI.csproj index 523353c..9ca9651 100644 --- a/LiMan.UI/LiMan.UI.csproj +++ b/LiMan.UI/LiMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 2.1.2501.2907 + 2.1.2501.2910 LiMan.UI LiMan.UI @@ -43,8 +43,8 @@ - - + + @@ -52,7 +52,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/LiMan.UI/Pages/Reset.razor.cs b/LiMan.UI/Pages/Reset.razor.cs index 941f2c5..db49d07 100644 --- a/LiMan.UI/Pages/Reset.razor.cs +++ b/LiMan.UI/Pages/Reset.razor.cs @@ -18,13 +18,13 @@ namespace LiMan.UI.Pages [Inject] protected MessageService MServ { get; set; } = null!; + #endregion Protected Properties #region Protected Methods protected override async Task OnInitializedAsync() { - await DataService.InvalidateAllCache(); await DataService.FlushRedisCache(); await CCService.FlushRedisCache(); await MServ.FlushRedisCache(); diff --git a/LiMan.UI/Program.cs b/LiMan.UI/Program.cs index 43b94ba..b1c1e56 100644 --- a/LiMan.UI/Program.cs +++ b/LiMan.UI/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using NLog; using NLog.Web; using System; using System.Collections.Generic; @@ -20,19 +21,14 @@ namespace LiMan.UI { webBuilder.UseStartup(); }) - .ConfigureLogging(logging => - { - logging.ClearProviders(); - logging.SetMinimumLevel(LogLevel.Debug); - }) - .UseNLog(); + // importante x onorare i livelli di log impostati in appsettings.json + .UseNLog(new NLogAspNetCoreOptions() { RemoveLoggerFactoryFilter = false }); public static void Main(string[] args) { - // inclusione NLog: - // https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-5 - // https://codewithmukesh.com/blog/logging-with-nlog-in-aspnet-core/ - var logger = NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger(); + var logger = LogManager.Setup() + .LoadConfigurationFromAppSettings() + .GetCurrentClassLogger(); try { logger.Info("LiMan.UI Application Starting Up"); @@ -48,7 +44,6 @@ namespace LiMan.UI NLog.LogManager.Shutdown(); } - //CreateHostBuilder(args).Build().Run(); } #endregion Public Methods diff --git a/LiMan.UI/Resources/ChangeLog.html b/LiMan.UI/Resources/ChangeLog.html index 5bdadfc..30894b2 100644 --- a/LiMan.UI/Resources/ChangeLog.html +++ b/LiMan.UI/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

    Versione: 2.1.2501.2907

    +

    Versione: 2.1.2501.2910


    Note di rilascio:
    • diff --git a/LiMan.UI/Resources/VersNum.txt b/LiMan.UI/Resources/VersNum.txt index 1e22251..83dfcaa 100644 --- a/LiMan.UI/Resources/VersNum.txt +++ b/LiMan.UI/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.2907 +2.1.2501.2910 diff --git a/LiMan.UI/Resources/manifest.xml b/LiMan.UI/Resources/manifest.xml index 8cc3a19..dba703e 100644 --- a/LiMan.UI/Resources/manifest.xml +++ b/LiMan.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.2907 + 2.1.2501.2910 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false diff --git a/LiMan.UI/Startup.cs b/LiMan.UI/Startup.cs index a2e8522..d125608 100644 --- a/LiMan.UI/Startup.cs +++ b/LiMan.UI/Startup.cs @@ -139,12 +139,14 @@ namespace LiMan.UI o.SlidingExpiration = true; }); +#if false services.AddStackExchangeRedisCache(options => - { - //options.Configuration = "localhost:6379"; - options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 5, EndPoints = { { "localhost", 6379 } } }; - options.InstanceName = "LiMan"; - }); + { + //options.Configuration = "localhost:6379"; + options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 5, EndPoints = { { "localhost", 6379 } } }; + options.InstanceName = "LiMan"; + }); +#endif // REDIS setup var redisConnString = Configuration.GetConnectionString("Redis"); diff --git a/LiMan.UI/appsettings.json b/LiMan.UI/appsettings.json index 3ffb87c..ef84657 100644 --- a/LiMan.UI/appsettings.json +++ b/LiMan.UI/appsettings.json @@ -2,10 +2,60 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Components.RenderTree.Renderer": "Warning", + "Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository": "Warning", + "Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware": "Warning", + "Microsoft.AspNetCore.Hosting.Diagnostics": "Warning", + "Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport": "Warning", + "Microsoft.AspNetCore.Server.Kestrel": "Warning", + "Microsoft.AspNetCore.SignalR.HubConnectionContext": "Warning", + "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher": "Warning", + "Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware": "Warning", + "Microsoft.WebTools.BrowserLink.Net.VsContentMiddleware": "Warning" } }, + "NLog": { + "variables": { + "baseFileDir": "${basedir}/logs/", + "layout": "${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}" + }, + "extensions": [ + { "assembly": "NLog.Extensions.Logging" }, + { "assembly": "NLog.Web.AspNetCore" } + ], + "throwConfigExceptions": true, + "targets": { + "async": true, + "logfile": { + "type": "File", + "fileName": "${basedir}/logs/${shortdate}.log", + "archiveEvery": "Day", + "archiveFileName": "${basedir}/logs/old/${shortdate}_{#}.log", + "archiveNumbering": "DateAndSequence", + "archiveAboveSize": "1024000", + "archiveDateFormat": "HH", + "maxArchiveFiles": "60", + "maxArchiveDays": "30" + }, + "logconsole": { + "type": "ColoredConsole", + "layout": "${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}" + } + }, + "rules": [ + { + "logger": "*", + "minLevel": "Trace", + "writeTo": "logconsole" + }, + { + "logger": "*", + "minLevel": "Info", + "writeTo": "logfile" + } + ] + }, "AllowedHosts": "*", "ConnectionStrings": { "LiMan.GLS": "Server=W2019-SQL-STEAM;Database=SteamWare_Auth;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=LiMan.UI;", @@ -37,7 +87,7 @@ }, "RuntimeOpt": { "BaseUrl": "/ELM.UI", - "MultiRoleEnab": true + "MultiRoleEnab": true }, "ApiUrl": "https://liman.egalware.com", "HostOs": "Win"