private Dictionary <string, SKUItem> GetSkus(ProductInfo product, decimal weight, HttpContext context)
        {
            Dictionary <string, SKUItem> dictionary = null;
            string text = context.Request.Form["SkuString"];

            if (string.IsNullOrEmpty(text))
            {
                product.HasSKU = false;
                dictionary     = new Dictionary <string, SKUItem>
                {
                    {
                        "0",
                        new SKUItem
                        {
                            SkuId     = "0",
                            SKU       = product.ProductCode,
                            SalePrice = decimal.Parse(context.Request.Form["SalePrice"]),
                            CostPrice = decimal.Zero,
                            Stock     = int.Parse(context.Request.Form["Stock"]),
                            Weight    = weight
                        }
                    }
                };
            }
            else
            {
                product.HasSKU = true;
                dictionary     = new Dictionary <string, SKUItem>();
                text           = HttpUtility.UrlDecode(text);
                string[] array = text.Split('|');
                foreach (string text2 in array)
                {
                    string[] array2  = text2.Split(',');
                    SKUItem  sKUItem = new SKUItem();
                    sKUItem.SKU       = array2[0].Replace("_", "-");
                    sKUItem.Weight    = weight;
                    sKUItem.Stock     = int.Parse(array2[1]);
                    sKUItem.SalePrice = decimal.Parse(array2[2]);
                    string   text3  = array2[3];
                    string   text4  = "";
                    string[] array3 = text3.Split(';');
                    foreach (string text5 in array3)
                    {
                        string[] array4               = text5.Split(':');
                        int      specificationId      = ProductTypeHelper.GetSpecificationId(product.TypeId.Value, array4[0]);
                        int      specificationValueId = ProductTypeHelper.GetSpecificationValueId(specificationId, array4[1].Replace("\\", "/"));
                        text4 = text4 + specificationValueId + "_";
                        sKUItem.SkuItems.Add(specificationId, specificationValueId);
                    }
                    sKUItem.SkuId = text4.Substring(0, text4.Length - 1);
                    dictionary.Add(sKUItem.SkuId, sKUItem);
                }
            }
            return(dictionary);
        }
Beispiel #2
0
        private Dictionary <string, SKUItem> GetSkus(ProductInfo product, decimal weight, HttpContext context)
        {
            Dictionary <string, SKUItem> dictionary = null;
            string str = context.Request.Form["SkuString"];

            if (string.IsNullOrEmpty(str))
            {
                product.HasSKU = false;
                Dictionary <string, SKUItem> dictionary2 = new Dictionary <string, SKUItem>();
                SKUItem item = new SKUItem
                {
                    SkuId     = "0",
                    SKU       = product.ProductCode,
                    SalePrice = decimal.Parse(context.Request.Form["SalePrice"]),
                    CostPrice = 0M,
                    Stock     = int.Parse(context.Request.Form["Stock"]),
                    Weight    = weight
                };
                dictionary2.Add("0", item);
                return(dictionary2);
            }
            product.HasSKU = true;
            dictionary     = new Dictionary <string, SKUItem>();
            foreach (string str2 in HttpUtility.UrlDecode(str).Split(new char[] { '|' }))
            {
                string[] strArray = str2.Split(new char[] { ',' });
                SKUItem  item2    = new SKUItem
                {
                    SKU       = strArray[0],
                    Weight    = weight,
                    Stock     = int.Parse(strArray[1]),
                    SalePrice = decimal.Parse(strArray[2])
                };
                string str3 = strArray[3];
                string str4 = "";
                foreach (string str5 in str3.Split(new char[] { ';' }))
                {
                    string[] strArray2            = str5.Split(new char[] { ':' });
                    int      specificationId      = ProductTypeHelper.GetSpecificationId(product.TypeId.Value, strArray2[0]);
                    int      specificationValueId = ProductTypeHelper.GetSpecificationValueId(specificationId, strArray2[1].Replace(@"\", "/"));
                    str4 = str4 + specificationValueId + "_";
                    item2.SkuItems.Add(specificationId, specificationValueId);
                }
                item2.SkuId = str4.Substring(0, str4.Length - 1);
                dictionary.Add(item2.SkuId, item2);
            }
            return(dictionary);
        }
Beispiel #3
0
        private System.Collections.Generic.Dictionary <string, SKUItem> GetSkus(ProductInfo product, decimal weight, System.Web.HttpContext context)
        {
            string str = context.Request.Form["SkuString"];

            System.Collections.Generic.Dictionary <string, SKUItem> result;
            if (string.IsNullOrEmpty(str))
            {
                product.HasSKU = false;
                System.Collections.Generic.Dictionary <string, SKUItem> dictionary2 = new System.Collections.Generic.Dictionary <string, SKUItem>();
                SKUItem item = new SKUItem
                {
                    SkuId     = "0",
                    SKU       = product.ProductCode,
                    SalePrice = decimal.Parse(context.Request.Form["SalePrice"]),
                    CostPrice = 0m,
                    Stock     = int.Parse(context.Request.Form["Stock"]),
                    Weight    = weight
                };
                dictionary2.Add("0", item);
                result = dictionary2;
            }
            else
            {
                product.HasSKU = true;
                System.Collections.Generic.Dictionary <string, SKUItem> dictionary3 = new System.Collections.Generic.Dictionary <string, SKUItem>();
                string[] array = System.Web.HttpUtility.UrlDecode(str).Split(new char[]
                {
                    '|'
                });
                for (int i = 0; i < array.Length; i++)
                {
                    string   str2     = array[i];
                    string[] strArray = str2.Split(new char[]
                    {
                        ','
                    });
                    SKUItem item2 = new SKUItem
                    {
                        SKU       = strArray[0],
                        Weight    = weight,
                        Stock     = int.Parse(strArray[1]),
                        SalePrice = decimal.Parse(strArray[2])
                    };
                    string   str3   = strArray[3];
                    string   str4   = "";
                    string[] array2 = str3.Split(new char[]
                    {
                        ';'
                    });
                    for (int j = 0; j < array2.Length; j++)
                    {
                        string   str5      = array2[j];
                        string[] strArray2 = str5.Split(new char[]
                        {
                            ':'
                        });
                        int specificationId      = ProductTypeHelper.GetSpecificationId(product.TypeId.Value, strArray2[0]);
                        int specificationValueId = ProductTypeHelper.GetSpecificationValueId(specificationId, strArray2[1]);
                        str4 = str4 + specificationValueId + "_";
                        item2.SkuItems.Add(specificationId, specificationValueId);
                    }
                    item2.SkuId = str4.Substring(0, str4.Length - 1);
                    dictionary3.Add(item2.SkuId, item2);
                }
                result = dictionary3;
            }
            return(result);
        }
Beispiel #4
0
        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);
                }
            }
        }
Beispiel #5
0
        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);
        }
        private System.Collections.Generic.Dictionary <string, SKUItem> GetSkus(ProductInfo product, int weight, System.Web.HttpContext context)
        {
            string text = context.Request.Form["SkuString"];

            System.Collections.Generic.Dictionary <string, SKUItem> dictionary;
            if (string.IsNullOrEmpty(text))
            {
                product.HasSKU = false;
                dictionary     = new System.Collections.Generic.Dictionary <string, SKUItem>
                {
                    {
                        "0",
                        new SKUItem
                        {
                            SkuId         = "0",
                            SKU           = product.ProductCode,
                            SalePrice     = decimal.Parse(context.Request.Form["SalePrice"]),
                            PurchasePrice = decimal.Parse(context.Request.Form["SalePrice"]),
                            CostPrice     = 0m,
                            Stock         = int.Parse(context.Request.Form["Stock"]),
                            Weight        = weight
                        }
                    }
                };
            }
            else
            {
                product.HasSKU = true;
                dictionary     = new System.Collections.Generic.Dictionary <string, SKUItem>();
                text           = System.Web.HttpUtility.UrlDecode(text);
                string[] array = text.Split(new char[]
                {
                    '|'
                });
                for (int i = 0; i < array.Length; i++)
                {
                    string   text2  = array[i];
                    string[] array2 = text2.Split(new char[]
                    {
                        ','
                    });
                    SKUItem sKUItem = new SKUItem();
                    sKUItem.SKU           = array2[0];
                    sKUItem.Weight        = weight;
                    sKUItem.Stock         = int.Parse(array2[1]);
                    sKUItem.PurchasePrice = (sKUItem.SalePrice = decimal.Parse(array2[2]));
                    string   text3  = array2[3];
                    string   text4  = "";
                    string[] array3 = text3.Split(new char[]
                    {
                        ';'
                    });
                    for (int j = 0; j < array3.Length; j++)
                    {
                        string   text5  = array3[j];
                        string[] array4 = text5.Split(new char[]
                        {
                            ':'
                        });
                        int specificationId      = ProductTypeHelper.GetSpecificationId(product.TypeId.Value, array4[0]);
                        int specificationValueId = ProductTypeHelper.GetSpecificationValueId(specificationId, array4[1]);
                        text4 = text4 + specificationValueId + "_";
                        sKUItem.SkuItems.Add(specificationId, specificationValueId);
                    }
                    sKUItem.SkuId = text4.Substring(0, text4.Length - 1);
                    dictionary.Add(sKUItem.SkuId, sKUItem);
                }
            }
            return(dictionary);
        }