예제 #1
0
        private bool CheckRemoved(bool removed)
        {
            var collection = Client.GetDatabase(DatabaseName).GetCollection <T>(CollectionName);

            List <T> reloadedItems = new List <T>();

            using (var cursor = collection.FindSync(Filter))
            {
                var countryList = cursor.ToList();
                foreach (var country in countryList)
                {
                    reloadedItems.Add(country);
                }
            }

            if (reloadedItems.Count != LoadedItems.Count)
            {
                removed = true;
                LoadedItems.Clear();
                foreach (var item in reloadedItems)
                {
                    LoadedItems.Add(item);
                }
            }

            return(removed);
        }
        /// <summary>
        /// Loads all the items from the database into the list.
        /// </summary>
        /// <param name="itemsRead">The items retrieved from the database.</param>
        private void LoadAllItemsFromDatabase(IMongoCollection <T> itemsRead)
        {
            LoadedItems.Clear();

            using (IAsyncCursor <T> cursor = itemsRead.FindSync(Filter))
            {
                List <T> itemList = cursor.ToList();
                foreach (T item in itemList)
                {
                    LoadedItems.Add(item);
                }
            }
        }
        /// <summary>
        /// Loads all the items from the database into the list.
        /// </summary>
        /// <param name="itemsRead">The items retrieved from the database.</param>
        private void LoadAllItemsFromDatabase(IMongoCollection <T> itemsRead)
        {
            LoadedItems.Clear();

            using (var cursor = itemsRead.FindSync(Filter))
            {
                var countryList = cursor.ToList();
                foreach (var country in countryList)
                {
                    LoadedItems.Add(country);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Executes the operation of retrieving and processing new items.
        /// </summary>
        private void LoadMoreAction()
        {
            // Get the amount of items to load.
            int loadCount = GetItemsPerPage();

            // Get the next batch of items.
            IEnumerable <Tentity> nextItems = _itemList.GetNext(loadCount);

            // Browse  and process each retrieved item.
            foreach (Tentity item in nextItems)
            {
                Tmodel model = ProcessItem(item);

                // Invoke the item addition on the dispatcher.
                DispatcherHelper.Invoke(() =>
                {
                    LoadedItems.Add(model);
                });

                LoadedItemCount++;
            }
        }
        /// <summary>
        /// Gets the loaded items matching the database after an item has been removed.
        /// </summary>
        private void UpdateLoadedAfterRemove()
        {
            IMongoCollection <T> collection =
                Client.GetDatabase(DatabaseName).GetCollection <T>(CollectionName);

            List <T> reloadedItems = new List <T>();

            using (IAsyncCursor <T> cursor = collection.FindSync(Filter))
            {
                List <T> itemList = cursor.ToList();
                reloadedItems.AddRange(itemList);
            }

            if (reloadedItems.Count != LoadedItems.Count)
            {
                LoadedItems.Clear();
                foreach (T item in reloadedItems)
                {
                    LoadedItems.Add(item);
                }
            }
        }