Example #1
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            AttributeInfo attributeInfo = new AttributeInfo();

            attributeInfo.TypeId        = this.typeId;
            attributeInfo.AttributeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtName.Text).Replace(",", ",").Replace("\\", ""));
            if (string.IsNullOrEmpty(attributeInfo.AttributeName))
            {
                string str = string.Format("ShowMsg(\"{0}\", {1});", "规格名称限制在1-30个字符以内,不允许包含脚本标签、HTML标签和\\,系统会自动过滤", "false");
                this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>");
                return;
            }
            attributeInfo.UsageMode         = AttributeUseageMode.Choose;
            attributeInfo.UseAttributeImage = this.radIsImage.SelectedValue;
            ValidationResults validationResults = Validation.Validate <AttributeInfo>(attributeInfo, new string[]
            {
                "ValAttribute"
            });
            string str2 = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    str2 += Formatter.FormatErrorMessage(current.Message);
                }
                return;
            }
            ProductTypeHelper.GetAttributes(this.typeId, AttributeUseageMode.Choose);
            if (ProductTypeHelper.AddAttributeName(attributeInfo))
            {
                base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true);
            }
        }
Example #2
0
        private void DoCallback()
        {
            base.Response.Clear();
            base.Response.ContentType = "text/xml";
            string a = base.Request.QueryString["action"];

            if (a == "getAttributes")
            {
                System.Collections.Generic.IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(int.Parse(base.Request.QueryString["typeId"]));
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                stringBuilder.Append("<xml><attributes>");
                foreach (AttributeInfo current in attributes)
                {
                    stringBuilder.Append("<item attributeId=\"").Append(current.AttributeId.ToString(System.Globalization.CultureInfo.InvariantCulture)).Append("\" attributeName=\"").Append(current.AttributeName).Append("\" typeId=\"").Append(current.TypeId.ToString(System.Globalization.CultureInfo.InvariantCulture)).Append("\" />");
                }
                stringBuilder.Append("</attributes></xml>");
                base.Response.Write(stringBuilder.ToString());
            }
            if (a == "getValues")
            {
                AttributeInfo             attribute      = ProductTypeHelper.GetAttribute(int.Parse(base.Request.QueryString["attributeId"]));
                System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder();
                stringBuilder2.Append("<xml><values>");
                if (attribute != null && attribute.AttributeValues.Count > 0)
                {
                    foreach (AttributeValueInfo current2 in attribute.AttributeValues)
                    {
                        stringBuilder2.Append("<item valueId=\"").Append(current2.ValueId.ToString(System.Globalization.CultureInfo.InvariantCulture)).Append("\" valueStr=\"").Append(current2.ValueStr).Append("\" attributeId=\"").Append(current2.AttributeId.ToString(System.Globalization.CultureInfo.InvariantCulture)).Append("\" />");
                    }
                }
                stringBuilder2.Append("</values></xml>");
                base.Response.Write(stringBuilder2.ToString());
            }
            base.Response.End();
        }
Example #3
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            AttributeInfo attributeInfo = new AttributeInfo();

            attributeInfo.TypeId            = this.typeId;
            attributeInfo.AttributeName     = Globals.HtmlEncode(this.txtName.Text).Replace(",", ",");
            attributeInfo.UsageMode         = AttributeUseageMode.Choose;
            attributeInfo.UseAttributeImage = this.radIsImage.SelectedValue;
            ValidationResults validationResults = Validation.Validate <AttributeInfo>(attributeInfo, new string[]
            {
                "ValAttribute"
            });
            string str = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in ((System.Collections.Generic.IEnumerable <ValidationResult>)validationResults))
                {
                    str += Formatter.FormatErrorMessage(current.Message);
                }
                return;
            }
            ProductTypeHelper.GetAttributes(this.typeId, AttributeUseageMode.Choose);
            if (ProductTypeHelper.AddAttributeName(attributeInfo))
            {
                base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true);
            }
        }
Example #4
0
        private string GetSimpleProductView()
        {
            string productBrand = "";
            string categorys    = "";
            string productTags  = "";
            IList <ProductTypeInfo> productTypeList = null;
            string str4 = "";
            IList <AttributeInfo> attributes = null;
            string str5 = "";

            productBrand    = this.GetProductBrand();
            categorys       = this.GetCategorys();
            productTags     = this.GetProductTags();
            productTypeList = this.GetProductTypeList();
            attributes      = ProductTypeHelper.GetAttributes(AttributeUseageMode.MultiView);
            if (productTypeList != null)
            {
                str4 = JavaScriptConvert.SerializeObject(productTypeList);
            }
            if (attributes.Count > 0)
            {
                str5 = JavaScriptConvert.SerializeObject(attributes);
            }
            return("{\"Categorys\":" + categorys + ",\"Brands\":" + productBrand + ",\"Tags\":" + productTags + ",\"ProductTypes\":" + str4 + ",\"Attributes\":" + str5 + "}");
        }
Example #5
0
        private string GetSimpleProductView()
        {
            string text         = "";
            string text2        = "";
            string productBrand = this.GetProductBrand();
            string categorys    = this.GetCategorys();
            string productTags  = this.GetProductTags();

            System.Collections.Generic.IList <ProductTypeInfo> productTypeList = this.GetProductTypeList();
            System.Collections.Generic.IList <AttributeInfo>   attributes      = ProductTypeHelper.GetAttributes(AttributeUseageMode.MultiView);
            if (productTypeList != null)
            {
                text = JavaScriptConvert.SerializeObject(productTypeList);
            }
            if (attributes.Count > 0)
            {
                text2 = JavaScriptConvert.SerializeObject(attributes);
            }
            return(string.Concat(new string[]
            {
                "{\"Categorys\":",
                categorys,
                ",\"Brands\":",
                productBrand,
                ",\"Tags\":",
                productTags,
                ",\"ProductTypes\":",
                text,
                ",\"Attributes\":",
                text2,
                "}"
            }));
        }
Example #6
0
        private string GetSimpleProductView()
        {
            string text  = "";
            string text2 = "";
            string text3 = "";
            IList <ProductTypeInfo> list = null;
            string text4 = "[]";
            IList <AttributeInfo> list2 = null;
            string text5 = "[]";

            text  = this.GetProductBrand();
            text2 = this.GetCategorys();
            text3 = this.GetProductTags();
            list  = this.GetProductTypeList();
            list2 = ProductTypeHelper.GetAttributes(AttributeUseageMode.MultiView);
            if (list != null)
            {
                text4 = JsonConvert.SerializeObject(list);
            }
            if (list2.Count > 0)
            {
                text5 = JsonConvert.SerializeObject(list2);
            }
            return("{\"Categorys\":" + text2 + ",\"Brands\":" + text + ",\"Tags\":" + text3 + ",\"ProductTypes\":" + text4 + ",\"Attributes\":" + text5 + "}");
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            AttributeInfo target = new AttributeInfo
            {
                TypeId            = this.typeId,
                AttributeName     = Globals.HtmlEncode(this.txtName.Text).Replace(",", ","),
                UsageMode         = AttributeUseageMode.Choose,
                UseAttributeImage = this.radIsImage.SelectedValue
            };
            ValidationResults results = Hishop.Components.Validation.Validation.Validate <AttributeInfo>(target, new string[] { "ValAttribute" });
            string            str     = string.Empty;

            if (!results.IsValid)
            {
                foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                {
                    str = str + Formatter.FormatErrorMessage(result.Message);
                }
            }
            else
            {
                ProductTypeHelper.GetAttributes(this.typeId, AttributeUseageMode.Choose);
                if (ProductTypeHelper.AddAttributeName(target))
                {
                    base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
                }
            }
        }
        /// <summary>
        /// 创建产品规格
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            AttributeInfo attrInfo = new AttributeInfo();

            attrInfo.TypeId            = typeId;
            attrInfo.AttributeName     = Globals.HtmlEncode(txtName.Text);
            attrInfo.UsageMode         = AttributeUseageMode.Choose;
            attrInfo.UseAttributeImage = radIsImage.SelectedValue;

            ValidationResults results = Hishop.Components.Validation.Validation.Validate <AttributeInfo>(attrInfo, new string[] { "ValAttribute" });

            string str = string.Empty;

            if (!results.IsValid)
            {
                foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                {
                    str = str + Formatter.FormatErrorMessage(result.Message);
                }
            }
            else
            {
                ProductTypeHelper.GetAttributes(typeId, AttributeUseageMode.Choose);

                if (ProductTypeHelper.AddAttributeName(attrInfo))
                {
                    Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
                }
            }
        }
Example #9
0
        private DataGridViewModel <AttributeInfo> GetDataList(int typeId)
        {
            DataGridViewModel <AttributeInfo> dataGridViewModel = new DataGridViewModel <AttributeInfo>();
            IList <AttributeInfo>             attributes        = ProductTypeHelper.GetAttributes(typeId, AttributeUseageMode.Choose);

            dataGridViewModel.rows  = attributes.ToList();
            dataGridViewModel.total = attributes.Count;
            foreach (AttributeInfo row in dataGridViewModel.rows)
            {
            }
            return(dataGridViewModel);
        }
Example #10
0
        private void EditSku(HttpContext context)
        {
            int  value  = base.GetIntParam(context, "attributeId", false).Value;
            bool value2 = base.GetBoolParam(context, "UseAttributeImage", false).Value;
            int  value3 = base.GetIntParam(context, "typeId", false).Value;

            if (value < 1)
            {
                throw new HidistroAshxException("请选择要修改的规格,或刷新页面重试!");
            }
            int num = ProductTypeHelper.HasSetUseImg(value3);

            if (num > 0 && (num != value & value2))
            {
                throw new HidistroAshxException("已有其他规格可上传图片,最多只有一个规格允许上传商品规格图!");
            }
            string        parameter = base.GetParameter(context, "SkuName", false);
            AttributeInfo attribute = ProductTypeHelper.GetAttribute(value);

            if (attribute == null)
            {
                throw new HidistroAshxException("规格不存在,请刷新页面重试!");
            }
            string text = Globals.StripHtmlXmlTags(Globals.StripScriptTags(parameter)).Replace("\\", "").Trim();

            if (string.IsNullOrEmpty(text) || text.Length > 30)
            {
                throw new HidistroAshxException("规格名称限制在1-30个字符以内,不允许包含脚本标签、HTML标签和\\\\(反斜杠),系统会自动过滤!");
            }
            IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(attribute.TypeId);

            foreach (AttributeInfo item in attributes)
            {
                if (item.AttributeName.Trim() == text && item.AttributeId != value)
                {
                    throw new HidistroAshxException("同一个类型中不能存相同的规格/属性名称!");
                }
            }
            attribute.AttributeName     = text;
            attribute.UsageMode         = AttributeUseageMode.Choose;
            attribute.UseAttributeImage = value2;
            if (ProductTypeHelper.UpdateAttributeName(attribute))
            {
                base.ReturnSuccessResult(context, "修改成功!", 0, true);
                return;
            }
            throw new HidistroAshxException(" 修改规格错误!");
        }
Example #11
0
        protected void DoCallback()
        {
            base.Response.Clear();
            base.Response.ContentType = "application/json";
            string text = base.Request.QueryString["action"];

            if (text.Equals("getPrepareData"))
            {
                int typeId = int.Parse(base.Request.QueryString["typeId"]);
                System.Collections.Generic.IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(typeId);
                System.Data.DataTable dataTable = ProductTypeHelper.GetBrandCategoriesByTypeId(typeId);
                if (dataTable.Rows.Count == 0)
                {
                    dataTable = ControlProvider.Instance().GetBrandCategories();
                }
                base.Response.Write(this.GenerateJsonString(attributes, dataTable));
                attributes.Clear();
            }
            else
            {
                if (text.Equals("getMemberGradeList"))
                {
                    System.Collections.Generic.IList <MemberGradeInfo> memberGrades = MemberHelper.GetMemberGrades();
                    if (memberGrades == null || memberGrades.Count == 0)
                    {
                        base.Response.Write("{\"Status\":\"0\"}");
                    }
                    else
                    {
                        System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                        stringBuilder.Append("{\"Status\":\"OK\",\"MemberGrades\":[");
                        foreach (MemberGradeInfo current in memberGrades)
                        {
                            stringBuilder.Append("{");
                            stringBuilder.AppendFormat("\"GradeId\":\"{0}\",", current.GradeId);
                            stringBuilder.AppendFormat("\"Name\":\"{0}\",", current.Name);
                            stringBuilder.AppendFormat("\"Discount\":\"{0}\"", current.Discount);
                            stringBuilder.Append("},");
                        }
                        stringBuilder.Remove(stringBuilder.Length - 1, 1);
                        stringBuilder.Append("]}");
                        base.Response.Write(stringBuilder.ToString());
                    }
                }
            }
            base.Response.End();
        }
Example #12
0
        private void AddSku(HttpContext context)
        {
            int           value         = base.GetIntParam(context, "typeId", false).Value;
            bool          value2        = base.GetBoolParam(context, "UseAttributeImage", false).Value;
            string        parameter     = base.GetParameter(context, "SkuName", false);
            AttributeInfo attributeInfo = new AttributeInfo();

            attributeInfo.TypeId        = value;
            attributeInfo.AttributeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(parameter).Replace(",", ",").Replace("\\", "")).Trim();
            if (string.IsNullOrEmpty(attributeInfo.AttributeName))
            {
                throw new HidistroAshxException("规格名称限制在1-30个字符以内,不允许包含脚本标签、HTML标签和\\\\(反斜杠),系统会自动过滤!");
            }
            if (ProductTypeHelper.HasSetUseImg(value) > 0 && value2)
            {
                throw new HidistroAshxException("已有其他规格可上传图片,最多只有一个规格允许上传商品规格图!");
            }
            IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(attributeInfo.TypeId);

            foreach (AttributeInfo item in attributes)
            {
                if (item.AttributeName.Trim() == attributeInfo.AttributeName)
                {
                    throw new HidistroAshxException("同一个类型中不能存相同的规格/属性名称!");
                }
            }
            attributeInfo.UsageMode         = AttributeUseageMode.Choose;
            attributeInfo.UseAttributeImage = value2;
            ValidationResults validationResults = Validation.Validate(attributeInfo, "ValAttribute");
            string            str = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult item2 in (IEnumerable <ValidationResult>)validationResults)
                {
                    str += item2.Message;
                }
            }
            else
            {
                IList <AttributeInfo> attributes2 = ProductTypeHelper.GetAttributes(value, AttributeUseageMode.Choose);
                if (ProductTypeHelper.AddAttributeName(attributeInfo))
                {
                    base.ReturnSuccessResult(context, "添加成功!", 0, true);
                }
            }
        }
Example #13
0
        protected void DoCallback()
        {
            base.Response.Clear();
            base.Response.ContentType = "application/json";
            string str = base.Request.QueryString["action"];

            if (str.Equals("getPrepareData"))
            {
                int typeId = int.Parse(base.Request.QueryString["typeId"]);
                IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(typeId);
                DataTable             brandCategoriesByTypeId = ProductTypeHelper.GetBrandCategoriesByTypeId(typeId);
                if (brandCategoriesByTypeId.Rows.Count == 0)
                {
                    brandCategoriesByTypeId = CatalogHelper.GetBrandCategories(wid);
                }
                base.Response.Write(this.GenerateJsonString(attributes, brandCategoriesByTypeId));
                attributes.Clear();
            }
            else if (str.Equals("getMemberGradeList"))
            {
                IList <MemberGradeInfo> memberGrades = MemberHelper.GetMemberGrades(this.wid);
                if ((memberGrades == null) || (memberGrades.Count == 0))
                {
                    base.Response.Write("{\"Status\":\"0\"}");
                }
                else
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append("{\"Status\":\"OK\",\"MemberGrades\":[");
                    foreach (MemberGradeInfo info in memberGrades)
                    {
                        builder.Append("{");
                        builder.AppendFormat("\"GradeId\":\"{0}\",", info.GradeId);
                        builder.AppendFormat("\"Name\":\"{0}\",", info.Name);
                        builder.AppendFormat("\"Discount\":\"{0}\"", info.Discount);
                        builder.Append("},");
                    }
                    builder.Remove(builder.Length - 1, 1);
                    builder.Append("]}");
                    base.Response.Write(builder.ToString());
                }
            }
            base.Response.End();
        }
Example #14
0
        private void EditName(HttpContext context)
        {
            int value = base.GetIntParam(context, "id", false).Value;

            if (value < 1)
            {
                throw new HidistroAshxException("错误的参数!");
            }
            string parameter = base.GetParameter(context, "name", true);

            if (string.IsNullOrWhiteSpace(parameter))
            {
                throw new HidistroAshxException("错误的参数!");
            }
            AttributeInfo attribute = ProductTypeHelper.GetAttribute(value);

            if (attribute == null)
            {
                throw new HidistroAshxException("错误的参数!");
            }
            parameter = Globals.StripHtmlXmlTags(Globals.StripScriptTags(parameter)).Replace("\\", "").Trim();
            if (string.IsNullOrEmpty(parameter) || parameter.Length > 30)
            {
                throw new HidistroAshxException("属性名称限制在1-15个字符以内,不允许包含html字符和\\\\(反斜杠),系统会自动过滤");
            }
            IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(attribute.TypeId);

            foreach (AttributeInfo item in attributes)
            {
                if (item.AttributeName.Trim() == parameter && item.AttributeId != value)
                {
                    throw new HidistroAshxException("同一个类型中不能存相同的规格/属性名称!");
                }
            }
            attribute.AttributeName = parameter;
            if (ProductTypeHelper.UpdateAttributeName(attribute))
            {
                base.ReturnSuccessResult(context, "修改成功!", 0, true);
                return;
            }
            throw new HidistroAshxException(" 操作失败!");
        }
Example #15
0
        private void grdProductTypes_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            int typeId = (int)this.grdProductTypes.DataKeys[e.RowIndex].Value;

            System.Collections.Generic.IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(typeId, AttributeUseageMode.Choose);
            if (ProductTypeHelper.DeleteProductType(typeId))
            {
                foreach (AttributeInfo current in attributes)
                {
                    foreach (AttributeValueInfo current2 in current.AttributeValues)
                    {
                        StoreHelper.DeleteImage(current2.ImageUrl);
                    }
                }
                this.BindTypes();
                this.ShowMsg("成功删除了一个商品类型", true);
                return;
            }
            this.ShowMsg("删除商品类型失败, 可能有商品正在使用该类型", false);
        }
Example #16
0
        private void DoCallback()
        {
            base.Response.Clear();
            base.Response.ContentType = "text/xml";
            string str = base.Request.QueryString["action"];

            if (str != null)
            {
                if (!(str == "getAttributes"))
                {
                    if (str == "getValues")
                    {
                        AttributeInfo attribute = ProductTypeHelper.GetAttribute(int.Parse(base.Request.QueryString["attributeId"]));
                        StringBuilder builder2  = new StringBuilder();
                        builder2.Append("<xml><values>");
                        if ((attribute != null) && (attribute.AttributeValues.Count > 0))
                        {
                            foreach (AttributeValueInfo info3 in attribute.AttributeValues)
                            {
                                builder2.Append("<item valueId=\"").Append(info3.ValueId.ToString(CultureInfo.InvariantCulture)).Append("\" valueStr=\"").Append(info3.ValueStr).Append("\" attributeId=\"").Append(info3.AttributeId.ToString(CultureInfo.InvariantCulture)).Append("\" />");
                            }
                        }
                        builder2.Append("</values></xml>");
                        base.Response.Write(builder2.ToString());
                    }
                }
                else
                {
                    IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(int.Parse(base.Request.QueryString["typeId"]));
                    StringBuilder         builder    = new StringBuilder();
                    builder.Append("<xml><attributes>");
                    foreach (AttributeInfo info in attributes)
                    {
                        builder.Append("<item attributeId=\"").Append(info.AttributeId.ToString(CultureInfo.InvariantCulture)).Append("\" attributeName=\"").Append(info.AttributeName).Append("\" typeId=\"").Append(info.TypeId.ToString(CultureInfo.InvariantCulture)).Append("\" />");
                    }
                    builder.Append("</attributes></xml>");
                    base.Response.Write(builder.ToString());
                }
            }
            base.Response.End();
        }
Example #17
0
        private void grdProductTypes_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int typeId = (int)this.grdProductTypes.DataKeys[e.RowIndex].Value;
            IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(typeId, AttributeUseageMode.Choose);

            if (ProductTypeHelper.DeleteProductType(typeId))
            {
                foreach (AttributeInfo info in attributes)
                {
                    foreach (AttributeValueInfo info2 in info.AttributeValues)
                    {
                        StoreHelper.DeleteImage(info2.ImageUrl);
                    }
                }
                this.BindTypes();
                this.ShowMsg("成功删除了一个商品类型", true);
            }
            else
            {
                this.ShowMsg("删除商品类型失败, 可能有商品正在使用该类型", false);
            }
        }
Example #18
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);
                }
            }
        }
 /// <summary>
 /// 绑定属性
 /// </summary>
 void BindAttribute()
 {
     grdSKU.DataSource = ProductTypeHelper.GetAttributes(typeId, AttributeUseageMode.Choose);
     grdSKU.DataBind();
 }
Example #20
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);
        }
Example #21
0
 private void BindAttribute()
 {
     this.grdSKU.DataSource = ProductTypeHelper.GetAttributes(this.typeId, AttributeUseageMode.Choose);
     this.grdSKU.DataBind();
 }
Example #22
0
        protected void DoCallback()
        {
            base.Response.Clear();
            base.Response.ContentType = "application/json";
            string text = base.Request.QueryString["action"];

            if (text.Equals("getPrepareData"))
            {
                int typeId = int.Parse(base.Request.QueryString["typeId"]);
                IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(typeId);
                DataTable             dataTable  = ProductTypeHelper.GetBrandCategoriesByTypeId(typeId);
                if (dataTable.Rows.Count == 0)
                {
                    dataTable = CatalogHelper.GetBrandCategories(0);
                }
                base.Response.Write(this.GenerateJsonString(attributes, dataTable));
                attributes.Clear();
            }
            else if (text.Equals("getMemberGradeList"))
            {
                IList <MemberGradeInfo> memberGrades = MemberHelper.GetMemberGrades();
                if (memberGrades == null || memberGrades.Count == 0)
                {
                    base.Response.Write("{\"Status\":\"0\"}");
                }
                else
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append("{\"Status\":\"OK\",\"MemberGrades\":[");
                    foreach (MemberGradeInfo item in memberGrades)
                    {
                        stringBuilder.Append("{");
                        stringBuilder.AppendFormat("\"GradeId\":\"{0}\",", item.GradeId);
                        stringBuilder.AppendFormat("\"Name\":\"{0}\",", item.Name);
                        stringBuilder.AppendFormat("\"Discount\":\"{0}\"", item.Discount);
                        stringBuilder.Append("},");
                    }
                    stringBuilder.Remove(stringBuilder.Length - 1, 1);
                    stringBuilder.Append("]}");
                    base.Response.Write(stringBuilder.ToString());
                }
            }
            else if (text.Equals("checkProductCode"))
            {
                string productCode = Globals.StripAllTags(base.Request.QueryString["productCode"].ToNullString());
                int    productId   = 0;
                int.TryParse(base.Request.QueryString["productId"], out productId);
                ProductDao productDao = new ProductDao();
                if (productDao.IsExistsProductCode(productCode, productId))
                {
                    base.Response.Write(true);
                }
                else
                {
                    base.Response.Write(false);
                }
            }
            else if (text.Equals("checkSkuCode"))
            {
                string skuCode    = Globals.StripAllTags(base.Request.QueryString["skuCode"].ToNullString());
                int    productId2 = 0;
                int.TryParse(base.Request.QueryString["productId"], out productId2);
                ProductDao productDao2 = new ProductDao();
                if (productDao2.IsExistsSkuCode(skuCode, productId2))
                {
                    base.Response.Write(true);
                }
                else
                {
                    base.Response.Write(false);
                }
            }
            else if (text.Equals("getShippingTemplatesValuationMethod"))
            {
                int num = base.Request.QueryString["shippingTemplatesId"].ToInt(0);
                if (num > 0)
                {
                    ShippingTemplateInfo shippingTemplate = SalesHelper.GetShippingTemplate(num, false);
                    if (shippingTemplate != null)
                    {
                        StringBuilder stringBuilder2 = new StringBuilder();
                        stringBuilder2.Append("{\"Status\":\"OK\",\"ValuationMethod\":\"" + (int)shippingTemplate.ValuationMethod + "\"}");
                        base.Response.Write(stringBuilder2.ToString());
                        base.Response.End();
                    }
                }
                base.Response.Write("{\"Status\":\"FAIL\"}");
                base.Response.End();
            }
            base.Response.End();
        }