private void ProcessTaobaoProductDown(HttpContext context) { long taobaoProductId = 0L; if (long.TryParse(context.Request.Form["TaobaoProductId"], out taobaoProductId) && ProductHelper.IsExitTaobaoProduct(taobaoProductId)) { return; } ProductInfo productInfo = new ProductInfo(); productInfo.AuditStatus = ProductAuditStatus.Pass; productInfo.CategoryId = 0; productInfo.BrandId = 0; productInfo.ProductName = HttpUtility.UrlDecode(context.Request.Form["ProductName"]).ToString().Replace("\\", ""); productInfo.ProductCode = context.Request.Form["ProductCode"]; productInfo.Description = HttpUtility.UrlDecode(context.Request.Form["Description"]).ToString().Replace("\\", ""); if (context.Request.Form["SaleStatus"] == "onsale") { productInfo.SaleStatus = ProductSaleStatus.OnSale; } else { productInfo.SaleStatus = ProductSaleStatus.OnStock; } productInfo.AddedDate = DateTime.Parse(context.Request.Form["AddedDate"]); productInfo.TaobaoProductId = taobaoProductId; string text = context.Request.Form["ImageUrls"]; if (!string.IsNullOrEmpty(text)) { this.DownloadImage(productInfo, text, context); } productInfo.TypeId = ProductTypeHelper.GetTypeId(context.Request.Form["TypeName"]); decimal weight = decimal.Parse(context.Request.Form["Weight"]); Dictionary <string, SKUItem> skus = this.GetSkus(productInfo, weight, context); ProductActionStatus productActionStatus = ProductHelper.AddProduct(productInfo, skus, null, null, null, true, ""); if (productActionStatus == ProductActionStatus.Success) { TaobaoProductInfo taobaoProduct = this.GetTaobaoProduct(context); taobaoProduct.ProductId = productInfo.ProductId; taobaoProduct.ProTitle = productInfo.ProductName; taobaoProduct.Num = productInfo.Stock; ProductHelper.UpdateToaobProduct(taobaoProduct); } context.Response.ContentType = "text/string"; context.Response.Write(productActionStatus.ToString()); }
private void ProcessTaobaoProductDown(HttpContext context) { ProductInfo product = new ProductInfo { CategoryId = 0, BrandId = 0, ProductName = HttpUtility.UrlDecode(context.Request.Form["ProductName"]), ProductCode = context.Request.Form["ProductCode"], Description = HttpUtility.UrlDecode(context.Request.Form["Description"]) }; if (context.Request.Form["SaleStatus"] == "onsale") { product.SaleStatus = ProductSaleStatus.OnSale; } else { product.SaleStatus = ProductSaleStatus.OnStock; } product.AddedDate = DateTime.Parse(context.Request.Form["AddedDate"]); product.TaobaoProductId = long.Parse(context.Request.Form["TaobaoProductId"]); string str = context.Request.Form["ImageUrls"]; if (!string.IsNullOrEmpty(str)) { this.DownloadImage(product, str, context); } product.TypeId = new int?(ProductTypeHelper.GetTypeId(context.Request.Form["TypeName"])); int weight = int.Parse(context.Request.Form["Weight"]); Dictionary <string, SKUItem> skus = this.GetSkus(product, weight, context); ProductActionStatus status = ProductHelper.AddProduct(product, skus, null, null); if (status == ProductActionStatus.Success) { TaobaoProductInfo taobaoProduct = this.GetTaobaoProduct(context); taobaoProduct.ProductId = product.ProductId; taobaoProduct.ProTitle = product.ProductName; taobaoProduct.Num = product.Stock; if (product.Stock <= 0) { taobaoProduct.Num = long.Parse(context.Request.Form["Stock"]); } ProductHelper.UpdateToaobProduct(taobaoProduct); } context.Response.Write(status.ToString()); }
private void ProcessTaobaoProductDown(System.Web.HttpContext context) { ProductInfo productInfo = new ProductInfo(); productInfo.CategoryId = 0; productInfo.BrandId = new int?(0); productInfo.ProductName = System.Web.HttpUtility.UrlDecode(context.Request.Form["ProductName"]); productInfo.ProductCode = context.Request.Form["ProductCode"]; productInfo.Description = System.Web.HttpUtility.UrlDecode(context.Request.Form["Description"]); if (context.Request.Form["SaleStatus"] == "onsale") { productInfo.SaleStatus = ProductSaleStatus.OnSale; } else { productInfo.SaleStatus = ProductSaleStatus.OnStock; } productInfo.AddedDate = System.DateTime.Parse(context.Request.Form["AddedDate"]); productInfo.TaobaoProductId = long.Parse(context.Request.Form["TaobaoProductId"]); string text = context.Request.Form["ImageUrls"]; if (!string.IsNullOrEmpty(text)) { this.DownloadImage(productInfo, text, context); } productInfo.TypeId = new int?(ProductTypeHelper.GetTypeId(context.Request.Form["TypeName"])); int weight = int.Parse(context.Request.Form["Weight"]); System.Collections.Generic.Dictionary <string, SKUItem> skus = this.GetSkus(productInfo, weight, context); productInfo.LowestSalePrice = skus.Values.First <SKUItem>().SalePrice; ProductActionStatus productActionStatus = ProductHelper.AddProduct(productInfo, skus, null, null); if (productActionStatus == ProductActionStatus.Success) { TaobaoProductInfo taobaoProduct = this.GetTaobaoProduct(context); taobaoProduct.ProductId = productInfo.ProductId; taobaoProduct.ProTitle = productInfo.ProductName; taobaoProduct.Num = (long)productInfo.Stock; if (productInfo.Stock <= 0) { taobaoProduct.Num = long.Parse(context.Request.Form["Stock"]); } ProductHelper.UpdateToaobProduct(taobaoProduct); } context.Response.Write(productActionStatus.ToString()); }
private void btnImport_Click(object sender, EventArgs e) { string selectedValue = this.dropFiles.SelectedValue; selectedValue = Path.Combine(this._dataPath, selectedValue); if (!File.Exists(selectedValue)) { this.ShowMsg("选择的数据包文件有问题!", false); } else { int num = 0; int num2 = 0; this.PrepareDataFiles(selectedValue); List <List <string> > list = this.ReadCsv(this.csvPath, true, '\t', Encoding.GetEncoding("GB2312")); int i = 0; for (int count = list.Count; i < count; i++) { ProductInfo productInfo = new ProductInfo(); productInfo.AuditStatus = ProductAuditStatus.Pass; try { List <string> list2 = list[i]; if (list2[18] != "") { DataTable brandCategories = CatalogHelper.GetBrandCategories(list2[18]); if (brandCategories.Rows.Count > 0) { productInfo.BrandId = Convert.ToInt32(brandCategories.Rows[0]["BrandId"]); } } if (list2[1] != "") { DataTable categoryes = CatalogHelper.GetCategoryes(list2[1]); if (categoryes.Rows.Count > 0) { productInfo.CategoryId = Convert.ToInt32(categoryes.Rows[0]["CategoryId"]); } else { productInfo.CategoryId = 0; } } else { productInfo.CategoryId = 0; } if (list2[7] != "") { string path = Path.Combine(this.csvPath.Replace(".csv", ""), list2[7]); using (StreamReader streamReader = new StreamReader(path, Encoding.GetEncoding("gb2312"))) { productInfo.Description = streamReader.ReadToEnd(); } } if (productInfo.CategoryId > 0) { productInfo.MainCategoryPath = CatalogHelper.GetCategory(productInfo.CategoryId).Path + "|"; } productInfo.HasSKU = (int.Parse(list2[19]) == 1); productInfo.ImageUrl1 = ""; productInfo.ImageUrl2 = ""; productInfo.ImageUrl3 = ""; productInfo.ImageUrl4 = ""; productInfo.ImageUrl5 = ""; if (list2[12] != "") { FileInfo fileInfo = new FileInfo(Path.Combine(this.csvPath.Replace(".csv", ""), list2[12])); if (fileInfo.Exists) { this.GetImg(fileInfo.FullName, ref productInfo, 1); } } if (list2[13] != "") { FileInfo fileInfo2 = new FileInfo(Path.Combine(this.csvPath.Replace(".csv", ""), list2[13])); if (fileInfo2.Exists) { this.GetImg(fileInfo2.FullName, ref productInfo, 2); } } if (list2[14] != "") { FileInfo fileInfo3 = new FileInfo(Path.Combine(this.csvPath.Replace(".csv", ""), list2[14])); if (fileInfo3.Exists) { this.GetImg(fileInfo3.FullName, ref productInfo, 3); } } if (list2[15] != "") { FileInfo fileInfo4 = new FileInfo(Path.Combine(this.csvPath.Replace(".csv", ""), list2[15])); if (fileInfo4.Exists) { this.GetImg(fileInfo4.FullName, ref productInfo, 4); } } if (list2[16] != "") { FileInfo fileInfo5 = new FileInfo(Path.Combine(this.csvPath.Replace(".csv", ""), list2[16])); if (fileInfo5.Exists) { this.GetImg(fileInfo5.FullName, ref productInfo, 5); } } if (list2[17] != "") { productInfo.MarketPrice = decimal.Parse(list2[17]); } if (list2[9] != "") { productInfo.Meta_Description = list2[9]; } if (list2[10] != "") { productInfo.Meta_Keywords = list2[10]; } if (list2[4] != "") { productInfo.ProductCode = list2[4]; } productInfo.ProductName = list2[3].Replace("\\", ""); string text = list2[11]; switch (text) { case "出售中": productInfo.SaleStatus = ProductSaleStatus.OnSale; break; case "下架区": productInfo.SaleStatus = ProductSaleStatus.UnSale; break; case "仓库中": productInfo.SaleStatus = ProductSaleStatus.OnStock; break; } if (list2[5] != "") { productInfo.ShortDescription = list2[5].Replace("\\", ""); } if (list2[8] != "") { productInfo.Title = list2[8].Replace("\\", ""); } if (list2[2] != "") { int typeId = ProductTypeHelper.GetTypeId(list2[2]); if (typeId > 0) { productInfo.TypeId = typeId; } } if (!productInfo.TypeId.HasValue) { productInfo.HasSKU = false; } if (list2[6] != "") { productInfo.Unit = list2[6]; } Dictionary <string, SKUItem> dictionary = null; Dictionary <int, IList <int> > dictionary2 = null; IList <int> list3 = new List <int>(); if (list2[20] == "") { dictionary = new Dictionary <string, SKUItem>(); SKUItem sKUItem = new SKUItem(); sKUItem.SkuId = "0"; sKUItem.CostPrice = decimal.Parse(list2[24].Split(';')[0]); sKUItem.SalePrice = decimal.Parse(list2[25].Split(';')[0]); sKUItem.SKU = list2[21].Split(';')[0]; sKUItem.Stock = int.Parse(list2[23].Split(';')[0]); sKUItem.Weight = decimal.Parse(list2[22].Split(';')[0]); dictionary.Add(sKUItem.SkuId, sKUItem); } else if (productInfo.TypeId.HasValue) { dictionary = new Dictionary <string, SKUItem>(); int value = productInfo.TypeId.Value; if (productInfo.HasSKU) { IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(value, AttributeUseageMode.Choose); string[] array = list2[20].Split(';'); int num3 = array.Length; for (int j = 0; j < num3; j++) { SKUItem sKUItem2 = new SKUItem(); sKUItem2.CostPrice = decimal.Parse(list2[24].Split(';')[j]); sKUItem2.SalePrice = decimal.Parse(list2[25].Split(';')[j]); sKUItem2.SKU = list2[21].Split(';')[j]; sKUItem2.Stock = int.Parse(list2[23].Split(';')[j]); sKUItem2.Weight = decimal.Parse(list2[22].Split(';')[j]); string text2 = array[j]; Dictionary <int, int> dictionary3 = new Dictionary <int, int>(); string[] array2 = text2.Split(','); int num4 = 0; while (num4 < array2.Length) { string text3 = array2[num4]; string specificationName = text3.Split(':')[0]; string valueStr = text3.Split(':')[1]; int specificationId = ProductTypeHelper.GetSpecificationId(value, specificationName); if (specificationId > 0) { int specificationValueId = ProductTypeHelper.GetSpecificationValueId(specificationId, valueStr); if (specificationValueId > 0) { dictionary3.Add(specificationId, specificationValueId); num4++; continue; } productInfo.HasSKU = false; } else { productInfo.HasSKU = false; } break; } if (productInfo.HasSKU && dictionary3.Count > 0) { string text4 = ""; foreach (KeyValuePair <int, int> item in dictionary3) { sKUItem2.SkuItems.Add(item.Key, item.Value); text4 = text4 + item.Value + "_"; } sKUItem2.SkuId = text4.Substring(0, text4.Length - 1); dictionary.Add(sKUItem2.SkuId, sKUItem2); } } if (dictionary.Count > 0) { productInfo.HasSKU = true; } } else { SKUItem sKUItem3 = new SKUItem(); sKUItem3.SkuId = "0"; sKUItem3.CostPrice = decimal.Parse(list2[24].Split(';')[0]); sKUItem3.SalePrice = decimal.Parse(list2[25].Split(';')[0]); sKUItem3.SKU = list2[21].Split(';')[0]; sKUItem3.Stock = int.Parse(list2[23].Split(';')[0]); sKUItem3.Weight = int.Parse(list2[22].Split(';')[0]); dictionary.Add(sKUItem3.SkuId, sKUItem3); } } if (list2[26] != "" && productInfo.TypeId.HasValue) { int value2 = productInfo.TypeId.Value; dictionary2 = new Dictionary <int, IList <int> >(); IList <AttributeInfo> attributes2 = ProductTypeHelper.GetAttributes(value2, AttributeUseageMode.View); foreach (AttributeInfo attribute in ProductTypeHelper.GetAttributes(value2, AttributeUseageMode.MultiView)) { attributes2.Add(attribute); } string[] array3 = list2[26].Split(','); foreach (string text5 in array3) { string value3 = text5.Split(':')[0]; string valueStr2 = text5.Split(':')[1]; bool flag = false; int num5 = 0; foreach (AttributeInfo item2 in attributes2) { if (item2.AttributeName.Equals(value3)) { num5 = item2.AttributeId; flag = true; break; } } if (flag) { int specificationValueId2 = ProductTypeHelper.GetSpecificationValueId(num5, valueStr2); if (specificationValueId2 > 0) { if (dictionary2.ContainsKey(num5)) { dictionary2[num5].Add(specificationValueId2); } else { dictionary2.Add(num5, new List <int> { specificationValueId2 }); } } } } } if (list2[27] != "") { list3 = new List <int>(); IList <TagInfo> tags = CatalogHelper.GetTags(); string[] array4 = list2[27].Split(','); foreach (string value4 in array4) { foreach (TagInfo item3 in tags) { if (item3.TagName.Equals(value4)) { list3.Add(item3.TagID); break; } } } } productInfo.AddedDate = DateTime.Now; if (list2.Count >= 28) { productInfo.ProductType = ((!(list2[28].Trim() == "实物商品")) ? 1 : 0); } if (list2.Count >= 29) { productInfo.IsValid = (list2[29].ToInt(0) == 1); } if (list2.Count >= 30) { productInfo.ValidStartDate = ((!productInfo.IsValid) ? list2[30].ToDateTime() : null); } if (list2.Count >= 31) { productInfo.ValidEndDate = ((!productInfo.IsValid) ? list2[31].ToDateTime() : null); } if (list2.Count >= 32) { productInfo.IsRefund = (list2[32].ToInt(0) == 1); } if (list2.Count >= 33) { productInfo.IsOverRefund = (list2[33].ToInt(0) == 1); } if (list2.Count >= 34) { productInfo.IsGenerateMore = (list2[34].ToInt(0) == 1); } switch (ProductHelper.AddProduct(productInfo, dictionary, dictionary2, list3, null, false, "")) { case ProductActionStatus.Success: num++; break; case ProductActionStatus.AttributeError: num2++; break; case ProductActionStatus.DuplicateName: num2++; break; case ProductActionStatus.DuplicateSKU: num2++; break; case ProductActionStatus.SKUError: num2++; break; default: num2++; break; } } catch (Exception ex) { Globals.WriteExceptionLog(ex, null, "ImportFromLocal"); num2++; } } File.Delete(this.csvPath); File.Delete(selectedValue); this.BindFiles(); if (num2 == 0) { this.ShowMsg("此次商品批量导入操作已成功!", true); } else { this.ShowMsg("此次商品批量导入操作," + num2 + "件商品导入失败!", false); } } }
private void btnImport_Click(object sender, System.EventArgs e) { string text = this.dropFiles.SelectedValue; text = System.IO.Path.Combine(this._dataPath, text); if (!System.IO.File.Exists(text)) { this.ShowMsg("选择的数据包文件有问题!", false); return; } int num = 0; int num2 = 0; this.PrepareDataFiles(new object[] { text }); System.Collections.Generic.List <System.Collections.Generic.List <string> > list = this.ReadCsv(this.csvPath, true, '\t', System.Text.Encoding.GetEncoding("GB2312")); int i = 0; int count = list.Count; while (i < count) { ProductInfo productInfo = new ProductInfo(); try { System.Collections.Generic.List <string> list2 = list[i]; if (list2[18] != "") { System.Data.DataTable brandCategories = CatalogHelper.GetBrandCategories(list2[18]); if (brandCategories.Rows.Count > 0) { productInfo.BrandId = new int?(System.Convert.ToInt32(brandCategories.Rows[0]["BrandId"])); } } if (list2[1] != "") { System.Data.DataTable categoryes = CatalogHelper.GetCategoryes(list2[1]); if (categoryes.Rows.Count > 0) { productInfo.CategoryId = System.Convert.ToInt32(categoryes.Rows[0]["CategoryId"]); } else { productInfo.CategoryId = 0; } } else { productInfo.CategoryId = 0; } if (list2[7] != "") { string path = System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[7]); using (System.IO.StreamReader streamReader = new System.IO.StreamReader(path, System.Text.Encoding.GetEncoding("gb2312"))) { productInfo.Description = streamReader.ReadToEnd(); } } if (productInfo.CategoryId > 0) { productInfo.MainCategoryPath = CatalogHelper.GetCategory(productInfo.CategoryId).Path + "|"; } productInfo.HasSKU = (int.Parse(list2[19]) == 1); productInfo.ImageUrl1 = ""; productInfo.ImageUrl2 = ""; productInfo.ImageUrl3 = ""; productInfo.ImageUrl4 = ""; productInfo.ImageUrl5 = ""; if (list2[12] != "") { System.IO.FileInfo fileInfo = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[12])); if (fileInfo.Exists) { this.GetImg(fileInfo.FullName, ref productInfo, 1); } } if (list2[13] != "") { System.IO.FileInfo fileInfo2 = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[13])); if (fileInfo2.Exists) { this.GetImg(fileInfo2.FullName, ref productInfo, 2); } } if (list2[14] != "") { System.IO.FileInfo fileInfo3 = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[14])); if (fileInfo3.Exists) { this.GetImg(fileInfo3.FullName, ref productInfo, 3); } } if (list2[15] != "") { System.IO.FileInfo fileInfo4 = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[15])); if (fileInfo4.Exists) { this.GetImg(fileInfo4.FullName, ref productInfo, 4); } } if (list2[16] != "") { System.IO.FileInfo fileInfo5 = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[16])); if (fileInfo5.Exists) { this.GetImg(fileInfo5.FullName, ref productInfo, 5); } } if (list2[17] != "") { productInfo.MarketPrice = new decimal?(decimal.Parse(list2[17])); } if (list2[9] != "") { productInfo.MetaDescription = list2[9]; } if (list2[10] != "") { productInfo.MetaKeywords = list2[10]; } if (list2[4] != "") { productInfo.ProductCode = list2[4]; } productInfo.ProductName = list2[3]; string text2 = list2[11]; string a; if ((a = text2) != null) { if (!(a == "出售中")) { if (!(a == "下架区")) { if (a == "仓库中") { productInfo.SaleStatus = ProductSaleStatus.OnStock; } } else { productInfo.SaleStatus = ProductSaleStatus.UnSale; } } else { productInfo.SaleStatus = ProductSaleStatus.OnSale; } } if (list2[5] != "") { productInfo.ShortDescription = list2[5]; } if (list2[8] != "") { productInfo.Title = list2[8]; } if (list2[2] != "") { int typeId = ProductTypeHelper.GetTypeId(list2[2]); if (typeId > 0) { productInfo.TypeId = new int?(typeId); } } if (!productInfo.TypeId.HasValue) { productInfo.HasSKU = false; } if (list2[6] != "") { productInfo.Unit = list2[6]; } System.Collections.Generic.Dictionary <string, SKUItem> dictionary = null; System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > dictionary2 = null; System.Collections.Generic.IList <int> list3 = new System.Collections.Generic.List <int>(); if (list2[20] == "") { dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>(); SKUItem sKUItem = new SKUItem(); sKUItem.SkuId = "0"; sKUItem.CostPrice = decimal.Parse(list2[24].Split(new char[] { ';' })[0]); sKUItem.SalePrice = decimal.Parse(list2[25].Split(new char[] { ';' })[0]); sKUItem.SKU = list2[21].Split(new char[] { ';' })[0]; sKUItem.Stock = int.Parse(list2[23].Split(new char[] { ';' })[0]); sKUItem.Weight = decimal.Parse(list2[22].Split(new char[] { ';' })[0]); dictionary.Add(sKUItem.SKU, sKUItem); } else { if (productInfo.TypeId.HasValue) { dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>(); int value = productInfo.TypeId.Value; if (productInfo.HasSKU) { ProductTypeHelper.GetAttributes(value, AttributeUseageMode.Choose); string[] array = list2[20].Split(new char[] { ';' }); int num3 = array.Length; for (int j = 0; j < num3; j++) { SKUItem sKUItem2 = new SKUItem(); sKUItem2.CostPrice = decimal.Parse(list2[24].Split(new char[] { ';' })[j]); sKUItem2.SalePrice = decimal.Parse(list2[25].Split(new char[] { ';' })[j]); sKUItem2.SKU = list2[21].Split(new char[] { ';' })[j]; sKUItem2.Stock = int.Parse(list2[23].Split(new char[] { ';' })[j]); sKUItem2.Weight = decimal.Parse(list2[22].Split(new char[] { ';' })[j]); string text3 = array[j]; System.Collections.Generic.Dictionary <int, int> dictionary3 = new System.Collections.Generic.Dictionary <int, int>(); string[] array2 = text3.Split(new char[] { ',' }); for (int k = 0; k < array2.Length; k++) { string text4 = array2[k]; string specificationName = text4.Split(new char[] { ':' })[0]; string valueStr = text4.Split(new char[] { ':' })[1]; int specificationId = ProductTypeHelper.GetSpecificationId(value, specificationName); if (specificationId <= 0) { productInfo.HasSKU = false; break; } int specificationValueId = ProductTypeHelper.GetSpecificationValueId(specificationId, valueStr); if (specificationValueId <= 0) { productInfo.HasSKU = false; break; } dictionary3.Add(specificationId, specificationValueId); } if (productInfo.HasSKU && dictionary3.Count > 0) { string text5 = ""; foreach (System.Collections.Generic.KeyValuePair <int, int> current in dictionary3) { sKUItem2.SkuItems.Add(current.Key, current.Value); text5 = text5 + current.Value + "_"; } sKUItem2.SkuId = text5.Substring(0, text5.Length - 1); dictionary.Add(sKUItem2.SKU, sKUItem2); } } if (dictionary.Count > 0) { productInfo.HasSKU = true; } } else { SKUItem sKUItem3 = new SKUItem(); sKUItem3.SkuId = "0"; sKUItem3.CostPrice = decimal.Parse(list2[24].Split(new char[] { ';' })[0]); sKUItem3.SalePrice = decimal.Parse(list2[25].Split(new char[] { ';' })[0]); sKUItem3.SKU = list2[21].Split(new char[] { ';' })[0]; sKUItem3.Stock = int.Parse(list2[23].Split(new char[] { ';' })[0]); sKUItem3.Weight = int.Parse(list2[22].Split(new char[] { ';' })[0]); dictionary.Add(sKUItem3.SKU, sKUItem3); } } } if (list2[26] != "" && productInfo.TypeId.HasValue) { int value2 = productInfo.TypeId.Value; dictionary2 = new System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> >(); System.Collections.Generic.IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(value2, AttributeUseageMode.View); foreach (AttributeInfo current2 in ProductTypeHelper.GetAttributes(value2, AttributeUseageMode.MultiView)) { attributes.Add(current2); } string[] array2 = list2[26].Split(new char[] { ',' }); for (int k = 0; k < array2.Length; k++) { string text6 = array2[k]; string value3 = text6.Split(new char[] { ':' })[0]; string valueStr2 = text6.Split(new char[] { ':' })[1]; bool flag = false; int num4 = 0; foreach (AttributeInfo current3 in attributes) { if (current3.AttributeName.Equals(value3)) { num4 = current3.AttributeId; flag = true; break; } } if (flag) { int specificationValueId2 = ProductTypeHelper.GetSpecificationValueId(num4, valueStr2); if (specificationValueId2 > 0) { if (dictionary2.ContainsKey(num4)) { dictionary2[num4].Add(specificationValueId2); } else { dictionary2.Add(num4, new System.Collections.Generic.List <int> { specificationValueId2 }); } } } } } if (list2[27] != "") { list3 = new System.Collections.Generic.List <int>(); System.Data.DataTable tags = CatalogHelper.GetTags(); string[] array2 = list2[27].Split(new char[] { ',' }); for (int k = 0; k < array2.Length; k++) { string obj = array2[k]; foreach (System.Data.DataRow dataRow in tags.Rows) { if (dataRow["TagName"].Equals(obj)) { list3.Add(System.Convert.ToInt32(dataRow["TagId"])); break; } } } } productInfo.AddedDate = System.DateTime.Now; ProductActionStatus productActionStatus = ProductHelper.AddProduct(productInfo, dictionary, dictionary2, list3); if (productActionStatus == ProductActionStatus.Success) { num++; } else { if (productActionStatus == ProductActionStatus.AttributeError) { num2++; } else { if (productActionStatus == ProductActionStatus.DuplicateName) { num2++; } else { if (productActionStatus == ProductActionStatus.DuplicateSKU) { num2++; } else { if (productActionStatus == ProductActionStatus.SKUError) { num2++; } else { num2++; } } } } } } catch { num2++; } i++; } System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(this.csvPath.Replace(".csv", "")); directoryInfo.Delete(true); System.IO.File.Delete(this.csvPath); System.IO.File.Delete(text); this.BindFiles(); if (num2 == 0) { this.ShowMsg("此次商品批量导入操作已成功!", true); return; } this.ShowMsg("此次商品批量导入操作," + num2 + "件商品导入失败!", false); }