Beispiel #1
0
        public static string GetFullCategory(int categoryId)
        {
            CategoryInfo category = CatalogHelper.GetCategory(categoryId);
            string       result;

            if (category == null)
            {
                result = null;
            }
            else
            {
                string text = category.Name;
                while (category != null && category.ParentCategoryId.HasValue)
                {
                    category = CatalogHelper.GetCategory(category.ParentCategoryId.Value);
                    if (category != null)
                    {
                        text = category.Name + " » " + text;
                    }
                }
                result = text;
            }
            return(result);
        }
Beispiel #2
0
        public static bool UpdateProductCategory(int productId, int newCategoryId)
        {
            bool flag;

            if (newCategoryId != 0)
            {
                flag = new ProductDao().UpdateProductCategory(productId, newCategoryId, CatalogHelper.GetCategory(newCategoryId).Path + "|");
            }
            else
            {
                flag = new ProductDao().UpdateProductCategory(productId, newCategoryId, null);
            }
            if (flag)
            {
                EventLogs.WriteOperationLog(Privilege.EditProducts, string.Format(CultureInfo.InvariantCulture, "修改编号 “{0}” 的店铺分类为 “{1}”", new object[] { productId, newCategoryId }));
            }
            return(flag);
        }
Beispiel #3
0
 public static void ImportProducts(DataTable productData, int categoryId, int lineId, string brandId, ProductSaleStatus saleStatus, bool isImportFromTaobao)
 {
     if ((productData != null) && (productData.Rows.Count > 0))
     {
         foreach (DataRow row in productData.Rows)
         {
             ProductInfo product = new ProductInfo {
                 CategoryId       = categoryId,
                 MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|",
                 ProductName      = (string)row["ProductName"],
                 ProductCode      = (string)row["SKU"],
                 BrandId          = brandId
             };
             if (row["Description"] != DBNull.Value)
             {
                 product.Description = (string)row["Description"];
             }
             product.AddedDate  = DateTime.Now;
             product.SaleStatus = saleStatus;
             product.HasSKU     = false;
             HttpContext current = HttpContext.Current;
             if (row["ImageUrl1"] != DBNull.Value)
             {
                 product.ImageUrl1 = (string)row["ImageUrl1"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl1) && (product.ImageUrl1.Length > 0))
             {
                 string[] strArray = ProcessImages(current, product.ImageUrl1);
                 product.ThumbnailUrl40  = strArray[0];
                 product.ThumbnailUrl60  = strArray[1];
                 product.ThumbnailUrl100 = strArray[2];
                 product.ThumbnailUrl160 = strArray[3];
                 product.ThumbnailUrl180 = strArray[4];
                 product.ThumbnailUrl220 = strArray[5];
                 product.ThumbnailUrl310 = strArray[6];
                 product.ThumbnailUrl410 = strArray[7];
             }
             if (row["ImageUrl2"] != DBNull.Value)
             {
                 product.ImageUrl2 = (string)row["ImageUrl2"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl2) && (product.ImageUrl2.Length > 0))
             {
                 ProcessImages(current, product.ImageUrl2);
             }
             if (row["ImageUrl3"] != DBNull.Value)
             {
                 product.ImageUrl3 = (string)row["ImageUrl3"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl3) && (product.ImageUrl3.Length > 0))
             {
                 ProcessImages(current, product.ImageUrl3);
             }
             if (row["ImageUrl4"] != DBNull.Value)
             {
                 product.ImageUrl4 = (string)row["ImageUrl4"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl4) && (product.ImageUrl4.Length > 0))
             {
                 ProcessImages(current, product.ImageUrl4);
             }
             if (row["ImageUrl5"] != DBNull.Value)
             {
                 product.ImageUrl5 = (string)row["ImageUrl5"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl5) && (product.ImageUrl5.Length > 0))
             {
                 ProcessImages(current, product.ImageUrl5);
             }
             SKUItem item = new SKUItem {
                 SkuId = "0",
                 SKU   = (string)row["SKU"]
             };
             if (row["Stock"] != DBNull.Value)
             {
                 item.Stock = (int)row["Stock"];
             }
             if (row["Weight"] != DBNull.Value)
             {
                 item.Weight = (decimal)row["Weight"];
             }
             item.SalePrice = (decimal)row["SalePrice"];
             Dictionary <string, SKUItem> skus = new Dictionary <string, SKUItem>();
             skus.Add(item.SkuId, item);
             ProductActionStatus status = AddProduct(product, skus, null, null);
             if (isImportFromTaobao && (status == ProductActionStatus.Success))
             {
                 TaobaoProductInfo taobaoProduct = new TaobaoProductInfo {
                     ProductId = product.ProductId,
                     ProTitle  = product.ProductName,
                     Cid       = (long)row["Cid"]
                 };
                 if (row["StuffStatus"] != DBNull.Value)
                 {
                     taobaoProduct.StuffStatus = (string)row["StuffStatus"];
                 }
                 taobaoProduct.Num           = (long)row["Num"];
                 taobaoProduct.LocationState = (string)row["LocationState"];
                 taobaoProduct.LocationCity  = (string)row["LocationCity"];
                 taobaoProduct.FreightPayer  = (string)row["FreightPayer"];
                 if (row["PostFee"] != DBNull.Value)
                 {
                     taobaoProduct.PostFee = (decimal)row["PostFee"];
                 }
                 if (row["ExpressFee"] != DBNull.Value)
                 {
                     taobaoProduct.ExpressFee = (decimal)row["ExpressFee"];
                 }
                 if (row["EMSFee"] != DBNull.Value)
                 {
                     taobaoProduct.EMSFee = (decimal)row["EMSFee"];
                 }
                 taobaoProduct.HasInvoice  = (bool)row["HasInvoice"];
                 taobaoProduct.HasWarranty = (bool)row["HasWarranty"];
                 taobaoProduct.HasDiscount = (bool)row["HasDiscount"];
                 taobaoProduct.ValidThru   = (long)row["ValidThru"];
                 if (row["ListTime"] != DBNull.Value)
                 {
                     taobaoProduct.ListTime = (DateTime)row["ListTime"];
                 }
                 else
                 {
                     taobaoProduct.ListTime = DateTime.Now;
                 }
                 if (row["PropertyAlias"] != DBNull.Value)
                 {
                     taobaoProduct.PropertyAlias = (string)row["PropertyAlias"];
                 }
                 if (row["InputPids"] != DBNull.Value)
                 {
                     taobaoProduct.InputPids = (string)row["InputPids"];
                 }
                 if (row["InputStr"] != DBNull.Value)
                 {
                     taobaoProduct.InputStr = (string)row["InputStr"];
                 }
                 if (row["SkuProperties"] != DBNull.Value)
                 {
                     taobaoProduct.SkuProperties = (string)row["SkuProperties"];
                 }
                 if (row["SkuQuantities"] != DBNull.Value)
                 {
                     taobaoProduct.SkuQuantities = (string)row["SkuQuantities"];
                 }
                 if (row["SkuPrices"] != DBNull.Value)
                 {
                     taobaoProduct.SkuPrices = (string)row["SkuPrices"];
                 }
                 if (row["SkuOuterIds"] != DBNull.Value)
                 {
                     taobaoProduct.SkuOuterIds = (string)row["SkuOuterIds"];
                 }
                 UpdateToaobProduct(taobaoProduct);
             }
         }
     }
 }
Beispiel #4
0
 public static void ImportProducts(DataTable productData, int categoryId, int lineId, int?brandId, ProductSaleStatus saleStatus)
 {
     if ((productData != null) && (productData.Rows.Count > 0))
     {
         foreach (DataRow row in productData.Rows)
         {
             string[]    strArray;
             ProductInfo product = new ProductInfo();
             product.CategoryId       = categoryId;
             product.MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|";
             product.ProductName      = (string)row["ProductName"];
             product.ProductCode      = (string)row["SKU"];
             product.LineId           = lineId;
             product.BrandId          = brandId;
             if (row["Description"] != DBNull.Value)
             {
                 product.Description = (string)row["Description"];
             }
             product.PenetrationStatus = PenetrationStatus.Notyet;
             product.AddedDate         = DateTime.Now;
             product.SaleStatus        = saleStatus;
             product.HasSKU            = false;
             HttpContext current = HttpContext.Current;
             if (row["ImageUrl1"] != DBNull.Value)
             {
                 product.ImageUrl1 = (string)row["ImageUrl1"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl1) || (product.ImageUrl1.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl1);
                 product.ThumbnailUrl40  = strArray[0];
                 product.ThumbnailUrl60  = strArray[1];
                 product.ThumbnailUrl100 = strArray[2];
                 product.ThumbnailUrl160 = strArray[3];
                 product.ThumbnailUrl180 = strArray[4];
                 product.ThumbnailUrl220 = strArray[5];
                 product.ThumbnailUrl310 = strArray[6];
                 product.ThumbnailUrl410 = strArray[7];
             }
             if (row["ImageUrl2"] != DBNull.Value)
             {
                 product.ImageUrl2 = (string)row["ImageUrl2"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl2) || (product.ImageUrl2.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl2);
             }
             if (row["ImageUrl3"] != DBNull.Value)
             {
                 product.ImageUrl3 = (string)row["ImageUrl3"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl3) || (product.ImageUrl3.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl3);
             }
             if (row["ImageUrl4"] != DBNull.Value)
             {
                 product.ImageUrl4 = (string)row["ImageUrl4"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl4) || (product.ImageUrl4.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl4);
             }
             if (row["ImageUrl5"] != DBNull.Value)
             {
                 product.ImageUrl5 = (string)row["ImageUrl5"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl5) || (product.ImageUrl5.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl5);
             }
             SKUItem item = new SKUItem();
             item.SkuId = "_0";
             item.SKU   = (string)row["SKU"];
             product.LowestSalePrice = item.PurchasePrice = item.SalePrice = (decimal)row["SalePrice"];
             if (row["Stock"] != DBNull.Value)
             {
                 item.Stock = (int)row["Stock"];
             }
             if (row["Weight"] != DBNull.Value)
             {
                 item.Weight = (int)row["Weight"];
             }
             Dictionary <string, SKUItem> skus = new Dictionary <string, SKUItem>();
             skus.Add(item.SkuId, item);
             AddProduct(product, skus, null);
         }
     }
 }
Beispiel #5
0
        static ProductInfo ConverToProduct(DataRow productRow, int categoryId, int lineId, int?bandId, ProductSaleStatus saleStatus, bool includeImages)
        {
            ProductInfo info2 = new ProductInfo();

            info2.CategoryId        = categoryId;
            info2.TypeId            = new int?((int)productRow["SelectedTypeId"]);
            info2.ProductName       = (string)productRow["ProductName"];
            info2.ProductCode       = (string)productRow["ProductCode"];
            info2.LineId            = lineId;
            info2.BrandId           = bandId;
            info2.LowestSalePrice   = (decimal)productRow["LowestSalePrice"];
            info2.Unit              = (string)productRow["Unit"];
            info2.ShortDescription  = (string)productRow["ShortDescription"];
            info2.Description       = (string)productRow["Description"];
            info2.PenetrationStatus = PenetrationStatus.Notyet;
            info2.Title             = (string)productRow["Title"];
            info2.MetaDescription   = (string)productRow["Meta_Description"];
            info2.MetaKeywords      = (string)productRow["Meta_Keywords"];
            info2.AddedDate         = DateTime.Now;
            info2.SaleStatus        = saleStatus;
            info2.HasSKU            = (bool)productRow["HasSKU"];
            info2.MainCategoryPath  = CatalogHelper.GetCategory(categoryId).Path + "|";
            info2.ImageUrl1         = (string)productRow["ImageUrl1"];
            info2.ImageUrl2         = (string)productRow["ImageUrl2"];
            info2.ImageUrl3         = (string)productRow["ImageUrl3"];
            info2.ImageUrl4         = (string)productRow["ImageUrl4"];
            info2.ImageUrl5         = (string)productRow["ImageUrl5"];
            ProductInfo info = info2;

            if (productRow["MarketPrice"] != DBNull.Value)
            {
                info.MarketPrice = new decimal?((decimal)productRow["MarketPrice"]);
            }
            if (includeImages)
            {
                string[]    strArray;
                HttpContext current = HttpContext.Current;
                if (!(string.IsNullOrEmpty(info.ImageUrl1) || (info.ImageUrl1.Length <= 0)))
                {
                    strArray             = ProcessImages(current, info.ImageUrl1);
                    info.ThumbnailUrl40  = strArray[0];
                    info.ThumbnailUrl60  = strArray[1];
                    info.ThumbnailUrl100 = strArray[2];
                    info.ThumbnailUrl160 = strArray[3];
                    info.ThumbnailUrl180 = strArray[4];
                    info.ThumbnailUrl220 = strArray[5];
                    info.ThumbnailUrl310 = strArray[6];
                    info.ThumbnailUrl410 = strArray[7];
                }
                if (!(string.IsNullOrEmpty(info.ImageUrl2) || (info.ImageUrl2.Length <= 0)))
                {
                    strArray = ProcessImages(current, info.ImageUrl2);
                }
                if (!(string.IsNullOrEmpty(info.ImageUrl3) || (info.ImageUrl3.Length <= 0)))
                {
                    strArray = ProcessImages(current, info.ImageUrl3);
                }
                if (!(string.IsNullOrEmpty(info.ImageUrl4) || (info.ImageUrl4.Length <= 0)))
                {
                    strArray = ProcessImages(current, info.ImageUrl4);
                }
                if (!(string.IsNullOrEmpty(info.ImageUrl5) || (info.ImageUrl5.Length <= 0)))
                {
                    strArray = ProcessImages(current, info.ImageUrl5);
                }
            }
            return(info);
        }
Beispiel #6
0
        private static ProductInfo ConverToProduct(DataRow productRow, int categoryId, int lineId, int?bandId, ProductSaleStatus saleStatus, bool includeImages)
        {
            ProductInfo info = new ProductInfo {
                CategoryId       = categoryId,
                TypeId           = new int?((int)productRow["SelectedTypeId"]),
                ProductName      = (string)productRow["ProductName"],
                ProductCode      = (string)productRow["ProductCode"],
                BrandId          = bandId,
                Unit             = (string)productRow["Unit"],
                ShortDescription = (string)productRow["ShortDescription"],
                Description      = (string)productRow["Description"],
                AddedDate        = DateTime.Now,
                SaleStatus       = saleStatus,
                HasSKU           = (bool)productRow["HasSKU"],
                MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|",
                ImageUrl1        = (string)productRow["ImageUrl1"],
                ImageUrl2        = (string)productRow["ImageUrl2"],
                ImageUrl3        = (string)productRow["ImageUrl3"],
                ImageUrl4        = (string)productRow["ImageUrl4"],
                ImageUrl5        = (string)productRow["ImageUrl5"]
            };

            if (productRow["MarketPrice"] != DBNull.Value)
            {
                info.MarketPrice = new decimal?((decimal)productRow["MarketPrice"]);
            }
            if (includeImages)
            {
                string[]    strArray;
                HttpContext current = HttpContext.Current;
                if (!(string.IsNullOrEmpty(info.ImageUrl1) || (info.ImageUrl1.Length <= 0)))
                {
                    strArray             = ProcessImages(current, info.ImageUrl1);
                    info.ThumbnailUrl40  = strArray[0];
                    info.ThumbnailUrl60  = strArray[1];
                    info.ThumbnailUrl100 = strArray[2];
                    info.ThumbnailUrl160 = strArray[3];
                    info.ThumbnailUrl180 = strArray[4];
                    info.ThumbnailUrl220 = strArray[5];
                    info.ThumbnailUrl310 = strArray[6];
                    info.ThumbnailUrl410 = strArray[7];
                }
                if (!(string.IsNullOrEmpty(info.ImageUrl2) || (info.ImageUrl2.Length <= 0)))
                {
                    strArray = ProcessImages(current, info.ImageUrl2);
                }
                if (!(string.IsNullOrEmpty(info.ImageUrl3) || (info.ImageUrl3.Length <= 0)))
                {
                    strArray = ProcessImages(current, info.ImageUrl3);
                }
                if (!(string.IsNullOrEmpty(info.ImageUrl4) || (info.ImageUrl4.Length <= 0)))
                {
                    strArray = ProcessImages(current, info.ImageUrl4);
                }
                if (!(string.IsNullOrEmpty(info.ImageUrl5) || (info.ImageUrl5.Length <= 0)))
                {
                    strArray = ProcessImages(current, info.ImageUrl5);
                }
            }
            return(info);
        }