Esempio n. 1
0
        public static void Set(IItem item, PropertyDefinition propertyDefinition, Reminders <T> newReminders)
        {
            Util.ThrowOnNullArgument(item, "item");
            Util.ThrowOnNullArgument(propertyDefinition, "propertyDefinition");
            Util.ThrowOnMismatchType <byte[]>(propertyDefinition, "propertyDefinition");
            ExTraceGlobals.RemindersTracer.TraceDebug <StoreObjectId, PropertyDefinition>(0L, "Reminders.Set - item={0}, propertyDefinition={1}", item.StoreObjectId, propertyDefinition);
            if (newReminders == null)
            {
                ExTraceGlobals.RemindersTracer.TraceDebug <PropertyDefinition>(0L, "Reminders.Set - Reminder list is null, deleting property={0}", propertyDefinition);
                item.Delete(propertyDefinition);
                return;
            }
            Reminders <T> .UpdateReminderIdentifiers(newReminders);

            ExTraceGlobals.RemindersTracer.TraceDebug <int>(0L, "Reminders.Set - Serializing reminders, count={0}", newReminders.ReminderList.Count);
            using (Stream stream = item.OpenPropertyStream(propertyDefinition, PropertyOpenMode.Create))
            {
                if (newReminders.ReminderList.Count > 0)
                {
                    IReminder reminder = newReminders.ReminderList[0];
                    newReminders.Version = reminder.GetCurrentVersion();
                }
                using (XmlWriter xmlWriter = XmlWriter.Create(stream))
                {
                    DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(Reminders <T>));
                    dataContractSerializer.WriteObject(xmlWriter, newReminders);
                }
            }
        }
Esempio n. 2
0
        public static Reminders <T> Get(IItem item, PropertyDefinition propertyDefinition)
        {
            Util.ThrowOnNullArgument(item, "item");
            Util.ThrowOnNullArgument(propertyDefinition, "propertyDefinition");
            ExTraceGlobals.RemindersTracer.TraceDebug <StoreObjectId, PropertyDefinition>(0L, "Reminders.Get - item={0}, propertyDefinition={1}", item.StoreObjectId, propertyDefinition);
            Reminders <T> result;

            try
            {
                using (Stream stream = item.OpenPropertyStream(propertyDefinition, PropertyOpenMode.ReadOnly))
                {
                    DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(Reminders <T>));
                    result = (Reminders <T>)dataContractSerializer.ReadObject(stream);
                }
            }
            catch (ObjectNotFoundException arg)
            {
                ExTraceGlobals.RemindersTracer.TraceError <ObjectNotFoundException>(0L, "Reminders.Get - object not found, exception={0}", arg);
                result = null;
            }
            catch (Exception ex)
            {
                ExTraceGlobals.RemindersTracer.TraceError <Exception>(0L, "Reminders.Get - exception={0}", ex);
                if (!Reminders <T> .IsCorruptDataException(ex))
                {
                    throw;
                }
                result = new Reminders <T>();
            }
            return(result);
        }
Esempio n. 3
0
 public static EventTimeBasedInboxReminder GetSeriesReminder(Reminders <EventTimeBasedInboxReminder> reminders, Guid reminderId)
 {
     foreach (EventTimeBasedInboxReminder eventTimeBasedInboxReminder in reminders.ReminderList)
     {
         Guid a = eventTimeBasedInboxReminder.IsFormerSeriesReminder ? eventTimeBasedInboxReminder.SeriesReminderId : eventTimeBasedInboxReminder.Identifier;
         if (a == reminderId)
         {
             return(eventTimeBasedInboxReminder);
         }
     }
     return(null);
 }
Esempio n. 4
0
 public static void UpdateIdentifiersForModifiedReminders(Reminders <EventTimeBasedInboxReminder> reminders)
 {
     if (reminders != null)
     {
         foreach (EventTimeBasedInboxReminder eventTimeBasedInboxReminder in reminders.ReminderList)
         {
             if (eventTimeBasedInboxReminder.IsFormerSeriesReminder && eventTimeBasedInboxReminder.SeriesReminderId == Guid.Empty)
             {
                 eventTimeBasedInboxReminder.SeriesReminderId = eventTimeBasedInboxReminder.Identifier;
                 eventTimeBasedInboxReminder.Identifier       = Guid.NewGuid();
             }
         }
     }
 }
Esempio n. 5
0
        internal static void UpdateReminderIdentifiers(Reminders <T> newReminders)
        {
            ExTraceGlobals.RemindersTracer.TraceDebug(0L, "Reminders.UpdateReminderIdentifiers");
            List <T> list = newReminders.ReminderList;

            Util.ThrowOnNullArgument(list, "newReminderList");
            ExTraceGlobals.RemindersTracer.TraceDebug <int>(0L, "Reminders.UpdateReminderIdentifiers - newReminders count={0}", list.Count);
            foreach (T t in list)
            {
                if (t.Identifier == Guid.Empty)
                {
                    ExTraceGlobals.RemindersTracer.TraceDebug(0L, "Generating new reminder identifier");
                    t.Identifier = Guid.NewGuid();
                }
            }
        }
Esempio n. 6
0
 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);
     }
 }
Esempio n. 7
0
        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 override void UpdateEventTimeBasedInboxRemindersForSave(Reminders <EventTimeBasedInboxReminder> reminders)
        {
            if (reminders == null)
            {
                return;
            }
            List <EventTimeBasedInboxReminder> list = new List <EventTimeBasedInboxReminder>();

            foreach (EventTimeBasedInboxReminder eventTimeBasedInboxReminder in reminders.ReminderList)
            {
                if (eventTimeBasedInboxReminder.OccurrenceChange == EmailReminderChangeType.None)
                {
                    list.Add(eventTimeBasedInboxReminder);
                }
            }
            foreach (EventTimeBasedInboxReminder item in list)
            {
                reminders.ReminderList.Remove(item);
            }
            EventTimeBasedInboxReminder.UpdateIdentifiersForModifiedReminders(reminders);
        }
        protected override Reminders <EventTimeBasedInboxReminder> FetchEventTimeBasedInboxReminders()
        {
            Reminders <EventTimeBasedInboxReminder> reminders = Reminders <EventTimeBasedInboxReminder> .Get(this, CalendarItemBaseSchema.EventTimeBasedInboxReminders);

            if (this.IsException)
            {
                Reminders <EventTimeBasedInboxReminder> reminders2 = Reminders <EventTimeBasedInboxReminder> .Get(this.OccurrencePropertyBag.MasterCalendarItem, CalendarItemBaseSchema.EventTimeBasedInboxReminders);

                if (reminders2 == null)
                {
                    return(reminders);
                }
                if (reminders == null)
                {
                    return(reminders2);
                }
                List <EventTimeBasedInboxReminder> list = new List <EventTimeBasedInboxReminder>();
                foreach (EventTimeBasedInboxReminder eventTimeBasedInboxReminder in reminders.ReminderList)
                {
                    if (eventTimeBasedInboxReminder.OccurrenceChange == EmailReminderChangeType.Deleted && reminders2.GetReminder(eventTimeBasedInboxReminder.SeriesReminderId) == null)
                    {
                        list.Add(eventTimeBasedInboxReminder);
                    }
                }
                foreach (EventTimeBasedInboxReminder item in list)
                {
                    reminders.ReminderList.Remove(item);
                }
                foreach (EventTimeBasedInboxReminder eventTimeBasedInboxReminder2 in reminders2.ReminderList)
                {
                    if (EventTimeBasedInboxReminder.GetSeriesReminder(reminders, eventTimeBasedInboxReminder2.Identifier) == null)
                    {
                        reminders.ReminderList.Add(eventTimeBasedInboxReminder2);
                    }
                }
            }
            return(reminders);
        }