Esempio n. 1
0
 private bool CompareVisibility(Event googleItem, object outlookItem)
 {
     return((googleItem.Visibility ?? "default") == ConvertTo.GoogleVisibility(((Outlook.AppointmentItem)outlookItem).Sensitivity));
 }
Esempio n. 2
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);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 private bool CompareShowTimeAs(Event googleItem, object outlookItem)
 {
     return((googleItem.Transparency ?? "opaque") == ConvertTo.GoogleAvailability(((Outlook.AppointmentItem)outlookItem).BusyStatus));
 }