From 063eb30b8f25275c4cf7f08ab7c75d2bb17ae3ea Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Wed, 10 Jan 2018 23:55:28 +0100
Subject: [PATCH] Check for service suspension and report it.

Refers to #2
---
 ATXTray/AutoTxTray.cs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/ATXTray/AutoTxTray.cs b/ATXTray/AutoTxTray.cs
index e76356b..fc0aa08 100644
--- a/ATXTray/AutoTxTray.cs
+++ b/ATXTray/AutoTxTray.cs
@@ -87,6 +87,7 @@ namespace ATXTray
             if (_svcRunning) {
                 serviceRunning = "OK";
                 ReadStatus();
+                UpdateSvcSuspended();
                 if ((DateTime.Now - _status.LastStatusUpdate).TotalSeconds < 60)
                     heartBeat = "OK";
                 if (_status.TransferInProgress)
@@ -155,5 +156,24 @@ namespace ATXTray
                     "Service stopped.", ToolTipIcon.Error);
             }
         }
+
+        private void UpdateSvcSuspended() {
+            if (_svcSuspended == _status.ServiceSuspended)
+                return;
+
+            _statusChanged = true;
+            _svcSuspended = _status.ServiceSuspended;
+            if (_svcSuspended) {
+                _miSvcSuspended.Text = @"Service suspended, reason: " + _status.LimitReason;
+                _miSvcSuspended.BackColor = Color.LightYellow;
+                _notifyIcon.ShowBalloonTip(500, "AutoTx Monitor",
+                    "Service suspended: " + _status.LimitReason, ToolTipIcon.Warning);
+            } else {
+                _miSvcSuspended.Text = @"No limits apply, service active.";
+                _miSvcSuspended.BackColor = Color.LightGreen;
+                _notifyIcon.ShowBalloonTip(500, "AutoTx Monitor",
+                    "Service resumed, no limits apply.", ToolTipIcon.Info);
+            }
+        }
     }
 }
-- 
GitLab