private void StartAuthentication(TaskScheduler taskScheduler) { //// Authenticate Oauth2 string clientId = "68932173233-e7nf2hlqhl9o16knj0iatg82bmgdkvom.apps.googleusercontent.com"; string clientSecret = "QRDGYelWPnCOsCiWlXVl6Cc3"; string redirectUri = "urn:ietf:wg:oauth:2.0:oob"; string userName = "******"; // A string used to identify a user (locally). var calenderService = (new AccountAuthentication()).AuthenticateCalenderOauth(clientId, clientSecret, userName, "OutlookGoogleSyncRefresh.Auth.Store", "OutlookGoogleSyncRefresh"); var googleCalenderService = new GoogleCalendarService(calenderService); googleCalenderService.GetAvailableCalendars() .ContinueWith(task => ContinuationActionGoogle(task, googleCalenderService, taskScheduler)); }
private void ContinuationActionGoogle(Task<List<Calendar>> task, GoogleCalendarService googleCalenderService, TaskScheduler taskScheduler) { string calenderId = string.Empty; var calender = task.Result.FirstOrDefault(calendar => calendar.Name.Contains("Test")); if (calender != null) { calenderId = calender.Id; } googleCalenderService.GetCalendarEventsInRangeAsync(0, 1, calenderId) .ContinueWith(ContinuationActionGoogleAppointments, taskScheduler); }
private void Button_Click_Selected(object sender, RoutedEventArgs e) { MyGrid.IsEnabled = false; //// Authenticate Oauth2 string clientId = "68932173233-e7nf2hlqhl9o16knj0iatg82bmgdkvom.apps.googleusercontent.com"; string clientSecret = "QRDGYelWPnCOsCiWlXVl6Cc3"; string redirectUri = "urn:ietf:wg:oauth:2.0:oob"; string userName = "******"; // A string used to identify a user (locally). var calenderService = (new AccountAuthenticationService(new ApplicationLogger(), new MessageService())).AuthenticateCalenderOauth(clientId, clientSecret, userName, "OutlookGoogleSyncRefresh.Auth.Store", "OutlookGoogleSyncRefresh"); var googleCalenderService = new GoogleCalendarService(calenderService, new ApplicationLogger()); var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); googleCalenderService.GetAvailableCalendars() .ContinueWith( task => GetInformation(task.Result, scheduler, googleCalenderService)); }
private void GetInformation(IEnumerable<Calendar> list, TaskScheduler currentSynchronizationContext, GoogleCalendarService googleCalenderService) { string calenderId = string.Empty; var calender = list.FirstOrDefault(calendar => calendar.Name.Contains("Office")); if (calender != null) { calenderId = calender.Id; } var outlookService = new OutlookCalendarService(); GetEqualAppointments(googleCalenderService, outlookService, calenderId).ContinueWith(ContinuationActionGoogleAppointments, currentSynchronizationContext); }
private async Task<List<Appointment>> GetEqualAppointments(GoogleCalendarService googleCalenderService, OutlookCalendarService outlookCalendarService, string calenderId) { List<Appointment> googleAppointments = await googleCalenderService.GetCalendarEventsInRangeAsync(0, 2, calenderId); List<Appointment> outLookAppointments = await outlookCalendarService.GetOutlookAppointmentsAsync(0, 2); return (from lookAppointment in outLookAppointments let isAvailable = googleAppointments.Any(appointment => appointment.Equals(lookAppointment)) where isAvailable select lookAppointment).ToList(); }