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 = GetTimeLimit(freq); 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) { if (IsRelatedPath(@event.ContentPath, subscription.ContentPath)) { if (HasPermission(subscription, @event)) { subscription.AddRelatedEvent(@event); } } } } } LastProcessTime.SetLastProcessTime(freq, lastTime); return(subscriptions); }
private static LastProcessTime GetDefaultInstance(NotificationFrequency freq, DateTime value) { var instance = new LastProcessTime(); SetValue(instance, freq, value); return(instance); }
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); }
private static void SetValue(LastProcessTime instance, NotificationFrequency freq, DateTime value) { DateTime?dbValue = null; if (value >= SenseNet.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; } }
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); } }
partial void DeleteLastProcessTime(LastProcessTime instance);
partial void UpdateLastProcessTime(LastProcessTime instance);
partial void InsertLastProcessTime(LastProcessTime instance);
partial void DeleteLastProcessTime(LastProcessTime instance);
partial void UpdateLastProcessTime(LastProcessTime instance);
partial void InsertLastProcessTime(LastProcessTime instance);
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; }
private static void SetValue(LastProcessTime instance, NotificationFrequency freq, DateTime value) { DateTime? dbValue = null; if (value >= SenseNet.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; } }
private static LastProcessTime GetDefaultInstance(NotificationFrequency freq, DateTime value) { var instance = new LastProcessTime(); SetValue(instance, freq, value); return instance; }