Example #1
0
        public async Task RestoreBackupAsync(BackupMode backupMode = BackupMode.Automatic)
        {
            if (backupMode == BackupMode.Automatic && !settingsFacade.IsBackupAutouploadEnabled)
            {
                logger.Info("Backup is in Automatic Mode but Auto Backup isn't enabled.");
                return;
            }

            if (!connectivity.IsConnected)
            {
                throw new NetworkConnectionException();
            }

            try
            {
                BackupRestoreResult result = await DownloadBackupAsync(backupMode);

                if (result == BackupRestoreResult.NewBackupRestored)
                {
                    settingsFacade.LastDatabaseUpdate = DateTime.Now;

                    await toastService.ShowToastAsync(Strings.BackupRestoredMessage);

                    messenger.Send(new ReloadMessage());
                }
            }
            catch (BackupOperationCanceledException ex)
            {
                logger.Error(ex, "Operation canceled during restore backup. Execute logout");
                await LogoutAsync();

                await toastService.ShowToastAsync(Strings.FailedToLoginToBackupMessage, Strings.FailedToLoginToBackupTitle);
            }
        }
Example #2
0
        public async Task RestoreBackupAsync(BackupMode backupMode = BackupMode.Automatic)
        {
            if (backupMode == BackupMode.Automatic && !settingsFacade.IsBackupAutouploadEnabled)
            {
                logger.Info("Backup is in Automatic Mode but Auto Backup isn't enabled.");
                return;
            }

            if (!connectivity.IsConnected)
            {
                throw new NetworkConnectionException();
            }

            BackupRestoreResult result = await DownloadBackupAsync(backupMode);

            if (result == BackupRestoreResult.NewBackupRestored)
            {
                settingsFacade.LastDatabaseUpdate = DateTime.Now;

                await toastService.ShowToastAsync(Strings.BackupRestoredMessage);

                messenger.Send(new ReloadMessage());
            }
        }