public static int CalculateReminderMinutesBeforeStart(VAlarm valarm, ExDateTime startTime, ExDateTime endTime) { int result; if (valarm.ValueType == CalendarValueType.Duration) { if (valarm.TriggerRelationship == TriggerRelationship.Start || valarm.TriggerRelationship == TriggerRelationship.None) { result = ((valarm.TimeSpan != TimeSpan.MinValue) ? ((int)valarm.TimeSpan.Negate().TotalMinutes) : 15); } else if (valarm.TriggerRelationship == TriggerRelationship.End) { int num = (int)valarm.TimeSpan.TotalMinutes; ExDateTime dt = endTime.AddMinutes((double)num); result = (int)(startTime - dt).TotalMinutes; } else { result = 15; } } else { result = (int)(startTime - valarm.ExDateTime).TotalMinutes; } return(result); }
public static void PromoteEmailReminders(Item item, List <VAlarm> emailVAlarms, ExDateTime startTime, ExDateTime endTime, bool isOccurrence) { if (item != null && emailVAlarms != null && emailVAlarms.Count > 0) { Reminders <EventTimeBasedInboxReminder> reminders = new Reminders <EventTimeBasedInboxReminder>(); foreach (VAlarm valarm in emailVAlarms) { int reminderOffset = VAlarm.CalculateReminderMinutesBeforeStart(valarm, startTime, endTime); EventTimeBasedInboxReminder eventTimeBasedInboxReminder = new EventTimeBasedInboxReminder(); eventTimeBasedInboxReminder.CustomMessage = valarm.Message; eventTimeBasedInboxReminder.ReminderOffset = reminderOffset; eventTimeBasedInboxReminder.OccurrenceChange = (isOccurrence ? EmailReminderChangeType.Added : EmailReminderChangeType.None); reminders.ReminderList.Add(eventTimeBasedInboxReminder); } Reminders <EventTimeBasedInboxReminder> .Set(item, InternalSchema.EventTimeBasedInboxReminders, reminders); } }
protected void DemoteEmailReminders() { if (base.Context.Method != CalendarMethod.Request && base.Context.Method != CalendarMethod.Publish) { return; } Reminders <EventTimeBasedInboxReminder> reminders = Reminders <EventTimeBasedInboxReminder> .Get(this.item, InternalSchema.EventTimeBasedInboxReminders); if (reminders != null) { foreach (EventTimeBasedInboxReminder eventTimeBasedInboxReminder in reminders.ReminderList) { TimeSpan minutes = TimeSpan.FromMinutes((double)eventTimeBasedInboxReminder.ReminderOffset).Negate(); VAlarm.Demote(base.OutboundContext.Writer, minutes, eventTimeBasedInboxReminder.CustomMessage, this.item.Session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()); } } }
protected void DemoteReminder() { if (base.Context.Method != CalendarMethod.Request && base.Context.Method != CalendarMethod.Publish) { return; } if (!this.item.GetValueOrDefault <bool>(InternalSchema.ReminderIsSetInternal)) { return; } int?valueAsNullable = this.item.GetValueAsNullable <int>(InternalSchema.ReminderMinutesBeforeStartInternal); if (valueAsNullable == null) { return; } valueAsNullable = new int?(Reminder.NormalizeMinutesBeforeStart(valueAsNullable.Value, 15)); TimeSpan minutes = ((double)valueAsNullable.Value != TimeSpan.MinValue.TotalMinutes) ? TimeSpan.FromMinutes((double)valueAsNullable.Value).Negate() : TimeSpan.FromMinutes(-15.0); VAlarm.Demote(base.OutboundContext.Writer, minutes, "REMINDER", null); }
protected override bool ProcessSubComponent(CalendarComponentBase calendarComponent) { ComponentId componentId = calendarComponent.ComponentId; if (componentId == ComponentId.VAlarm) { VAlarm valarm = (VAlarm)calendarComponent; if (valarm.Action == VAlarmAction.Display) { if (this.displayVAlarm == null) { this.displayVAlarm = valarm; } else { ExTraceGlobals.ICalTracer.TraceDebug((long)this.GetHashCode(), "VItemBase::ProcessSubComponent. Ignoring additional display VALARMs in VItemBase."); } } else if (valarm.Action == VAlarmAction.Email) { if (this.emailVAlarms == null) { this.emailVAlarms = new List <VAlarm>(); } if (this.emailVAlarms.Count < 12) { this.emailVAlarms.Add(valarm); } else { ExTraceGlobals.ICalTracer.TraceDebug <int>((long)this.GetHashCode(), "VItemBase::ProcessSubComponent. Ignoring email VALARM in VItemBase because max limit of {0} is reached.", 12); } } else { ExTraceGlobals.ICalTracer.TraceDebug((long)this.GetHashCode(), "VItemBase::ProcessSubComponent. Ignoring VALARM with unsupported action type in VItemBase."); } } return(true); }
private bool PromoteReminders() { if (base.Context.Method == CalendarMethod.Request || base.Context.Method == CalendarMethod.Publish) { ExDateTime valueOrDefault = base.GetValueOrDefault <ExDateTime>(InternalSchema.DueDate, ExDateTime.MinValue); bool flag = false; if (this.item != null && this.item.Session != null && this.item.Session.IsOlcMoveDestination) { InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(this.item); ExDateTime exDateTime; if (recurrenceFromItem != null) { exDateTime = recurrenceFromItem.EndDate + recurrenceFromItem.EndOffset; } else { exDateTime = valueOrDefault; } flag = (exDateTime.CompareTo(ExDateTime.UtcNow) < 0); } if (this.displayVAlarm != null && this.displayVAlarm.Validate() && !flag && (this.dueTime != null || this.displayVAlarm.ValueType == CalendarValueType.DateTime)) { int num = VAlarm.CalculateReminderMinutesBeforeStart(this.displayVAlarm, valueOrDefault, valueOrDefault); base.SetProperty(InternalSchema.ReminderIsSetInternal, true); base.SetProperty(InternalSchema.ReminderDueBy, valueOrDefault.AddMinutes((double)(-(double)num))); } else { base.SetProperty(InternalSchema.ReminderMinutesBeforeStart, 0); base.SetProperty(InternalSchema.ReminderIsSetInternal, false); } if (!flag) { VAlarm.PromoteEmailReminders(this.item, this.emailVAlarms, valueOrDefault, valueOrDefault, false); } } return(true); }