Fix check errori presenti

This commit is contained in:
Samuele Locatelli
2023-05-12 15:07:02 +02:00
parent a510e9196a
commit 59d6bc1205
3 changed files with 97 additions and 24 deletions
@@ -63,6 +63,25 @@ namespace WebDoorCreator.Data.Services
redisConn.Dispose();
}
/// <summary>
/// Restitusice gli errori della porta in oggetto
/// </summary>
/// <param name="doorIdVers">formato DoorId:Versione</param>
/// <returns></returns>
public async Task<bool> DoorErrExists(string doorIdVers)
{
bool hasErr = false;
// cerco versione errore x la porta...
var doorData = doorIdVers.Split(":");
if (doorData.Length == 2)
{
RedisKey currErrKey = new RedisKey($"{Constants.CALC_REQ_ERRS}");
int currId = await RedHashGet(currErrKey, doorData[0]);
hasErr = doorData[1] == $"{currId}";
}
return hasErr;
}
/// <summary>
/// Restitusice gli errori della porta in oggetto
/// </summary>
@@ -188,6 +207,31 @@ namespace WebDoorCreator.Data.Services
Log.Trace($"RedHashRemove | {currKey} | in: {ts.TotalMilliseconds} ms");
return fatto;
}
/// <summary>
/// Verify existence for single hash record
/// </summary>
/// <param name="currKey">Chiave redis della Hashlist</param>
/// <param name="chiave">Chiave nella HashList</param>
/// <returns>Esito rimozione</returns>
public async Task<int> RedHashGet(RedisKey currKey, string chiave)
{
int result = 0;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
var hasVal = await redisDb.HashExistsAsync(currKey, chiave);
if (hasVal)
{
var rawRes = await redisDb.HashGetAsync(currKey, chiave);
if (rawRes.HasValue)
{
int.TryParse($"{rawRes}", out result);
}
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"RedHashGet | {currKey} | in: {ts.TotalMilliseconds} ms");
return result;
}
/// <summary>
/// Get Queue request done