private static void ExportProduct(string productCode) { String ConnStr = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=True", Settings.GetValue("WebSpiderDB")); InProduct product = new InProduct(); product.Code = productCode; var secLockProduct = new InProductManager(Constants.ConnectionString).GetData(product); if (secLockProduct.Count() == 0) return; product = secLockProduct[0]; FinalTable ft = new FinalTable(); ft.SLD_SOURCE_ID = String.Empty; ft.SLD_COST = product.YourPrice; ft.SLD_PART = product.Code; ft.SLD_IMG1 = product.ImageUrl1; ft.SLD_IMG2 = product.ImageUrl2; ft.SLD_VENDOR = product.ManufacturerName; ft.SLD_INV = product.Stock; ft.SLD_DESC = product.Description; ft.SLD_TECHDOC = product.TechDoc; ft.SLD_LastUpdate = DateTime.Now.ToString(Settings.GetValue("DateFormat")); new FinalTableManager(ConnStr).SaveProduct(ft); }
private void GetCategoryProductsFromSite(InCategory category) { String Url = string.Format("http://www.seclock.com/products/ajax/advanced-search-results.asp?i=&m=&c={0}&search_in=all", category.Code); HtmlAgilityPack.HtmlDocument document = browser.GetWebRequest(Url); HtmlNodeCollection productNodes = document.DocumentNode.SelectNodes("//a[@class='product-detail-from-search']"); foreach (HtmlNode productNode in productNodes) { InProduct product = new InProduct(); product.Code = productNode.InnerHtml; var dbProducts = new InProductManager(Constants.ConnectionString).GetData(product); if (dbProducts.Count() > 0) { product = dbProducts[0]; } product.Name = productNode.InnerHtml; product.Url = productNode.Attributes["href"].Value; product.CategoryName = category.Name; product.CategoyCode = category.Code; new InProductManager(Constants.ConnectionString).Save(product); category.Products.Add(product); } }
public void GetProductsByManufacturerFromSite(InManufacturer manufacturer) { String Url = "http://www.seclock.com/products/items.asp?m=" + manufacturer.Code; if (!LoggedIn) Login(); HtmlAgilityPack.HtmlDocument document = browser.GetWebRequest(Url); HtmlNodeCollection seriesNodes = document.DocumentNode.SelectNodes("//ul[@class='products']/li"); manufacturer.SeriesList = new List<InManufacturerSeries>(); if (!ReferenceEquals(seriesNodes, null)) { foreach (HtmlNode seriesNode in seriesNodes) { InManufacturerSeries series = new InManufacturerSeries(); var seriesDetail = seriesNode.SelectSingleNode("a"); if (!ReferenceEquals(seriesDetail, null)) { series.Name = seriesNode.SelectSingleNode("a").InnerText; series.Products = new List<InProduct>(); HtmlNodeCollection anchorNodes = seriesNode.SelectNodes("ul/li/a"); foreach (HtmlNode anchorNode in anchorNodes) { InProduct product = new InProduct(); product.Code = anchorNode.InnerHtml; var dbProducts = new InProductManager(Constants.ConnectionString).GetData(product); if (dbProducts.Count() > 0) { product = dbProducts[0]; } product.Name = anchorNode.InnerText; product.Url = anchorNode.Attributes["href"].Value; product.ManufacturerSeries = series.Name; product.ManufacturerName = manufacturer.Name; product.ManufacturerCode = manufacturer.Code; new InProductManager(Constants.ConnectionString).Save(product); series.Products.Add(product); } new InManufacturerSeriesManager(Constants.ConnectionString).Save(manufacturer.Code, series); manufacturer.SeriesList.Add(series); } } exportManager.Insert(Constants.SiteName.SECLOCK, Constants.ExportType.SECLOCK_MANUFACTURER_SERIES, manufacturer.Code); } }