示例#1
0
        public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            await base.OnNavigatedToAsync(parameters);

            _NowNavigateProccess = true;

            try
            {
                VideoTitleFilteringItems.Clear();
                foreach (var item in _videoFilteringRepository.GetVideoTitleFilteringEntries().Select(x =>
                                                                                                      new VideoFilteringTitleViewModel(x, OnRemoveVideoTitleFilterEntry, _videoFilteringRepository, TestText))
                         )
                {
                    VideoTitleFilteringItems.Add(item);
                }


                try
                {
                    var listing = await Models.Domain.Purchase.HohoemaPurchase.GetAvailableCheersAddOn();

                    PurchaseItems = listing.ProductListings.Select(x => new ProductViewModel(x.Value)).ToList();
                    OnPropertyChanged(nameof(PurchaseItems));
                }
                catch { }



                var lisenceSummary = await LisenceSummary.Load();

                LisenceItems = lisenceSummary.Items
                               .OrderBy(x => x.Name)
                               .Select(x => new LisenceItemViewModel(x))
                               .ToList();
                OnPropertyChanged(nameof(LisenceItems));
            }
            finally
            {
                _NowNavigateProccess = false;
            }
        }
示例#2
0
        async void ExecuteImportBackupCommand()
        {
            try
            {
                var picker = new FileOpenPicker();
                picker.ViewMode = PickerViewMode.List;
                picker.FileTypeFilter.Add(".json");
                var file = await picker.PickSingleFileAsync();

                if (file != null)
                {
                    try
                    {
                        var backup = await _backupManager.ReadBackupContainerAsync(file, default);

                        Action <BackupContainer>[] BackupActions = new Action <BackupContainer>[]
                        {
                            _backupManager.RestoreLocalMylist,
                            _backupManager.RestoreSubscription,
                            _backupManager.RestorePin,
                            _backupManager.RestoreRankingSettings,
                            _backupManager.RestoreVideoFilteringSettings,
                            _backupManager.RestorePlayerSettings,
                            _backupManager.RestoreAppearanceSettings,
                            _backupManager.RestoreNicoRepoSettings,
                            _backupManager.RestoreCommentSettings,
                        };

                        List <Exception> exceptions = new List <Exception>();
                        foreach (var backupAction in BackupActions)
                        {
                            try
                            {
                                backupAction(backup);
                            }
                            catch (Exception e)
                            {
                                exceptions.Add(e);
                            }
                        }

                        WeakReferenceMessenger.Default.Send <SettingsRestoredMessage>();

                        _notificationService.ShowLiteInAppNotification_Success("BackupRestoreComplete".Translate());

                        NGVideoOwnerUserIds = _videoFilteringRepository.GetVideoOwnerIdFilteringEntries();
                        OnPropertyChanged(nameof(NGVideoOwnerUserIds));

                        VideoTitleFilteringItems.Clear();
                        foreach (var item in _videoFilteringRepository.GetVideoTitleFilteringEntries().Select(x =>
                                                                                                              new VideoFilteringTitleViewModel(x, OnRemoveVideoTitleFilterEntry, _videoFilteringRepository, TestText)))
                        {
                            VideoTitleFilteringItems.Add(item);
                        }

                        if (exceptions.Any())
                        {
                            throw new AggregateException(exceptions);
                        }
                    }
                    catch
                    {
                        _notificationService.ShowLiteInAppNotification_Fail("BackupRestoreFailed".Translate());
                        throw;
                    }
                }
            }
            catch (Exception e)
            {
                _logger.ZLogError(e, "Backup import failed");
            }
        }