public async void SetCalendarColor(Category background, IDictionary<string, object> calendarSpecificData) { CheckCalendarSpecificData(calendarSpecificData); var calendarService = GetCalendarService(AccountName); var calendarListEntry = await calendarService.CalendarList.Get(CalendarId).ExecuteAsync(); calendarListEntry.BackgroundColor = background.HexValue; await calendarService.CalendarList.Update(calendarListEntry, CalendarId).ExecuteAsync(); }
public async void SetCalendarColor(Category background, IDictionary<string, object> calendarSpecificData) { CheckCalendarSpecificData(calendarSpecificData); await ThreadingTask.Factory.StartNew( () => SetColor(background)); }
private OutlookAppointmentsWrapper SetColorForSelectedCalendar(Category background) { var disposeOutlookInstances = false; Application application = null; NameSpace nameSpace = null; //Close and Shutdown try { // Get Application and Namespace GetOutlookApplication(out disposeOutlookInstances, out application, out nameSpace, ProfileName); if (nameSpace.Categories[background.CategoryName] == null) { nameSpace.Categories.Add(background.CategoryName, CategoryHelper.GetOutlookColor(background.HexValue), OlCategoryShortcutKey.olCategoryShortcutKeyNone); } else { nameSpace.Categories[background.CategoryName].Color = CategoryHelper.GetOutlookColor(background.HexValue); } } catch (Exception exception) { Logger.Error(exception); return new OutlookAppointmentsWrapper { Appointments = null, WaitForApplicationQuit = disposeOutlookInstances }; } finally { if (disposeOutlookInstances) { nameSpace.Logoff(); } Marshal.FinalReleaseComObject(nameSpace); nameSpace = null; if (disposeOutlookInstances) { // Casting Removes a warninig for Ambigous Call application.Quit(); Marshal.FinalReleaseComObject(application); } application = null; GC.Collect(); GC.WaitForPendingFinalizers(); } return new OutlookAppointmentsWrapper { Appointments = null, WaitForApplicationQuit = disposeOutlookInstances }; }
private void SetColor(Category background) { var list = SetColorForSelectedCalendar(background); if (!list.WaitForApplicationQuit) { return; } while (Process.GetProcessesByName("OUTLOOK").Any()) { ThreadingTask.Delay(5000); } }
public void CheckCalendarSpecificData(IDictionary<string, object> calendarSpecificData) { if (calendarSpecificData == null) { throw new ArgumentNullException("calendarSpecificData", "Calendar Specific Data cannot be null"); } object ewsCalendar; object serverSettings; object addAsAppointments; if (!//(calendarSpecificData.TryGetValue(EWSCALENDAR, out ewsCalendar) && calendarSpecificData.TryGetValue(EXCHANGE_SERVER_SETTINGS, out serverSettings))// && //calendarSpecificData.TryGetValue("AddAsAppointments", out addAsAppointments))) { throw new InvalidOperationException( string.Format( "{0} {1} and {2} keys should be present, both of them can be null in case Default Profile and Default Calendar will be used. {0} is of 'string' type, {1} is of 'OutlookCalendar' type and {2} is of bool type.", EWSCALENDAR, EXCHANGE_SERVER_SETTINGS, "AddAsAppointments")); } //_ewsCalendar = ewsCalendar as EWSCalendar; ExchangeServerSettings = serverSettings as ExchangeServerSettings; //_addAsAppointments = (bool) addAsAppointments; object eventCategory; if (calendarSpecificData.TryGetValue("EventCategory", out eventCategory)) { _eventCategory = eventCategory as Category; } else { _eventCategory = null; } }
public void SetCalendarColor(Category background, IDictionary<string, object> calendarSpecificData) { throw new NotImplementedException(); }