Update webAPI:

- Riorganizzazione costanti
- aggiunta metodi a progetto
- aggiunta pacchetti nuget
This commit is contained in:
Samuele Locatelli
2023-04-18 20:18:22 +02:00
parent cc08f30647
commit 96fdf85b27
8 changed files with 443 additions and 59 deletions
+253
View File
@@ -0,0 +1,253 @@
using Microsoft.AspNetCore.Identity.UI.Services;
using Newtonsoft.Json;
using NLog;
using StackExchange.Redis;
using System.Diagnostics;
using WebDoorCreator.Core;
using WebDoorCreator.Data.DbModels;
namespace WebDoorCreator.API.Data
{
public class ApiDataService : IDisposable
{
#region Public Fields
/// <summary>
/// Classe Accesso metodi DB
/// </summary>
public static WebDoorCreator.Data.Controllers.WebDoorCreatorController dbController = null!;
#endregion Public Fields
#region Public Constructors
/// <summary>
/// Init classe
/// </summary>
/// <param name="configuration"></param>
/// <param name="logger"></param>
/// <param name="emailSender"></param>
/// <param name="redisCacheClient"></param>
public ApiDataService(IConfiguration configuration, IEmailSender emailSender, IConnectionMultiplexer redisConn)
{
_configuration = configuration;
_emailSender = emailSender;
// setup compoenti REDIS
var redConnString = _configuration.GetConnectionString("Redis");
if (redConnString == null)
{
Log.Error("REDIS ConnString empty!");
}
else
{
this.redisConn = ConnectionMultiplexer.Connect(redConnString);
this.redisDb = this.redisConn.GetDatabase();
}
// Conf DB
var connStrDB = _configuration.GetConnectionString("WDC.DB");
if (string.IsNullOrEmpty(connStrDB))
{
Log.Error("ConnString empty!");
}
else
{
dbController = new WebDoorCreator.Data.Controllers.WebDoorCreatorController(configuration);
Log.Info("DbController OK");
}
}
#endregion Public Constructors
#region Public Methods
public void Dispose()
{
// Clear database controller
dbController.Dispose();
}
/// <summary>
/// Doors list by orderId
/// </summary>
public async Task<List<DoorModel>?> DoorGetByOrderId(int orderId)
{
string source = "DB";
List<DoorModel>? dbResult = new List<DoorModel>();
// cerco da cache
string currKey = $"{Constants.rKeyOrderDetail}:{orderId}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<DoorModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<DoorModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.DoorsGetByOrderId(orderId);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<DoorModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"DoorGetByOrderId | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
#endregion Public Methods
#region Protected Fields
protected const string rKeyCalcOreFase = "Check:OreFasi";
protected const string rKeyFasiAct = "Check:FasiAct";
protected const string rKeyProjAct = "Check:ProjAct";
/// <summary>
/// TTL da 1 min x cache Redis
/// </summary>
protected const int shortTTL = 60 * 5;
protected Random rnd = new Random();
#endregion Protected Fields
#region Protected Methods
/// <summary>
/// Recupero chiave da redis
/// </summary>
/// <param name="rKey"></param>
/// <returns></returns>
protected async Task<string> getRSV(string rKey)
{
string answ = "";
var rawData = await redisDb.StringGetAsync(rKey);
if (rawData.HasValue)
{
answ = $"{rawData}";
}
return answ;
}
/// <summary>
/// Salvataggio chiave in redis
/// </summary>
/// <param name="rKey"></param>
/// <param name="rVal"></param>
/// <param name="ttlSec"></param>
/// <returns></returns>
protected async Task<bool> setRSV(string rKey, string rVal, int ttlSec)
{
bool fatto = false;
await redisDb.StringSetAsync(rKey, rVal, TimeSpan.FromSeconds(ttlSec));
fatto = true;
return fatto;
}
/// <summary>
/// Salvataggio chiave in redis
/// </summary>
/// <param name="rKey"></param>
/// <param name="rValInt"></param>
/// <param name="ttlSec"></param>
/// <returns></returns>
protected async Task<bool> setRSV(string rKey, int rValInt, int ttlSec)
{
bool fatto = false;
await redisDb.StringSetAsync(rKey, rValInt, TimeSpan.FromSeconds(ttlSec));
fatto = true;
return fatto;
}
/// <summary>
/// Registra in cache chiave se non fosse già in elenco
/// </summary>
/// <param name="newKey"></param>
protected void trackCache(string newKey)
{
if (!cachedDataList.Contains(newKey))
{
cachedDataList.Add(newKey);
}
}
#endregion Protected Methods
#region Private Fields
private static IConfiguration _configuration = null!;
private static JsonSerializerSettings? JSSettings;
private static Logger Log = LogManager.GetCurrentClassLogger();
private readonly IEmailSender _emailSender;
/// <summary>
/// Elenco obj in cache
/// </summary>
private List<string> cachedDataList = new List<string>();
/// <summary>
/// Durata cache lunga IN SECONDI
/// </summary>
private int cacheTtlLong = 60 * 5;
/// <summary>
/// Durata cache breve IN SECONDI
/// </summary>
private int cacheTtlShort = 60 * 1;
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
private ConnectionMultiplexer redisConn = null!;
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
private IDatabase redisDb = null!;
#endregion Private Fields
#region Private Properties
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
/// </summary>
private TimeSpan FastCache
{
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
/// </summary>
private TimeSpan LongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
/// </summary>
private TimeSpan UltraLongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
}
#endregion Private Properties
}
}
+46
View File
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue" />
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
<target xsi:type="File" name="fileTarget" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}" />
<target xsi:type="ColoredConsole" name="consoleTarget" layout="${longdate} | ${uppercase:${level}} | ${logger:shortName=true}| ${message}" />
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
<logger name="*" minlevel="Trace" writeTo="consoleTarget" />
<!--<logger name="Microsoft.*" maxlevel="Info" final="true" />-->
<logger name="*" minlevel="Info" writeTo="fileTarget" />
</rules>
</nlog>
+65 -2
View File
@@ -1,14 +1,63 @@
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Localization;
using StackExchange.Redis;
using StackExchange.Redis.Extensions.Core.Configuration;
using StackExchange.Redis.Extensions.Newtonsoft;
using System.Globalization;
using System.Text.Json.Serialization;
using WebDoorCreator.API.Data;
using WebDoorCreator.Data;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// configuration setup
ConfigurationManager configuration = builder.Configuration;
// Redis
var connStringRedis = configuration.GetConnectionString("Redis");
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
// avvio oggetto shared x redis...
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// aggiunta servizi x accesso dati...
// abilitazione x email management con MailKit
//builder.Services.AddTransient<IEmailSender, MailKitEmailSender>();
builder.Services.AddSingleton<IEmailSender, MailKitEmailSender>();
builder.Services.Configure<MailKitEmailSenderOptions>(options =>
{
options.Host_Address = configuration["ExternalProviders:MailKit:SMTP:Address"] ?? "";
options.Host_Port = Convert.ToInt32(configuration["ExternalProviders:MailKit:SMTP:Port"] ?? "");
options.Host_Username = configuration["ExternalProviders:MailKit:SMTP:Account"] ?? "";
options.Host_Password = configuration["ExternalProviders:MailKit:SMTP:Password"] ?? "";
options.Sender_EMail = configuration["ExternalProviders:MailKit:SMTP:SenderEmail"] ?? "";
options.Sender_Name = configuration["ExternalProviders:MailKit:SMTP:SenderName"] ?? "";
});
// aggiunta servizi x accesso dati...
builder.Services.AddControllers()
.AddJsonOptions(c => c.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve);
builder.Services.AddStackExchangeRedisExtensions<NewtonsoftSerializer>((options) =>
{
List<RedisConfiguration> newConf = new List<RedisConfiguration>();
var currConf = configuration.GetSection("Redis").Get<RedisConfiguration>();
if (currConf != null)
{
newConf.Add(currConf);
}
return newConf;
//return configuration.GetSection("Redis").Get<RedisConfiguration>();
});
builder.Services.AddSingleton<ApiDataService>();
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
var app = builder.Build();
@@ -21,6 +70,20 @@ if (app.Environment.IsDevelopment() || app.Environment.IsStaging())
app.UseSwaggerUI();
}
//// cultura IT...
//var supportedCultures = new[]{
// new CultureInfo("it-IT")
// };
//app.UseRequestLocalization(new RequestLocalizationOptions
//{
// DefaultRequestCulture = new RequestCulture("it-IT"),
// SupportedCultures = supportedCultures,
// FallBackToParentCultures = false
//});
//CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("it-IT");
app.UseHttpsRedirection();
app.UseAuthorization();
@@ -11,8 +11,18 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NLog" Version="5.1.2" />
<PackageReference Include="StackExchange.Redis" Version="2.6.96" />
<PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="9.1.0" />
<PackageReference Include="StackExchange.Redis.Extensions.Core" Version="9.1.0" />
<PackageReference Include="StackExchange.Redis.Extensions.Newtonsoft" Version="9.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebDoorCreator.Core\WebDoorCreator.Core.csproj" />
<ProjectReference Include="..\WebDoorCreator.Data\WebDoorCreator.Data.csproj" />
</ItemGroup>
</Project>
+22 -1
View File
@@ -5,5 +5,26 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ConnectionStrings": {
"Redis": "localhost:6379,DefaultDatabase=11,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false",
"WDC.DB": "Server=SQL2016DEV;Database=WebDoorCreator; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=WebDoorCreator.UI;"
},
"ExternalProviders": {
"MailKit": {
"SMTP": {
"Address": "smtp-mail.outlook.com",
"Port": "587",
"Account": "steamwarebot@outlook.it",
"Password": "siamoInViaNazionale93",
"SenderEmail": "steamwarebot@outlook.it",
"SenderName": "Steamware Email BOT"
}
}
},
"MailDest": {
"Admin": "samuele@steamware.net",
"ProjCheck": "samuele.locatelli@egalware.com,mara.baroni@egalware.com",
"TimbCheck": "samuele.locatelli@egalware.com,mara.baroni@egalware.com"
}
}
+1
View File
@@ -0,0 +1 @@

+19
View File
@@ -23,5 +23,24 @@ namespace WebDoorCreator.Core
// REDIS Channels messaggi (verso UI)
public static readonly string CALC_REQ_QUEUE = $"CalcRequest";
public static readonly string CALC_DONE_QUEUE = $"CalcCompleted";
public const string passPhrase = "9eb4660f-8753-46bc-b23b-08759ba03fe9";
// classi utilità x cache REDIS dati DB
public const string redisBaseAddr = "WDC";
public const string rKeyCompany = $"{redisBaseAddr}:Cache:Company";
public const string rKeyDoor = $"{redisBaseAddr}:Cache:Door";
public const string rKeyDoorOp = $"{redisBaseAddr}:Cache:DoorOp";
public const string rKeyDoorOpType = $"{redisBaseAddr}:Cache:DoorOpType";
public const string rKeyGraphicParameters = $"{redisBaseAddr}:Cache:GraphicParameters";
public const string rKeyListValues = $"{redisBaseAddr}:Cache:ListValues";
public const string rKeyOrderDetail = $"{redisBaseAddr}:Cache:OrderDetail";
public const string rKeyOrderStatus = $"{redisBaseAddr}:Cache:OrderStatus";
public const string rKeyRoles = $"{redisBaseAddr}:Cache:Roles";
public const string rKeyUsers = $"{redisBaseAddr}:Cache:Users";
public const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView";
public const string rKeyVocLemma = $"{redisBaseAddr}:Cache:VocLemma";
public const string rKeyLanguage = $"{redisBaseAddr}:Cache:Languages";
}
}
+27 -56
View File
@@ -74,7 +74,7 @@ namespace WebDoorCreator.UI.Data
{
var dbResult = await dbController.CompanyAddMod(currRec);
// elimino cache redis...
RedisValue pattern = new RedisValue($"{rKeyCompany}");
RedisValue pattern = new RedisValue($"{Constants.rKeyCompany}");
bool answ = await ExecFlushRedisPattern(pattern);
await Task.Delay(1);
return dbResult;
@@ -91,7 +91,7 @@ namespace WebDoorCreator.UI.Data
List<CompanyModel> dbResult = new List<CompanyModel>();
// cerco da cache
string currKey = $"{rKeyCompany}:{id}";
string currKey = $"{Constants.rKeyCompany}:{id}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -433,7 +433,7 @@ namespace WebDoorCreator.UI.Data
public string DecriptData(string encData)
{
return SteamCrypto.DecryptString(encData, passPhrase);
return SteamCrypto.DecryptString(encData, Constants.passPhrase);
}
/// <summary>
@@ -462,10 +462,10 @@ namespace WebDoorCreator.UI.Data
/// <returns></returns>
public async Task<bool> DoorFlushCache(int DoorId)
{
RedisValue pattern = new RedisValue($"{rKeyDoor}:*");
RedisValue pattern = new RedisValue($"{Constants.rKeyDoor}:*");
if (DoorId > 0)
{
pattern = new RedisValue($"{rKeyDoor}:{DoorId}:*");
pattern = new RedisValue($"{Constants.rKeyDoor}:{DoorId}:*");
}
bool answ = await ExecFlushRedisPattern(pattern);
return answ;
@@ -479,7 +479,7 @@ namespace WebDoorCreator.UI.Data
string source = "DB";
List<DoorModel>? dbResult = new List<DoorModel>();
// cerco da cache
string currKey = $"{rKeyOrderDetail}:{orderId}";
string currKey = $"{Constants.rKeyOrderDetail}:{orderId}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -550,10 +550,10 @@ namespace WebDoorCreator.UI.Data
/// <returns></returns>
public async Task<bool> DoorOpFlushCache(int DoorId)
{
RedisValue pattern = new RedisValue($"{rKeyDoorOp}*");
RedisValue pattern = new RedisValue($"{Constants.rKeyDoorOp}*");
if (DoorId > 0)
{
pattern = new RedisValue($"{rKeyDoorOp}:{DoorId}*");
pattern = new RedisValue($"{Constants.rKeyDoorOp}:{DoorId}*");
}
bool answ = await ExecFlushRedisPattern(pattern);
return answ;
@@ -567,7 +567,7 @@ namespace WebDoorCreator.UI.Data
string source = "DB";
List<DoorOpModel>? dbResult = new List<DoorOpModel>();
// cerco da cache
string currKey = $"{rKeyDoorOp}:{doorId}";
string currKey = $"{Constants.rKeyDoorOp}:{doorId}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -607,7 +607,7 @@ namespace WebDoorCreator.UI.Data
// cerco da cache
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string currKey = $"{rKeyVocLemma}";
string currKey = $"{Constants.rKeyVocLemma}";
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
@@ -723,7 +723,7 @@ namespace WebDoorCreator.UI.Data
string source = "DB";
List<DoorOpTypeModel>? dbResult = new List<DoorOpTypeModel>();
// cerco da cache
string currKey = $"{rKeyDoorOpType}";
string currKey = $"{Constants.rKeyDoorOpType}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
#if false
@@ -767,7 +767,7 @@ namespace WebDoorCreator.UI.Data
List<DoorOpTypeModel>? dbResult = new List<DoorOpTypeModel>();
string source = "DB";
// cerco da cache
string currKey = $"{rKeyDoorOpType}:DEFAULT";
string currKey = $"{Constants.rKeyDoorOpType}:DEFAULT";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
#if false
@@ -887,13 +887,13 @@ namespace WebDoorCreator.UI.Data
public string EncriptData(string rawData)
{
return SteamCrypto.EncryptString(rawData, passPhrase);
return SteamCrypto.EncryptString(rawData, Constants.passPhrase);
}
public async Task<bool> FlushRedisCache()
{
await Task.Delay(1);
RedisValue pattern = new RedisValue($"{redisBaseAddr}*");
RedisValue pattern = new RedisValue($"{Constants.redisBaseAddr}*");
bool answ = await ExecFlushRedisPattern(pattern);
return answ;
}
@@ -975,7 +975,7 @@ namespace WebDoorCreator.UI.Data
List<ListValuesModel>? dbResult = new List<ListValuesModel>();
string currKey = "";
// cerco da cache
currKey = $"{rKeyListValues}:{tableName}:{fieldName}";
currKey = $"{Constants.rKeyListValues}:{tableName}:{fieldName}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
@@ -1019,7 +1019,7 @@ namespace WebDoorCreator.UI.Data
List<LanguageModel>? dbResult = new List<LanguageModel>();
// cerco da cache
string currKey = $"{rKeyLanguage}";
string currKey = $"{Constants.rKeyLanguage}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -1061,7 +1061,7 @@ namespace WebDoorCreator.UI.Data
{
var dbResult = await dbController.OrderAdd(currRec);
// elimino cache redis...
RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*");
RedisValue pattern = new RedisValue($"{Constants.rKeyOrderStatus}:*");
bool answ = await ExecFlushRedisPattern(pattern);
return dbResult;
}
@@ -1073,10 +1073,10 @@ namespace WebDoorCreator.UI.Data
/// <returns></returns>
public async Task<bool> OrderDetailFlushCache(int OrderId)
{
RedisValue pattern = new RedisValue($"{rKeyOrderDetail}:*");
RedisValue pattern = new RedisValue($"{Constants.rKeyOrderDetail}:*");
if (OrderId > 0)
{
pattern = new RedisValue($"{rKeyOrderDetail}:{OrderId}");
pattern = new RedisValue($"{Constants.rKeyOrderDetail}:{OrderId}");
}
bool answ = await ExecFlushRedisPattern(pattern);
return answ;
@@ -1091,7 +1091,7 @@ namespace WebDoorCreator.UI.Data
{
var dbResult = await dbController.OrderRem(OrdId);
// elimino cache redis...
RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*");
RedisValue pattern = new RedisValue($"{Constants.rKeyOrderStatus}:*");
bool answ = await ExecFlushRedisPattern(pattern);
return dbResult;
}
@@ -1103,7 +1103,7 @@ namespace WebDoorCreator.UI.Data
/// <returns></returns>
public async Task<bool> OrdersFlushCache()
{
RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*");
RedisValue pattern = new RedisValue($"{Constants.rKeyOrderStatus}:*");
bool answ = await ExecFlushRedisPattern(pattern);
return answ;
}
@@ -1114,7 +1114,7 @@ namespace WebDoorCreator.UI.Data
List<OrderStatusViewModel>? dbResult = new List<OrderStatusViewModel>();
// cerco da cache
string currKey = $"{rKeyOrderStatus}:{companyId}:{orderStatus}:{dataFrom:yyyyMMdd}:{dataTo:yyyyMMdd}";
string currKey = $"{Constants.rKeyOrderStatus}:{companyId}:{orderStatus}:{dataFrom:yyyyMMdd}:{dataTo:yyyyMMdd}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -1156,7 +1156,7 @@ namespace WebDoorCreator.UI.Data
List<GraphicParamsModel>? dbResult = new List<GraphicParamsModel>();
// cerco da cache
string currKey = $"{rKeyGraphicParameters}:{hwId}";
string currKey = $"{Constants.rKeyGraphicParameters}:{hwId}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -1198,7 +1198,7 @@ namespace WebDoorCreator.UI.Data
List<AspNetRoles>? dbResult = new List<AspNetRoles>();
// cerco da cache
string currKey = rKeyRoles;
string currKey = Constants.rKeyRoles;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -1240,7 +1240,7 @@ namespace WebDoorCreator.UI.Data
List<AspNetUsers>? dbResult = new List<AspNetUsers>();
// cerco da cache
string currKey = rKeyUsers;
string currKey = Constants.rKeyUsers;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -1282,7 +1282,7 @@ namespace WebDoorCreator.UI.Data
AspNetUsers dbResult = new AspNetUsers();
// cerco da cache
string currKey = $"{rKeyUsers}:{userId}";
string currKey = $"{Constants.rKeyUsers}:{userId}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -1324,7 +1324,7 @@ namespace WebDoorCreator.UI.Data
List<UsersViewModel>? dbResult = new List<UsersViewModel>();
// cerco da cache
string currKey = rKeyUsersView;
string currKey = Constants.rKeyUsersView;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -1361,35 +1361,6 @@ namespace WebDoorCreator.UI.Data
#region Protected Fields
protected const string passPhrase = "9eb4660f-8753-46bc-b23b-08759ba03fe9";
protected const string redisBaseAddr = "WDC";
protected const string rKeyCompany = $"{redisBaseAddr}:Cache:Company";
protected const string rKeyDoor = $"{redisBaseAddr}:Cache:Door";
protected const string rKeyDoorOp = $"{redisBaseAddr}:Cache:DoorOp";
protected const string rKeyDoorOpType = $"{redisBaseAddr}:Cache:DoorOpType";
protected const string rKeyGraphicParameters = $"{redisBaseAddr}:Cache:GraphicParameters";
protected const string rKeyListValues = $"{redisBaseAddr}:Cache:ListValues";
protected const string rKeyOrderDetail = $"{redisBaseAddr}:Cache:OrderDetail";
protected const string rKeyOrderStatus = $"{redisBaseAddr}:Cache:OrderStatus";
protected const string rKeyRoles = $"{redisBaseAddr}:Cache:Roles";
protected const string rKeyUsers = $"{redisBaseAddr}:Cache:Users";
protected const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView";
protected const string rKeyVocLemma = $"{redisBaseAddr}:Cache:VocLemma";
protected const string rKeyLanguage = $"{redisBaseAddr}:Cache:Languages";
protected Random rnd = new Random();