public void DeleteItem()
        {
            if (SelectedItem == null)
            {
                return;
            }
            Item deletedItem = Items.Where(x => x.ItemId == SelectedItem.ItemId).FirstOrDefault();

            try
            {
                ItemsProcessor.DeleteItem(deletedItem);
                Items.Remove(deletedItem);
            }
            catch (AggregateException)
            {
                var dialogViewModel = IoC.Get <DialogViewModel>();
                dialogViewModel.Title   = "Error";
                dialogViewModel.Message = "Item cannot be deleted because it's added to a store";

                IWindowManager manager = new WindowManager();
                manager.ShowDialog(dialogViewModel);
            }
            Items.Refresh();
            Reset();
        }
        public void UpdateItem()
        {
            if (SelectedItem == null)
            {
                return;
            }
            Item updateItem = Items.Where(x => x.ItemId == SelectedItem.ItemId).FirstOrDefault();

            if (!string.IsNullOrWhiteSpace(Title))
            {
                updateItem.Title = Title;
            }
            updateItem.Description = Description;
            if (Price > 0)
            {
                updateItem.Price = Price;
            }
            updateItem.Sold = Sold;
            updateItem.PaymentDistributed = PaymentDistributed;
            if (SelectedVendor != null)
            {
                updateItem.Owner = Owner;
            }
            ItemsProcessor.UpdateItem(updateItem);
            Items.Refresh();
            Reset();
        }
 public AddItemToStoreViewModel()
 {
     Items      = new BindableCollection <Item>(ItemsProcessor.GetItems <Item>());
     Stores     = new BindableCollection <Store>(StoreProcessor.GetStores <Store>());
     Vendors    = new BindableCollection <Vendor>(VendorsProcessor.GetVendors <Vendor>());
     StoreItems = new BindableCollection <Item>();
 }
Beispiel #4
0
        /// <summary>
        /// Gets items from website or database
        /// </summary>
        /// <param name="fromDB"></param>
        /// <returns></returns>
        private List <Item> GetItems(bool fromDB = false)
        {
            List <Item> items = !fromDB
                ? ItemsProcessor.LoadItems(txtbSearchBar.Text, _page).Result
                : ItemsProcessor.LoadItemsFromDB(txtbSearchBar.Text).Result;

            return(items);
        }
        public void ProcessListItems(SPList list, SPQuery query, ItemsProcessor itemsProcessor, ItemsProcessorErrorCallout errorCallout)
        {
            if (list == null)
            {
                throw new ArgumentNullException("list");
            }

            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            if (itemsProcessor == null)
            {
                throw new ArgumentNullException("itemsProcessor");
            }

            if (!list.HasExternalDataSource && (list.ItemCount == 0))
            {
                return;
            }

            if (list.HasExternalDataSource && (query.RowLimit == 0))
            {
                query.RowLimit = 0x7fffffff;
            }
            else if ((query.RowLimit == 0) || (query.RowLimit == 0x7fffffff))
            {
                query.RowLimit = (uint)(string.IsNullOrEmpty(query.ViewFields) ? 200 : 0x7d0);
            }

            if (!list.HasExternalDataSource && StrictQuerySemantics)
            {
                query.QueryThrottleMode = SPQueryThrottleOption.Strict;
            }

            do
            {
                SPListItemCollection items = list.GetItems(query);

                try
                {
                    itemsProcessor(items);
                }
                catch (System.Exception exception)
                {
                    if ((errorCallout == null) || errorCallout(items, exception))
                    {
                        throw;
                    }
                }

                query.ListItemCollectionPosition = items.ListItemCollectionPosition;
            } while (!ShouldCancel(IterationGranularity.Item) && query.ListItemCollectionPosition != null);
        }
        /// <summary>
        /// Process ListItems batch by batch
        /// </summary>
        /// <param name="listName">ListName</param>
        /// <param name="camlQuery">CamlQuery</param>
        /// <param name="itemsProcessor">itemprocessor delegate</param>
        /// <param name="errorCallout">error delegate</param>
        public void ProcessListItems(string listName, CamlQuery camlQuery, ItemsProcessor itemsProcessor, ItemsProcessorErrorCallout errorCallout)
        {
            List      list  = _context.Web.Lists.GetByTitle(listName);
            CamlQuery query = camlQuery;

            ListItemCollectionPosition position = null;

            query.ListItemCollectionPosition = position;

            while (true)
            {
                ListItemCollection listItems = list.GetItems(query);
                _context.Load(listItems, items => items.ListItemCollectionPosition);
                _context.ExecuteQuery();
                try
                {
                    itemsProcessor(listItems);
                }
                catch (System.Exception ex)
                {
                    if (errorCallout == null || errorCallout(listItems, ex))
                    {
                        throw;
                    }
                }

                if (listItems.ListItemCollectionPosition == null)
                {
                    return;
                }
                else
                {
                    /*if query contains lookup column filter last batch returns null
                     * by removing the lookup column in paginginfo query will return next records
                     */
                    string        pagingInfo         = listItems.ListItemCollectionPosition.PagingInfo;
                    string[]      parameters         = pagingInfo.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
                    List <string> requiredParameters = new List <string>();
                    foreach (string str in parameters)
                    {
                        if (str.Contains("Paged=") || str.Contains("p_ID="))
                        {
                            requiredParameters.Add(str);
                        }
                    }

                    pagingInfo = string.Join("&", requiredParameters.ToArray());
                    listItems.ListItemCollectionPosition.PagingInfo = pagingInfo;
                    query.ListItemCollectionPosition = listItems.ListItemCollectionPosition;
                }
            }
        }
        public void SearchItem()
        {
            Item searchedItem = new Item
            {
                Title              = Title,
                Description        = Description,
                Price              = Price,
                Sold               = Sold,
                PaymentDistributed = PaymentDistributed,
                Owner              = Owner
            };

            Items = new BindableCollection <Item>(ItemsProcessor.GetItems <Item>(searchedItem));
        }
Beispiel #8
0
        /// <summary>
        /// Populates panel with controls and upserts items to DB after backgroundworker_DoWork is completed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            btnSearch.Enabled       = true;
            btnNextPage.Enabled     = true;
            btnPreviousPage.Enabled = true;

            spinningCircles1.Visible = false;

            if (_items != null)
            {
                PopulatePanelWithControls();
                await ItemsProcessor.SaveItemsToDB(_items);
            }
        }
        public void AddItem()
        {
            Item addedItem = new Item
            {
                Title              = Title,
                Description        = Description,
                Price              = Price,
                Sold               = Sold,
                PaymentDistributed = PaymentDistributed,
                Owner              = Owner
            };

            Items.Add(addedItem);
            ItemsProcessor.InsertItem(addedItem);
            Reset();
        }
        public void TestGetKeywordList()
        {
            IItemsProcessor         itemsProcessor = new ItemsProcessor();
            IList <KeywordListItem> actual         = itemsProcessor.GetKeywordListItems(goodZip, goodCsv).ToList();

            //make sure we found the correct assessment items
            Assert.AreEqual(actual.Count(), 2);

            //ensure that all the item ids match the keywordlistitem ids
            foreach (KeywordListItem kitem in actual)
            {
                foreach (AssessmentItem aitem in kitem.AssessmentItems)
                {
                    Assert.AreEqual(kitem.ItemId, aitem.KeywordListItemId);
                    Assert.IsTrue(aitem.FullPath.Contains(aitem.ItemId));
                }
            }
            IGlossaryAugmenter ga = new GlossaryAugmenter();

            ga.AddItemsToGlossary(goodZip, goodCsv);
        }
 public void PackageNotFoundError()
 {
     IItemsProcessor         itemsProcessor = new ItemsProcessor();
     IList <KeywordListItem> actual         = itemsProcessor.GetKeywordListItems(badZip, goodCsv).ToList();
 }
Beispiel #12
0
 public ItemsController(ItemsProcessor pr)
 {
     itProcessor = pr;
 }
 public ItemsController(
     ItemsProcessor myItemPro
     )
 {
     itemPro = myItemPro;
 }
Beispiel #14
0
 public ItemsController(ItemsProcessor itemsProcessor)
 {
     this.itemsProcessor = itemsProcessor;
 }
 public AddNewItemViewModel()
 {
     Items   = new BindableCollection <Item>(ItemsProcessor.GetItems <Item>());
     Vendors = new BindableCollection <Vendor>(VendorsProcessor.GetVendors <Vendor>());
 }
 public void ProcessListItems(SPList list, string strQuery, bool fRecursive, ItemsProcessor itemsProcessor, ItemsProcessorErrorCallout errorCallout)
 {
     ProcessListItems(list, strQuery, 0, fRecursive, itemsProcessor, errorCallout);
 }
 public void ProcessListItems(SPList list, string strQuery, uint rowLimit, bool fRecursive, ItemsProcessor itemsProcessor, ItemsProcessorErrorCallout errorCallout)
 {
     ProcessListItems(list, strQuery, rowLimit, fRecursive, null, itemsProcessor, errorCallout);
 }
        public void ProcessListItems(SPList list, string strQuery, uint rowLimit, bool fRecursive, SPFolder folder, ItemsProcessor itemsProcessor, ItemsProcessorErrorCallout errorCallout)
        {
            if (list == null)
            {
                throw new ArgumentNullException("list");
            }

            if (itemsProcessor == null)
            {
                throw new ArgumentNullException("itemsProcessor");
            }

            var query = new SPQuery();

            if (!string.IsNullOrEmpty(strQuery))
            {
                query.Query = strQuery;
            }

            query.RowLimit          = rowLimit;
            query.QueryThrottleMode = SPQueryThrottleOption.Override;

            if (folder != null)
            {
                query.Folder = folder;
            }

            if (fRecursive)
            {
                query.ViewAttributes = "Scope=\"RecursiveAll\"";
            }

            ProcessListItems(list, query, itemsProcessor, errorCallout);
        }
		public async Task<SyncState> SyncStepAsync (Action syncProgressChanged)
		{
			switch (SyncState) {
			case SyncState.Start:
				SyncState = SyncState.FindingUser;
				break;
			case SyncState.FindingUser:
				UserKeyStore = new RdioUserKeyStore (await FindUserAsync ());
				SyncState = SyncState.FoundUser;
				break;
			case SyncState.FoundUser:
				SyncState = SyncState.SyncingUserKeys;
				break;
			case SyncState.SyncingUserKeys:
				foreach (var kind in new [] { "owned", "favorites", "subscribed", "collab" })
					await api.LoadUserPlaylists (kind, UserKeyStore);
				await api.LoadFavoritesAndSyncedKeysAsync (UserKeyStore);
				SyncState = SyncState.SyncedUserKeys;
				break;
			case SyncState.SyncedUserKeys:
				SyncState = SyncState.SyncingObjects;
				break;
			case SyncState.SyncingObjects:
				keysProcessor = new ItemsProcessor<string> (
					UserKeyStore.AllKeys.Where (k => !ObjectStore.ContainsKey (k)),
					KeyProcessorAsync,
					chunkCount => {
						TotalObjects = keysProcessor.TotalEnqueued;
						SyncedObjects = keysProcessor.TotalProcessed;
						syncProgressChanged?.Invoke ();
					}
				);

				TotalObjects = keysProcessor.TotalEnqueued;
				SyncedObjects = 0;

				await keysProcessor.ProcessAsync (CancellationToken);

				SyncState = SyncState.SyncedObjects;
				break;
			case SyncState.SyncedObjects:
				SyncState = SyncState.Finished;
				break;
			}

			return SyncState;
		}
 public ItemsController(ItemsProcessor processor)
 {
     _processor = processor;
 }
Beispiel #21
0
        /// <summary>
        /// Process ListItems batch by batch
        /// </summary>
        /// <param name="listName">ListName</param>
        /// <param name="camlQuery">CamlQuery</param>
        /// <param name="itemsProcessor">itemprocessor delegate</param>
        /// <param name="errorCallout">error delegate</param>
        public void ProcessListItems(string listName, CamlQuery camlQuery, ItemsProcessor itemsProcessor, ItemsProcessorErrorCallout errorCallout)
        {
            List list = _context.Web.Lists.GetByTitle(listName);
            CamlQuery query = camlQuery;

            ListItemCollectionPosition position = null;
            query.ListItemCollectionPosition = position;

            while (true)
            {
                ListItemCollection listItems = list.GetItems(query);
                _context.Load(listItems, items => items.ListItemCollectionPosition);
                _context.ExecuteQuery();
                try
                {
                    itemsProcessor(listItems);
                }
                catch (System.Exception ex)
                {
                    if (errorCallout == null || errorCallout(listItems, ex))
                    {
                        throw;
                    }
                }

                if (listItems.ListItemCollectionPosition == null)
                {
                    return;
                }
                else
                {
                    /*if query contains lookup column filter last batch returns null 
                     by removing the lookup column in paginginfo query will return next records
                     */
                    string pagingInfo = listItems.ListItemCollectionPosition.PagingInfo;
                    string[] parameters = pagingInfo.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
                    List<string> requiredParameters = new List<string>();
                    foreach (string str in parameters)
                    {
                        if (str.Contains("Paged=") || str.Contains("p_ID="))
                            requiredParameters.Add(str);
                    }

                    pagingInfo = string.Join("&", requiredParameters.ToArray());
                    listItems.ListItemCollectionPosition.PagingInfo = pagingInfo;
                    query.ListItemCollectionPosition = listItems.ListItemCollectionPosition;
                }

            }

        }