32fb68fa68
- Cleanup codice area MapoDb
163 lines
4.6 KiB
C#
163 lines
4.6 KiB
C#
using MapoDb;
|
|
using Newtonsoft.Json;
|
|
using SteamWare;
|
|
using System;
|
|
|
|
public class selData
|
|
{
|
|
#region Public Fields
|
|
|
|
public static selData mng = new selData();
|
|
|
|
#endregion Public Fields
|
|
|
|
#region Public Constructors
|
|
|
|
/// <summary>
|
|
/// classe accesso tabelle selettori
|
|
/// </summary>
|
|
public selData()
|
|
{
|
|
DataLayerObj = new DataLayer();
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Tabella elenco Articoli
|
|
/// NB: mantenuta in cache redis x evitare continue letture...
|
|
/// </summary>
|
|
/// <param name="conditio"></param>
|
|
/// <returns></returns>
|
|
public DS_ProdTempi.AnagArticoliDataTable getSelAllArticoli()
|
|
{
|
|
return DataLayerObj.taAnagArt.GetData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invalida e svuota la cache di selezione post update vari...
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool invalidateCache()
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
string redKey = memLayer.ML.redHash("Cache:Art:");
|
|
memLayer.ML.redFlushKey(redKey);
|
|
redKey = memLayer.ML.redHash("Cache:StatoMacc:");
|
|
memLayer.ML.redFlushKey(redKey);
|
|
answ = true;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Riga dettaglio singolo articolo
|
|
/// NB: mantenuta in cache redis x evitare continue letture...
|
|
/// </summary>
|
|
/// <param name="conditio"></param>
|
|
/// <returns></returns>
|
|
public DS_ProdTempi.AnagArticoliRow rigaArt(string codArt)
|
|
{
|
|
DS_ProdTempi.AnagArticoliRow answ = null;
|
|
// cerco in REDIS...
|
|
string redKey = memLayer.ML.redHash("Cache:Art:" + codArt);
|
|
string serVal = memLayer.ML.getRSV(redKey);
|
|
if (serVal != null && serVal != "")
|
|
{
|
|
try
|
|
{
|
|
DS_ProdTempi.AnagArticoliDataTable tab = JsonConvert.DeserializeObject<DS_ProdTempi.AnagArticoliDataTable>(serVal);
|
|
if (tab.Rows.Count > 0)
|
|
{
|
|
answ = tab[0];
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("rigaArt|Errore in deserializzazione chiave {0}{1}{2}", codArt, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// se non trovo --> DB!
|
|
try
|
|
{
|
|
DS_ProdTempi.AnagArticoliDataTable tab = DataLayerObj.taAnagArt.getByCod(codArt);
|
|
if (tab.Rows.Count > 0)
|
|
{
|
|
answ = tab[0];
|
|
}
|
|
serVal = JsonConvert.SerializeObject(tab);
|
|
memLayer.ML.setRSV(redKey, serVal, cacheDuration);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Riga STATO macchina
|
|
/// NB: mantenuta in cache redis x evitare continue letture...
|
|
/// </summary>
|
|
/// <param name="conditio"></param>
|
|
/// <returns></returns>
|
|
public DS_applicazione.StatoMacchineRow rigaStato(string idxMacc)
|
|
{
|
|
DS_applicazione.StatoMacchineRow answ = null;
|
|
// cerco in REDIS...
|
|
string redKey = memLayer.ML.redHash("Cache:StatoMacc:" + idxMacc);
|
|
string serVal = memLayer.ML.getRSV(redKey);
|
|
if (serVal != null && serVal != "")
|
|
{
|
|
try
|
|
{
|
|
DS_applicazione.StatoMacchineDataTable tab = JsonConvert.DeserializeObject<DS_applicazione.StatoMacchineDataTable>(serVal);
|
|
if (tab.Rows.Count > 0)
|
|
{
|
|
answ = tab[0];
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("rigaStato|Errore in deserializzazione chiave {0}{1}{2}", idxMacc, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// se non trovo --> DB!
|
|
try
|
|
{
|
|
DS_applicazione.StatoMacchineDataTable tab = DataLayerObj.taStatoMacchine.GetDataByIdxMacchina(idxMacc);
|
|
if (tab.Rows.Count > 0)
|
|
{
|
|
answ = tab[0];
|
|
}
|
|
serVal = JsonConvert.SerializeObject(tab);
|
|
memLayer.ML.setRSV(redKey, serVal, cacheDuration);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
/// <summary>
|
|
/// Durata standard cache info
|
|
/// </summary>
|
|
protected int cacheDuration = 5;
|
|
|
|
protected DataLayer DataLayerObj;
|
|
|
|
#endregion Protected Fields
|
|
} |