Aggiunta metodo GetIdlePeriod
This commit is contained in:
@@ -483,7 +483,6 @@ namespace MP.IOC.Controllers
|
||||
return Ok(answ);
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Restituisce il valore dello stato di IDLE della macchina, quindi SOLO SE NON é in lavoro
|
||||
/// e già convertito in minuti...
|
||||
@@ -492,38 +491,43 @@ namespace MP.IOC.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getIdlePeriod/{id}")]
|
||||
public int GetIdlePeriod(string id)
|
||||
public async Task<IActionResult> GetIdlePeriod(string id)
|
||||
{
|
||||
// attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
|
||||
// carattere "|" che poi trasformiamo ora in "#"
|
||||
if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID");
|
||||
// Multi: gestione carattere "|" trasformato in "#"
|
||||
id = id.Replace("|", "#");
|
||||
int answ = 0;
|
||||
DataLayer DataLayerObj = new DataLayer();
|
||||
DS_applicazione.StatoMacchineDataTable currData = null;
|
||||
// chiamo metodo redis/db...
|
||||
|
||||
// chiamo metodo x avere stato macchina...
|
||||
try
|
||||
{
|
||||
currData = DataLayerObj.currSMTab(id);
|
||||
if (currData.Count > 0)
|
||||
var mseData = await DService.MseGetAllAsync();
|
||||
if (mseData.Count > 0)
|
||||
{
|
||||
// recupero da redis elenco stati
|
||||
DS_applicazione.AnagraficaStatiDataTable anagStati = DataLayerObj.AnagraficaStati();
|
||||
DS_applicazione.AnagraficaStatiRow currStato = anagStati.FindByIdxStato(currData[0].IdxStato);
|
||||
// calcolo SE sia idle... OVVERO SEMAFORO NON VERDE!!!
|
||||
if (currStato.Semaforo != "sVe")
|
||||
var currRec = mseData.FirstOrDefault(x => x.IdxMacchina == id);
|
||||
if (currRec != null)
|
||||
{
|
||||
// calcolo durata...
|
||||
answ = (int)DateTime.Now.Subtract(currData[0].InizioStato).TotalMinutes;
|
||||
// recupero da redis elenco stati
|
||||
var anagStati = await DService.AnagStatiGetAllAsync();
|
||||
var currStato = anagStati.FirstOrDefault(x => x.IdxStato == currRec.IdxStato);
|
||||
// calcolo SE sia idle... OVVERO SEMAFORO NON VERDE!!!
|
||||
if (currStato != null && currStato.Semaforo != "sVe")
|
||||
{
|
||||
// calcolo durata...
|
||||
answ = (int)(currRec.Durata ?? 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog($"Eccezione in recupero getIdlePeriod{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
||||
Log.Error($"Errore in GetIdlePeriod{Environment.NewLine}{exc}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "NO");
|
||||
}
|
||||
return answ;
|
||||
return Ok(answ);
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupera codice numerico ODL/PODL dato CodXdl, in pratica la parte finale SENZA ODL/PODL
|
||||
/// Funzione per impianti che accettano solo INT in scrittura:
|
||||
|
||||
Reference in New Issue
Block a user