Aggiunta metodi per la gestione del magazzino

This commit is contained in:
zaccaria.majid
2022-11-18 12:51:12 +01:00
parent 3dddc33ec1
commit 629489fa85
2 changed files with 192 additions and 73 deletions
+67 -8
View File
@@ -1,6 +1,7 @@
using Egw.Core;
using MP.Data.Conf;
using MP.Data.DatabaseModels;
using MP.INVE.Pages;
using Newtonsoft.Json;
using NLog;
using StackExchange.Redis;
@@ -68,19 +69,66 @@ namespace MP.INVE.Data
public async Task<bool> InsertNewSessione(InventorySessionModel newSess)
{
bool result = false;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
result = await dbController.InsertNewSessione(newSess);
// elimino cache redis...
RedisValue pattern = new RedisValue($"{redisBaseAddr}{redisSessionBaseAddr}*");
bool answ = await ExecFlushRedisPattern(pattern);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"InsertNewSessione | Id sessione: {newSess.InveSessID} | Id sessione: {newSess.Description} | {ts.TotalMilliseconds}ms");
return result;
// aggiungo record al DB
bool answ = await dbController.InsertNewSessione(newSess);
return answ;
}
public async Task<bool> deleteSessione(InventorySessionModel session)
{
bool result = false;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
result = await dbController.deleteSessione(session);
// elimino cache redis...
RedisValue pattern = new RedisValue($"{redisBaseAddr}{redisSessionBaseAddr}*");
bool answ = await ExecFlushRedisPattern(pattern);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"deleteSessione | Id sessione: {session.InveSessID} | Id sessione: {session.Description} | {ts.TotalMilliseconds}ms");
return result;
// elimino record dal DB
bool answ = await dbController.deleteSessione(session);
return answ;
}
public async Task<bool> InsertNewMag(AnagMagModel newMag)
{
bool result = false;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
result = await dbController.InsertNewMag(newMag);
// elimino cache redis...
RedisValue pattern = new RedisValue($"{redisMagList}");
bool answ = await ExecFlushRedisPattern(pattern);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"InsertNewMag | Codice magazzino: {newMag.CodMag} | Descrizione magazzino: {newMag.DescMag} | {ts.TotalMilliseconds}ms");
return result;
// aggiungo record al DB
}
public async Task<bool> DeleteMag(AnagMagModel Mag)
{
bool result = false;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
result = await dbController.DeleteMag(Mag);
// elimino cache redis...
RedisValue pattern = new RedisValue($"{redisMagList}:*");
bool answ = await ExecFlushRedisPattern(pattern);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"DeleteMag | Codice magazzino: {Mag.CodMag} | Descrizione magazzino: {Mag.DescMag} | {ts.TotalMilliseconds}ms");
return result;
}
public List<AnagOperatoriModel> ElencoOperatori(int matrOpr, string authkey)
{
Stopwatch stopWatch = new Stopwatch();
@@ -247,6 +295,16 @@ namespace MP.INVE.Data
bool answ = await ExecFlushRedisPattern(pattern);
return answ;
}
#if false
public async Task<bool> FlushRedisCache(string keyPattern)
{
await Task.Delay(1);
RedisValue pattern = new RedisValue($"{keyPattern}*");
bool answ = await ExecFlushRedisPattern(pattern);
return answ;
}
#endif
/// <summary>
/// Esegue flush memoria redis dato pattern
@@ -282,9 +340,10 @@ namespace MP.INVE.Data
#region Private Fields
private const string redisBaseAddr = "MP:INVE";
private const string redisSessionBaseAddr = ":Session:";
private const string redisElencoOperatori = redisBaseAddr + ":ListOperatori";
private const string redisSessionCurrList = redisBaseAddr + ":ListSessHist";
private const string redisSessionHistList = redisBaseAddr + ":ListSessCurr";
private const string redisSessionCurrList = redisBaseAddr + redisSessionBaseAddr + ":ListSessHist";
private const string redisSessionHistList = redisBaseAddr + redisSessionBaseAddr + ":ListSessCurr";
private const string redisMagList = redisBaseAddr + ":ListMag";
private static IConfiguration _configuration = null!;