gestione currBunks x macchina: inizio modifica
This commit is contained in:
+45
-26
@@ -1165,9 +1165,13 @@ namespace AppData
|
||||
/// <summary>
|
||||
/// Chiave bunk corrente su redis
|
||||
/// </summary>
|
||||
protected static string redCurrBunkTabKey()
|
||||
protected static string redCurrBunkTabKey(string machine)
|
||||
{
|
||||
return $"{redProdReq}:CurrBunks";
|
||||
if (string.IsNullOrEmpty(machine))
|
||||
{
|
||||
machine = "WRK001";
|
||||
}
|
||||
return $"{redProdReq}:CurrBunks:{machine}";
|
||||
}
|
||||
/// <summary>
|
||||
/// Chiave bunk corrente su redis
|
||||
@@ -1436,20 +1440,20 @@ namespace AppData
|
||||
/// BUNK corrente (x ora copia di first, poi sarà quello SELEZIONATO tra quelli SELEZIONABILI)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DS_App.StackListRow getCurrBunk()
|
||||
public static DS_App.StackListRow getCurrBunk(string machine = "WRK001")
|
||||
{
|
||||
DS_App.StackListRow answ = null;
|
||||
DS_App.StackListDataTable tabBunk = null;
|
||||
// cerco in cache....
|
||||
if (cachedCurrBunkTab != null)
|
||||
if (getCurrBunkTab(machine) != null)
|
||||
{
|
||||
tabBunk = cachedCurrBunkTab;
|
||||
tabBunk = getCurrBunkTab(machine);
|
||||
}
|
||||
else
|
||||
{
|
||||
tabBunk = DataLayer.man.taSTL.getLoaded();
|
||||
// salvo in redis
|
||||
cachedCurrBunkTab = tabBunk;
|
||||
setCurrBunkTab(machine, tabBunk);
|
||||
}
|
||||
if (tabBunk != null && tabBunk.Count > 0)
|
||||
{
|
||||
@@ -1457,31 +1461,46 @@ namespace AppData
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected static DS_App.StackListDataTable cachedCurrBunkTab
|
||||
/// <summary>
|
||||
/// resetto curr bunk
|
||||
/// </summary>
|
||||
/// <param name="machine"></param>
|
||||
protected static void resetCurrBunk(string machine = "WRK001")
|
||||
{
|
||||
get
|
||||
// svuoto"
|
||||
memLayer.ML.redFlushKey(redCurrBunkTabKey(machine));
|
||||
}
|
||||
/// <summary>
|
||||
/// lettura currBunk table da cache
|
||||
/// </summary>
|
||||
/// <param name="machine"></param>
|
||||
/// <returns></returns>
|
||||
protected static DS_App.StackListDataTable getCurrBunkTab(string machine)
|
||||
{
|
||||
DS_App.StackListDataTable answ = null;
|
||||
string rawData = memLayer.ML.getRSV(redCurrBunkTabKey(machine));
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
DS_App.StackListDataTable answ = null;
|
||||
string rawData = memLayer.ML.getRSV(redCurrBunkTabKey());
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
// deserializzo...
|
||||
answ = JsonConvert.DeserializeObject<DS_App.StackListDataTable>(rawData);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
// deserializzo...
|
||||
answ = JsonConvert.DeserializeObject<DS_App.StackListDataTable>(rawData);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
string rawData = JsonConvert.SerializeObject(value);
|
||||
// TTL 5 sec
|
||||
memLayer.ML.setRSV(redCurrBunkTabKey(), rawData, 5);
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// salvataggio inc ache currBunk table
|
||||
/// </summary>
|
||||
/// <param name="machine"></param>
|
||||
/// <param name="tabBunks"></param>
|
||||
protected static void setCurrBunkTab(string machine, DS_App.StackListDataTable tabBunks)
|
||||
{
|
||||
string rawData = JsonConvert.SerializeObject(tabBunks);
|
||||
// TTL 15 sec
|
||||
memLayer.ML.setRSV(redCurrBunkTabKey(machine), rawData, 15);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user