Completata gestione metodi Auth da service controller con DB + REDIS

This commit is contained in:
Samuele E. Locatelli
2024-07-13 16:22:48 +02:00
parent f84dd6e9fe
commit 2b14b256c1
9 changed files with 560 additions and 192 deletions
+162 -163
View File
@@ -8,7 +8,6 @@ using Microsoft.Extensions.Configuration;
using NLog;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Data;
using System.IO;
using System.Linq;
@@ -116,168 +115,6 @@ namespace LiMan.DB.Controllers
return dbResult;
}
public List<AuthUserModel> AuthUserGetFilt(string userName)
{
List<AuthUserModel> dbResult = new List<AuthUserModel>();
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
DateTime oggi = DateTime.Today;
dbResult = localDbCtx
.DbSetUsers
.Where(x => x.Username == userName)
.ToList();
}
return dbResult;
}
public bool AuthUserUpsert(AuthUserModel newRec)
{
bool answ = false;
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
try
{
var currData = localDbCtx
.DbSetUsers
.Where(x => x.UserID == newRec.UserID)
.FirstOrDefault();
if (currData != null)
{
currData.Username = newRec.Username;
currData.AD_Domain = newRec.AD_Domain;
currData.AD_User = newRec.AD_User;
// segno aggiornato
localDbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
localDbCtx
.DbSetUsers
.Add(newRec);
}
localDbCtx.SaveChanges();
answ = true;
}
catch (Exception exc)
{
Log.Error($"Errore in AuthUserUpsert | UserID: {newRec.UserID} | userName: {newRec.Username}{Environment.NewLine}{exc}");
}
}
return answ;
}
public List<AuthRoleModel> AuthRolesGetAll(string userName)
{
List<AuthRoleModel> dbResult = new List<AuthRoleModel>();
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
DateTime oggi = DateTime.Today;
dbResult = localDbCtx
.DbSetRoles
.ToList();
}
return dbResult;
}
public bool AuthRoleUpsert(AuthRoleModel newRec)
{
bool answ = false;
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
try
{
var currData = localDbCtx
.DbSetRoles
.Where(x => x.RoleID == newRec.RoleID)
.FirstOrDefault();
if (currData != null)
{
currData.Descrizione = newRec.Descrizione;
currData.Ruolo = newRec.Ruolo;
// segno aggiornato
localDbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
localDbCtx
.DbSetRoles
.Add(newRec);
}
localDbCtx.SaveChanges();
answ = true;
}
catch (Exception exc)
{
Log.Error($"Errore in AuthRoleUpsert | RoleID: {newRec.RoleID} | Ruolo: {newRec.Ruolo}{Environment.NewLine}{exc}");
}
}
return answ;
}
public List<AuthClaimModel> AuthClaimByUserID(int userID)
{
List<AuthClaimModel> dbResult = new List<AuthClaimModel>();
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
DateTime oggi = DateTime.Today;
dbResult = localDbCtx
.DbSetClaims
.Where(x => x.UserID == userID)
.ToList();
}
return dbResult;
}
public List<AuthClaimModel> AuthClaimByUserName(string userName)
{
List<AuthClaimModel> dbResult = new List<AuthClaimModel>();
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
DateTime oggi = DateTime.Today;
dbResult = localDbCtx
.DbSetClaims
.Where(x => x.UserNav.Username == userName)
.ToList();
}
return dbResult;
}
public bool AuthClaimUpsert(AuthClaimModel newRec)
{
bool answ = false;
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
try
{
var currData = localDbCtx
.DbSetClaims
.Where(x => x.ClaimID == newRec.ClaimID)
.FirstOrDefault();
if (currData != null)
{
currData.UserID = newRec.UserID;
currData.RoleID = newRec.RoleID;
currData.DtMod = DateTime.Now;
// segno aggiornato
localDbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
localDbCtx
.DbSetClaims
.Add(newRec);
}
localDbCtx.SaveChanges();
answ = true;
}
catch (Exception exc)
{
Log.Error($"Errore in AuthClaimUpsert | ClaimID: {newRec.ClaimID} | UserID: {newRec.UserID} | RoleID: {newRec.RoleID}{Environment.NewLine}{exc}");
}
}
return answ;
}
/// <summary>
/// Elimino le licenze con veto scaduto
/// </summary>
@@ -435,6 +272,168 @@ namespace LiMan.DB.Controllers
return fatto;
}
public List<AuthClaimModel> AuthClaimByUserID(int userID)
{
List<AuthClaimModel> dbResult = new List<AuthClaimModel>();
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
DateTime oggi = DateTime.Today;
dbResult = localDbCtx
.DbSetClaims
.Where(x => x.UserID == userID)
.ToList();
}
return dbResult;
}
public List<AuthClaimModel> AuthClaimByUserName(string userName)
{
List<AuthClaimModel> dbResult = new List<AuthClaimModel>();
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
DateTime oggi = DateTime.Today;
dbResult = localDbCtx
.DbSetClaims
.Where(x => x.UserNav.Username == userName)
.ToList();
}
return dbResult;
}
public bool AuthClaimUpsert(AuthClaimModel newRec)
{
bool answ = false;
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
try
{
var currData = localDbCtx
.DbSetClaims
.Where(x => x.ClaimID == newRec.ClaimID)
.FirstOrDefault();
if (currData != null)
{
currData.UserID = newRec.UserID;
currData.RoleID = newRec.RoleID;
currData.DtMod = DateTime.Now;
// segno aggiornato
localDbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
localDbCtx
.DbSetClaims
.Add(newRec);
}
localDbCtx.SaveChanges();
answ = true;
}
catch (Exception exc)
{
Log.Error($"Errore in AuthClaimUpsert | ClaimID: {newRec.ClaimID} | UserID: {newRec.UserID} | RoleID: {newRec.RoleID}{Environment.NewLine}{exc}");
}
}
return answ;
}
public List<AuthRoleModel> AuthRolesGetAll()
{
List<AuthRoleModel> dbResult = new List<AuthRoleModel>();
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
DateTime oggi = DateTime.Today;
dbResult = localDbCtx
.DbSetRoles
.ToList();
}
return dbResult;
}
public bool AuthRoleUpsert(AuthRoleModel newRec)
{
bool answ = false;
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
try
{
var currData = localDbCtx
.DbSetRoles
.Where(x => x.RoleID == newRec.RoleID)
.FirstOrDefault();
if (currData != null)
{
currData.Descrizione = newRec.Descrizione;
currData.Ruolo = newRec.Ruolo;
// segno aggiornato
localDbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
localDbCtx
.DbSetRoles
.Add(newRec);
}
localDbCtx.SaveChanges();
answ = true;
}
catch (Exception exc)
{
Log.Error($"Errore in AuthRoleUpsert | RoleID: {newRec.RoleID} | Ruolo: {newRec.Ruolo}{Environment.NewLine}{exc}");
}
}
return answ;
}
public List<AuthUserModel> AuthUserGetFilt(string userName)
{
List<AuthUserModel> dbResult = new List<AuthUserModel>();
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
DateTime oggi = DateTime.Today;
dbResult = localDbCtx
.DbSetUsers
.Where(x => x.Username == userName)
.ToList();
}
return dbResult;
}
public bool AuthUserUpsert(AuthUserModel newRec)
{
bool answ = false;
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
{
try
{
var currData = localDbCtx
.DbSetUsers
.Where(x => x.UserID == newRec.UserID)
.FirstOrDefault();
if (currData != null)
{
currData.Username = newRec.Username;
currData.AD_Domain = newRec.AD_Domain;
currData.AD_User = newRec.AD_User;
// segno aggiornato
localDbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
localDbCtx
.DbSetUsers
.Add(newRec);
}
localDbCtx.SaveChanges();
answ = true;
}
catch (Exception exc)
{
Log.Error($"Errore in AuthUserUpsert | UserID: {newRec.UserID} | userName: {newRec.Username}{Environment.NewLine}{exc}");
}
}
return answ;
}
public bool DbForceMigrate()
{
bool answ = false;
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>License Manager</i>
<h4>Versione: 1.1.2407.1315</h4>
<h4>Versione: 1.1.2407.1316</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
1.1.2407.1315
1.1.2407.1316
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2407.1315</version>
<version>1.1.2407.1316</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>
+391 -22
View File
@@ -1,18 +1,22 @@
using Core;
using Core.DTO;
using Liman.CadCam.DbModel;
using LiMan.DB.Controllers;
using LiMan.DB.DBModels;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using NLog;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime;
using System.Text;
using System.Threading.Tasks;
using static Core.Enum;
@@ -51,12 +55,76 @@ namespace LiMan.UI.Data
#endregion Public Fields
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
protected IConnectionMultiplexer redisConn = null!;
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
protected IDatabase redisDb = null!;
protected Random rnd = new Random();
protected static JsonSerializerSettings? JSSettings;
/// <summary>
/// Durata cache lunga IN SECONDI
/// </summary>
protected int cacheTtlLong = 60 * 5;
/// <summary>
/// Durata cache breve IN SECONDI
/// </summary>
protected int cacheTtlShort = 60 * 1;
/// <summary>
/// Durata cache breve (1 min circa + perturbazione percentuale +/-10%)
/// </summary>
protected TimeSpan FastCache
{
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
/// </summary>
protected TimeSpan LongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache MOLTO breve (10 sec circa + perturbazione percentuale +/-10%)
/// </summary>
protected TimeSpan UltraFastCache
{
get => TimeSpan.FromSeconds(cacheTtlShort / 6 * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache MOLTO lunga (+ perturbazione percentuale +/-10%)
/// </summary>
protected TimeSpan UltraLongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
}
#region Public Constructors
public LiManDataService(IConfiguration configuration, ILogger<LiManDataService> logger, IMemoryCache memoryCache, IDistributedCache distributedCache, IEmailSender emailSender)
public LiManDataService(IConfiguration configuration, ILogger<LiManDataService> logger, IMemoryCache memoryCache, IDistributedCache distributedCache, IConnectionMultiplexer redisConnMult, IEmailSender emailSender)
{
_logger = logger;
_configuration = configuration;
// Conf cache
redisConn = redisConnMult;
redisDb = this.redisConn.GetDatabase();
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
JSSettings = new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};
_emailSender = emailSender;
// conf cache
this.memoryCache = memoryCache;
@@ -168,16 +236,16 @@ namespace LiMan.UI.Data
return await Task.FromResult(done);
}
public async Task<List<DB.DBModels.ApplicativoModel>> ApplicazioniNextGetAll()
public async Task<List<ApplicativoModel>> ApplicazioniNextGetAll()
{
List<DB.DBModels.ApplicativoModel> dbResult = new List<DB.DBModels.ApplicativoModel>();
List<ApplicativoModel> dbResult = new List<ApplicativoModel>();
string cacheKey = mHash("Next:Applicazioni");
string rawData;
var redisDataList = await distributedCache.GetAsync(cacheKey);
if (redisDataList != null)
{
rawData = Encoding.UTF8.GetString(redisDataList);
dbResult = JsonConvert.DeserializeObject<List<DB.DBModels.ApplicativoModel>>(rawData);
dbResult = JsonConvert.DeserializeObject<List<ApplicativoModel>>(rawData);
}
else
{
@@ -194,7 +262,7 @@ namespace LiMan.UI.Data
return await Task.FromResult(dbResult);
}
public async Task<bool> ApplicazioniNextUpdate(DB.DBModels.ApplicativoModel currItem)
public async Task<bool> ApplicazioniNextUpdate(ApplicativoModel currItem)
{
bool done = false;
try
@@ -226,10 +294,10 @@ namespace LiMan.UI.Data
/// </summary>
/// <param name="CurrFilter"></param>
/// <returns></returns>
public async Task<List<DB.DBModels.SubLicenzaModel>> AttivazioniGetByLic(int IdxLic)
public async Task<List<SubLicenzaModel>> AttivazioniGetByLic(int IdxLic)
{
Stopwatch stopWatch = new Stopwatch();
List<DB.DBModels.SubLicenzaModel> dbResult = new List<DB.DBModels.SubLicenzaModel>();
List<SubLicenzaModel> dbResult = new List<SubLicenzaModel>();
stopWatch.Start();
dbResult = dbControllerNext.AttivazioniGetByLic(IdxLic);
stopWatch.Stop();
@@ -238,6 +306,308 @@ namespace LiMan.UI.Data
return await Task.FromResult(dbResult);
}
/// <summary>
/// Recupera elenco Claim dato UserID
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
public async Task<List<AuthClaimModel>> AuthClaimByUserID(int userID)
{
string source = "DB";
List<AuthClaimModel>? dbResult = new List<AuthClaimModel>();
try
{
string currKey = $"{Const.rKeyConfig}:Auth:Claims:UID:{userID}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<AuthClaimModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<AuthClaimModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerNext.AuthClaimByUserID(userID);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
// per evitare loopback uso deserialize...
var tempResult = JsonConvert.DeserializeObject<List<AuthClaimModel>>(rawData);
if (tempResult != null)
{
dbResult = tempResult;
}
}
if (dbResult == null)
{
dbResult = new List<AuthClaimModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AuthClaimByUserID | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during AuthClaimByUserID:{Environment.NewLine}{exc}");
}
//return await Task.FromResult(dbResult);
return dbResult;
}
/// <summary>
/// Recupera elenco Claim dato UserName
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public async Task<List<AuthClaimModel>> AuthClaimByUserName(string userName)
{
string source = "DB";
List<AuthClaimModel>? dbResult = new List<AuthClaimModel>();
try
{
string currKey = $"{Const.rKeyConfig}:Auth:Claims:UName:{userName}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<AuthClaimModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<AuthClaimModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerNext.AuthClaimByUserName(userName);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
// per evitare loopback uso deserialize...
var tempResult = JsonConvert.DeserializeObject<List<AuthClaimModel>>(rawData);
if (tempResult != null)
{
dbResult = tempResult;
}
}
if (dbResult == null)
{
dbResult = new List<AuthClaimModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AuthClaimByUserName | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during AuthClaimByUserName:{Environment.NewLine}{exc}");
}
//return await Task.FromResult(dbResult);
return dbResult;
}
/// <summary>
/// Refresh globale cache redis
/// </summary>
/// <returns></returns>
public async Task<bool> FlushRedisCache()
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
await Task.Delay(1);
RedisValue pattern = new RedisValue($"{Const.rKeyConfig}:*");
bool answ = await ExecFlushRedisPattern(pattern);
stopWatch.Stop();
Log.Debug($"FlushRedisCache in {stopWatch.Elapsed.TotalMilliseconds} ms");
return answ;
}
/// <summary>
/// Esegue flush memoria redis dato pattern
/// </summary>
/// <param name="pattern"></param>
/// <returns></returns>
protected async Task<bool> ExecFlushRedisPattern(RedisValue pattern)
{
bool answ = false;
var listEndpoints = redisConn.GetEndPoints();
foreach (var endPoint in listEndpoints)
{
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
var server = redisConn.GetServer(endPoint);
if (server != null)
{
var keyList = server.Keys(redisDb.Database, pattern);
foreach (var item in keyList)
{
await redisDb.KeyDeleteAsync(item);
}
answ = true;
}
}
return answ;
}
/// <summary>
/// Upsesrt del Claim di auth utente
/// </summary>
/// <param name="newRec"></param>
/// <returns></returns>
public async Task<bool> AuthClaimUpsert(AuthClaimModel newRec)
{
bool fatto = dbControllerNext.AuthClaimUpsert(newRec);
await FlushRedisCache();
return fatto;
}
/// <summary>
/// Recupera elenco Roles (completo)
/// </summary>
/// <returns></returns>
public async Task<List<AuthRoleModel>> AuthRolesGetAll()
{
string source = "DB";
List<AuthRoleModel>? dbResult = new List<AuthRoleModel>();
try
{
string currKey = $"{Const.rKeyConfig}:Auth:Roles";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<AuthRoleModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<AuthRoleModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerNext.AuthRolesGetAll();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
// per evitare loopback uso deserialize...
var tempResult = JsonConvert.DeserializeObject<List<AuthRoleModel>>(rawData);
if (tempResult != null)
{
dbResult = tempResult;
}
}
if (dbResult == null)
{
dbResult = new List<AuthRoleModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AuthRolesGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during AuthRolesGetAll:{Environment.NewLine}{exc}");
}
//return await Task.FromResult(dbResult);
return dbResult;
}
/// <summary>
/// Upsert del ROLE
/// </summary>
/// <param name="newRec"></param>
/// <returns></returns>
public async Task<bool> AuthRoleUpsert(AuthRoleModel newRec)
{
bool fatto = dbControllerNext.AuthRoleUpsert(newRec);
await FlushRedisCache();
return fatto;
}
/// <summary>
/// Recupera elenco Utenti UserName (idealmente 1...)
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public async Task<List<AuthUserModel>> AuthUserGetFilt(string userName)
{
string source = "DB";
List<AuthUserModel>? dbResult = new List<AuthUserModel>();
try
{
string currKey = $"{Const.rKeyConfig}:Auth:Users:{userName}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<AuthUserModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<AuthUserModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbControllerNext.AuthUserGetFilt(userName);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
// per evitare loopback uso deserialize...
var tempResult = JsonConvert.DeserializeObject<List<AuthUserModel>>(rawData);
if (tempResult != null)
{
dbResult = tempResult;
}
}
if (dbResult == null)
{
dbResult = new List<AuthUserModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AuthUserGetFilt | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during AuthUserGetFilt:{Environment.NewLine}{exc}");
}
//return await Task.FromResult(dbResult);
return dbResult;
}
/// <summary>
/// Upsert AuthUser
/// </summary>
/// <param name="newRec"></param>
/// <returns></returns>
public async Task<bool> AuthUserUpsert(AuthUserModel newRec)
{
bool fatto = dbControllerNext.AuthUserUpsert(newRec);
await FlushRedisCache();
return fatto;
}
public async Task<bool> DbForceMigrate()
{
return await Task.FromResult(dbControllerGLS.DbForceMigrate());
@@ -307,16 +677,16 @@ namespace LiMan.UI.Data
return await Task.FromResult(done);
}
public async Task<List<DB.DBModels.InstallazioneModel>> InstallazioniNextGetAll()
public async Task<List<InstallazioneModel>> InstallazioniNextGetAll()
{
List<DB.DBModels.InstallazioneModel> dbResult = new List<DB.DBModels.InstallazioneModel>();
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<DB.DBModels.InstallazioneModel>>(rawData);
dbResult = JsonConvert.DeserializeObject<List<InstallazioneModel>>(rawData);
}
else
{
@@ -333,7 +703,7 @@ namespace LiMan.UI.Data
return await Task.FromResult(dbResult);
}
public async Task<bool> InstallazioniNextUpdate(DB.DBModels.InstallazioneModel currItem)
public async Task<bool> InstallazioniNextUpdate(InstallazioneModel currItem)
{
bool done = false;
try
@@ -376,7 +746,7 @@ namespace LiMan.UI.Data
var currLicenza = dbControllerNext.GetLicenza(IdxLicNext);
// step 1: converto licenza, faccio upsert
var logLicNext = new DB.DBModels.LogLicenzaModel()
var logLicNext = new LogLicenzaModel()
{
CodApp = currItem.ApplicativoNavigation.Applicativo,
CodInst = currItem.InstallazioneNavigation.Installazione,
@@ -408,7 +778,7 @@ namespace LiMan.UI.Data
{
bool done = false;
// step 1: controllo applicazione esistente
DB.DBModels.ApplicativoModel appNext = new DB.DBModels.ApplicativoModel()
ApplicativoModel appNext = new ApplicativoModel()
{
CodApp = currItem.ApplicativoNavigation.Applicativo,
Descrizione = currItem.ApplicativoNavigation.Descrizione
@@ -416,7 +786,7 @@ namespace LiMan.UI.Data
bool step1 = dbControllerNext.UpsertApplicazione(appNext);
// step 2: controllo installazione esistente
var instNext = new DB.DBModels.InstallazioneModel()
var instNext = new InstallazioneModel()
{
Cliente = currItem.InstallazioneNavigation.Installazione,
CodInst = currItem.InstallazioneNavigation.Installazione,
@@ -427,7 +797,7 @@ namespace LiMan.UI.Data
bool step2 = dbControllerNext.UpsertInstallazione(instNext);
// step 3: converto licenza, faccio upsert
var licNext = new DB.DBModels.LicenzaModel()
var licNext = new LicenzaModel()
{
CodApp = currItem.ApplicativoNavigation.Applicativo,
CodInst = currItem.InstallazioneNavigation.Installazione,
@@ -511,16 +881,16 @@ namespace LiMan.UI.Data
return await Task.FromResult(done);
}
public async Task<List<DB.DBModels.LicenzaModel>> LicenzeNextGetAll()
public async Task<List<LicenzaModel>> LicenzeNextGetAll()
{
List<DB.DBModels.LicenzaModel> dbResult = new List<DB.DBModels.LicenzaModel>();
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<DB.DBModels.LicenzaModel>>(rawData);
dbResult = JsonConvert.DeserializeObject<List<LicenzaModel>>(rawData);
}
else
{
@@ -542,10 +912,10 @@ namespace LiMan.UI.Data
/// </summary>
/// <param name="CurrFilter"></param>
/// <returns></returns>
public async Task<List<DB.DBModels.LicenzaModel>> LicenzeNextGetFilt(SelectNext CurrFilter)
public async Task<List<LicenzaModel>> LicenzeNextGetFilt(SelectNext CurrFilter)
{
Stopwatch stopWatch = new Stopwatch();
List<DB.DBModels.LicenzaModel> dbResult = new List<DB.DBModels.LicenzaModel>();
List<LicenzaModel> dbResult = new List<LicenzaModel>();
stopWatch.Start();
dbResult = dbControllerNext.GetLicenzeFilt(CurrFilter.OnlyActive, CurrFilter.ApplicazioneSel, CurrFilter.InstallazioneSel);
stopWatch.Stop();
@@ -554,7 +924,7 @@ namespace LiMan.UI.Data
return await Task.FromResult(dbResult);
}
public async Task<bool> LicenzeNextUpdate(DB.DBModels.LicenzaModel currItem)
public async Task<bool> LicenzeNextUpdate(LicenzaModel currItem)
{
bool done = false;
@@ -590,7 +960,6 @@ namespace LiMan.UI.Data
return answ;
}
/// <summary>
/// Statistiche del LOG chiamate all'API dato filtro
/// </summary>
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.1.2407.1315</Version>
<Version>1.1.2407.1316</Version>
<RootNamespace>LiMan.UI</RootNamespace>
<AssemblyName>LiMan.UI</AssemblyName>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>License Manager</i>
<h4>Versione: 1.1.2407.1315</h4>
<h4>Versione: 1.1.2407.1316</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.1.2407.1315
1.1.2407.1316
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2407.1315</version>
<version>1.1.2407.1316</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>