From 4c23e7c2cdd7386d5fd76937f238e5ae482c7a80 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 24 Mar 2017 08:28:22 +0100 Subject: [PATCH] Aggiunto semafoto in fase di salvataggio persistenceLayer (si spera x evitare corruzione file...) --- MTC_Adapter/MTC_Adapter/AdapterGeneric.cs | 4 ++++ MTC_Adapter/MTC_Adapter/MainForm.cs | 28 +++++++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs index c72908a..cc999d9 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs @@ -523,6 +523,10 @@ namespace MTC_Adapter /// public bool adpRunning = false; /// + /// valore booleano di check se l'adapter STIA SALVANDO + /// + public bool adpSaving = false; + /// /// valore booleano (richiesta di riavvio automatico) /// public bool adpTryRestart; diff --git a/MTC_Adapter/MTC_Adapter/MainForm.cs b/MTC_Adapter/MTC_Adapter/MainForm.cs index 391c466..1c29cf2 100644 --- a/MTC_Adapter/MTC_Adapter/MainForm.cs +++ b/MTC_Adapter/MTC_Adapter/MainForm.cs @@ -1178,21 +1178,29 @@ namespace MTC_Adapter /// public void savePersistLayer(string filePath) { - // se HO dei dati... - if (agObj.persistenceLayer != null) + // in primis check semaforo salvataggio... + if (!agObj.adpSaving) { - try + // alzo semaforo salvataggio + agObj.adpSaving = true; + // se HO dei dati... + if (agObj.persistenceLayer != null) { - utils.WritePlain(agObj.persistenceLayer, filePath); + try + { + utils.WritePlain(agObj.persistenceLayer, filePath); + } + catch (Exception exc) + { + lg.Error(string.Format("Errore salvataggio file{0}{1}", Environment.NewLine, exc)); + } } - catch (Exception exc) + else { - lg.Error(string.Format("Errore salvataggio file{0}{1}", Environment.NewLine, exc)); + lg.Info("persistenceLayer null, non salvato..."); } - } - else - { - lg.Info("persistenceLayer null, non salvato..."); + // abbasso semaforo salvataggio + agObj.adpSaving = false; } } ///