ULteriore ottimizzazione procedura cache articoli no eliminabili

This commit is contained in:
Samuele Locatelli
2022-04-30 11:25:39 +02:00
parent 7310054ab6
commit 920e8d9ee3
3 changed files with 33 additions and 10 deletions
@@ -1,4 +1,5 @@
using SteamWare;
using MapoDb;
using SteamWare;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -51,6 +52,8 @@ namespace MP_ADM.WebUserControls
if (!string.IsNullOrEmpty(aziendaSel))
{
memLayer.ML.updateAppConf("AZIENDA", aziendaSel);
// resetto cache filtro articoli
memLayer.ML.setRSV(DataLayer.redKeyTabCheckArt,"");
}
showBtn(false);
}
@@ -2,6 +2,7 @@
using Newtonsoft.Json;
using SteamWare;
using System;
using System.Collections.Generic;
using System.Data;
using System.Web.UI.WebControls;
@@ -17,8 +18,8 @@ namespace MP_ADM.WebUserControls
bool answ = false;
string codArticolo = $"{_idx}";
// cerco in cache redis...
string redKeyArtUsed = DataLayer.mHash($"CACHE:CheckArtUsed:{codArticolo}");
string redKeyTabCheckArt = DataLayer.mHash($"CACHE:TabCheckArt");
string redKeyArtUsed = $"{ DataLayer.redKeyArtUsed}:{codArticolo}";
string redKeyTabCheckArt = DataLayer.redKeyTabCheckArt;
string rawData = memLayer.ML.getRSV(redKeyArtUsed);
if (!string.IsNullOrEmpty(rawData))
{
@@ -31,24 +32,34 @@ namespace MP_ADM.WebUserControls
{
// cerco in cache se ci sia la tabella con gli articoli impiegati...
string rawTable = memLayer.ML.getRSV(redKeyTabCheckArt);
DS_ProdTempi.AnagArticoliDataTable tabArticoli = new DS_ProdTempi.AnagArticoliDataTable();
List<string> artList = new List<string>();
if (!string.IsNullOrEmpty(rawTable))
{
tabArticoli = JsonConvert.DeserializeObject<DS_ProdTempi.AnagArticoliDataTable>(rawTable);
artList = JsonConvert.DeserializeObject<List<string>>(rawTable);
}
// rileggo...
if (tabArticoli == null || tabArticoli.Count == 0)
if (artList == null || artList.Count == 0)
{
tabArticoli = DataLayerObj.taAnagArt.getUsed();
var tabArticoli = DataLayerObj.taAnagArt.getUsed();
var codList = tabArticoli.Select(x => x.CodArticolo);
foreach (string cod in codList)
{
artList.Add(cod);
}
// SE fosse vuoto aggiungo comunque il cado "ND"...
if (artList.Count == 0)
{
artList.Add("ND");
}
// salvo
rawTable = JsonConvert.SerializeObject(tabArticoli);
rawTable = JsonConvert.SerializeObject(artList);
memLayer.ML.setRSV(redKeyTabCheckArt, rawTable, 60 * memLayer.ML.cdvi("cacheCheckArtUsato"));
}
// cerco nella tabella: se ci fosse --> disabilitato delete
bool usato = false;
if (tabArticoli != null && tabArticoli.Rows.Count > 0)
if (artList != null && artList.Count > 0)
{
usato = tabArticoli.Rows.Contains(codArticolo);
usato = artList.Contains(codArticolo);
}
answ = !usato;
memLayer.ML.setRSV(redKeyArtUsed, $"{answ}", 60 * memLayer.ML.cdvi("cacheCheckArtUsato"));
+9
View File
@@ -126,6 +126,15 @@ namespace MapoDb
}
}
public static string redKeyArtUsed
{
get => mHash($"CACHE:CheckArtUsed");
}
public static string redKeyTabCheckArt
{
get => mHash($"CACHE:TabCheckArt");
}
/// <summary>
/// Cognome Nome da MatrOpr in sessione
/// </summary>