From b8baa9f868d584acb1be067b4810157a7bd2d0d2 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Tue, 12 Sep 2017 14:50:50 +0200 Subject: [PATCH] =?UTF-8?q?spostato=20da=20IOB=20a=20datalayer=20controllo?= =?UTF-8?q?=20SE=20modalit=C3=A0=20DB/Redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MP-IO/Controllers/IOBController.cs | 27 ++-------------------- MapoDb/DataLayer.cs | 36 +++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 35 deletions(-) diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs index 7a4a71b7..00a9ecb8 100644 --- a/MP-IO/Controllers/IOBController.cs +++ b/MP-IO/Controllers/IOBController.cs @@ -29,19 +29,8 @@ namespace MP_IO.Controllers try { - bool isEnabled = false; - // verifico se sia abilitato INSERT x una data macchina... con REDIS se abilitato - if (memLayer.ML.CRB("IOB_RedEnab")) - { - isEnabled = DataLayer.insEnab(idx); - } - // ...oppure dritto su DB - else - { - isEnabled = MapoDb.MapoDb.obj.insEnabled(idx); - } // salvo risposta! - answ = isEnabled ? "OK" : "NO"; + answ = DataLayer.insEnab(idx) ? "OK" : "NO"; } catch (Exception exc) { @@ -66,19 +55,7 @@ namespace MP_IO.Controllers Int32.TryParse(id.ToString(), out idx); try { - bool isEnabled = false; - // verifico se sia abilitato SignalLog x una data macchina... con REDIS se abilitato - if (memLayer.ML.CRB("IOB_RedEnab")) - { - isEnabled = DataLayer.sLogEnab(idx); - } - // ...oppure dritto su DB - else - { - isEnabled = MapoDb.MapoDb.obj.sLogEnabled(idx); - } - // salvo risposta! - answ = isEnabled ? "OK" : "NO"; + answ = DataLayer.sLogEnab(idx) ? "OK" : "NO"; } catch (Exception exc) { diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs index be83bc4d..7f0bb083 100644 --- a/MapoDb/DataLayer.cs +++ b/MapoDb/DataLayer.cs @@ -555,7 +555,7 @@ namespace MapoDb /// /// /// - public static Dictionary mDatiMacchine(int idxMacchina) + public static Dictionary mDatiMacchine(int idxMacchina) { // hard coded dimensione vettore DatiMacchine Dictionary answ = new Dictionary(); @@ -605,7 +605,7 @@ namespace MapoDb answ.Add("MatrOpr", rigaMSFD.MatrOpr.ToString()); answ.Add("lastVal", rigaMSFD.lastVal); answ.Add("TCBase", rigaMSFD.TempoCicloBase.ToString()); - + //...e SETUP answ.Add("CodMacc", rigaMSFD.codmacchina); answ.Add("IdxFamIn", rigaMSFD.IdxFamigliaIngresso.ToString()); @@ -728,12 +728,20 @@ namespace MapoDb public static bool insEnab(int idxMacchina) { bool answ = false; - try + if (memLayer.ML.CRB("IOB_RedEnab")) { - answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "insEnabled")); + try + { + answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "insEnabled")); + } + catch + { } + } + // ...oppure dritto su DB + else + { + answ = MapoDb.obj.insEnabled(idxMacchina); } - catch - { } return answ; } /// @@ -744,12 +752,20 @@ namespace MapoDb public static bool sLogEnab(int idxMacchina) { bool answ = false; - try + if (memLayer.ML.CRB("IOB_RedEnab")) { - answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "sLogEnabled")); + try + { + answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "sLogEnabled")); + } + catch + { } + } + // ...oppure dritto su DB + else + { + answ = MapoDb.obj.sLogEnabled(idxMacchina); } - catch - { } return answ; }