Exemplo n.º 1
0
        private static LastProcessTime GetDefaultInstance(NotificationFrequency freq, DateTime value)
        {
            var instance = new LastProcessTime();

            SetValue(instance, freq, value);
            return(instance);
        }
Exemplo n.º 2
0
        private static IEnumerable <Subscription> CollectEventsPerSubscription(NotificationFrequency freq, DateTime now)
        {
            var lastTime      = now;
            var subscriptions = Subscription.GetActiveSubscriptionsByFrequency(freq);

            if (subscriptions.Count() == 0)
            {
                return(null);
            }

            var time = LastProcessTime.GetLastProcessTime(freq);

            using (var context = new DataHandler())
            {
                var events = (time == DateTime.MinValue) ?
                             context.Events.Where(x => x.When <= lastTime) :
                             context.Events.Where(x => x.When > time && x.When <= lastTime);
                foreach (var @event in events.OrderBy(x => x.When))
                {
                    foreach (var subscription in subscriptions.Where(subscription => IsRelatedPath(@event.ContentPath, subscription.ContentPath) && HasPermission(subscription, @event)))
                    {
                        subscription.AddRelatedEvent(@event);
                    }
                }
            }

            LastProcessTime.SetLastProcessTime(freq, lastTime);

            return(subscriptions);
        }
Exemplo n.º 3
0
        private static DateTime GetValue(LastProcessTime instance, NotificationFrequency freq)
        {
            DateTime?value = null;

            switch (freq)
            {
            case NotificationFrequency.Immediately: value = instance.Immediately; break;

            case NotificationFrequency.Daily: value = instance.Daily; break;

            case NotificationFrequency.Weekly: value = instance.Weekly; break;

            case NotificationFrequency.Monthly: value = instance.Monthly; break;
            }
            return(value.HasValue ? value.Value : DateTime.MinValue);
        }
Exemplo n.º 4
0
        private static void SetValue(LastProcessTime instance, NotificationFrequency freq, DateTime value)
        {
            DateTime?dbValue = null;

            if (value >= ContentRepository.Storage.Data.DataProvider.Current.DateTimeMinValue)
            {
                dbValue = value;
            }
            switch (freq)
            {
            case NotificationFrequency.Immediately: instance.Immediately = dbValue; break;

            case NotificationFrequency.Daily: instance.Daily = dbValue; _nextDaily = null; break;

            case NotificationFrequency.Weekly: instance.Weekly = dbValue; _nextWeekly = null; break;

            case NotificationFrequency.Monthly: instance.Monthly = dbValue; _nextMonthly = null; break;
            }
        }
Exemplo n.º 5
0
        internal static void TimerTick(DateTime now, NotificationFrequency freq)
        {
            switch (freq)
            {
            case NotificationFrequency.Immediately: if (!Configuration.ImmediatelyEnabled)
                {
                    return;
                }
                break;

            case NotificationFrequency.Daily: if (!Configuration.DailyEnabled)
                {
                    return;
                }
                break;

            case NotificationFrequency.Weekly: if (!Configuration.WeeklyEnabled)
                {
                    return;
                }
                break;

            case NotificationFrequency.Monthly: if (!Configuration.MonthlyEnabled)
                {
                    return;
                }
                break;

            default: throw GetUnknownFrequencyException(freq);
            }

            if (now >= LastProcessTime.GetNextTime(freq, now))
            {
                GenerateMessages(freq, now);
            }
        }
Exemplo n.º 6
0
 partial void DeleteLastProcessTime(LastProcessTime instance);
Exemplo n.º 7
0
 partial void UpdateLastProcessTime(LastProcessTime instance);
Exemplo n.º 8
0
 partial void InsertLastProcessTime(LastProcessTime instance);