Esempio n. 1
0
        public static void PollingSuppliersMetadataFromUrl(String connString)
        {
            Int32 totalCategory = 0;
            Int32 countCategory = 0;

            List <SupplierUrlInfo> list = DataOperation.GetSupplierUrls(connString);

            totalCategory = list.Count;
            display(String.Format("Polling Suppliers from URL Start ... [{0}]", totalCategory), true, true);
            try
            {
                foreach (SupplierUrlInfo supplierUrl in list)
                {
                    display(String.Format("[{0}/{1}] - [{2}] {3} [{4}] Processing ...", ++countCategory, totalCategory, supplierUrl.Id, supplierUrl.CategoryName, supplierUrl.Tries), false, true);
                    supplierUrl.Update();
                    DataOperation.UpdateSupplierURL(connString, supplierUrl);
                    display(String.Format(" [{0}]", supplierUrl.HasError ? "XXXX" : "Done"), true, false);
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("ERROR: {0}", ex.Message);
            }
            Console.WriteLine("Polling Suppliers End. [{0}]", totalCategory);
        }
Esempio n. 2
0
        public static void PollingSuppliersFromUrlMetadata(String connString, Boolean byWebDriver)
        {
            ChromeDriver driver        = null;
            Boolean      success       = false;
            Int32        totalCategory = 0;
            Int32        countCategory = 0;
            Int64        totalTicks    = 0;

            try
            {
                if (byWebDriver)
                {
                    driver = Utilities.WebDriverExtension.GetChromeDriver(hideBrowser: true, hideCommand: true);
                }
                List <SupplierUrlInfo> list = DataOperation.GetSupplierUrls(connString);
                totalCategory = list.Count;
                display(String.Format("Polling Suppliers from URL Start ... [{0}]", totalCategory), true, true);
                foreach (SupplierUrlInfo supplierUrl in list)
                {
                    Stopwatch stopWatch = new Stopwatch();
                    stopWatch.Start();
                    //display(String.Format("[{0}/{1}] - [{2}] {3} [{4}] Processing ...", ++countCategory, totalCategory, supplierUrl.Id, supplierUrl.CategoryName, supplierUrl.Tries), false, true);
                    display($"[{++countCategory}/{totalCategory}] - [{supplierUrl.Id}] [{supplierUrl.Tries}] Processing ...", false, true);
                    //supplierUrl.ProfileUrl = "http://chukuang.en.alibaba.com/contactinfo.html";
                    //supplierUrl.Id = 69570;
                    SupplierInfo supplier = new SupplierInfo(supplierUrl, driver);
                    if (!supplier.HasError)
                    {
                        success = DataOperation.UpdateSupplier(connString, supplier);
                    }
                    success = DataOperation.UpdateSupplierUrlStatus(connString, supplierUrl, supplier);
                    stopWatch.Stop();
                    totalTicks += stopWatch.Elapsed.Ticks;
                    TimeSpan timeSpan = new TimeSpan((long)(totalTicks / countCategory) * (totalCategory - countCategory));
                    display(String.Format(" [{0}] [{1:d\\.hh\\:mm\\:ss}]", supplier.HasError ? "XX" : supplier.CompanyId, timeSpan), true, false);
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("[Webdriver] ERROR: {0}", ex.Message);
            }
            Console.WriteLine("Polling Suppliers End. [{0}]", totalCategory);
            if (driver != null)
            {
                driver.Quit();
            }
        }
Esempio n. 3
0
        public static void PollingSuppliersFromUrl(String connString)
        {
            WebDriverSettingInfo webDriverSetting = new WebDriverSettingInfo(true, true);
            Boolean success       = false;
            Int32   totalCategory = 0;
            Int32   countCategory = 0;
            Random  random        = new Random();

            List <SupplierUrlInfo> list = DataOperation.GetSupplierUrls(connString);

            totalCategory = list.Count;
            display(String.Format("Polling Suppliers from URL Start ... [{0}]", totalCategory), true, true);
            try
            {
                ChromeDriver  driver = Utilities.WebDriverExtension.GetChromeDriver(hideBrowser: webDriverSetting.HideBrowser, hideCommand: webDriverSetting.HideCommand);
                WebDriverWait wait   = new WebDriverWait(driver, new TimeSpan(0, 3, 0));
                foreach (SupplierUrlInfo supplierUrl in list)
                {
                    display(String.Format("[{0}/{1}] - [{2}] {3} [{4}] Processing ...", ++countCategory, totalCategory, supplierUrl.Id, supplierUrl.CategoryName, supplierUrl.Tries), false, true);
                    try
                    {
                        SupplierInfo supplier = new SupplierInfo(driver, wait, supplierUrl.ProfileUrl, new SupplierCategoryInfo(supplierUrl.CategoryId, supplierUrl.CategoryName, supplierUrl.CategoryLevel));
                        if (!supplier.HasError)
                        {
                            success = DataOperation.UpdateSupplier(connString, supplier);
                        }
                        success = DataOperation.UpdateSupplierUrlStatus(connString, supplierUrl, supplier);
                        display(String.Format(" [{0}]", supplier.HasError ? "XX" : supplier.CompanyId), true, false);
                    }
                    catch (System.Exception ex)
                    {
                        Console.WriteLine("[Post] ERROR: {0}", ex.Message);
                    }
                }
                driver.Quit();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("[Webdriver] ERROR: {0}", ex.Message);
            }
            Console.WriteLine("Polling Suppliers End. [{0}]", totalCategory);
        }