fix gestione calcolo possibilità nesting x caching redis
This commit is contained in:
@@ -604,6 +604,43 @@ namespace AppData
|
||||
// restituisco ok
|
||||
return answ;
|
||||
}
|
||||
public static string canStartNewKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"{redOutPath}:CanStartNew";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// verifica se sia avviabile un nuovo task nesting controllando cache Redis o tabelle batch/offlineOrders
|
||||
/// </summary>
|
||||
public static bool canStartNew
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
bool valido = false;
|
||||
// cerco in redis
|
||||
if (memLayer.ML.redKeyPresent(canStartNewKey))
|
||||
{
|
||||
string rawData = memLayer.ML.getRSV(canStartNewKey);
|
||||
valido = bool.TryParse(rawData, out answ);
|
||||
}
|
||||
if (!valido)
|
||||
{
|
||||
// in primis controllo SE ci siano task running, nel qual caso è false e basta...
|
||||
int numEst = DataLayer.man.taBL.getByStatus((int)BatchStatus.EstimationRequested, "", 0).Count;
|
||||
int numNest = DataLayer.man.taBL.getByStatus((int)BatchStatus.NestRequested, "", 0).Count;
|
||||
// ora controllo anche offline orders...
|
||||
int numOffOrd = DataLayer.man.taOffOL.getRunning().Count;
|
||||
// ora la somma di tutti DEVE essere zero...
|
||||
answ = ((numEst + numNest + numOffOrd) == 0);
|
||||
// salvo in redis
|
||||
memLayer.ML.setRSV(canStartNewKey, answ.ToString(), 2);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica lo stato di una richiesta di esecuzione BATCH x stima/nesting
|
||||
|
||||
Reference in New Issue
Block a user