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;
 }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
 public Google()
 {
     api    = new GoogleCalendarAPI();
     Reader = new ReadFromGoogleCalendar(api);
     Writer = new WriteToGoogleCalendar(api);
 }
Exemplo n.º 5
0
 public WriteToGoogleCalendar(GoogleCalendarAPI api)
 {
     calendarAPI = api;
 }
Exemplo n.º 6
0
 public ReadFromGoogleCalendar(GoogleCalendarAPI api)
 {
     calendarAPI = api;
 }