Merge branch 'release/CleanOldRedisCache_01'

This commit is contained in:
Samuele Locatelli
2025-01-29 10:13:36 +01:00
29 changed files with 1358 additions and 1123 deletions
-2
View File
@@ -47,7 +47,6 @@ namespace LiMan.APi.Data
/// <param name="redisCacheClient"></param>
/// <param name="redisConnMult"></param>
public ApiDataService(IConfiguration configuration, ILogger<ApiDataService> logger, IEmailSender emailSender, IRedisCacheClient redisCacheClient, IConnectionMultiplexer redisConnMult)
//public ApiDataService(IConfiguration configuration, ILogger<ApiDataService> 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;
/// <summary>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>License Manager</i>
<h4>Versione: 2.1.2501.2907</h4>
<h4>Versione: 2.1.2501.2910</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
2.1.2501.2907
2.1.2501.2910
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>2.1.2501.2907</version>
<version>2.1.2501.2910</version>
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+155 -18
View File
@@ -618,6 +618,136 @@ namespace LiMan.DB.Services
return answ;
}
/// <summary>
/// Recupera licenza dato IDX
/// </summary>
/// <param name="IdxLic"></param>
/// <returns></returns>
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<bool> ReleaseDelete(ReleaseModel rec2del)
{
bool fatto = dbControllerNext.ReleaseDelete(rec2del);
await FlushRedisCache();
return fatto;
}
/// <summary>
/// Elenco Release dato Applicativo
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <returns></returns>
public async Task<List<ReleaseModel>> ReleaseGetByApp(string CodApp)
{
string source = "DB";
List<ReleaseModel>? dbResult = new List<ReleaseModel>();
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<List<ReleaseModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<ReleaseModel>();
}
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<List<ReleaseModel>>(rawData);
if (tempResult != null)
{
dbResult = tempResult;
}
}
if (dbResult == null)
{
dbResult = new List<ReleaseModel>();
}
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;
}
/// <summary>
/// Elenco Release dato Applicativo + versione minima
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <param name="VersMin">Versione minima richiesta</param>
/// <returns></returns>
public async Task<List<ReleaseModel>> ReleaseGetByAppVers(string CodApp, string VersMin)
{
await Task.Delay(1);
List<ReleaseModel> dbResult = new List<ReleaseModel>();
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;
}
/// <summary>
/// Ultima Release dato Applicativo VALIDA (= rilasciata)
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <returns></returns>
public async Task<string> 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;
}
/// <summary>
/// Restituisce i task associati ad un dato EgwACC in stato DONE
/// </summary>
@@ -901,21 +1031,11 @@ namespace LiMan.DB.Services
return answ;
}
#endregion Protected Methods
#region Private Fields
private Dictionary<string, bool> UserClaimsLUT = new Dictionary<string, bool>();
#endregion Private Fields
#region Private Methods
/// <summary>
/// Eliminazione di un HashSet Redis
/// </summary>
/// <param name="dictKey">Chiave del dizionario</param>
private bool redisHashDictDelete(RedisKey dictKey)
protected bool redisHashDictDelete(RedisKey dictKey)
{
bool fatto = false;
try
@@ -940,7 +1060,7 @@ namespace LiMan.DB.Services
/// </summary>
/// <param name="dictKey">Chiave del dizionario</param>
/// <returns>Dizionario valori salvato</returns>
private Dictionary<string, string> redisHashDictGet(RedisKey dictKey)
protected Dictionary<string, string> redisHashDictGet(RedisKey dictKey)
{
Dictionary<string, string> answ = new Dictionary<string, string>();
try
@@ -961,7 +1081,7 @@ namespace LiMan.DB.Services
/// </summary>
/// <param name="dictKey">Chiave del dizionario</param>
/// <param name="dict">Valore Dizionario da salvare</param>
private bool redisHashDictSet(RedisKey dictKey, Dictionary<string, string> dict)
protected bool redisHashDictSet(RedisKey dictKey, Dictionary<string, string> dict)
{
// ove non indicato expiry è 0 = MAI
return redisHashDictSet(dictKey, dict, 0);
@@ -973,7 +1093,7 @@ namespace LiMan.DB.Services
/// <param name="dictKey">Chiave del dizionario</param>
/// <param name="dict">Valore Dizionario da salvare</param>
/// <param name="expireMin">Expiry in minuti del valore, se 0 = mai</param>
private bool redisHashDictSet(RedisKey dictKey, Dictionary<string, string> dict, double expireMin)
protected bool redisHashDictSet(RedisKey dictKey, Dictionary<string, string> dict, double expireMin)
{
bool fatto = false;
try
@@ -1006,7 +1126,7 @@ namespace LiMan.DB.Services
/// </summary>
/// <param name="dictKey">Chiave del dizionario</param>
/// <param name="recKey">Chiave del valore da eliminare (singolo record)</param>
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;
}
/// <summary>
/// recupero un singolo valore in HashSet Redis
/// </summary>
/// <param name="dictKey">Chiave del dizionario</param>
/// <param name="recKey">Chiave valore da recuperare</param>
protected string redisHashKeyGet(RedisKey dictKey, string recKey)
{
string answ = redisDb.HashGet(dictKey, (RedisValue)recKey);
return answ;
}
/// <summary>
/// Salvataggio di un singolo valore in HashSet Redis, con expiry NON gestito (0 = mai)
/// </summary>
/// <param name="dictKey">Chiave del dizionario</param>
/// <param name="recKey">Chiave valore da salvare</param>
/// <param name="recVal">Valore da salvare</param>
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
/// <param name="recKey">Chiave valore da salvare</param>
/// <param name="recVal">Valore da salvare</param>
/// <param name="expireMin">Expiry in minuti del valore, se 0 = mai</param>
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<string, bool> UserClaimsLUT = new Dictionary<string, bool>();
#endregion Private Fields
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>License Manager</i>
<h4>Versione: 2.1.2501.2907</h4>
<h4>Versione: 2.1.2501.2910</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
2.1.2501.2907
2.1.2501.2910
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>2.1.2501.2907</version>
<version>2.1.2501.2910</version>
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.Transfer.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -179,7 +179,7 @@ namespace LiMan.UI.Components
private async Task fullReload()
{
await DataService.InvalidateAllCache();
await DataService.FlushRedisCache();
await ReloadAllData();
}
@@ -281,7 +281,7 @@ namespace LiMan.UI.Components
{
recordEdit = null;
recordSel = null;
await DataService.InvalidateAllCache();
await DataService.FlushRedisCache();
await ReloadAllData();
}
@@ -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
}
}
+32 -11
View File
@@ -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<FileAttachModel> ListRecords;
#region Public Properties
[Parameter]
public EventCallback<int> 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<FileAttachModel> 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<int> 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
}
}
+72 -72
View File
@@ -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<InstallazioneModel> ListRecords;
private List<InstallazioneModel> 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<InstallazioneModel> ListRecords;
private List<InstallazioneModel> 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
}
}
@@ -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<AnagInstallazioni> ListRecords;
private List<AnagInstallazioni> 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<AnagInstallazioni> ListRecords;
private List<AnagInstallazioni> 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
}
}
+7 -8
View File
@@ -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<string, bool> UserClaimsLUT = new Dictionary<string, bool>();
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();
}
+115 -115
View File
@@ -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
/// <summary>
/// formatta testo secondo scadenza:
/// scadenza > 60gg --> verde
/// 0 < scadenza < 60 gg --> giallo
/// scadenza < 0 --> rosso
/// </summary>
/// <param name="scadenza"></param>
/// <returns></returns>
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
/// <summary>
/// formatta testo secondo scadenza:
/// scadenza > 60gg --> verde
/// 0 < scadenza < 60 gg --> giallo
/// scadenza < 0 --> rosso
/// </summary>
/// <param name="scadenza"></param>
/// <returns></returns>
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
}
}
+1 -1
View File
@@ -37,7 +37,7 @@
<thead>
<tr>
<th>
<button type="button" class="btn btn-sm btn-primary" @onclick="() => fullReload()"><i class="fas fa-sync"></i></button>
<button type="button" class="btn btn-sm btn-primary" @onclick="() => FullReload()"><i class="fas fa-sync"></i></button>
</th>
<th>Anno</th>
<th>Codice</th>
+5 -5
View File
@@ -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();
}
+202 -215
View File
@@ -15,212 +15,80 @@ namespace LiMan.UI.Components
{
public partial class Tickets
{
#region Private Fields
#region Public Methods
private List<TicketDTO> ListRecords;
private List<TicketDTO> SearchRecords;
private List<InstallazioneModel> ListInstall;
private List<SubLicenzaModel> ListActivations;
private List<ApplicativoModel> 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<FileAttachModel> 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<int> DataReset { get; set; }
//[Parameter]
//public EventCallback<int> 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();
}
/// <summary>
/// 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<FileAttachModel> FileAttached;
private List<SubLicenzaModel> ListActivations;
private List<ApplicativoModel> ListApp;
private List<InstallazioneModel> ListInstall;
private List<TicketDTO> ListRecords;
private List<TicketDTO> 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<int> DataReset { get; set; }
//[Parameter]
//public EventCallback<int> 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
}
}
+173 -182
View File
@@ -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<SubLicenzaModel> ListActivations;
private List<TicketModel> ListRecords;
#endregion Private Fields
#region Protected Fields
protected SubLicenzaModel _currRecord = new SubLicenzaModel();
protected LicenzaModel _masterLic = new LicenzaModel();
private List<FileAttachModel> 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";
/// <summary>
/// formatta testo secondo scadenza:
/// scadenza < oggi --> verde
/// scadenza > oggi --> rosso
/// </summary>
/// <param name="scadenza"></param>
/// <returns></returns>
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<bool>("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<bool>("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();
}
/// <summary>
/// formatta testo secondo scadenza:
/// scadenza < oggi --> verde
/// scadenza > oggi --> rosso
/// </summary>
/// <param name="scadenza"></param>
/// <returns></returns>
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<bool>("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<bool>("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<FileAttachModel> FileAttached;
private List<SubLicenzaModel> ListActivations;
private List<TicketModel> 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
}
}
+356 -300
View File
@@ -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<List<GLS.DatabaseModels.AnagApplicazioni>> ApplicazioniGLSGetAll()
{
List<GLS.DatabaseModels.AnagApplicazioni> dbResult = new List<GLS.DatabaseModels.AnagApplicazioni>();
string cacheKey = mHash("GLS:Applicazioni");
string rawData;
var redisDataList = await distributedCache.GetAsync(cacheKey);
if (redisDataList != null)
string source = "DB";
List<GLS.DatabaseModels.AnagApplicazioni>? dbResult = new List<GLS.DatabaseModels.AnagApplicazioni>();
try
{
rawData = Encoding.UTF8.GetString(redisDataList);
dbResult = JsonConvert.DeserializeObject<List<GLS.DatabaseModels.AnagApplicazioni>>(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<List<GLS.DatabaseModels.AnagApplicazioni>>(rawData);
if (tempResult == null)
{
dbResult = new List<GLS.DatabaseModels.AnagApplicazioni>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerGLS.GetApplicazioni();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<GLS.DatabaseModels.AnagApplicazioni>();
}
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<bool> 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<bool> 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<bool>(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<bool>(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;
}
/// <summary>
@@ -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<List<ApplicativoModel>> ApplicazioniNextGetAll()
{
string source = "DB";
List<ApplicativoModel> dbResult = new List<ApplicativoModel>();
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<List<ApplicativoModel>>(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<List<ApplicativoModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<ApplicativoModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerNext.GetApplicazioni();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<ApplicativoModel>();
}
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<bool> 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
/// <returns></returns>
public async Task<List<SubLicenzaModel>> AttivazioniGetByLic(int IdxLic)
{
Stopwatch stopWatch = new Stopwatch();
Stopwatch sw = new Stopwatch();
List<SubLicenzaModel> dbResult = new List<SubLicenzaModel>();
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<List<FileAttachModel>> FileGetFilt(int idxTicket)
{
List<FileAttachModel> dbResult = new List<FileAttachModel>();
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<List<GLS.DatabaseModels.AnagInstallazioni>> InstallazioniGLSGetAll()
{
string source = "DB";
List<GLS.DatabaseModels.AnagInstallazioni> dbResult = new List<GLS.DatabaseModels.AnagInstallazioni>();
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<List<GLS.DatabaseModels.AnagInstallazioni>>(rawData);
if (tempResult == null)
{
dbResult = new List<GLS.DatabaseModels.AnagInstallazioni>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerGLS.GetInstallazioni();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<GLS.DatabaseModels.AnagInstallazioni>();
}
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<GLS.DatabaseModels.AnagInstallazioni> dbResult = new List<GLS.DatabaseModels.AnagInstallazioni>();
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<bool> 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<List<InstallazioneModel>> InstallazioniNextGetAll()
{
string source = "DB";
List<InstallazioneModel> dbResult = new List<InstallazioneModel>();
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<List<InstallazioneModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<InstallazioneModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerNext.GetInstallazioni();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<InstallazioneModel>();
}
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<InstallazioneModel> dbResult = new List<InstallazioneModel>();
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<bool> 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;
}
/// <summary>
/// invalida tutta la cache in caso di update
/// </summary>
/// <returns></returns>
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"));
}
/// <summary>
/// Trasferisce una licenza da GLS a Next come LOG di una licenza scaduta
/// </summary>
@@ -438,23 +539,6 @@ namespace LiMan.UI.Data
return await Task.FromResult(done);
}
/// <summary>
/// Recupera licenza dato IDX
/// </summary>
/// <param name="IdxLic"></param>
/// <returns></returns>
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;
}
/// <summary>
/// Trasferisce una licenza da GLS a Next
/// </summary>
@@ -509,6 +593,47 @@ namespace LiMan.UI.Data
public async Task<List<GLS.DatabaseModels.LicenzeAttive>> LicenzeGLSGetAll()
{
string source = "DB";
List<GLS.DatabaseModels.LicenzeAttive> dbResult = new List<GLS.DatabaseModels.LicenzeAttive>();
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<List<GLS.DatabaseModels.LicenzeAttive>>(rawData);
if (tempResult == null)
{
dbResult = new List<GLS.DatabaseModels.LicenzeAttive>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerGLS.GetLicenze();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<GLS.DatabaseModels.LicenzeAttive>();
}
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<GLS.DatabaseModels.LicenzeAttive> dbResult = new List<GLS.DatabaseModels.LicenzeAttive>();
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
}
/// <summary>
@@ -540,13 +666,12 @@ namespace LiMan.UI.Data
/// <returns></returns>
public async Task<List<GLS.DatabaseModels.LicenzeAttive>> LicenzeGLSGetFilt(SelectGLS CurrFilter)
{
Stopwatch stopWatch = new Stopwatch();
Stopwatch sw = new Stopwatch();
List<GLS.DatabaseModels.LicenzeAttive> dbResult = new List<GLS.DatabaseModels.LicenzeAttive>();
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<List<LicenzaModel>> LicenzeNextGetAll()
{
string source = "DB";
List<LicenzaModel> dbResult = new List<LicenzaModel>();
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<List<LicenzaModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<LicenzaModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerNext.GetLicenze();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<LicenzaModel>();
}
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<LicenzaModel> dbResult = new List<LicenzaModel>();
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
}
/// <summary>
@@ -600,13 +767,12 @@ namespace LiMan.UI.Data
/// <returns></returns>
public async Task<List<LicenzaModel>> LicenzeNextGetFilt(SelectNext CurrFilter)
{
Stopwatch stopWatch = new Stopwatch();
Stopwatch sw = new Stopwatch();
List<LicenzaModel> dbResult = new List<LicenzaModel>();
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<bool> ReleaseDelete(ReleaseModel rec2del)
{
bool fatto = dbControllerNext.ReleaseDelete(rec2del);
await FlushRedisCache();
return fatto;
}
/// <summary>
/// Elenco Release dato Applicativo
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <returns></returns>
public async Task<List<ReleaseModel>> ReleaseGetByApp(string CodApp)
{
string source = "DB";
List<ReleaseModel>? dbResult = new List<ReleaseModel>();
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<List<ReleaseModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<ReleaseModel>();
}
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<List<ReleaseModel>>(rawData);
if (tempResult != null)
{
dbResult = tempResult;
}
}
if (dbResult == null)
{
dbResult = new List<ReleaseModel>();
}
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<ReleaseModel> dbResult = new List<ReleaseModel>();
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
}
/// <summary>
/// Elenco Release dato Applicativo + versione minima
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <param name="VersMin">Versione minima richiesta</param>
/// <returns></returns>
public async Task<List<ReleaseModel>> ReleaseGetByAppVers(string CodApp, string VersMin)
{
await Task.Delay(1);
List<ReleaseModel> dbResult = new List<ReleaseModel>();
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;
}
/// <summary>
/// Ultima Release dato Applicativo VALIDA (= rilasciata)
/// </summary>
/// <param name="CodApp">Codice Applicazione</param>
/// <returns></returns>
public async Task<string> 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;
}
/// <summary>
/// Upsert record Release applicazione
/// </summary>
@@ -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
/// <returns></returns>
public async Task<List<StatsCallModel>> StatsLogCallGetFilt(DateTime DateFrom, DateTime DateTo, string SearchVal = "")
{
string source = "DB";
List<StatsCallModel> dbResult = new List<StatsCallModel>();
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<List<StatsCallModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<StatsCallModel>();
}
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<StatsCallModel>();
}
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<StatsCallModel> dbResult = new List<StatsCallModel>();
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
}
/// <summary>
@@ -840,12 +930,12 @@ namespace LiMan.UI.Data
/// <returns></returns>
public async Task<List<TicketDTO>> TicketsGetAll()
{
Stopwatch stopWatch = new Stopwatch();
Stopwatch sw = new Stopwatch();
List<TicketDTO> dbResult = new List<TicketDTO>();
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
/// <returns></returns>
public async Task<List<TicketDTO>> TicketsGetFilt(SelectNext CurrFilter)
{
Stopwatch stopWatch = new Stopwatch();
Stopwatch sw = new Stopwatch();
List<TicketDTO> dbResult = new List<TicketDTO>();
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
/// <returns></returns>
public async Task<List<TicketDTO>> TicketsGetFilt(bool onlyOpen, string CodApp, string CodInst)
{
Stopwatch stopWatch = new Stopwatch();
Stopwatch sw = new Stopwatch();
List<TicketDTO> dbResult = new List<TicketDTO>();
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;
/// <summary>
/// Durata assoluta massima della cache IN SECONDI
/// </summary>
private int chAbsExp = 60 * 5;
/// <summary>
/// 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)
/// </summary>
private int chSliExp = 60 * 1;
#endregion Private Fields
#region Private Methods
/// <summary>
/// Hash Redis contenente i dati MP di una specifico TYPE (es StatusMacchina,
/// StateMachineIngressi, ...)
/// </summary>
/// <param name="dataType"></param>
/// <returns></returns>
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
}
}
+3 -4
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>2.1.2501.2907</Version>
<Version>2.1.2501.2910</Version>
<RootNamespace>LiMan.UI</RootNamespace>
<AssemblyName>LiMan.UI</AssemblyName>
</PropertyGroup>
@@ -43,8 +43,8 @@
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.5.2501.1509" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.5.2501.1509" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.5.2501.1716" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.5.2501.1716" />
<PackageReference Include="EgwProxy.MP.Core" Version="1.0.2412.2310" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.28" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="6.0.21" />
@@ -52,7 +52,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.3" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.36.0" />
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.36.0" />
<PackageReference Include="Microsoft.IdentityModel.Protocols" Version="6.36.0" />
+1 -1
View File
@@ -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();
+6 -11
View File
@@ -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<Startup>();
})
.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
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>License Manager</i>
<h4>Versione: 2.1.2501.2907</h4>
<h4>Versione: 2.1.2501.2910</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
2.1.2501.2907
2.1.2501.2910
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>2.1.2501.2907</version>
<version>2.1.2501.2910</version>
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+7 -5
View File
@@ -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");
+53 -3
View File
@@ -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"