Exemple #1
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            var file = args.Files.FirstOrDefault();

            if (file == null)
            {
                CurtainPrompt.ShowError("No backup file picked.");
                return;
            }

            UiBlockerUtility.Block("Preparing...");
            App.Locator.AudioPlayerHelper.FullShutdown();
            App.Locator.SqlService.Dispose();
            App.Locator.BgSqlService.Dispose();

            using (var stream = await file.OpenStreamForReadAsync())
            {
                if (AutcpFormatHelper.ValidateHeader(stream))
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    var restoreFile = await StorageHelper.CreateFileAsync("_current_restore.autcp");

                    using (var restoreStream = await restoreFile.OpenAsync(FileAccess.ReadAndWrite))
                    {
                        await stream.CopyToAsync(restoreStream);
                    }

                    UiBlockerUtility.Unblock();

                    await
                    MessageBox.ShowAsync(
                        "To finish applying the restore the app will close. Next time you start the app, it will finish restoring.",
                        "Application Restart Required");

                    App.Locator.AppSettingsHelper.Write("Restore", true);
                    Application.Current.Exit();
                }
                else
                {
                    CurtainPrompt.ShowError("Not a valid backup file.");
                }
            }
        }