public IList <ProductRawData> Get(Product product) { var result = new List <ProductRawData>(); var searchWebPage = new HtmlWeb(); var searchDocument = searchWebPage.Load(searchUrl + product.Description + "&a=false"); // SearchEncode(product.Description)); var searchResultNodes = searchDocument.DocumentNode.SelectNodes("//*/span[@class='itens-section']/a"); if (searchResultNodes == null) { Console.WriteLine($"Produto {product.Sku} não encontrado"); return(null);// buscar apenas por códigos [a-zA-Z0-9].?[0-9][0-9] } else { foreach (var node in searchResultNodes) { var productRaw = new ProductRawData(); var url = node.Attributes["href"].DeEntitizeValue; productRaw.Url = baseUrl + url; productRaw.Sku = GetSkuFromUrl(productRaw.Url); productRaw.Vendor = GetVendorFromSKU(productRaw.Sku); productRaw.Platform = PlatformName; productRaw.CostPriceFrom = node.SelectSingleNode("//span[@class='block-from-price-value']").InnerText; productRaw.CostPrice = node.SelectSingleNode("//span[@class='item-main-pricing']").InnerText; result.Add(productRaw); } } return(result); }
public List <ProductRawData> GetSystemProducts() { DataTable dataTable = queries.GetSystemProducts(); if (dataTable == null) { return(null); } List <ProductRawData> productsList = new List <ProductRawData>(); foreach (DataRow row in dataTable.Rows) { String[] tpStr = new String[dataTable.Columns.Count]; int i = 0; foreach (DataColumn col in dataTable.Columns) { tpStr[i] = row[col].ToString(); i++; } ProductRawData tempData = new ProductRawData(); tempData.Handler(tpStr); productsList.Add(tempData); } return(productsList); }
private void RemoveCheckedProduct_Click(object sender, EventArgs e) { List <ProductRawData> removeList = new List <ProductRawData>(); for (int i = 0; i < ProductsList.Items.Count; i++) { if (ProductsList.GetItemChecked(i)) { ProductRawData tempData = new ProductRawData(); tempData.RefactorString(ProductsList.Items[i].ToString()); removeList.Add(tempData); } } for (int i = 0; i < removeList.Count; i++) { bool DONE = controller.RemoveProduct(removeList[i].ID); if (DONE) { MessageBox.Show(removeList[i].ToString() + " Removed"); } else { MessageBox.Show(removeList[i].ToString() + " Remove Failed"); } } RefreshProductsList_Click(sender, e); }
public StoreProduct(String storeProductID, String storeID, ProductRawData product, BrandRawData brand, double price, int amount) { this.storeProductID = storeProductID; this.storeID = storeID; this.product = product; this.brand = brand; this.price = price; this.amount = amount; }
public StoreProduct() { this.storeProductID = null; this.storeID = null; this.product = new ProductRawData(); this.brand = new BrandRawData(); this.price = 0.0; this.amount = 0; }
private List <ProductRawData> LoadProductDetails(string url) { var result = new List <ProductRawData>(); // productRaw.Url = url; // $x("//div[contains(@class, 'pdpparceirosinfo')]") var detailWebPage = new HtmlWeb(); var detailDocument = detailWebPage.Load(url); var nodes = detailDocument.DocumentNode.SelectNodes("//div[contains(@class, 'pdpparceirosinfo')]"); if (nodes != null) { foreach (var node in nodes) { var productRaw = new ProductRawData(); productRaw.Url = url; productRaw.CostPriceInPoints = detailDocument.DocumentNode.SelectSingleNode("//span[@class='ptrsku-price')]").InnerText; productRaw.CostPriceFrom = productRaw.CostPriceInPoints; productRaw.CostPrice = productRaw.CostPriceInPoints; var imageUrl = detailDocument.DocumentNode.SelectSingleNode("//span[@class='ptr-image')]/img").Attributes["src"].DeEntitizeValue; if (imageUrl.EndsWith("casasbahia.png")) { productRaw.Vendor = "Casas Bahia"; } else if (imageUrl.EndsWith("pontofrio.png")) { productRaw.Vendor = "Ponto Frio"; } else if (imageUrl.EndsWith("extra.png")) { productRaw.Vendor = "Ponto Frio"; } result.Add(productRaw); } } else { var productRaw = new ProductRawData(); var priceNode = detailDocument.DocumentNode.SelectSingleNode("//span[@class='prodprice']"); if (priceNode != null) { productRaw.CostPriceInPoints = priceNode.InnerText; productRaw.CostPriceFrom = productRaw.CostPriceInPoints; productRaw.CostPrice = productRaw.CostPriceInPoints; productRaw.Platform = PlatformName; result.Add(productRaw); } } return(result); }
private void BAddStoreProduct_Click(object sender, EventArgs e) { if (SystemProductsList.SelectedItem == null || SystemBrandsList.SelectedItem == null) { MessageBox.Show("Please select brand and product"); return; } String product = SystemProductsList.SelectedItem.ToString(); String Brand = SystemBrandsList.SelectedItem.ToString(); ProductRawData productRawData = new ProductRawData(); productRawData.RefactorString(product); BrandRawData brandRawData = new BrandRawData(); brandRawData.RefactorString(Brand); InputData inputData = new InputData("price", "amount", "Submit Product"); inputData.ShowDialog(); StoreProduct storeProduct = new StoreProduct("0", controllerStore.GetStoreID(), productRawData, brandRawData, price, amount); StoreCommandInvoker invoker = new StoreCommandInvoker(); IStoreCommand command = new AddCommand(); CommandData commandData = new CommandData(); commandData.UserIDCollab = controllerSO.storeOwner.Data.ID; commandData.UsernameCollab = controllerSO.storeOwner.Data.userName; commandData.CmdType = "Add"; commandData.ProductID = storeProduct.storeProductID; commandData.ProductName = storeProduct.product.Name; commandData.PAmount = storeProduct.amount; commandData.Price = storeProduct.price; commandData.StoreID = storeProduct.storeID; bool DONE = invoker.DoCommand(command, commandData, this.collMode, storeProduct); //controllerStoreProduct.AddStoreProduct(controllerStore.GetStoreID(), storeProduct); if (DONE) { MessageBox.Show("Product Added"); } else { MessageBox.Show("Product Add failed"); } BShowStoreProduct_Click(sender, e); }
private void LoadProductDetails(ProductRawData productRaw, string url) { productRaw.Url = url; var detailWebPage = new HtmlWeb(); var detailDocument = detailWebPage.Load(productRaw.Url); var descriptionNode = detailDocument.DocumentNode.SelectSingleNode("//*[@id='produto:formProduto:produtoNome']"); if (descriptionNode == null) { return; } productRaw.Description = descriptionNode?.InnerText; productRaw.CostPriceFrom = detailDocument.DocumentNode.SelectSingleNode("//span[contains(@class, 'produto-reference-price')]/strike").InnerText; productRaw.CostPrice = detailDocument.DocumentNode.SelectSingleNode("//span[contains(@class, 'produto-reference-price')]/span[@class='preco-reais-acumulo']").InnerText; }
public void LoadProductList() { for (int row = 2; _worksheet.Cells[row, 1].Value != null; row++) { var productRawData = new ProductRawData(); productRawData.Description = _worksheet.Cells[row, 1].Value.ToString(); productRawData.Sku = _worksheet.Cells[row, 2].Value.ToString(); productRawData.Category = _worksheet.Cells[row, 3].Value.ToString(); productRawData.Brand = _worksheet.Cells[row, 4].Value.ToString(); productRawData.CostPriceFrom = _worksheet.Cells[row, 5].Value.ToString(); productRawData.CostPrice = _worksheet.Cells[row, 6].Value.ToString(); productRawData.CostPriceInPoints = _worksheet.Cells[row, 7].Value.ToString(); productRawData.Discount = _worksheet.Cells[row, 8].Value.ToString(); productRawData.Vendor = _worksheet.Cells[row, 9].Value.ToString(); productRawData.Url = _worksheet.Cells[row, 10].Value.ToString(); productRawData.Platform = "excel-import"; _productRawDataList.Add(productRawData); } }
public Product GetProduct(ProductRawData productRaw) { var product = new Product(); product.Brand = productRaw.Brand; product.Vendor = productRaw.Vendor; product.Url = productRaw.Url; product.Sku = productRaw.Sku; product.Description = productRaw.Description; product.Platform = productRaw.Platform; decimal discount; decimal costPriceInPoints; decimal costPriceFrom; decimal costPrice; if (decimal.TryParse(productRaw.Discount, out discount)) { product.Discount = discount; } if (decimal.TryParse(productRaw.CostPriceInPoints, out costPriceInPoints)) { product.CostPriceInPoints = costPriceInPoints; } if (decimal.TryParse(productRaw.CostPriceFrom, out costPriceFrom)) { product.CostPriceFrom = costPriceFrom; } if (decimal.TryParse(productRaw.CostPrice, out costPrice)) { product.CostPrice = costPrice; } //product.Discount = decimal.Parse(, NumberStyles.Any, CultureInfo.CurrentCulture); //product.CostPriceInPoints = decimal.Parse(productRaw.CostPriceInPoints, NumberStyles.Any, CultureInfo.CurrentCulture); //product.CostPriceFrom = decimal.Parse(productRaw.CostPriceFrom, NumberStyles.Any, CultureInfo.CurrentCulture); //product.CostPrice = decimal.Parse(productRaw.CostPrice, NumberStyles.Any, CultureInfo.CurrentCulture); return(product); }