Update x fluxLog da SoiTaab
This commit is contained in:
@@ -117,6 +117,11 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dati fluxLog serializzati in REDIS di reference durante run (precedenti)
|
||||
/// </summary>
|
||||
protected List<GenLogRow> fluxLogDataRef { get; set; } = new List<GenLogRow>();
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Properties
|
||||
@@ -554,60 +559,37 @@ namespace IOB_WIN_NEXT
|
||||
private bool processFluxLogTable(DateTime adesso)
|
||||
{
|
||||
bool fatto = false;
|
||||
string tabNameIn = "FluxLog";
|
||||
string tabNameOut = "FluxLogToMes";
|
||||
// cerco info sui SignLog (ToMes e letti)
|
||||
var currFluxLogRead = elencoSyncState.FirstOrDefault(x => x.TableName == tabNameIn);
|
||||
// se nullo inizializzo
|
||||
if (currFluxLogRead == null)
|
||||
bool doSend = false;
|
||||
// leggo eventuali dati di fluxlog ed invio...
|
||||
if (fluxLogData != null && fluxLogData.Count>0)
|
||||
{
|
||||
currFluxLogRead = new SyncStateModel()
|
||||
// confronto ultimo record dei prev se corrispondono x saltare...
|
||||
if(fluxLogDataRef!=null && fluxLogDataRef.Count>0)
|
||||
{
|
||||
LastIdx = 0,
|
||||
LastUpdate = adesso,
|
||||
TableName = tabNameIn,
|
||||
Note = "Init"
|
||||
};
|
||||
}
|
||||
var currFluxLogSent = elencoSyncState.FirstOrDefault(x => x.TableName == tabNameOut);
|
||||
// se nullo inizializzo
|
||||
if (currFluxLogSent == null)
|
||||
{
|
||||
currFluxLogSent = new SyncStateModel()
|
||||
doSend = (!fluxLogDataRef.LastOrDefault().Equals(fluxLogData.LastOrDefault()));
|
||||
}
|
||||
else
|
||||
{
|
||||
LastIdx = 0,
|
||||
LastUpdate = adesso,
|
||||
TableName = tabNameOut,
|
||||
Note = "Init"
|
||||
};
|
||||
}
|
||||
// verifica se ci siano dati da trasmettere (sui valori LastIdx)
|
||||
if (currFluxLogRead.LastIdx > currFluxLogSent.LastIdx)
|
||||
{
|
||||
// recupero i dati dal DB...
|
||||
var data2send = dbProxy.MachFluxLogGetNew(currFluxLogSent.LastIdx);
|
||||
// se ho dati preparo invio
|
||||
if (data2send != null && data2send.Count > 0)
|
||||
doSend = true;
|
||||
}
|
||||
// controllo se devo inviare
|
||||
if (doSend)
|
||||
{
|
||||
string sVal = "";
|
||||
foreach (var fLog2send in data2send)
|
||||
foreach (var fLog2send in fluxLogData)
|
||||
{
|
||||
sVal = $"[DYNDATA] |{fLog2send.DtEvento:yyyy-MM-dd HH:mm:ss}|{fLog2send.CodFlux}|{fLog2send.Valore}";
|
||||
var kvpFlux = fLog2send.valString.Split(";");
|
||||
sVal = $"[DYNDATA] |{fLog2send.dtRif:yyyy-MM-dd HH:mm:ss}|{kvpFlux[0]}|{kvpFlux[1]}";
|
||||
// chiamo accodamento con dataora corretta...
|
||||
accodaFLog(sVal, qEncodeFLog(fLog2send.DtEvento, fLog2send.CodFlux, fLog2send.Valore));
|
||||
}
|
||||
fatto = true;
|
||||
|
||||
// salvo info...
|
||||
fluxLogDataRef = fluxLogData;
|
||||
}
|
||||
|
||||
// aggiorno idx inviato...
|
||||
currFluxLogSent.Note = $"Updated from {currFluxLogRead.LastIdx}";
|
||||
currFluxLogSent.LastUpdate = adesso;
|
||||
currFluxLogSent.LastIdx = currFluxLogRead.LastIdx;
|
||||
}
|
||||
|
||||
// alla fine aggiorno i dati inviati!
|
||||
dbProxy.SyncStateUpsert(currFluxLogSent);
|
||||
|
||||
return fatto;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user