예제 #1
0
 public bool UpdateToaobProduct(TaobaoProductInfo taobaoProduct)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE FROM Taobao_Products WHERE ProductId = @ProductId;INSERT INTO Taobao_Products(Cid, StuffStatus, ProductId, ProTitle,Num, LocationState, LocationCity, FreightPayer, PostFee, ExpressFee, EMSFee, HasInvoice, HasWarranty, HasDiscount, ValidThru, ListTime, PropertyAlias,InputPids,InputStr, SkuProperties, SkuQuantities, SkuPrices, SkuOuterIds) VALUES(@Cid, @StuffStatus, @ProductId, @ProTitle,@Num, @LocationState, @LocationCity, @FreightPayer, @PostFee, @ExpressFee, @EMSFee, @HasInvoice, @HasWarranty, @HasDiscount, @ValidThru, @ListTime,@PropertyAlias,@InputPids, @InputStr, @SkuProperties, @SkuQuantities, @SkuPrices, @SkuOuterIds);");
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, taobaoProduct.ProductId);
     this.database.AddInParameter(sqlStringCommand, "Cid", DbType.Int64, taobaoProduct.Cid);
     this.database.AddInParameter(sqlStringCommand, "StuffStatus", DbType.String, taobaoProduct.StuffStatus);
     this.database.AddInParameter(sqlStringCommand, "ProTitle", DbType.String, taobaoProduct.ProTitle);
     this.database.AddInParameter(sqlStringCommand, "Num", DbType.Int64, taobaoProduct.Num);
     this.database.AddInParameter(sqlStringCommand, "LocationState", DbType.String, taobaoProduct.LocationState);
     this.database.AddInParameter(sqlStringCommand, "LocationCity", DbType.String, taobaoProduct.LocationCity);
     this.database.AddInParameter(sqlStringCommand, "FreightPayer", DbType.String, taobaoProduct.FreightPayer);
     this.database.AddInParameter(sqlStringCommand, "PostFee", DbType.Currency, taobaoProduct.PostFee);
     this.database.AddInParameter(sqlStringCommand, "ExpressFee", DbType.Currency, taobaoProduct.ExpressFee);
     this.database.AddInParameter(sqlStringCommand, "EMSFee", DbType.Currency, taobaoProduct.EMSFee);
     this.database.AddInParameter(sqlStringCommand, "HasInvoice", DbType.Boolean, taobaoProduct.HasInvoice);
     this.database.AddInParameter(sqlStringCommand, "HasWarranty", DbType.Boolean, taobaoProduct.HasWarranty);
     this.database.AddInParameter(sqlStringCommand, "HasDiscount", DbType.Boolean, taobaoProduct.HasDiscount);
     this.database.AddInParameter(sqlStringCommand, "ValidThru", DbType.Int64, taobaoProduct.ValidThru);
     this.database.AddInParameter(sqlStringCommand, "ListTime", DbType.DateTime, taobaoProduct.ListTime);
     this.database.AddInParameter(sqlStringCommand, "PropertyAlias", DbType.String, taobaoProduct.PropertyAlias);
     this.database.AddInParameter(sqlStringCommand, "InputPids", DbType.String, taobaoProduct.InputPids);
     this.database.AddInParameter(sqlStringCommand, "InputStr", DbType.String, taobaoProduct.InputStr);
     this.database.AddInParameter(sqlStringCommand, "SkuProperties", DbType.String, taobaoProduct.SkuProperties);
     this.database.AddInParameter(sqlStringCommand, "SkuQuantities", DbType.String, taobaoProduct.SkuQuantities);
     this.database.AddInParameter(sqlStringCommand, "SkuPrices", DbType.String, taobaoProduct.SkuPrices);
     this.database.AddInParameter(sqlStringCommand, "SkuOuterIds", DbType.String, taobaoProduct.SkuOuterIds);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
예제 #2
0
 public static bool UpdateToaobProduct(TaobaoProductInfo taobaoProduct)
 {
     return new TaobaoProductDao().UpdateToaobProduct(taobaoProduct);
 }
예제 #3
0
 public static void ImportProducts(DataTable productData, int categoryId, int lineId, int? brandId, ProductSaleStatus saleStatus, bool isImportFromTaobao)
 {
     if ((productData != null) && (productData.Rows.Count > 0))
     {
         foreach (DataRow row in productData.Rows)
         {
             string[] strArray;
             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)))
             {
                 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 {
                 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);
             }
         }
     }
 }