예제 #1
0
        public static void Process()
        {
            Utility.LogFile(fileName, "Process Start");
            if (!processing)
            {
                processing = true;
                AdiSpider adiSpider = new AdiSpider();

                try
                {
                    //AdiSpider AdiSpider = new AdiSpider();
                    if (adiSpider.Login())
                    {
                        Utility.LogFile(fileName, "Login Done");
                        List <AdiProduct> productsList = adiSpider.GetAllPriorityProducts();
                        Utility.LogFile(fileName, "Product Found-" + productsList.Count.ToString());
                        for (int index = 0; index < productsList.Count; index++)
                        {
                            //if (productsList[index].LastUpdateDatetime <= System.DateTime.Now.AddDays(-1))
                            //{
                            AdiProduct product = productsList[index];

                            //product = oSpider.GetProduct(product);
                            //oSpider.SaveProduct(product, false);
                            //oSpider.GetProductDetails(product, true);
                            double total = adiSpider.GetProductInventory(product, false);
                            if (total < productsList[index].LeastCount)
                            {
                                //Send Mail
                                Utility.SendAlertMail("Stock Alert", "Product- " + productsList[index].AdiNumber + " Stock Quantity- " + total.ToString());
                                Utility.LogFile(fileName, "Mail Send-" + productsList[index].AdiNumber);
                            }
                            //}
                        }
                    }
                    else
                    {
                        Utility.SendAlertMail("Login Failed", "Login Failed for http://adiglobal.us");
                    }
                    Utility.LogFile(fileName, "Process End");
                }
                catch (Exception ex) {
                    Utility.ErrorLog(ex, null);
                }
                processing = false;
            }
        }
예제 #2
0
        private void RunAdiSchedules()
        {
            List <TaskDetail> tasksList = new TasksScheduler().GetPendingSchedules(Constants.SiteName.ADIGLOBAL);

            for (int index = 0; index < tasksList.Count; index++)
            {
                if (tasksList[index].TaskMode == Constants.TaskMode.ADI_CRAWL)
                {
                    AdiSpider.CrawlProduct(tasksList[index]);
                }
                else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_UPDATE)
                {
                    AdiSpider.UpdateProduct(tasksList[index]);
                }
                else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_CLEARANCE_ZONE)
                {
                    AdiSpider.GetClearanzeZone(tasksList[index]);
                }
                else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_HOT_DEALS)
                {
                    AdiSpider.GetHotDeals(tasksList[index]);
                }
                else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_ONLINE_SPECIALS)
                {
                    AdiSpider.GetOnlineSpecials(tasksList[index]);
                }
                else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_SALE_CENTER)
                {
                    AdiSpider.GetSaleCenter(tasksList[index]);
                }
                else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_IN_STOCK)
                {
                    AdiSpider.GetInStockItems(tasksList[index]);
                }
                else
                {
                    AdiSpider.ProcessProductLeastCount();
                }
                TaskheaderUpdate(tasksList[index].TaskHeaderID);
            }
        }