예제 #1
0
        private void linkDeleteBackup_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var caption = RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_header");
            var content = RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_body");

            if (MessageBox.Show(
                    content,
                    caption,
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                try {
                    var restService      = _authAuthService.GetRestService();
                    var cloudSyncService = new CloudSyncService(_authAuthService.GetRestService());
                    if (restService != null && cloudSyncService.DeleteAccount())
                    {
                        MessageBox.Show(
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_success_body"),
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_success_header"),
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation
                            );

                        _settings.GetPersistent().CloudUploadTimestamp = 0;
                        _authAuthService.UnAuthenticate();
                        _playerItemDao.ResetOnlineSyncState();
                        _settings.GetPersistent().BuddySyncUserIdV3 = null;
                    }
                    else
                    {
                        MessageBox.Show(
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_body"),
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_header"),
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error
                            );
                    }
                }
                catch (Exception ex) {
                    Logger.Warn("Error deleting account", ex);
                    MessageBox.Show(
                        RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_body"),
                        RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_header"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
            }

            UpdateUi();
        }
예제 #2
0
        public static async Task CloudSync(bool refreshProfile = true)
        {
            if (!App.Locator.AudioticaService.IsAuthenticated) return;

            var displayingStatus = App.Locator.CollectionService.Songs.Count == 0;
            try
            {
                if (refreshProfile)
                {
                    await App.Locator.AudioticaService.GetProfileAsync().ConfigureAwait(false);
                    IdentifyXamarin();
                }

                if (App.Locator.AudioticaService.CurrentUser != null
                    && App.Locator.AudioticaService.CurrentUser.Subscription != SubscriptionType.None)
                {
                    var mobileService = new MobileServiceClient(
                        "https://audiotica-cloud.azure-mobile.net/",
                        "AypzKLKRIDPGkXXzCGYGqjJNliXTwp74")
                    {
                        CurrentUser =
                            new MobileServiceUser(App.Locator.AudioticaService.CurrentUser.Id)
                            {
                                MobileServiceAuthenticationToken =
                                    App.Locator.AudioticaService.AuthenticationToken
                            }
                    };
                    var sync = new CloudSyncService(
                        mobileService,
                        App.Locator.CollectionService,
                        App.Locator.AppSettingsHelper,
                        App.Locator.SqlService,
                        App.Locator.PclDispatcherHelper);

                    EventHandler handlerStarted = (sender, args) => UiBlockerUtility.Block("Syncing new songs...");
                    sync.OnLargeSyncStarted += handlerStarted;
                    EventHandler handlerFinish = (sender, args) => UiBlockerUtility.Unblock();
                    sync.OnLargeSyncFinished += handlerFinish;

                    if (displayingStatus)
                    {
                        await
                            App.Locator.PclDispatcherHelper.RunAsync(
                                () => StatusBarHelper.ShowStatus("Starting sync...")).ConfigureAwait(false);
                    }

                    await sync.PrepareAsync().ConfigureAwait(false);
                    await sync.PullAsync().ConfigureAwait(false);

                    // update artwork and match new pulled songs
                    MatchSongs();
                    DownloadAlbumsArtworkAsync();
                    DownloadArtistsArtworkAsync();

                    // then continue with push
                    await sync.PushAsync().ConfigureAwait(false);

                    sync.OnLargeSyncStarted -= handlerStarted;
                    sync.OnLargeSyncFinished -= handlerFinish;
                }
            }
            catch (Exception e)
            {
                Insights.Report(e, "Where", "CloudSync");
            }

            if (displayingStatus)
            {
                await App.Locator.PclDispatcherHelper.RunAsync(StatusBarHelper.HideStatus).ConfigureAwait(false);
            }
        }