From d2b7e71c4adb254b8ff406d03c9e52b3e874a1d8 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 7 Dec 2020 11:49:30 -0700 Subject: [PATCH] Added GetScheduledEventGroup Method added logic to enable/disable events --- .../Global/Scheduler.cs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs index 85832cba..64ba57df 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs @@ -1,12 +1,9 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharp.Scheduler; using PepperDash.Core; -using PepperDash.Essentials.Core.Fusion; using PepperDash.Essentials.Room.Config; namespace PepperDash.Essentials.Core @@ -16,7 +13,7 @@ namespace PepperDash.Essentials.Core /// public static class Scheduler { - private static Dictionary EventGroups = new Dictionary(); + private static readonly Dictionary EventGroups = new Dictionary(); static Scheduler() { @@ -51,7 +48,6 @@ namespace PepperDash.Essentials.Core /// /// Adds the event group to the global list /// - /// /// public static void AddEventGroup(ScheduledEventGroup eventGroup) { @@ -69,6 +65,13 @@ namespace PepperDash.Essentials.Core if(!EventGroups.ContainsKey(eventGroup.Name)) EventGroups.Remove(eventGroup.Name); } + + public static ScheduledEventGroup GetEventGroup(string key) + { + ScheduledEventGroup returnValue; + + return EventGroups.TryGetValue(key, out returnValue) ? returnValue : null; + } } public static class SchedulerUtilities @@ -161,6 +164,15 @@ namespace PepperDash.Essentials.Core Persistent = config.Persistent }; + if (config.Enable) + { + scheduledEvent.Resume(); + } + else + { + scheduledEvent.Pause(); + } + scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday); scheduledEvent.Recurrence.Weekly(config.Days);