Beispiel #1
0
        internal static bool Equals(Event googleItem, Outlook.AppointmentItem outlookItem)
        {
            var privacyMode    = (int)Utilities.GetRegistryValue(VSTO.Properties.Settings.Default.Privacy) == 1;
            var attendeesEqual = privacyMode ? true : AttendeeComparer.Equals(googleItem.Attendees, outlookItem.Recipients);
            var bodiesEqual    = privacyMode ? true : googleItem.Description == outlookItem.Body;
            var locationsEqual = privacyMode ? true : LocationIsEqual(googleItem, outlookItem);

            return
                (googleItem.Summary == outlookItem.Subject &&
                 bodiesEqual &&
                 attendeesEqual &&
                 locationsEqual &&
                 ReminderIsEqual(googleItem, outlookItem));
        }
Beispiel #2
0
 private bool CompareAttendees(Event googleItem, object outlookItem)
 {
     return(AttendeeComparer.Equals(googleItem.Attendees, ((Outlook.AppointmentItem)outlookItem).Recipients)); // ((vbMAPI_AppointmentItem)vbMAPI_Init.NewOutlookWrapper((Outlook.AppointmentItem)outlookItem)).Recipients);
 }
Beispiel #3
0
        private void SetAttendees(Event googleItem, object outlookItem, Target target)
        {
            if (target == Target.Google)
            {
                if (googleItem.Attendees == null)
                {
                    googleItem.Attendees = new List <EventAttendee>();
                }
                foreach (Outlook.Recipient outlookRecipient in ((Outlook.AppointmentItem)outlookItem).Recipients)
                {
                    try
                    {
#if DEBUG
                        Logger.Log(string.Format("Adding attendee {0} to Google event", outlookRecipient.Address), EventType.Debug);
#endif
                        /// Organizator is omited
                        if (((Outlook.OlMeetingRecipientType)outlookRecipient.Type == Outlook.OlMeetingRecipientType.olOrganizer) ||
                            (outlookRecipient.Address == null) ||
                            !Utilities.SMTPAddressPattern.IsMatch(outlookRecipient.Address))
                        {
#if DEBUG
                            Logger.Log(string.Format("{0} is a meeting organizer or it's not valid SMTP address, so it won't be added", outlookRecipient.Address),
                                       EventType.Debug);
#endif
                            continue;
                        }
                        var googleRecipient = googleItem.Attendees.FirstOrDefault(recipient => recipient.Email == outlookRecipient.Address);
                        if (googleRecipient == null)
                        {
                            googleRecipient = new EventAttendee
                            {
                                Email = outlookRecipient.Address
                            };
                            googleItem.Attendees.Add(googleRecipient);
                        }
                        else if (AttendeeComparer.Equals(googleRecipient, outlookRecipient))
                        {
                            continue;
                        }
                        googleRecipient = ConvertTo.GoogleRecipientType(googleRecipient, (Outlook.OlMeetingRecipientType)outlookRecipient.Type);
                        googleRecipient.ResponseStatus = ConvertTo.GoogleResponseStatus(outlookRecipient.MeetingResponseStatus);
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(outlookRecipient);
                    }
                }
            }
            else
            {
                if (googleItem.Attendees != null)
                {
                    foreach (var googleRecipient in googleItem.Attendees)
                    {
                        /// Organizator and not valid SMTP addresses are omited
                        if (googleRecipient.Organizer.HasValue && googleRecipient.Organizer.Value ||
                            !Utilities.SMTPAddressPattern.IsMatch(googleRecipient.Email))
                        {
                            continue;
                        }
                        var matchIsFound = false;
                        foreach (Outlook.Recipient outlookRecipient in ((Outlook.AppointmentItem)outlookItem).Recipients)
                        {
                            if (googleRecipient.Email == outlookRecipient.Address)
                            {
                                matchIsFound = true;
                                Marshal.ReleaseComObject(outlookRecipient);
                                break;
                            }
                            Marshal.ReleaseComObject(outlookRecipient);
                        }
                        if (!matchIsFound)
                        {
                            Outlook.Recipient outlookRecipient = ((Outlook.AppointmentItem)outlookItem).Recipients.Add(googleRecipient.Email);
                            outlookRecipient.Type = (int)ConvertTo.OutlookRecipientType(googleRecipient);
                            Marshal.ReleaseComObject(outlookRecipient);
                        }
                    }
                }
            }
        }