Modifica x gestione corretta CON SIGLETON o meno delel letture da DB

This commit is contained in:
Samuele E. Locatelli
2017-09-13 17:53:31 +02:00
parent c696bd72be
commit 7a029302ce
+37 -5
View File
@@ -467,7 +467,7 @@ namespace MapoDb
// ora processo e salvo il valore del microstato... INTERNAMENTE gestisce i casi DB/REDIS secondo necessità
connDb.checkMicroStato(idxMacchina, valore, dataOraEvento, contatore);
// registro in risposta che è andato tutto bene...
answ = "OK";
answ = "OK";
}
catch (Exception exc)
{
@@ -593,7 +593,18 @@ namespace MapoDb
// inizio con un bel reset...
memLayer.ML.redFlushKey(currHash);
Dictionary<string, string> answ = new Dictionary<string, string>();
DS_applicazione.MSFDDataTable tabMSFD = MapoDb.obj.taMSFD.getByIdxMacc(idxMacchina.ToString());
DS_applicazione.MSFDDataTable tabMSFD = new DS_applicazione.MSFDDataTable();
// 2017.09.13: inserisco gestione singleton condizionale
if (memLayer.ML.CRB("disable_singleton"))
{
// instanzio un nuovo oggetto MapoDb
MapoDb connDb = new MapoDb();
tabMSFD = connDb.taMSFD.getByIdxMacc(idxMacchina.ToString());
}
else
{
tabMSFD = MapoDb.obj.taMSFD.getByIdxMacc(idxMacchina.ToString());
}
try
{
DS_applicazione.MSFDRow rigaMSFD = tabMSFD[0];
@@ -649,7 +660,17 @@ namespace MapoDb
// ...oppure dritto su DB
else
{
answ = MapoDb.obj.insEnabled(idxMacchina);
if (memLayer.ML.CRB("disable_singleton"))
{
// instanzio un nuovo oggetto MapoDb
MapoDb connDb = new MapoDb();
answ = connDb.insEnabled(idxMacchina);
}
else
{
// leggo DB da singleton
answ = MapoDb.obj.insEnabled(idxMacchina);
}
}
return answ;
}
@@ -722,8 +743,19 @@ namespace MapoDb
public static KeyValuePair<string, string>[] resetSMI(int idxFamIn)
{
string currHash = hSMI(idxFamIn);
// leggo DB
DS_applicazione.TransizioneIngressiDataTable tabSMI = MapoDb.obj.taTransIngr.getByIdxFamIng(idxFamIn);
DS_applicazione.TransizioneIngressiDataTable tabSMI = new DS_applicazione.TransizioneIngressiDataTable();
// 2017.09.13: inserisco gestione singleton condizionale
if (memLayer.ML.CRB("disable_singleton"))
{
// instanzio un nuovo oggetto MapoDb
MapoDb connDb = new MapoDb();
tabSMI = connDb.taTransIngr.getByIdxFamIng(idxFamIn);
}
else
{
// leggo DB da singleton
tabSMI = MapoDb.obj.taTransIngr.getByIdxFamIng(idxFamIn);
}
KeyValuePair<string, string>[] answ = new KeyValuePair<string, string>[tabSMI.Count];
// salvo tutti i valori StateMachineIngressi...
int i = 0;