Fix selezione ODL quando disponibile....

This commit is contained in:
Samuele Locatelli
2023-11-06 19:57:46 +01:00
parent 705eeb56df
commit 6432bde3fa
8 changed files with 196 additions and 28 deletions
+30
View File
@@ -825,6 +825,36 @@ namespace MP.Data.Controllers
}
return fatto;
}
/// <summary>
/// Recupero PODL da chiave
/// </summary>
/// <param name="idxPODL"></param>
/// <returns></returns>
public PODLExpModel PODLExp_getByKey(int idxPODL)
{
PODLExpModel dbResult = new PODLExpModel();
using (var dbCtx = new MoonProContext(_configuration))
{
try
{
var IdxPromessa = new SqlParameter("@IdxPromessa", idxPODL);
var rawResult = dbCtx
.DbSetPODLExp
.FromSqlRaw("EXEC stp_PODL_getByIdx @IdxPromessa", IdxPromessa)
.AsNoTracking()
.ToList();
if (rawResult != null && rawResult.Count > 0)
{
dbResult = rawResult.FirstOrDefault();
}
}
catch (Exception exc)
{
Log.Error($"Eccezione durante PODL_getByKey{Environment.NewLine}{exc}");
}
}
return dbResult;
}
/// <summary>
/// Stato prod macchina
+35
View File
@@ -1156,6 +1156,41 @@ namespace MP.Data.Services
return result;
}
/// <summary>
/// Recupero PODL da chiave
/// </summary>
/// <param name="idxPODL"></param>
/// <returns></returns>
public async Task<PODLExpModel> PODLExp_getByKey(int idxPODL)
{
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
PODLExpModel result = new PODLExpModel();
// cerco in redis...
string currKey = $"{redisBaseKey}:PODL:{idxPODL}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<PODLExpModel>($"{rawData}");
source = "REDIS";
}
else
{
result = await Task.FromResult(dbTabController.PODLExp_getByKey(idxPODL));
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (result == null)
{
result = new PODLExpModel();
}
sw.Stop();
Log.Debug($"PODL_getByKey | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
/// <summary>
/// Restituisce elenco RC filtrato
/// </summary>