public void UpdateScheduleTasks(NotificationsPart notification)
        {
            var schedulingPart = notification.As <SchedulingPart>();

            // TODO: this can (should) never happen, throw error?
            if (schedulingPart == null || !schedulingPart.StartDateTime.HasValue)
            {
                return;
            }

            // Remove existing schedules
            DeleteExistingScheduleTasks(schedulingPart.ContentItem);

            // Event started task
            _scheduledTaskManager.CreateTask(Constants.EventStartedName, schedulingPart.StartDateTime.Value, schedulingPart.ContentItem);

            // Event ended task
            if (schedulingPart.EndDateTime.HasValue)
            {
                _scheduledTaskManager.CreateTask(Constants.EventEndedName, schedulingPart.EndDateTime.Value, schedulingPart.ContentItem);
            }
            else if (schedulingPart.IsAllDay)
            {
                // If event is all day, end time is start time + 1 day
                var endTime = schedulingPart.StartDateTime.Value.Date.AddDays(1);
                _scheduledTaskManager.CreateTask(Constants.EventEndedName, endTime, schedulingPart.ContentItem);
            }

            // TODO: schedule upcoming and followup
        }
        public bool CanSubscribeForNotifications(NotificationsPart part)
        {
            // Not enabled for this content item
            if (!part.AllowNotifications)
            {
                return(false);
            }

            // Not authorized
            if (!_authorizer.Authorize(Permissions.NotificationsPermissions.SubscribeForNotifications, part.ContentItem))
            {
                return(false);
            }

            var contentItem    = part.ContentItem;
            var schedulingPart = contentItem.As <SchedulingPart>();

            if (schedulingPart == null)
            {
                return(false);
            }

            // Cannot subscribe to events in the past when it is not recurring
            if (schedulingPart.StartDateTime < _clock.UtcNow && !schedulingPart.IsRecurring)
            {
                return(false);
            }

            return(true);
        }
        public void UpdateScheduleTasks(NotificationsPart notification) {
            var schedulingPart = notification.As<SchedulingPart>();

            // TODO: this can (should) never happen, throw error?
            if (schedulingPart == null || !schedulingPart.StartDateTime.HasValue)
                return;

            // Remove existing schedules
            DeleteExistingScheduleTasks(schedulingPart.ContentItem);

            // Event started task
            _scheduledTaskManager.CreateTask(Constants.EventStartedName, schedulingPart.StartDateTime.Value, schedulingPart.ContentItem);

            // Event ended task
            if (schedulingPart.EndDateTime.HasValue) {
                _scheduledTaskManager.CreateTask(Constants.EventEndedName, schedulingPart.EndDateTime.Value, schedulingPart.ContentItem);
            }
            else if (schedulingPart.IsAllDay) {
                // If event is all day, end time is start time + 1 day
                var endTime = schedulingPart.StartDateTime.Value.Date.AddDays(1);
                _scheduledTaskManager.CreateTask(Constants.EventEndedName, endTime, schedulingPart.ContentItem);
            }

            // TODO: schedule upcoming and followup
        }
        public bool CanSubscribeForNotifications(NotificationsPart part) {

            // Not enabled for this content item
            if (!part.AllowNotifications)
                return false;

            // Not authorized
            if (!_authorizer.Authorize(Permissions.NotificationsPermissions.SubscribeForNotifications, part.ContentItem))
                return false;

            var contentItem = part.ContentItem;
            var schedulingPart = contentItem.As<SchedulingPart>();

            if (schedulingPart == null)
                return false;

            // Cannot subscribe to events in the past when it is not recurring
            if (schedulingPart.StartDateTime < _clock.UtcNow && !schedulingPart.IsRecurring)
                return false;

            return true;
        }
Beispiel #5
0
 private void LazyLoadHandlers(ActivatedContentContext context, NotificationsPart part)
 {
     part._contentItem.Loader(() => part.NotificationsPlanPartRecord == null ? null : _contentManager.Get <NotificationsPlanPart>(part.NotificationsPlanPartRecord.Id));
 }
 private void LazyLoadHandlers(ActivatedContentContext context, NotificationsPart part) {
     part._contentItem.Loader(() => part.NotificationsPlanPartRecord == null ? null : _contentManager.Get<NotificationsPlanPart>(part.NotificationsPlanPartRecord.Id));
 }