示例#1
0
        /// <summary>
        /// Merges the with.
        /// </summary>
        /// <param name="outlookCalendarItem">The outlook calendar item.</param>
        /// <param name="googleCalendarItem">The google calendar item.</param>
        /// <returns>True if Changed.</returns>
        public static bool MergeWith(this AppointmentItem outlookCalendarItem, EventEntry googleCalendarItem)
        {
            var result = false;

            result |= outlookCalendarItem.ApplyProperty(c => c.Subject, googleCalendarItem.Title.Text);
            result |= outlookCalendarItem.ApplyProperty(c => c.Body, googleCalendarItem.Content.Content);
            result |= outlookCalendarItem.ApplyProperty(c => c.Location, googleCalendarItem.Locations.FirstOrInstance(l => l.Rel == Where.RelType.EVENT).ValueString);
            result |= outlookCalendarItem.ApplyProperty(c => c.BusyStatus, googleCalendarItem.EventTransparency.GetStatus());
            result |= outlookCalendarItem.ApplyProperty(c => c.Sensitivity, googleCalendarItem.EventVisibility.GetStatus());
            result |= outlookCalendarItem.MergeRecipients(googleCalendarItem.Participants);


            if (googleCalendarItem.Times.Any())
            {
                var time = googleCalendarItem.Times.First();
                result |= outlookCalendarItem.ApplyProperty(c => c.AllDayEvent, time.AllDay);
                result |= outlookCalendarItem.ApplyProperty(c => c.Start, time.StartTime);
                result |= outlookCalendarItem.ApplyProperty(c => c.End, time.EndTime);

                if (time.Reminders.Any(r => r.Method == Google.GData.Extensions.Reminder.ReminderMethod.alert))
                {
                    var reminder = time.Reminders.First(r => r.Method == Google.GData.Extensions.Reminder.ReminderMethod.alert);
                    result |= outlookCalendarItem.ApplyProperty(c => c.ReminderSet, true);
                    result |= outlookCalendarItem.ApplyProperty(c => c.ReminderOverrideDefault, true);
                    result |= outlookCalendarItem.ApplyProperty(c => c.ReminderMinutesBeforeStart, reminder.GetMinutes());
                }
                else
                {
                    result |= outlookCalendarItem.ApplyProperty(c => c.ReminderSet, false);
                    result |= outlookCalendarItem.ApplyProperty(c => c.ReminderOverrideDefault, false);
                }
            }

            result |= outlookCalendarItem.MergeRecurrence(googleCalendarItem.Recurrence);

            return(result);
        }