예제 #1
0
        public Event GetGoogleMasterEvent(AppointmentItem ai)
        {
            log.Fine("Found a master Outlook recurring item outside sync date range: " + OutlookCalendar.GetEventSummary(ai));
            List <Event> events = new List <Event>();

            if (ai.UserProperties[OutlookCalendar.gEventID] == null)
            {
                events = GoogleCalendar.Instance.GetCalendarEntriesInRange(ai.Start.Date, ai.Start.Date.AddDays(1));
                List <AppointmentItem> ais = new List <AppointmentItem>();
                ais.Add(ai);
                GoogleCalendar.Instance.ReclaimOrphanCalendarEntries(ref events, ref ais, neverDelete: true);
            }
            else
            {
                Event ev = GoogleCalendar.Instance.GetCalendarEntry(ai.UserProperties[OutlookCalendar.gEventID].Value.ToString());
                if (ev != null)
                {
                    events.Add(ev);
                }
            }
            for (int g = 0; g < events.Count(); g++)
            {
                String gEntryID;
                Event  ev = events[g];
                if (GoogleCalendar.GetOGCSproperty(ev, GoogleCalendar.oEntryID, out gEntryID))
                {
                    if (gEntryID == ai.EntryID)
                    {
                        log.Info("Migrating Master Event from EntryID to GlobalAppointmentID...");
                        GoogleCalendar.AddOutlookID(ref ev, ai);
                        GoogleCalendar.Instance.UpdateCalendarEntry_save(ref ev);
                        return(ev);
                    }
                    else if (gEntryID == OutlookCalendar.Instance.IOutlook.GetGlobalApptID(ai))
                    {
                        log.Fine("Found master event.");
                        return(ev);
                    }
                }
            }
            log.Warn("Failed to find master Google event for: " + OutlookCalendar.GetEventSummary(ai));
            return(null);
        }
예제 #2
0
        private static void createCalendarEntry_save(AppointmentItem ai, Event ev)
        {
            if (Settings.Instance.SyncDirection == SyncDirection.Bidirectional)
            {
                log.Debug("Saving timestamp when OGCS updated appointment.");
                AddOGCSproperty(ref ai, Program.OGCSmodified, DateTime.Now);
            }

            ai.Save();

            Boolean oKeyExists = false;

            try {
                oKeyExists = ev.ExtendedProperties.Private.ContainsKey(GoogleCalendar.oEntryID);
            } catch {}
            if (Settings.Instance.SyncDirection == SyncDirection.Bidirectional || oKeyExists)
            {
                log.Debug("Storing the Outlook appointment ID in Google event.");
                GoogleCalendar.AddOutlookID(ref ev, ai, Environment.MachineName);
                GoogleCalendar.Instance.UpdateCalendarEntry_save(ev);
            }
        }