public ICalendarService InitCalendarService(string token, EventSource source) { if (token == null) { throw new Exception("API token is null"); } ICalendarService calendarAPI = null; switch (source) { case EventSource.Microsoft: var serviceClient = GraphClient.GetAuthenticatedClient(token); calendarAPI = new MSGraphCalendarAPI(serviceClient); break; case EventSource.Google: var googleClient = GoogleClient.GetGoogleClient(_settings); var googlePeopleClient = GoogleCalendarAPI.GetServiceClient(googleClient, token); calendarAPI = new GoogleCalendarAPI(googlePeopleClient); break; default: throw new Exception("Event Type not Defined"); } return(new CalendarService(calendarAPI, source)); }
public EventsController(IAuthTokenRepo AuthTokenRepo, UserManager <IdentityUser> IdentitiyUserManager, RoleManager <IdentityRole> roleManager, GoogleCalendarAPI googleCalendarAPI, IUserEntryRepo userEntryRepo, IUserSettingsRepo userSettings) { this.AuthTokenRepo = AuthTokenRepo; UserManager = IdentitiyUserManager; RoleManager = roleManager; this.googleCalendarAPI = googleCalendarAPI; this.userEntryRepo = userEntryRepo; this.userSettings = userSettings; }
private void GoogleShereButton_Click(object sender, RoutedEventArgs e) { try { GoogleCalendarAPI.AuthorizeAccount(); } catch (System.IO.FileNotFoundException) { DiagnosticDictionary.WriteMessage("Nie można znaleźć pliku json!"); return; } catch (System.UnauthorizedAccessException) { DiagnosticDictionary.WriteMessage("Nie udane połączenie z kontem Google!"); return; } catch (System.Net.Http.HttpRequestException) { DiagnosticDictionary.WriteMessage("Brak połączenia z internetem!"); return; } catch (Exception AuthorizeAccountException) { DiagnosticDictionary.WriteMessage(AuthorizeAccountException.Message); return; } try { GoogleCalendarAPI.DeleteEvent(); } catch (System.Net.Http.HttpRequestException) { DiagnosticDictionary.WriteMessage("Brak połączenia z internetem!"); return; } catch (Exception DeleteEventException) { DiagnosticDictionary.WriteMessage(DeleteEventException.Message); return; } foreach (var item in AppControler.CalendarPointListSource) { DateTime startDateTime = new DateTime(item.DeadLineDate.Value.Year, item.DeadLineDate.Value.Month, item.DeadLineDate.Value.Day, 14, 00, 00); DateTime endDateTime = new DateTime(item.DeadLineDate.Value.Year, item.DeadLineDate.Value.Month, item.DeadLineDate.Value.Day, 16, 00, 00); GoogleCalendarAPI.AddEvent(item.Name, startDateTime, endDateTime); } }
public Google() { api = new GoogleCalendarAPI(); Reader = new ReadFromGoogleCalendar(api); Writer = new WriteToGoogleCalendar(api); }
public WriteToGoogleCalendar(GoogleCalendarAPI api) { calendarAPI = api; }
public ReadFromGoogleCalendar(GoogleCalendarAPI api) { calendarAPI = api; }