From 7a029302cece2f24a392f5d80617a5aefce2a915 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 13 Sep 2017 17:53:31 +0200 Subject: [PATCH] Modifica x gestione corretta CON SIGLETON o meno delel letture da DB --- MapoDb/DataLayer.cs | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs index 81e774da..34c02c89 100644 --- a/MapoDb/DataLayer.cs +++ b/MapoDb/DataLayer.cs @@ -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 answ = new Dictionary(); - 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[] 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[] answ = new KeyValuePair[tabSMI.Count]; // salvo tutti i valori StateMachineIngressi... int i = 0;