Exemplo n.º 1
0
        private static void SyncMilestoneToOutlook(Milestone milestone, AppointmentItem appointment)
        {
            bool modified = false;

            if ((appointment.Start.Date != milestone.GetStartDate().Date) || (appointment.End.Date != milestone.GetEndDate().Date))
            {
                appointment.Start = milestone.GetStartDate();
                appointment.End   = milestone.GetEndDate();
                modified          = true;
            }

            String milestoneName = getMilestoneAppointmentName(milestone);

            if (!milestoneName.Equals(appointment.Subject))
            {
                appointment.Subject = milestoneName;
                modified            = true;
            }

            MilestoneDataContainer notificationData = getMilestoneData(milestone);

            if (notificationData.ReminderMinutesBeforeStart == 0 && appointment.ReminderSet)
            {
                appointment.ReminderSet = false;
                modified = true;
            }
            if (notificationData.ReminderMinutesBeforeStart != appointment.ReminderMinutesBeforeStart)
            {
                appointment.ReminderSet = true;
                appointment.ReminderMinutesBeforeStart = notificationData.ReminderMinutesBeforeStart;
                modified = true;
            }

            if (!String.IsNullOrEmpty(notificationData.Category) &&
                (appointment.Categories == null || !appointment.Categories.Contains(notificationData.Category)))
            {
                appointment.Categories = appointment.Categories + notificationData.Category;
                modified = true;
            }

            if (modified)
            {
                appointment.Save();
            }
        }