diff --git a/MP-ADM/WebUserControls/cmp_CompanySelector.ascx.cs b/MP-ADM/WebUserControls/cmp_CompanySelector.ascx.cs index 7f8d3289..27b7df51 100644 --- a/MP-ADM/WebUserControls/cmp_CompanySelector.ascx.cs +++ b/MP-ADM/WebUserControls/cmp_CompanySelector.ascx.cs @@ -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); } diff --git a/MP-ADM/WebUserControls/mod_anagArticoli.ascx.cs b/MP-ADM/WebUserControls/mod_anagArticoli.ascx.cs index 6251c9d7..b6987ad6 100644 --- a/MP-ADM/WebUserControls/mod_anagArticoli.ascx.cs +++ b/MP-ADM/WebUserControls/mod_anagArticoli.ascx.cs @@ -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 artList = new List(); if (!string.IsNullOrEmpty(rawTable)) { - tabArticoli = JsonConvert.DeserializeObject(rawTable); + artList = JsonConvert.DeserializeObject>(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")); diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs index 4e13332d..e3892c82 100644 --- a/MapoDb/DataLayer.cs +++ b/MapoDb/DataLayer.cs @@ -126,6 +126,15 @@ namespace MapoDb } } + public static string redKeyArtUsed + { + get => mHash($"CACHE:CheckArtUsed"); + } + public static string redKeyTabCheckArt + { + get => mHash($"CACHE:TabCheckArt"); + } + /// /// Cognome Nome da MatrOpr in sessione ///