示例#1
0
        private void ProductPriority_Load(object sender, EventArgs e)
        {
            ADIProductManager productManager = new ADIProductManager(Constants.ConnectionString);

            List<AdiProduct> adiProducts = productManager.GetData();
            gridProduct.AutoGenerateColumns = false;
            gridProduct.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
            dv.Table = WebSpider.Data.DatabaseManager.DataParser.BuildDataTable(adiProducts);
            gridProduct.DataSource = adiProducts;
        }
示例#2
0
        private void gridProduct_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridViewCell leastCount = null;
                DataGridViewCell priority = null;
                DataGridViewCell partNo = null;
                if (e.RowIndex > -1 && e.ColumnIndex > -1)
                {
                    leastCount = ((DataGridView)sender).Rows[e.RowIndex].Cells[3];
                    priority = ((DataGridView)sender).Rows[e.RowIndex].Cells[4];
                    partNo = ((DataGridView)sender).Rows[e.RowIndex].Cells[2];
                    ADIProductManager productManager = new ADIProductManager(Constants.ConnectionString);
                    productManager.SetProductPriority(partNo.Value.ToString(), (bool)priority.Value, (int)leastCount.Value);
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#3
0
        public static void CrawlProduct(Object objItem)
        {
            TaskDetailManager taskDetailManager = new TaskDetailManager(Constants.ConnectionString);
            ADIProductManager adiProductManager = new ADIProductManager(Constants.ConnectionString);
            AdiMode mode = AdiMode.CRAWL;
            bool HasError = false;
            TaskDetail taskDetail = (TaskDetail)objItem;
            //Utility.ApplicationLog(String.Format("AdiGlobal product Crawling started for {0}, Ignito Mode - {1}, Download Images - {2}", taskDetail.TaskNameText, taskDetail.IgnitoMode, taskDetail.DownloadImages));
            try
            {

                if (!ReferenceEquals(taskDetail, null))
                {
                    taskDetail.TaskStatusText = Constants.PROCESSING_TEXT;
                    taskDetail.TaskStatus = TaskDetailStatus.Processing;
                    taskDetailManager.UpdateStatus(taskDetail.TaskID, taskDetail.TaskStatusText, taskDetail.TaskStatus);

                    LoginCheck(taskDetail);

                    List<AdiProduct> products = new List<AdiProduct>();
                    if (taskDetail.TaskType == Constants.ADICatagory)
                        products = AdiSpider.ParseCatagoryProducts(taskDetail.TaskNameValue);
                    else
                        products = AdiSpider.GetBrandProducts(taskDetail.TaskNameValue);

                    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, taskDetail.DownloadImages);
                            if (taskDetail.IncognitoMode == false)
                            {
                                AdiSpider.GetProductInventory(p, mode);
                            }
                            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;
                        }
                        taskDetail.TaskStatusText = String.Format("{0} - {1}%", Constants.PROCESSING_TEXT, (index / totalProducts * 100).ToString("0"));
                        taskDetail.TaskStatus = TaskDetailStatus.Processing;
                        taskDetailManager.UpdateStatus(taskDetail.TaskID, taskDetail.TaskStatusText, taskDetail.TaskStatus);
                    }
                    taskDetail.TaskStatusText = Constants.COMPLETED_TEXT;
                    taskDetail.TaskStatus = TaskDetailStatus.Completed;
                    taskDetailManager.UpdateStatus(taskDetail.TaskID, taskDetail.TaskStatusText, taskDetail.TaskStatus);
                    //Utility.ApplicationLog(String.Format("AdiGlobal product Crawling complete for {0}",taskDetail.TaskNameText));
                }
                //if (HasError) throw new Exception();
            }
            catch (TaskCanceledException ex)
            {
            }
            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);
                taskDetail.TaskStatusText = Constants.COMPLETED_ERROR_TEXT;
                taskDetail.TaskStatus = TaskDetailStatus.CompletedWithError;
                taskDetailManager.UpdateStatus(taskDetail.TaskID, taskDetail.TaskStatusText, taskDetail.TaskStatus);
            }
        }
示例#4
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;
        }
示例#5
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);
            }
        }