Esempio n. 1
0
        private void LoadDataAsync()
        {
            CultureInfo culture = Settings.DatabaseCulture;
            // get a processId so we can stop it if the user request a new batch before we finished this one
            int processId = ++_loadProcessId;

            SetCollectionView(null);
            Observable.Start(() =>
            {
                // load items from database
                using (var provider = new MangosProvider())
                    using (new PerformanceChecker("GetQuests"))
                    {
                        return(provider.GetQuests(culture)
                               .Where(o => o.Id >= 9874 && o.Id <= 9888)
                               .Select(o => new LocalizedQuest(o))
                               .ToList());
                    }
            })
            .ObserveOnDispatcher()
            .Subscribe(result =>
            {
                // check processId to make sure the user has not requested another batch meantime
                if (processId != _loadProcessId)
                {
                    return;
                }

                // display loaded items to user
                SetCollectionView(result);
            }, OnError);
        }
Esempio n. 2
0
        private void LoadDataAsync()
        {
            CultureInfo culture = Settings.DatabaseCulture;

            // get a processId so we can stop it if the user request a new batch before we finished this one
            int processId = ++_loadProcessId;

            SetCollectionView(null);
            Observable.Start(() =>
            {
                // load items from database
                var result = Enumerable.Empty <WowApiLocalizedData>();
                using (var provider = new MangosProvider())
                {
                    if (SelectedDataType.DataType == typeof(WowApi.Models.Achievement))
                    {
                        result = provider.GetAchievements(culture)
                                 .Select(o => new WowApiLocalizedData {
                            ItemId = o.Id
                        });
                    }
                    else if (SelectedDataType.DataType == typeof(WowApi.Models.Item))
                    {
                        result = provider.GetItems(culture)
                                 .Select(o => new WowApiLocalizedData {
                            ItemId = o.Id
                        });
                    }
                    else if (SelectedDataType.DataType == typeof(WowApi.Models.Quest))
                    {
                        result = provider.GetQuests(culture)
                                 .Select(o => new WowApiLocalizedData {
                            ItemId = o.Id
                        });
                    }
                    return(result.ToList());
                }
            })
            .ObserveOnDispatcher()
            .Subscribe(result =>
            {
                // check processId to make sure the user has not requested another batch meantime
                if (processId != _loadProcessId)
                {
                    return;
                }

                // display loaded items to user
                SetCollectionView(result);
            }, OnError);
        }