Exemplo n.º 1
0
        internal static Int32 UpdateProductCategory(String connString, SupplierCategoryInfo category)
        {
            DataTable dataTable = SQLExtension.GetDataTableFromStoredProcedure(connString: connString, storedProcedureName: "[qwi].[AB.UpdateProductCategory]", parameters: category.SQLParameters);

            SQLResultStatus = dataTable.SerializeFirst <SQLResultStatusInfo>();
            return(SQLResultStatus.Id);
        }
Exemplo n.º 2
0
        public virtual bool AddSupplierCategory(SupplierCategoryInfo entity)
        {
            string    SqlAdd = null;
            DataTable DtAdd  = null;
            DataRow   DrAdd  = null;

            SqlAdd = "SELECT TOP 0 * FROM Supplier_Category";
            DtAdd  = DBHelper.Query(SqlAdd);
            DrAdd  = DtAdd.NewRow();

            DrAdd["Supplier_Cate_ID"]         = entity.Supplier_Cate_ID;
            DrAdd["Supplier_Cate_Name"]       = entity.Supplier_Cate_Name;
            DrAdd["Supplier_Cate_Parentid"]   = entity.Supplier_Cate_Parentid;
            DrAdd["Supplier_Cate_SupplierID"] = entity.Supplier_Cate_SupplierID;
            DrAdd["Supplier_Cate_Sort"]       = entity.Supplier_Cate_Sort;
            DrAdd["Supplier_Cate_Site"]       = entity.Supplier_Cate_Site;

            DtAdd.Rows.Add(DrAdd);
            try
            {
                DBHelper.SaveChanges(SqlAdd, DtAdd);
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DtAdd.Dispose();
            }
        }
Exemplo n.º 3
0
        internal static bool UpdateSupplierCategoryStatus(string connString, SupplierCategoryInfo category)
        {
            Boolean success = false;
            List <KeyValuePair <String, Object> > parameters = getSQLParametersStatus(category);
            DataTable dataTable = SQLExtension.GetDataTableFromStoredProcedure(connString: connString, storedProcedureName: "[qwi].[AB.UpdateCategoryStatus]", parameters: parameters);

            SQLResultStatus = dataTable.SerializeFirst <SQLResultStatusInfo>();
            success         = !StatusExtension.HasError;
            return(success);
        }
Exemplo n.º 4
0
        private static List <KeyValuePair <String, Object> > getSQLParametersStatus(SupplierCategoryInfo category)
        {
            List <KeyValuePair <String, Object> > parameters = new List <KeyValuePair <String, Object> >()
            {
                new KeyValuePair <String, Object>("@PostCode", category.PostCode),
                new KeyValuePair <String, Object>("@Id", category.Id),
                new KeyValuePair <String, Object>("@Comments", category.HasError? category.Errors.ToString2():String.Empty)
            };

            return(parameters);
        }
Exemplo n.º 5
0
        internal static Int32 UpdateSupplierCategory(String connString, SupplierCategoryInfo supplierCategory)
        {
            if (String.IsNullOrEmpty(supplierCategory.Url))
            {
                SQLResultStatus.Status = "***";
            }
            DataTable dataTable = SQLExtension.GetDataTableFromStoredProcedure(connString: connString, storedProcedureName: "[qwi].[AB.UpdateSupplierCategory]", parameters: supplierCategory.SQLParameters);

            SQLResultStatus = dataTable.SerializeFirst <SQLResultStatusInfo>();
            return(SQLResultStatus.Id);
        }
Exemplo n.º 6
0
        public virtual IList <SupplierCategoryInfo> GetSupplierCategorys(QueryInfo Query)
        {
            int PageSize;
            int CurrentPage;
            IList <SupplierCategoryInfo> entitys = null;
            SupplierCategoryInfo         entity = null;
            string        SqlList, SqlField, SqlOrder, SqlParam, SqlTable;
            SqlDataReader RdrList = null;

            try
            {
                CurrentPage = Query.CurrentPage;
                PageSize    = Query.PageSize;
                SqlTable    = "Supplier_Category";
                SqlField    = "*";
                SqlParam    = DBHelper.GetSqlParam(Query.ParamInfos);
                SqlOrder    = DBHelper.GetSqlOrder(Query.OrderInfos);
                SqlList     = DBHelper.GetSqlPage(SqlTable, SqlField, SqlParam, SqlOrder, CurrentPage, PageSize);
                RdrList     = DBHelper.ExecuteReader(SqlList);
                if (RdrList.HasRows)
                {
                    entitys = new List <SupplierCategoryInfo>();
                    while (RdrList.Read())
                    {
                        entity = new SupplierCategoryInfo();
                        entity.Supplier_Cate_ID         = Tools.NullInt(RdrList["Supplier_Cate_ID"]);
                        entity.Supplier_Cate_Name       = Tools.NullStr(RdrList["Supplier_Cate_Name"]);
                        entity.Supplier_Cate_Parentid   = Tools.NullInt(RdrList["Supplier_Cate_Parentid"]);
                        entity.Supplier_Cate_SupplierID = Tools.NullInt(RdrList["Supplier_Cate_SupplierID"]);
                        entity.Supplier_Cate_Sort       = Tools.NullInt(RdrList["Supplier_Cate_Sort"]);
                        entity.Supplier_Cate_Site       = Tools.NullStr(RdrList["Supplier_Cate_Site"]);

                        entitys.Add(entity);
                        entity = null;
                    }
                }
                return(entitys);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (RdrList != null)
                {
                    RdrList.Close();
                    RdrList = null;
                }
            }
        }
Exemplo n.º 7
0
        public virtual bool EditSupplierCategory(SupplierCategoryInfo entity)
        {
            string    SqlAdd = null;
            DataTable DtAdd  = null;
            DataRow   DrAdd  = null;

            SqlAdd = "SELECT * FROM Supplier_Category WHERE Supplier_Cate_ID = " + entity.Supplier_Cate_ID;
            DtAdd  = DBHelper.Query(SqlAdd);
            try
            {
                if (DtAdd.Rows.Count > 0)
                {
                    DrAdd = DtAdd.Rows[0];
                    DrAdd["Supplier_Cate_ID"]         = entity.Supplier_Cate_ID;
                    DrAdd["Supplier_Cate_Name"]       = entity.Supplier_Cate_Name;
                    DrAdd["Supplier_Cate_Parentid"]   = entity.Supplier_Cate_Parentid;
                    DrAdd["Supplier_Cate_SupplierID"] = entity.Supplier_Cate_SupplierID;
                    DrAdd["Supplier_Cate_Sort"]       = entity.Supplier_Cate_Sort;
                    DrAdd["Supplier_Cate_Site"]       = entity.Supplier_Cate_Site;

                    DBHelper.SaveChanges(SqlAdd, DtAdd);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DtAdd.Dispose();
            }
            return(true);
        }
Exemplo n.º 8
0
        public virtual SupplierCategoryInfo GetSupplierCategoryByIDSupplier(int ID, int Supplier_ID)
        {
            SupplierCategoryInfo entity  = null;
            SqlDataReader        RdrList = null;

            try
            {
                string SqlList;
                SqlList = "SELECT * FROM Supplier_Category WHERE Supplier_Cate_SupplierID=" + Supplier_ID + " And Supplier_Cate_ID = " + ID;
                RdrList = DBHelper.ExecuteReader(SqlList);
                if (RdrList.Read())
                {
                    entity = new SupplierCategoryInfo();

                    entity.Supplier_Cate_ID         = Tools.NullInt(RdrList["Supplier_Cate_ID"]);
                    entity.Supplier_Cate_Name       = Tools.NullStr(RdrList["Supplier_Cate_Name"]);
                    entity.Supplier_Cate_Parentid   = Tools.NullInt(RdrList["Supplier_Cate_Parentid"]);
                    entity.Supplier_Cate_SupplierID = Tools.NullInt(RdrList["Supplier_Cate_SupplierID"]);
                    entity.Supplier_Cate_Sort       = Tools.NullInt(RdrList["Supplier_Cate_Sort"]);
                    entity.Supplier_Cate_Site       = Tools.NullStr(RdrList["Supplier_Cate_Site"]);
                }

                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (RdrList != null)
                {
                    RdrList.Close();
                    RdrList = null;
                }
            }
        }
Exemplo n.º 9
0
        private static List <KeyValuePair <String, Object> > getSQLParametersStatus(String url, String status, String errorMessage, SupplierCategoryInfo category)
        {
            List <KeyValuePair <String, Object> > parameters = new List <KeyValuePair <String, Object> >()
            {
                new KeyValuePair <String, Object>("@ProfileUrl", url),
                new KeyValuePair <String, Object>("@Status", status),
                new KeyValuePair <String, Object>("@ErrorMessage", errorMessage),
                new KeyValuePair <String, Object>("@CategoryId", category.Id),
                new KeyValuePair <String, Object>("@CategoryCode", category.FullCode)
            };

            return(parameters);
        }
Exemplo n.º 10
0
        internal static SQLResultStatusInfo UpdateSupplierURL(String connString, String url, String status, String errorMessage, SupplierCategoryInfo category)
        {
            List <KeyValuePair <String, Object> > parameters = getSQLParametersStatus(url, status, errorMessage, category);
            DataTable dataTable = SQLExtension.GetDataTableFromStoredProcedure(connString: connString, storedProcedureName: "[qwi].[AB.UpdateSupplierURL]", parameters: parameters);

            return(dataTable.SerializeFirst <SQLResultStatusInfo>());
        }
Exemplo n.º 11
0
 public virtual bool EditSupplierCategory(SupplierCategoryInfo entity)
 {
     return(MyDAL.EditSupplierCategory(entity));
 }
Exemplo n.º 12
0
        private static Boolean pollingSupplierUrls(String connString, ChromeDriver driver, WebDriverWait wait, SupplierCategoryInfo supplierCategory)
        {
            Boolean success = true;
            Random  random = new Random();
            Int32   totalPage, totalPageLast, currentPage;
            Int32   count  = 0;
            String  status = Utilities.Utilities.GetCurrentMethodName(); // "pollingSupplierUrls";

            try
            {
                driver.Navigate().GoToUrl(supplierCategory.Url);
                if (driver.PageSource.Contains("dpl-board-alert-large"))
                {
                    supplierCategory.Errors[status] = driver.GetElementValue(wait, "//div[@class='dpl-board-alert-large']/strong");
                }
                else
                {
                    totalPage     = getTotalPages(driver, wait);
                    totalPageLast = 0;
                    //String rootUrl = String.Empty;
                    if (totalPage > 0)
                    {
                        //rootUrl = driver.GetElementValue(wait, "//div[@class='ui2-pagination-pages']/a[@class='next']", "href");
                        //rootUrl = rootUrl.Substring(0, rootUrl.Length - 1);
                        do
                        {
                            currentPage = getCurrentPage(driver, wait, "//div[@class='ui2-pagination-pages']/span[@class='current']");
                            display(totalPage == totalPageLast? $"[{currentPage}]": $"[{currentPage}/{totalPage}]", isWriteLine: false, isPositionKept: false);
                            totalPageLast = totalPage;
                            //if (currentPage < 29)
                            //{
                            //    currentPage = 29;
                            //    driver.Navigate().GoToUrl("https://www.alibaba.com/catalogs/corporations/CID141905/29");
                            //}
                            List <String> urlList = getUrlList(driver, wait);
                            if (urlList.Count > 0)
                            {
                                count += urlList.Count;
                                updateSupplierUrls(connString, supplierCategory, urlList);
                                //display(String.Format(".", ""), false, false);
                            }
                            //String gotoUrl = String.Format("{0}{1}", rootUrl, currentPage + 1);
                            String gotoUrl = driver.GetElementValue(wait, "//div[@class='ui2-pagination-pages']/a[@class='next']", "href");
                            if (!String.IsNullOrEmpty(gotoUrl))
                            {
                                //if (currentPage < totalPage && gotoUrl.IsWebSiteAvailable())
                                //{
                                driver.Navigate().GoToUrl(gotoUrl);
                                if (driver.PageSource.Contains("ui2-pagination-pages"))
                                {
                                    totalPage = getTotalPages(driver, wait);
                                    if (totalPage < 0)
                                    {
                                        totalPage = currentPage;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                                //}
                                //else break;
                            }
                            else
                            {
                                break;
                            }
                        } while (true);
                    }
                }
                success = DataOperation.UpdateSupplierCategoryStatus(connString, supplierCategory);
                //System.Threading.Thread.Sleep(random.Next(20000, 30000));
                display(supplierCategory.HasError ? "[XX]" : $"[{supplierCategory.CountAdded}/{count}] Done", false, false);
            }
            catch (System.Exception ex)
            {
                display(String.Format("\n[pollingSuppliers] ERROR: {0}", ex.Message), true, true);
                success = false;
            }
            return(success);
        }