From ae9b9a27a315c2d2e5790ebd25721a0078f96d37 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Mon, 18 Sep 2017 18:33:44 +0200 Subject: [PATCH] Make ServiceSuspended part of the status class. --- AutoTx/AutoTx.cs | 8 ++++---- AutoTx/SystemChecks.cs | 5 ----- AutoTx/XmlConfiguration.cs | 10 ++++++++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs index 1ce2303..2a79234 100644 --- a/AutoTx/AutoTx.cs +++ b/AutoTx/AutoTx.cs @@ -418,7 +418,7 @@ namespace AutoTx // all parameters within valid ranges, so set the state to "Running": if (string.IsNullOrEmpty(limitReason)) { - _serviceSuspended = false; + _status.ServiceSuspended = false; if (!string.IsNullOrEmpty(_status.LimitReason)) { _status.LimitReason = ""; // reset to force a message on next service suspend writeLog("Service resuming operation (all parameters in valid ranges)."); @@ -428,7 +428,7 @@ namespace AutoTx // set state to "Running" if no-one is logged on: if (NoUserIsLoggedOn()) { - _serviceSuspended = false; + _status.ServiceSuspended = false; if (!string.IsNullOrEmpty(_status.LimitReason)) { _status.LimitReason = ""; // reset to force a message on next service suspend writeLog("Service resuming operation (no user logged on)."); @@ -437,7 +437,7 @@ namespace AutoTx } // by reaching this point we know the service should be suspended: - _serviceSuspended = true; + _status.ServiceSuspended = true; if (limitReason == _status.LimitReason) return; writeLog("Service suspended due to limitiations [" + limitReason + "]."); @@ -458,7 +458,7 @@ namespace AutoTx CreateIncomingDirectories(); // tasks depending on the service state: - if (_serviceSuspended) { + if (_status.ServiceSuspended) { // make sure to pause any running transfer: PauseTransfer(); } else { diff --git a/AutoTx/SystemChecks.cs b/AutoTx/SystemChecks.cs index 0dca881..6898c00 100644 --- a/AutoTx/SystemChecks.cs +++ b/AutoTx/SystemChecks.cs @@ -7,11 +7,6 @@ namespace AutoTx { public partial class AutoTx { - #region global variables - - private bool _serviceSuspended; // TODO: this should be part of _status! - - #endregion /// <summary> /// Get the available physical memory in MB. diff --git a/AutoTx/XmlConfiguration.cs b/AutoTx/XmlConfiguration.cs index dbaf200..7fce8b0 100644 --- a/AutoTx/XmlConfiguration.cs +++ b/AutoTx/XmlConfiguration.cs @@ -127,6 +127,7 @@ namespace AutoTx string _currentTargetTmp; bool _filecopyFinished; + private bool _serviceSuspended; private bool _cleanShutdown; private long _currentTransferSize; @@ -182,6 +183,15 @@ namespace AutoTx } } + public bool ServiceSuspended { + get { return _serviceSuspended; } + set { + _serviceSuspended = value; + log("ServiceSuspended was updated (" + value + "), calling Serialize()..."); + Serialize(); + } + } + public bool FilecopyFinished { get { return _filecopyFinished; } set { -- GitLab