internal static bool Equals(List <Event> googleExceptions, Outlook.Exceptions outlookExceptions) { var tmpGoogleExceptions = new List <Event>(googleExceptions); foreach (Outlook.Exception outlookException in outlookExceptions) { try { var found = false; foreach (var googleException in new List <Event>(tmpGoogleExceptions)) { if (Equals(googleException, outlookException)) { found = true; tmpGoogleExceptions.Remove(googleException); break; } } if (!found) { return(false); } } finally { Marshal.ReleaseComObject(outlookException); } } return(tmpGoogleExceptions.Count == 0); }
public static void CreateGoogleExceptions(AppointmentItem ai, String recurringEventId) { if (!ai.IsRecurring) { return; } log.Debug("Creating Google recurrence exceptions."); List <Event> gRecurrences = GoogleCalendar.Instance.GetCalendarEntriesInRecurrence(recurringEventId); if (gRecurrences != null) { Microsoft.Office.Interop.Outlook.Exceptions exps = ai.GetRecurrencePattern().Exceptions; foreach (Microsoft.Office.Interop.Outlook.Exception oExcp in exps) { for (int g = 0; g < gRecurrences.Count; g++) { Event ev = gRecurrences[g]; String gDate = ev.OriginalStartTime.DateTime ?? ev.OriginalStartTime.Date; Boolean isDeleted = exceptionIsDeleted(oExcp); if (isDeleted && !ai.AllDayEvent) //Deleted items get truncated?! { gDate = GoogleCalendar.GoogleTimeFrom(DateTime.Parse(gDate).Date); } if (oExcp.OriginalDate == DateTime.Parse(gDate)) { if (isDeleted) { MainForm.Instance.Logboxout(GoogleCalendar.GetEventSummary(ev)); MainForm.Instance.Logboxout("Recurrence deleted."); ev.Status = "cancelled"; GoogleCalendar.Instance.UpdateCalendarEntry_save(ref ev); } else { int exceptionItemsModified = 0; Event modifiedEv = GoogleCalendar.Instance.UpdateCalendarEntry(oExcp.AppointmentItem, ev, ref exceptionItemsModified, forceCompare: true); if (exceptionItemsModified > 0) { GoogleCalendar.Instance.UpdateCalendarEntry_save(ref modifiedEv); } } break; } } } } }
internal static bool Contains(Outlook.Exceptions outlookExceptions, Event googleException) { foreach (Outlook.Exception outlookException in outlookExceptions) { try { if (Equals(googleException, outlookException)) { return(true); } } finally { Marshal.ReleaseComObject(outlookException); } } return(false); }