Exemplo n.º 1
0
        /// <summary>
        /// Adds the Enable event to the local event group and sets its properties based on config
        /// </summary>
        void AddEnableEventToGroup()
        {
            if (!FeatureEventGroup.ScheduledEvents.ContainsKey(FeatureEnableEventName))
            {
                CreateEvent(FeatureEnableEvent, FeatureEnableEventName);
            }
            else
            {
                // Check if existing event has same time and recurrence as config values

                FeatureEnableEvent = FeatureEventGroup.ScheduledEvents[FeatureEnableEventName];
                Debug.Console(1, this, "Enable event already found in group");

                // Check config times and days against DateAndTime of existing event.  If different, delete existing event and create new event
                if (!CheckExistingEventTimeForMatch(FeatureEnableEvent, FeatureEnabledTime) || !CheckExistingEventRecurrenceForMatch(FeatureEnableEvent, CalculateDaysOfWeekRecurrence()))
                {
                    Debug.Console(1, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureEnableEvent.Name);
                    FeatureEventGroup.DeleteEvent(FeatureEnableEvent);

                    FeatureEnableEvent = null;

                    CreateEvent(FeatureEnableEvent, FeatureEnableEventName);
                }
            }
        }