Fix selezione ODL quando disponibile....
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user