Exemple #1
0
        private async void DisconnectGoogleHandler()
        {
            if (SelectedProfile.SelectedGoogleAccount == null)
            {
                MessageService.ShowMessageAsync("No account selected");
                return;
            }

            var dialogResult =
                await
                MessageService.ShowConfirmMessage(
                    "Disconnection of Google account cannot be reverted.\nClick Yes to continue.");

            if (dialogResult == MessageDialogResult.Negative)
            {
                return;
            }

            var result = AccountAuthenticationService.DisconnectGoogle(SelectedProfile.SelectedGoogleAccount.Name);

            if (result)
            {
                //Remove google account
                var googleAccount =
                    GoogleAccounts.FirstOrDefault(account => account.Name == SelectedProfile.SelectedGoogleAccount.Name);

                if (googleAccount != null)
                {
                    foreach (var profileViewModel in SyncProfileList)
                    {
                        if (profileViewModel.SelectedGoogleAccount != null &&
                            profileViewModel.SelectedGoogleAccount.Name.Equals(googleAccount.Name))
                        {
                            profileViewModel.SelectedGoogleAccount = null;
                            profileViewModel.GoogleCalendars       = null;
                            profileViewModel.SelectedCalendar      = null;
                        }
                    }

                    GoogleAccounts.Remove(googleAccount);

                    await MessageService.ShowMessage("Google account successfully disconnected");

                    foreach (var calendarSyncProfile in Settings.SyncProfiles)
                    {
                        if (calendarSyncProfile.GoogleAccount != null &&
                            calendarSyncProfile.GoogleAccount.Name.Equals(googleAccount.Name))
                        {
                            calendarSyncProfile.GoogleAccount = null;
                        }
                    }

                    await SettingsSerializationService.SerializeSettingsAsync(Settings);
                }
            }
            else
            {
                MessageService.ShowMessageAsync("Account wasn't authenticated earlier or disconnection failed.");
            }
        }
Exemple #2
0
        public async void LoadSyncProfile()
        {
            if (SelectedProfile == null)
            {
                return;
            }

            IsLoading = true;

            if (SelectedProfile.SyncFrequency != null)
            {
                SelectedFrequency = SelectedProfile.SyncFrequency.Name;
            }

            if (!SelectedProfile.IsLoaded)
            {
                if (!SelectedProfile.OutlookSettings.OutlookOptions.HasFlag(OutlookOptionsEnum.DefaultProfile))
                {
                    await GetOutlookProfileListInternal();
                }

                if (!SelectedProfile.OutlookSettings.OutlookOptions.HasFlag(OutlookOptionsEnum.DefaultMailBoxCalendar))
                {
                    await GetOutlookMailBoxesInternal();
                }

                if (SelectedProfile.GoogleSettings.GoogleAccount != null)
                {
                    SelectedProfile.GoogleSettings.GoogleAccount = GoogleAccounts.FirstOrDefault(t =>
                                                                                                 t.Name.Equals(SelectedProfile.GoogleSettings.GoogleAccount.Name));

                    if (SelectedProfile.GoogleSettings.GoogleCalendar != null)
                    {
                        await GetGoogleCalendarInternal();
                    }
                }

                SelectedProfile.IsLoaded = true;
            }

            if (SelectedProfile.EventCategory != null)
            {
                SelectedProfile.EventCategory =
                    Categories.First(t => t.CategoryName.Equals(SelectedProfile.EventCategory.CategoryName));
            }

            IsLoading = false;
        }
Exemple #3
0
        private GoogleAccount GetGoogleAccount(CalendarSyncProfile syncProfile)
        {
            GoogleAccount googleAccount = null;

            if (syncProfile.GoogleAccount != null)
            {
                if (GoogleAccounts.Any())
                {
                    googleAccount = GoogleAccounts.FirstOrDefault(
                        account => account.Name == syncProfile.GoogleAccount.Name);
                }
            }

            if (googleAccount != null)
            {
                googleAccount.GoogleCalendar = syncProfile.GoogleAccount.GoogleCalendar;
            }
            return(googleAccount);
        }