示例#1
0
        /// <summary>
        /// 保存数据到db
        /// </summary>
        /// <param name="httpResults"></param>
        /// <returns></returns>
        public static void SaveProductCategoryToDB(List <ProductCategory> productCategoryList)
        {
            if (productCategoryList == null)
            {
                return;
            }

            if (productCategoryList.Count <= 0)
            {
                return;
            }

            DBBaseDAL <ProductCategory> productCategoryDAL = new DBBaseDAL <ProductCategory>();

            foreach (var item in productCategoryList)
            {
                try
                {
                    productCategoryDAL.Add(item);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
        }
示例#2
0
        /// <summary>
        /// 获取所有ProductCategory
        /// </summary>
        /// <returns></returns>
        public static List <ProductCategory> GetAllProductCategory()
        {
            if (CacheAllProductCategory.Count > 0)
            {
                return(CacheAllProductCategory);
            }

            //从数据库获取
            DBBaseDAL <ProductCategory> productCategoryDAL = new DBBaseDAL <ProductCategory>();

            return(productCategoryDAL.FindList(q => 1 == 1).ToList());
        }
示例#3
0
        /// <summary>
        /// 抓取数据保存到db
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public static void CrawlerSingleProduct(string productId)
        {
            try
            {
                Console.WriteLine(productId);
                var httpResults = GetProductHTML(productId);
                var product     = ParsingHTMLToProductModel(httpResults);

                if (product != null)
                {
                    DBBaseDAL <Product> productDAL = new DBBaseDAL <Product>();
                    productDAL.Add(product);
                }
            }
            catch (Exception ex)
            {
                Log.Error("productId:" + productId + "---" + ex.ToString());
            }
        }