diff ServerMonitor/Objects/Schedule.cs @ 32:2342e9459444

Fix schedule times not being saved.
author Brad Greco <brad@bgreco.net>
date Sun, 16 Jun 2019 16:55:14 -0400
parents 68d7834dc28e
children 7645122aa7a9
line wrap: on
line diff
--- a/ServerMonitor/Objects/Schedule.cs	Sun Jun 16 16:54:46 2019 -0400
+++ b/ServerMonitor/Objects/Schedule.cs	Sun Jun 16 16:55:14 2019 -0400
@@ -1,4 +1,6 @@
 using System;
+using System.ComponentModel;
+using System.Xml.Serialization;
 
 namespace ServerMonitorApp
 {
@@ -33,11 +35,29 @@
         public FrequencyUnits Units { get; set; }
 
         /// <summary>Time of day the check should begin running.</summary>
+        [XmlIgnore]
         public TimeSpan StartTime { get; set; }
 
         /// <summary>Time of day the check should stop running.</summary>
+        [XmlIgnore]
         public TimeSpan EndTime { get; set; }
 
+        /// <summary>Property to serialize StartTime since serializing a TimeSpan does not work by default.</summary>
+        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+        public long StartTimeTicks
+        {
+            get { return StartTime.Ticks; }
+            set { StartTime = new TimeSpan(value); }
+        }
+
+        /// <summary>Property to serialize EndTime since serializing a TimeSpan does not work by default.</summary>
+        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+        public long EndTimeTicks
+        {
+            get { return EndTime.Ticks; }
+            set { EndTime = new TimeSpan(value); }
+        }
+
         /// <summary>Given the last time a check was scheduled to run, calculates the next time in the future it should run.</summary>
         /// <param name="lastScheduledTime">The last time a check was scheduled to run.</param>
         public DateTime GetNextTime(DateTime lastScheduledTime)