Prova moditica metodo setPzCount
This commit is contained in:
@@ -3005,9 +3005,21 @@ namespace MP.IOC.Data
|
||||
{
|
||||
string answ = "0";
|
||||
// inizio processing vero e proprio INPUT...
|
||||
if (!string.IsNullOrEmpty(idxMacchina))
|
||||
if (string.IsNullOrEmpty(idxMacchina))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(counter))
|
||||
string errore = "Errore: parametro macchina vuoto";
|
||||
Log.Info(errore);
|
||||
answ = errore;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(counter))
|
||||
{
|
||||
string errore = "Errore: parametro counter vuoto";
|
||||
Log.Error(errore);
|
||||
answ = errore;
|
||||
}
|
||||
else
|
||||
{
|
||||
int newCounter = -1;
|
||||
int.TryParse(counter, out newCounter);
|
||||
@@ -3019,30 +3031,18 @@ namespace MP.IOC.Data
|
||||
if (!rawData.HasValue)
|
||||
{
|
||||
// salvo per + tempo...
|
||||
await redisDb.StringSetAsync(currKey, answ.ToString(), TimeSpan.FromSeconds(30));
|
||||
await redisDb.StringSetAsync(currKey, answ.ToString());
|
||||
answ = counter;
|
||||
}
|
||||
else
|
||||
{
|
||||
int currCount = pzCounterTc(idxMacchina);
|
||||
int currCount = await pzCounterTcAsync(idxMacchina);
|
||||
answ = currCount.ToString();
|
||||
// salvo per meno tempo...
|
||||
await redisDb.StringSetAsync(currKey, answ, TimeSpan.FromSeconds(5));
|
||||
await redisDb.StringSetAsync(currKey, answ);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "Errore: parametro counter vuoto";
|
||||
Log.Error(errore);
|
||||
answ = errore;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "Errore: parametro macchina vuoto";
|
||||
Log.Info(errore);
|
||||
answ = errore;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -3768,7 +3768,7 @@ namespace MP.IOC.Data
|
||||
result = IocDbController.StatoProdMacchina(idxMacchina, dtReq);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(1));
|
||||
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(5));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
@@ -3778,22 +3778,19 @@ namespace MP.IOC.Data
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stato prod macchina (completo) - ASYNC
|
||||
/// Stato prod macchina (completo)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="dtReq"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<StatoProdModel> StatoProdMacchinaAsync(string idxMacchina, DateTime dtReq, bool forceDb = false)
|
||||
{
|
||||
int rndWait = rnd.Next(0, 2);
|
||||
await Task.Delay(rndWait);
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
StatoProdModel? result = new StatoProdModel();
|
||||
// cerco in _redisConn...
|
||||
string currKey = $"{Utils.redisStatoProd}:{idxMacchina}:{dtReq:HHmm}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue && !forceDb)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<StatoProdModel>($"{rawData}");
|
||||
@@ -3801,10 +3798,10 @@ namespace MP.IOC.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
result = IocDbController.StatoProdMacchina(idxMacchina, dtReq);
|
||||
result = await IocDbController.StatoProdMacchinaAsync(idxMacchina, dtReq);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromSeconds(2));
|
||||
await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromSeconds(5));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user