コード例 #1
0
        private void AssignTexboxesProshop(string rawHtml)
        {
            var pScraper = new ProshopScraper();

            if (pScraper.FetchProshopTitle(rawHtml) != string.Empty ||
                pScraper.FetchProshopPNumber(rawHtml) != string.Empty ||
                pScraper.FetchProshopPrice(rawHtml) != string.Empty ||
                pScraper.FetchProshopStockStatus(rawHtml) != string.Empty)
            {
                try
                {
                    _addedProduct.pPrice = CheckPrice.CheckPriceFormat(pScraper.FetchProshopPrice(rawHtml));
                }
                catch (FormatException)
                {
                    MessageBox.Show("Please provide a price containing only numbers and a single dot.",
                                    "Price contains letters.",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                    _addedProduct.pPrice = 0.00;
                }
                catch (OverflowException)
                {
                    MessageBox.Show("The price is too high.", "Price too high.",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                    _addedProduct.pPrice = 0.00;
                }
                catch (PriceTooLongException)
                {
                    MessageBox.Show("The price is too long.", "Price too long.",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                    _addedProduct.pPrice = 0.00;
                }
                catch (PriceContainsCommaException)
                {
                    MessageBox.Show("Please use a dot instead of comma in the product price.", "Price contains comma.",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                    _addedProduct.pPrice = 0.00;
                }
                _addedProduct.pName   = pScraper.FetchProshopTitle(rawHtml);
                _addedProduct.pNumber = pScraper.FetchProshopPNumber(rawHtml);

                _addedProduct.PStockStatus = pScraper.FetchProshopStockStatus(rawHtml);
                _addedProduct.pType        =
                    (Product.ProductType)
                    Enum.Parse(typeof(Product.ProductType),
                               pScraper.ProshopPTypeMapping(pScraper.FetchProshopPType(AddProductUrlTextBox.Text)));
            }
            else
            {
                MessageBox.Show("No product found at the given URL.");
            }
        }
コード例 #2
0
        private void AssignTexboxesProshop(string rawHtml)
        {
            var pScraper = new ProshopScraper();

            if (pScraper.FetchProshopTitle(rawHtml) != string.Empty ||
                pScraper.FetchProshopPNumber(rawHtml) != string.Empty ||
                pScraper.FetchProshopPrice(rawHtml) != string.Empty ||
                pScraper.FetchProshopStockStatus(rawHtml) != string.Empty)
            {
                PNameTxtBox.Text           = pScraper.FetchProshopTitle(rawHtml);
                PNumberTxtBox.Text         = pScraper.FetchProshopPNumber(rawHtml);
                PPriceTxtBox.Text          = pScraper.FetchProshopPrice(rawHtml);
                PStockStatus.Text          = pScraper.FetchProshopStockStatus(rawHtml);
                PTypeCombobox.SelectedItem =
                    (Product.ProductType)
                    Enum.Parse(typeof(Product.ProductType),
                               pScraper.ProshopPTypeMapping(pScraper.FetchProshopPType(PUrlTxtBox.Text)));
            }
            else
            {
                MessageBox.Show("No product found at the given URL.");
            }
        }