Aggiunta metodi ulog
This commit is contained in:
@@ -2116,39 +2116,107 @@ namespace MP.IOC.Data
|
||||
string answ = "";
|
||||
DateTime dataOraEvento = GetSrvDtEvent(dtEve, dtCurr);
|
||||
// inizio processing vero e proprio INPUT...
|
||||
if (idxMacchina != null && valore != null)
|
||||
|
||||
if (string.IsNullOrEmpty(idxMacchina) || string.IsNullOrEmpty(valore))
|
||||
{
|
||||
if (idxMacchina != "" && valore != "")
|
||||
{
|
||||
FluxLogModel newRec = new FluxLogModel()
|
||||
{
|
||||
IdxMacchina = idxMacchina,
|
||||
dtEvento = dataOraEvento,
|
||||
CodFlux = flux,
|
||||
Valore = valore,
|
||||
Cnt = contatore
|
||||
};
|
||||
await IocDbController.FluxLogInsertAsync(newRec);
|
||||
// 2022.06.06 salvo su redis il valore ULTIMO del flux x recupero rapido ultimo valore
|
||||
var currKey = Utils.RedKeyLastFLog(idxMacchina, flux, MpIoNS);
|
||||
// 10 min cache max...
|
||||
await redisDb.StringSetAsync(currKey, valore, TimeSpan.FromMinutes(10));
|
||||
// registro in risposta che è andato tutto bene...
|
||||
answ = "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "processFluxLog | Errore: parametri macchina/valore vuoti";
|
||||
Log.Error(errore);
|
||||
answ = errore;
|
||||
}
|
||||
string errore = "processFluxLog | Errore: parametri macchina/valore vuoti";
|
||||
Log.Error(errore);
|
||||
answ = errore;
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "processFluxLog | Errore: mancano parametri macchina/valore";
|
||||
FluxLogModel newRec = new FluxLogModel()
|
||||
{
|
||||
IdxMacchina = idxMacchina,
|
||||
dtEvento = dataOraEvento,
|
||||
CodFlux = flux,
|
||||
Valore = valore,
|
||||
Cnt = contatore
|
||||
};
|
||||
await IocDbController.FluxLogInsertAsync(newRec);
|
||||
// 2022.06.06 salvo su redis il valore ULTIMO del flux x recupero rapido ultimo valore
|
||||
var currKey = Utils.RedKeyLastFLog(idxMacchina, flux, MpIoNS);
|
||||
// 10 min cache max...
|
||||
await redisDb.StringSetAsync(currKey, valore, TimeSpan.FromMinutes(10));
|
||||
// registro in risposta che è andato tutto bene...
|
||||
answ = "OK";
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processa registrazione UserLog da IOB
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina">Macchina</param>
|
||||
/// <param name="flux">Flusso: DI/RC/RC</param>
|
||||
/// <param name="valore">valore = note/valString</param>
|
||||
/// <param name="dtEve">data evento</param>
|
||||
/// <param name="dtCurr">data corrente</param>
|
||||
/// <param name="contatore">contatore invio</param>
|
||||
/// <param name="matrOpr">Matricola Operatore</param>
|
||||
/// <param name="label">label = causale scarto / tagCode</param>
|
||||
/// <param name="valNum">valNum = esitoOk (0/1) / Quantità di scarto associata</param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> ProcessUserLogAsync(string idxMacchina, string flux, string valore, string dtEve, string dtCurr, int contatore, int matrOpr, string label, int valNum)
|
||||
{
|
||||
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
||||
ScriviKeepAlive(idxMacchina, DateTime.Now);
|
||||
// 2017.09.14 trimmo eventualmente lo zero finale dalle date SE supera i millisecondi...
|
||||
dtEve = dtEve.Length > 17 ? dtEve.Substring(0, 17) : dtEve;
|
||||
dtCurr = dtCurr.Length > 17 ? dtCurr.Substring(0, 17) : dtCurr;
|
||||
|
||||
string answ = "";
|
||||
DateTime dataOraEvento = GetSrvDtEvent(dtEve, dtCurr);
|
||||
|
||||
// inizio processing vero e proprio INPUT...
|
||||
if (string.IsNullOrEmpty(idxMacchina) || string.IsNullOrEmpty(flux))
|
||||
{
|
||||
string errore = "processFluxLog | Errore: parametri macchina/flux vuoti";
|
||||
Log.Error(errore);
|
||||
answ = errore;
|
||||
}
|
||||
else
|
||||
{
|
||||
// in base al flusso decido dove e cosa scrivere...
|
||||
switch (flux)
|
||||
{
|
||||
case "DI":
|
||||
RegistroDichiarazioniModel recDich = new RegistroDichiarazioniModel()
|
||||
{
|
||||
IdxMacchina = idxMacchina,
|
||||
DtRec = dataOraEvento,
|
||||
MatrOpr = matrOpr,
|
||||
ValString = valore,
|
||||
TagCode = label
|
||||
};
|
||||
await IocDbController.RegDichiarInsert(recDich);
|
||||
break;
|
||||
|
||||
case "RC":
|
||||
bool esitoOk = valNum != 0;
|
||||
await IocDbController.RegControlliInsert(idxMacchina, matrOpr, esitoOk, valore, dataOraEvento);
|
||||
break;
|
||||
|
||||
case "RS":
|
||||
RegistroScartiModel recSca = new RegistroScartiModel()
|
||||
{
|
||||
IdxMacchina = idxMacchina,
|
||||
DataOra = dataOraEvento,
|
||||
Causale = label,
|
||||
Qta = valNum,
|
||||
Note = valore,
|
||||
MatrOpr = matrOpr
|
||||
};
|
||||
await IocDbController.RegScartiInsert(recSca);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// registro in risposta che è andato tutto bene...
|
||||
answ = "OK";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user