Riorganizzazione codice strati DataAdapter (Common/UI)
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.UI.Data
|
||||
namespace Core
|
||||
{
|
||||
public class SelectData
|
||||
{
|
||||
@@ -55,4 +56,4 @@ namespace LiMan.UI.Data
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>License Manager</i>
|
||||
<h4>Versione: 2.1.2501.2910</h4>
|
||||
<h4>Versione: 2.1.2502.0110</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.1.2501.2910
|
||||
2.1.2502.0110
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>2.1.2501.2910</version>
|
||||
<version>2.1.2502.0110</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>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.UI.Data
|
||||
namespace LiMan.DB
|
||||
{
|
||||
public class SelectNext : SelectData
|
||||
{
|
||||
@@ -52,4 +54,4 @@ namespace LiMan.UI.Data
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using Core;
|
||||
using Core.DTO;
|
||||
using LiMan.DB.DBModels;
|
||||
using LiMan.DB.DTO;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
@@ -89,6 +91,161 @@ namespace LiMan.DB.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task<bool> ApplicazioniHasChild(string CodApp)
|
||||
{
|
||||
string source = "DB";
|
||||
bool dbResult = false;
|
||||
try
|
||||
{
|
||||
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");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ApplicazioniHasChild:{Environment.NewLine}{exc}");
|
||||
}
|
||||
await Task.Delay(0);
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina il record indicato (se non ci sono record correlati...)
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ApplicazioniNextDelete(ApplicativoModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
// controllo NON ci siano record figli...
|
||||
bool hasCHild = dbControllerNext.ApplicazioniHasChild(currItem.CodApp);
|
||||
if (!hasCHild)
|
||||
{
|
||||
done = dbControllerNext.ApplicazioniNextDelete(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ApplicazioniNextDelete:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
public async Task<List<ApplicativoModel>> ApplicazioniNextGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
List<ApplicativoModel> dbResult = new List<ApplicativoModel>();
|
||||
try
|
||||
{
|
||||
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");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ApplicazioniNextGetAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public async Task<bool> ApplicazioniNextUpdate(ApplicativoModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
done = dbControllerNext.ApplicazioniNextUpdate(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ApplicazioniNextUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua sblocco di una licenza impostando data veto a oggi
|
||||
/// </summary>
|
||||
/// <param name="idxSubLic"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AttivazioneDelete(int idxSubLic)
|
||||
{
|
||||
bool fatto = dbControllerNext.AttivazioniDelete(idxSubLic);
|
||||
await Task.Delay(1);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua sblocco di una licenza impostando data veto a oggi
|
||||
/// </summary>
|
||||
/// <param name="idxSubLic"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AttivazioneUnlock(int idxSubLic)
|
||||
{
|
||||
bool fatto = dbControllerNext.AttivazioniUnlock(idxSubLic);
|
||||
await Task.Delay(1);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera attivazioni data licenza
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<SubLicenzaModel>> AttivazioniGetByLic(int IdxLic)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<SubLicenzaModel> dbResult = new List<SubLicenzaModel>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.AttivazioniGetByLic(IdxLic);
|
||||
sw.Stop();
|
||||
Log.Trace($"Effettuata lettura da DB per AttivazioniGetByLic: {sw.Elapsed.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera elenco Claim dato UserID
|
||||
/// </summary>
|
||||
@@ -573,6 +730,22 @@ namespace LiMan.DB.Services
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco file registrati dato ticket id
|
||||
/// </summary>
|
||||
/// <param name="idxTicket">Identificativo del ticket</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<FileAttachModel>> FileGetFilt(int idxTicket)
|
||||
{
|
||||
List<FileAttachModel> dbResult = new List<FileAttachModel>();
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.FileGetFilt(idxTicket);
|
||||
sw.Stop();
|
||||
Log.Trace($"Effettuata lettura da DB per FileGetFilt: {sw.Elapsed.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush cache dati enroll x successiva rilettura
|
||||
/// </summary>
|
||||
@@ -618,6 +791,141 @@ namespace LiMan.DB.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
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;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<InstallazioneModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbControllerNext.GetInstallazioni();
|
||||
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 InstallazioniNextGetAll: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
#endif
|
||||
}
|
||||
|
||||
public async Task<bool> InstallazioniNextUpdate(InstallazioneModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
done = dbControllerNext.UpsertInstallazione(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in InstallazioniNextUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera info statistiche installazione dato periodo riferimento, da cache o da db
|
||||
/// </summary>
|
||||
/// <param name="dtStart"></param>
|
||||
/// <param name="dtEnd"></param>
|
||||
/// <param name="CodInst">Filtro Cliente (CodInstall)</param>
|
||||
/// <param name="TipoApp">Filtro TipoApp</param>
|
||||
public async Task<InstallStatusDTO> InstallStatusGetInfo(DateTime dtStart, DateTime dtEnd, string CodInst, string TipoApp)
|
||||
{
|
||||
string source = "DB";
|
||||
InstallStatusDTO dbResult = new InstallStatusDTO();
|
||||
try
|
||||
{
|
||||
string filtCli = string.IsNullOrEmpty(CodInst) ? "ALL-INSTALL" : $"{CodInst}";
|
||||
string filtTipo = string.IsNullOrEmpty(TipoApp) ? "ALL-TIPO" : $"{TipoApp}";
|
||||
string currKey = $"{Const.rKeyConfig}:InstVerSta:{filtTipo}:{filtCli}:{dtStart:yyyyMMdd-HHmmss}:{dtEnd:yyyyMMdd-HHmmss}";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<InstallStatusDTO>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new InstallStatusDTO();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbControllerNext.InstallStatusGetInfo(dtStart, dtEnd, CodInst, TipoApp);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new InstallStatusDTO();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"InstallStatusGetInfo | {source} in: {sw.Elapsed.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during InstallStatusGetInfo:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera licenza dato IDX
|
||||
/// </summary>
|
||||
@@ -635,6 +943,107 @@ namespace LiMan.DB.Services
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
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;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<LicenzaModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbControllerNext.GetLicenze();
|
||||
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 LicenzeNextGetAll: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera licenze SENZA cache
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<LicenzaModel>> LicenzeNextGetFilt(SelectNext CurrFilter)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<LicenzaModel> dbResult = new List<LicenzaModel>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.GetLicenzeFilt(CurrFilter.OnlyActive, CurrFilter.ApplicazioneSel, CurrFilter.InstallazioneSel);
|
||||
sw.Stop();
|
||||
Log.Trace($"Effettuata lettura da DB per LicenzeNextGetFilt: {sw.Elapsed.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<bool> LicenzeNextUpdate(LicenzaModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
|
||||
// chiamo Log licenza + update insieme
|
||||
try
|
||||
{
|
||||
done = dbControllerNext.UpsertLicenza(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ApplicazioniUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
|
||||
public async Task<bool> ReleaseDelete(ReleaseModel rec2del)
|
||||
{
|
||||
bool fatto = dbControllerNext.ReleaseDelete(rec2del);
|
||||
@@ -748,6 +1157,131 @@ namespace LiMan.DB.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upsert record Release applicazione
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ReleaseUpsert(ReleaseModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
done = await dbControllerNext.ReleaseUpsert(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ReleaseUpsert:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
public async Task<bool> SendEmail(string destEmail, string oggetto, string corpo)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
await _emailSender.SendEmailAsync(destEmail, oggetto, corpo);
|
||||
answ = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Statistiche del LOG chiamate all'API dato filtro
|
||||
/// </summary>
|
||||
/// <param name="DateFrom">Data minima</param>
|
||||
/// <param name="DateTo">DataMax</param>
|
||||
/// <param name="SearchVal">Valore cercato, se "" è tutti</param>
|
||||
/// <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))
|
||||
{
|
||||
cacheKey += $":{SearchVal}";
|
||||
}
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<StatsCallModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var rawResult = dbControllerNext.StatsLogCallGetFilt(DateFrom, DateTo, SearchVal);
|
||||
dbResult = rawResult
|
||||
.OrderByDescending(x => x.YearRef)
|
||||
.ThenByDescending(x => x.TotCall)
|
||||
.ToList();
|
||||
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 StatsLogCallGetFilt: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce i task associati ad un dato EgwACC in stato DONE
|
||||
/// </summary>
|
||||
@@ -865,6 +1399,80 @@ namespace LiMan.DB.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera elenco Tickets filtrato
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TicketDTO>> TicketsGetAll()
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<TicketDTO> dbResult = new List<TicketDTO>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.TicketGetAll(false, 1000);
|
||||
sw.Stop();
|
||||
TimeSpan ts = sw.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per TicketsGetAll: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricerca ticket filtrati
|
||||
/// </summary>
|
||||
/// <param name="onlyOpen"></param>
|
||||
/// <param name="CodApp"></param>
|
||||
/// <param name="CodInst"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TicketDTO>> TicketsGetFilt(bool onlyOpen, string CodApp, string CodInst)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<TicketDTO> dbResult = new List<TicketDTO>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.TicketGetFilt(onlyOpen, CodApp, CodInst);
|
||||
sw.Stop();
|
||||
TimeSpan ts = sw.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per TicketsGetFilt: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera elenco Tickets filtrato
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TicketDTO>> TicketsGetFilt(SelectNext CurrFilter)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<TicketDTO> dbResult = new List<TicketDTO>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.TicketGetFiltAllLic(CurrFilter.OnlyActive, Core.Enum.TipologiaTicket.ND, CurrFilter.ApplicazioneSel, CurrFilter.InstallazioneSel, 1000);
|
||||
sw.Stop();
|
||||
TimeSpan ts = sw.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per TicketsGetFilt: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiornamentos tato ticket
|
||||
/// </summary>
|
||||
/// <param name="IdxTicket"></param>
|
||||
/// <param name="NewStatus"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> TicketUpdateState(int IdxTicket, StatoRichiesta NewStatus)
|
||||
{
|
||||
bool fatto = false;
|
||||
// inserimento!
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
fatto = dbControllerNext.TicketUpdateState(IdxTicket, NewStatus);
|
||||
sw.Stop();
|
||||
TimeSpan ts = sw.Elapsed;
|
||||
Log.Trace($"Effettuata update con TicketUpdateState: {ts.TotalMilliseconds} ms");
|
||||
|
||||
// restituisce elenco
|
||||
return await Task.FromResult(fatto);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica di un role utente dall'elenco claims...
|
||||
/// </summary>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.UI.Data
|
||||
namespace LiMan.GLS
|
||||
{
|
||||
public class SelectGLS : SelectData
|
||||
{
|
||||
@@ -55,4 +57,4 @@ namespace LiMan.UI.Data
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>License Manager</i>
|
||||
<h4>Versione: 2.1.2501.2910</h4>
|
||||
<h4>Versione: 2.1.2502.0110</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.1.2501.2910
|
||||
2.1.2502.0110
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>2.1.2501.2910</version>
|
||||
<version>2.1.2502.0110</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>
|
||||
|
||||
@@ -7,6 +7,7 @@ using LiMan.DB.Controllers;
|
||||
using LiMan.DB.DBModels;
|
||||
using LiMan.DB.DTO;
|
||||
using LiMan.DB.Services;
|
||||
using LiMan.GLS;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
@@ -116,149 +117,6 @@ namespace LiMan.UI.Data
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
|
||||
public async Task<bool> ApplicazioniHasChild(string CodApp)
|
||||
{
|
||||
string source = "DB";
|
||||
bool dbResult = false;
|
||||
try
|
||||
{
|
||||
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");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ApplicazioniHasChild:{Environment.NewLine}{exc}");
|
||||
}
|
||||
await Task.Delay(0);
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina il record indicato (se non ci sono record correlati...)
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ApplicazioniNextDelete(ApplicativoModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
// controllo NON ci siano record figli...
|
||||
bool hasCHild = dbControllerNext.ApplicazioniHasChild(currItem.CodApp);
|
||||
if (!hasCHild)
|
||||
{
|
||||
done = dbControllerNext.ApplicazioniNextDelete(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ApplicazioniNextDelete:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
public async Task<List<ApplicativoModel>> ApplicazioniNextGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
List<ApplicativoModel> dbResult = new List<ApplicativoModel>();
|
||||
try
|
||||
{
|
||||
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");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ApplicazioniNextGetAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public async Task<bool> ApplicazioniNextUpdate(ApplicativoModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
done = dbControllerNext.ApplicazioniNextUpdate(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ApplicazioniNextUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua sblocco di una licenza impostando data veto a oggi
|
||||
/// </summary>
|
||||
/// <param name="idxSubLic"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AttivazioneUnlock(int idxSubLic)
|
||||
{
|
||||
bool fatto = dbControllerNext.AttivazioniUnlock(idxSubLic);
|
||||
await Task.Delay(1);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera attivazioni data licenza
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<SubLicenzaModel>> AttivazioniGetByLic(int IdxLic)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<SubLicenzaModel> dbResult = new List<SubLicenzaModel>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.AttivazioniGetByLic(IdxLic);
|
||||
sw.Stop();
|
||||
Log.Trace($"Effettuata lettura da DB per AttivazioniGetByLic: {sw.Elapsed.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<bool> DbForceMigrate()
|
||||
{
|
||||
return await Task.FromResult(dbControllerGLS.DbForceMigrate());
|
||||
@@ -271,22 +129,6 @@ namespace LiMan.UI.Data
|
||||
dbControllerGLS.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco file registrati dato ticket id
|
||||
/// </summary>
|
||||
/// <param name="idxTicket">Identificativo del ticket</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<FileAttachModel>> FileGetFilt(int idxTicket)
|
||||
{
|
||||
List<FileAttachModel> dbResult = new List<FileAttachModel>();
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.FileGetFilt(idxTicket);
|
||||
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";
|
||||
@@ -370,141 +212,6 @@ namespace LiMan.UI.Data
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
|
||||
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;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<InstallazioneModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbControllerNext.GetInstallazioni();
|
||||
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 InstallazioniNextGetAll: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
#endif
|
||||
}
|
||||
|
||||
public async Task<bool> InstallazioniNextUpdate(InstallazioneModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
done = dbControllerNext.UpsertInstallazione(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in InstallazioniNextUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera info statistiche installazione dato periodo riferimento, da cache o da db
|
||||
/// </summary>
|
||||
/// <param name="dtStart"></param>
|
||||
/// <param name="dtEnd"></param>
|
||||
/// <param name="CodInst">Filtro Cliente (CodInstall)</param>
|
||||
/// <param name="TipoApp">Filtro TipoApp</param>
|
||||
public async Task<InstallStatusDTO> InstallStatusGetInfo(DateTime dtStart, DateTime dtEnd, string CodInst, string TipoApp)
|
||||
{
|
||||
string source = "DB";
|
||||
InstallStatusDTO dbResult = new InstallStatusDTO();
|
||||
try
|
||||
{
|
||||
string filtCli = string.IsNullOrEmpty(CodInst) ? "ALL-INSTALL" : $"{CodInst}";
|
||||
string filtTipo = string.IsNullOrEmpty(TipoApp) ? "ALL-TIPO" : $"{TipoApp}";
|
||||
string currKey = $"{Const.rKeyConfig}:InstVerSta:{filtTipo}:{filtCli}:{dtStart:yyyyMMdd-HHmmss}:{dtEnd:yyyyMMdd-HHmmss}";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<InstallStatusDTO>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new InstallStatusDTO();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbControllerNext.InstallStatusGetInfo(dtStart, dtEnd, CodInst, TipoApp);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new InstallStatusDTO();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"InstallStatusGetInfo | {source} in: {sw.Elapsed.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during InstallStatusGetInfo:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trasferisce una licenza da GLS a Next come LOG di una licenza scaduta
|
||||
/// </summary>
|
||||
@@ -692,343 +399,17 @@ namespace LiMan.UI.Data
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
|
||||
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;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<LicenzaModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbControllerNext.GetLicenze();
|
||||
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 LicenzeNextGetAll: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera licenze SENZA cache
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<LicenzaModel>> LicenzeNextGetFilt(SelectNext CurrFilter)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<LicenzaModel> dbResult = new List<LicenzaModel>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.GetLicenzeFilt(CurrFilter.OnlyActive, CurrFilter.ApplicazioneSel, CurrFilter.InstallazioneSel);
|
||||
sw.Stop();
|
||||
Log.Trace($"Effettuata lettura da DB per LicenzeNextGetFilt: {sw.Elapsed.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<bool> LicenzeNextUpdate(LicenzaModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
|
||||
// chiamo Log licenza + update insieme
|
||||
try
|
||||
{
|
||||
done = dbControllerNext.UpsertLicenza(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ApplicazioniUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upsert record Release applicazione
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ReleaseUpsert(ReleaseModel currItem)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
done = await dbControllerNext.ReleaseUpsert(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ReleaseUpsert:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
public void rollBackEditGLS(object item)
|
||||
{
|
||||
dbControllerGLS.rollBackEntity(item);
|
||||
}
|
||||
|
||||
public async Task<bool> SendEmail(string destEmail, string oggetto, string corpo)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
await _emailSender.SendEmailAsync(destEmail, oggetto, corpo);
|
||||
answ = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Statistiche del LOG chiamate all'API dato filtro
|
||||
/// </summary>
|
||||
/// <param name="DateFrom">Data minima</param>
|
||||
/// <param name="DateTo">DataMax</param>
|
||||
/// <param name="SearchVal">Valore cercato, se "" è tutti</param>
|
||||
/// <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))
|
||||
{
|
||||
cacheKey += $":{SearchVal}";
|
||||
}
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<StatsCallModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var rawResult = dbControllerNext.StatsLogCallGetFilt(DateFrom, DateTo, SearchVal);
|
||||
dbResult = rawResult
|
||||
.OrderByDescending(x => x.YearRef)
|
||||
.ThenByDescending(x => x.TotCall)
|
||||
.ToList();
|
||||
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 StatsLogCallGetFilt: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera elenco Tickets filtrato
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TicketDTO>> TicketsGetAll()
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<TicketDTO> dbResult = new List<TicketDTO>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.TicketGetAll(false, 1000);
|
||||
sw.Stop();
|
||||
TimeSpan ts = sw.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per TicketsGetAll: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera elenco Tickets filtrato
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TicketDTO>> TicketsGetFilt(SelectNext CurrFilter)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<TicketDTO> dbResult = new List<TicketDTO>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.TicketGetFiltAllLic(CurrFilter.OnlyActive, Core.Enum.TipologiaTicket.ND, CurrFilter.ApplicazioneSel, CurrFilter.InstallazioneSel, 1000);
|
||||
sw.Stop();
|
||||
TimeSpan ts = sw.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per TicketsGetFilt: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricerca ticket filtrati
|
||||
/// </summary>
|
||||
/// <param name="onlyOpen"></param>
|
||||
/// <param name="CodApp"></param>
|
||||
/// <param name="CodInst"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TicketDTO>> TicketsGetFilt(bool onlyOpen, string CodApp, string CodInst)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
List<TicketDTO> dbResult = new List<TicketDTO>();
|
||||
sw.Start();
|
||||
dbResult = dbControllerNext.TicketGetFilt(onlyOpen, CodApp, CodInst);
|
||||
sw.Stop();
|
||||
TimeSpan ts = sw.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per TicketsGetFilt: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiornamentos tato ticket
|
||||
/// </summary>
|
||||
/// <param name="IdxTicket"></param>
|
||||
/// <param name="NewStatus"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> TicketUpdateState(int IdxTicket, StatoRichiesta NewStatus)
|
||||
{
|
||||
bool fatto = false;
|
||||
// inserimento!
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
fatto = dbControllerNext.TicketUpdateState(IdxTicket, NewStatus);
|
||||
sw.Stop();
|
||||
TimeSpan ts = sw.Elapsed;
|
||||
Log.Trace($"Effettuata update con TicketUpdateState: {ts.TotalMilliseconds} ms");
|
||||
|
||||
// restituisce elenco
|
||||
return await Task.FromResult(fatto);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua sblocco di una licenza impostando data veto a oggi
|
||||
/// </summary>
|
||||
/// <param name="idxSubLic"></param>
|
||||
/// <returns></returns>
|
||||
internal async Task<bool> AttivazioneDelete(int idxSubLic)
|
||||
{
|
||||
bool fatto = dbControllerNext.AttivazioniDelete(idxSubLic);
|
||||
await Task.Delay(1);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
string answ = $"{TableName}:D_{CurrFilter.DateStart:yyyyMMddHHmm}_{CurrFilter.DateEnd:yyyyMMddHHmm}";
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Core;
|
||||
using LiMan.DB;
|
||||
using LiMan.GLS;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
|
||||
@@ -2,11 +2,17 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>2.1.2501.2910</Version>
|
||||
<Version>2.1.2502.0110</Version>
|
||||
<RootNamespace>LiMan.UI</RootNamespace>
|
||||
<AssemblyName>LiMan.UI</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Data\SelectData.cs" />
|
||||
<Compile Remove="Data\SelectGLS.cs" />
|
||||
<Compile Remove="Data\SelectNext.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="compilerconfig.json" />
|
||||
<Content Remove="Components\CopyToClipboard.razor" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>License Manager</i>
|
||||
<h4>Versione: 2.1.2501.2910</h4>
|
||||
<h4>Versione: 2.1.2502.0110</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.1.2501.2910
|
||||
2.1.2502.0110
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>2.1.2501.2910</version>
|
||||
<version>2.1.2502.0110</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>
|
||||
|
||||
Reference in New Issue
Block a user