From ed019497b1e89cd92783bb2200a3798fc8812f0a Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Mon, 22 May 2017 13:00:35 +0200 Subject: [PATCH] modifica IOB x gestione migliore errori in scrittura DB (si spera...) --- MP-IO/Controllers/IOBController.cs | 42 +++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs index 01ffd64e..1c29b88d 100644 --- a/MP-IO/Controllers/IOBController.cs +++ b/MP-IO/Controllers/IOBController.cs @@ -30,13 +30,21 @@ namespace MP_IO.Controllers { int idx = 0; Int32.TryParse(id.ToString(), out idx); - // verifico se sia abilitato INSERT x una data macchina - if (MapoDb.MapoDb.obj.insEnabled(idx)) + try { - answ = "OK"; + // verifico se sia abilitato INSERT x una data macchina + if (MapoDb.MapoDb.obj.insEnabled(idx)) + { + answ = "OK"; + } + else + { + answ = "NO"; + } } - else + catch (Exception exc) { + logger.lg.scriviLog(string.Format("Errore in enabled{0}{1}", Environment.NewLine, exc)); answ = "NO"; } } @@ -55,13 +63,21 @@ namespace MP_IO.Controllers { int idx = 0; Int32.TryParse(id.ToString(), out idx); - // verifico se sia abilitato SignalLog x una data macchina - if (MapoDb.MapoDb.obj.sLogEnabled(idx)) + try { - answ = "OK"; + // verifico se sia abilitato SignalLog x una data macchina + if (MapoDb.MapoDb.obj.sLogEnabled(idx)) + { + answ = "OK"; + } + else + { + answ = "NO"; + } } - else + catch (Exception exc) { + logger.lg.scriviLog(string.Format("Errore in sLog{0}{1}", Environment.NewLine, exc)); answ = "NO"; } } @@ -78,7 +94,15 @@ namespace MP_IO.Controllers { logger.lg.scriviLog(string.Format("Valori letti:{0}idxMacchina: {1}{0}valore: {2}{0}dtEve: {3}{0}dtCurr: {4}{0}cnt: {5}", Environment.NewLine, id, valore, dtEve, dtCurr, cnt), tipoLog.INFO); } - answ = DataLayer.processInput(id, valore, dtEve, dtCurr, cnt); + try + { + answ = DataLayer.processInput(id, valore, dtEve, dtCurr, cnt); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in input{0}{1}", Environment.NewLine, exc)); + answ = "NO"; + } return answ; } }