Пример #1
0
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            var file = args.File;

            if (file == null)
            {
                CurtainPrompt.ShowError("Backup cancelled.");
                return;
            }

            using (Insights.TrackTime("Create Backup"))
            {
                UiBlockerUtility.Block("Backing up (this may take a bit)...");

                App.Locator.SqlService.Dispose();
                App.Locator.BgSqlService.Dispose();

                try
                {
                    var data = await AutcpFormatHelper.CreateBackup(ApplicationData.Current.LocalFolder);

                    using (var stream = await file.OpenStreamForWriteAsync())
                    {
                        await stream.WriteAsync(data, 0, data.Length);
                    }
                }
                catch (Exception e)
                {
                    Insights.Report(e, "Where", "Creating Backup");
                    CurtainPrompt.ShowError("Problem creating backup.");
                }

                App.Locator.SqlService.Initialize();
                App.Locator.BgSqlService.Initialize();
                UiBlockerUtility.Unblock();
            }

            CurtainPrompt.Show("Backup completed.");
        }