mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
Added GetScheduledEventGroup Method
added logic to enable/disable events
This commit is contained in:
@@ -1,12 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.Scheduler;
|
using Crestron.SimplSharp.Scheduler;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Fusion;
|
|
||||||
using PepperDash.Essentials.Room.Config;
|
using PepperDash.Essentials.Room.Config;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -16,7 +13,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Scheduler
|
public static class Scheduler
|
||||||
{
|
{
|
||||||
private static Dictionary<string, ScheduledEventGroup> EventGroups = new Dictionary<string,ScheduledEventGroup>();
|
private static readonly Dictionary<string, ScheduledEventGroup> EventGroups = new Dictionary<string,ScheduledEventGroup>();
|
||||||
|
|
||||||
static Scheduler()
|
static Scheduler()
|
||||||
{
|
{
|
||||||
@@ -51,7 +48,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds the event group to the global list
|
/// Adds the event group to the global list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static void AddEventGroup(ScheduledEventGroup eventGroup)
|
public static void AddEventGroup(ScheduledEventGroup eventGroup)
|
||||||
{
|
{
|
||||||
@@ -69,6 +65,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
if(!EventGroups.ContainsKey(eventGroup.Name))
|
if(!EventGroups.ContainsKey(eventGroup.Name))
|
||||||
EventGroups.Remove(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
|
public static class SchedulerUtilities
|
||||||
@@ -161,6 +164,15 @@ namespace PepperDash.Essentials.Core
|
|||||||
Persistent = config.Persistent
|
Persistent = config.Persistent
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (config.Enable)
|
||||||
|
{
|
||||||
|
scheduledEvent.Resume();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scheduledEvent.Pause();
|
||||||
|
}
|
||||||
|
|
||||||
scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday);
|
scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday);
|
||||||
|
|
||||||
scheduledEvent.Recurrence.Weekly(config.Days);
|
scheduledEvent.Recurrence.Weekly(config.Days);
|
||||||
|
|||||||
Reference in New Issue
Block a user