Ejemplo n.º 1
0
        public static List<AdiProduct> GetAllPriorityProducts()
        {
            List<AdiProduct> products = new List<AdiProduct>();
            try
            {
                //FinalTableManager fadapter = new FinalTableManager(finalcon);
                ADIProductManager fadapter = new ADIProductManager(Constants.ConnectionString);
                //fadapter.Connection = finalcon;

                //var oDt = fadapter.GetPriorityData(true);
                //products = oDt.Select(x => new AdiProduct()
                //        {
                //            AdiNumber = x.AID_PART,
                //            LastUpdateDatetime = DateTime.ParseExact(x.AID_LastUpdate, Settings.GetValue("DateFormat"), System.Globalization.CultureInfo.InvariantCulture),
                //            LeastCount = x.ADI_LeastCount == null ? 0 : (int) x.ADI_LeastCount
                //        }
                //    ).ToList();
                return fadapter.GetAllPriorityProducts();
            }
            catch (Exception ex)
            {
                Utility.ErrorLog(ex, null);
            }
            return products;
        }
Ejemplo n.º 2
0
        public static void ProcessProductLeastCount()
        {
            TaskDetailManager taskDetailManager = new TaskDetailManager(Constants.ConnectionString);
            ADIProductManager adiProductManager = new ADIProductManager(Constants.ConnectionString);
            AdiMode mode = AdiMode.CRAWL;
            bool HasError = false;
            //Utility.ApplicationLog(String.Format("AdiGlobal product Crawling started for {0}, Ignito Mode - {1}, Download Images - {2}", taskDetail.TaskNameText, taskDetail.IgnitoMode, taskDetail.DownloadImages));
            try
            {
                LoginCheck(new TaskDetail() { IncognitoMode = false });

                List<AdiProduct> products = new List<AdiProduct>();
                products = adiProductManager.GetAllPriorityProducts();

                double totalProducts = products.Count;

                for (int index = 0; index < products.Count; index++)
                {
                    AdiProduct p = products[index];
                    //Utility.ApplicationLog(String.Format("Processing Adi Product {0} {1}", p.AdiNumber, p.ProductDescription));
                    try
                    {
                        PingCheck();
                        AdiSpider.SaveProduct(p, mode);
                        AdiSpider.GetProductDetails(p, false);
                        double totalInventory = AdiSpider.GetProductInventory(p, mode);
                        if (totalInventory <= p.LeastCount)
                        {
                            //Send Mail
                            Utility.SendAlertMail("Stock Alert", "Product- " + p.AdiNumber + " Live Stock Quantity- " + totalInventory.ToString());
                            //Utility.LogFile(fileName, "Mail Send-" + productsList[index].AdiNumber);
                        }
                        //exportManager.Insert(Constants.SiteName.ADIGLOBAL, Constants.ExportType.ADI_PRODUCT_CRAWL, p.AdiNumber);

                    }
                    catch (Exception ex)
                    {
                        //Utility.ApplicationLog(String.Format("Error Processing Adi Product {0} {1}", p.AdiNumber, p.ProductDescription));
                        String json = JsonConvert.SerializeObject(p, Formatting.None);
                        Utility.ErrorLog(ex, json);
                        if (Settings.GetValue("MailErrors") == true)
                        {
                            Utility.ApplicationLog(String.Format("{0} {1}", p.PartNumber, ex.Message), Constants.EmailErrorFile);
                        }
                        HasError = true;
                    }
                }
            }
            catch (Exception ex)
            {
                //Utility.ApplicationLog(String.Format("AdiGlobal product Crawling completed with errors for {0}", taskDetail.TaskNameText));
                String json = null;
                Utility.ErrorLog(ex, json);
                if (Settings.GetValue("MailErrors") == true)
                    Utility.ApplicationLog(String.Format("{0}", ex.Message), Constants.EmailErrorFile);
            }
        }