Exemple #1
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            ProductInfo product = new ProductInfo();

            product.ID                = RequestHelper.GetQueryString <int>("ID");
            product.Name              = this.Name.Text;
            product.Spelling          = ChineseCharacterHelper.GetFirstLetter(this.Name.Text);
            product.Color             = RequestHelper.GetForm <string>("ProductColor");
            product.FontStyle         = this.FontStyle.Text;
            product.ProductNumber     = this.ProductNumber.Text;
            product.ClassID           = this.ProductClass.ClassIDList;
            product.Keywords          = this.Keywords.Text;
            product.BrandID           = this.BrandID.Text;
            product.MarketPrice       = Convert.ToDecimal(this.MarketPrice.Text);
            product.SendPoint         = Convert.ToInt32(this.SendPoint.Text);
            product.Photo             = this.Photo.Text;
            product.Summary           = this.Summary.Text;
            product.Introduction      = this.Introduction.Value;
            product.Weight            = Convert.ToInt32(this.Weight.Text);
            product.IsSpecial         = Convert.ToInt32(this.IsSpecial.Text);
            product.IsNew             = Convert.ToInt32(this.IsNew.Text);
            product.IsHot             = Convert.ToInt32(this.IsHot.Text);
            product.IsSale            = Convert.ToInt32(this.IsSale.Text);
            product.IsTop             = Convert.ToInt32(this.IsTop.Text);
            product.Remark            = this.Remark.Text;
            product.Accessory         = RequestHelper.GetForm <string>("RelationAccessoryID");
            product.RelationProduct   = RequestHelper.GetForm <string>("RelationProductID");
            product.RelationArticle   = RequestHelper.GetForm <string>("RelationArticleID");
            product.AllowComment      = Convert.ToInt32(this.AllowComment.Text);
            product.TotalStorageCount = Convert.ToInt32(this.TotalStorageCount.Text);
            product.LowerCount        = Convert.ToInt32(this.LowerCount.Text);
            product.UpperCount        = Convert.ToInt32(this.UpperCount.Text);
            product.AttributeClassID  = Convert.ToInt32(this.AttributeClassID.Text);
            product.StandardType      = Convert.ToInt32(this.StandardType.Text);
            product.AddDate           = RequestHelper.DateNow;
            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (product.ID == -2147483648)
            {
                base.CheckAdminPower("AddProduct", PowerCheckType.Single);
                int productID = ProductBLL.AddProduct(product);
                this.AddProductPhoto(productID);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Product"), productID);
            }
            else
            {
                base.CheckAdminPower("UpdateProduct", PowerCheckType.Single);
                ProductBLL.UpdateProduct(product);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Product"), product.ID);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            this.HanderAttribute(product);
            this.HanderMemberPrice(product.ID);
            this.HanderProductStandard(product);
            AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
        }
        /// <summary>
        /// 保存草稿
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DraftButton_Click(object sender, EventArgs e)
        {
            int         id      = RequestHelper.GetQueryString <int>("ID");
            ProductInfo product = new ProductInfo();

            if (id > 0)
            {
                product = ProductBLL.Read(id);
            }
            product.Name          = Name.Text;
            product.Spelling      = ChineseCharacterHelper.GetFirstLetter(Name.Text);
            product.Color         = RequestHelper.GetForm <string>("ProductColor");
            product.FontStyle     = FontStyle.Text;
            product.ProductNumber = ProductNumber.Text;
            //product.ClassId = ProductClass.ClassID;
            if (!string.IsNullOrEmpty(RequestHelper.GetQueryString <string>("classId")))
            {
                product.ClassId = RequestHelper.GetQueryString <string>("classId");
            }
            product.Keywords          = Keywords.Text;
            product.BrandId           = RequestHelper.GetForm <int>("ctl00$ContentPlaceHolder$BrandID");
            product.MarketPrice       = Convert.ToDecimal(MarketPrice.Text);
            product.SendPoint         = Convert.ToInt32(SendPoint.Text);
            product.Photo             = Photo.Text;
            product.Summary           = Summary.Text;
            product.Introduction1     = Introduction.Value;
            product.Weight            = Convert.ToDecimal(Weight.Text);
            product.IsSpecial         = Convert.ToInt32(IsSpecial.Checked);
            product.IsNew             = Convert.ToInt32(IsNew.Checked);
            product.IsHot             = Convert.ToInt32(IsHot.Checked);
            product.IsSale            = 2;//草稿状态
            product.IsTop             = Convert.ToInt32(IsTop.Checked);
            product.Remark            = Remark.Value;
            product.Accessory         = RequestHelper.GetForm <string>("RelationAccessoryID");
            product.RelationProduct   = RequestHelper.GetForm <string>("RelationProductID");
            product.RelationArticle   = RequestHelper.GetForm <string>("RelationArticleID");
            product.AllowComment      = Convert.ToInt32(AllowComment.Checked);
            product.TotalStorageCount = Convert.ToInt32(TotalStorageCount.Text);
            if (TotalStorageCount.ReadOnly)
            {
                product.TotalStorageCount = Convert.ToInt32(HidTotalStorageCount.Value);
            }
            product.LowerCount   = Convert.ToInt32(LowerCount.Text.Trim());
            product.UpperCount   = 0;
            product.StandardType = Convert.ToInt32(RequestHelper.GetForm <string>("StandardType"));
            product.AddDate      = RequestHelper.DateNow;


            product.OrderId = Convert.ToInt32(OrderID.Text.Trim());

            product.SalePrice            = Convert.ToDecimal(SalePrice.Text);
            product.Unit                 = Units.Text;
            product.Introduction1_Mobile = Introduction_Mobile.Value;
            product.SubTitle             = Sub_Title.Text;

            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            CheckAdminPower("AddProduct", PowerCheckType.Single);
            int pid = ProductBLL.Add(product);

            AddProductPhoto(pid);
            AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Product"), pid);

            HanderAttribute(product);
            //HanderMemberPrice(product.ID);
            HanderProductStandard(product);
            ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl);
        }
        /// <summary>
        /// 提交按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            int         id      = RequestHelper.GetQueryString <int>("ID");
            ProductInfo product = new ProductInfo();

            if (id > 0)
            {
                product = ProductBLL.Read(id);
            }
            product.YejiRatio     = YejiRatio.Text;
            product.Name          = Name.Text;
            product.SellPoint     = SellPoint.Text;
            product.Spelling      = ChineseCharacterHelper.GetFirstLetter(Name.Text);
            product.Color         = RequestHelper.GetForm <string>("ProductColor");
            product.FontStyle     = FontStyle.Text;
            product.ProductNumber = ProductNumber.Text;
            //product.ClassId = ProductClass.ClassID;
            if (!string.IsNullOrEmpty(RequestHelper.GetQueryString <string>("classId")))
            {
                product.ClassId = RequestHelper.GetQueryString <string>("classId");
            }
            product.Keywords      = Keywords.Text;
            product.BrandId       = RequestHelper.GetForm <int>("ctl00$ContentPlaceHolder$BrandID");
            product.MarketPrice   = Convert.ToDecimal(MarketPrice.Text);
            product.SendPoint     = Convert.ToInt32(SendPoint.Text);
            product.Photo         = Photo.Text;
            product.Summary       = Summary.Text;
            product.Introduction1 = Introduction.Value;
            product.Weight        = Convert.ToDecimal(Weight.Text);
            product.IsSpecial     = Convert.ToInt32(IsSpecial.Checked);
            product.IsNew         = Convert.ToInt32(IsNew.Checked);
            product.IsHot         = Convert.ToInt32(IsHot.Checked);
            product.IsSale        = Convert.ToInt32(IsSale.Checked);
            product.IsTop         = Convert.ToInt32(IsTop.Checked);
            //保存时如果售后服务为空则自动获取所属分类的售后服务并保存
            product.Remark            = string.IsNullOrEmpty(StringHelper.KillHTML(Remark.Value)) ? GetProductClassRemark(product.ClassId) : Remark.Value;
            product.Accessory         = RequestHelper.GetForm <string>("RelationAccessoryID");
            product.RelationProduct   = RequestHelper.GetForm <string>("RelationProductID");
            product.RelationArticle   = RequestHelper.GetForm <string>("RelationArticleID");
            product.AllowComment      = Convert.ToInt32(AllowComment.Checked);
            product.TotalStorageCount = Convert.ToInt32(TotalStorageCount.Text);
            if (TotalStorageCount.ReadOnly)
            {
                product.TotalStorageCount = Convert.ToInt32(HidTotalStorageCount.Value);
            }
            product.LowerCount   = Convert.ToInt32(LowerCount.Text.Trim());
            product.UpperCount   = 0;
            product.StandardType = Convert.ToInt32(RequestHelper.GetForm <string>("StandardType"));
            product.AddDate      = RequestHelper.DateNow;


            product.OrderId = Convert.ToInt32(OrderID.Text.Trim());

            product.SalePrice            = Convert.ToDecimal(SalePrice.Text);
            product.Unit                 = Units.Text;
            product.Introduction1_Mobile = Introduction_Mobile.Value;
            product.SubTitle             = Sub_Title.Text;
            #region 商品开团
            //是否开启开团
            product.OpenGroup = RequestHelper.GetForm <int>("ctl00$ContentPlaceHolder$OpenGroup") <= 0 ? 0 : 1;
            decimal _groupPrice = 0;
            decimal.TryParse(GroupPrice.Text.Trim(), out _groupPrice);
            product.GroupPrice = _groupPrice < 0 ? 0 : _groupPrice;
            int _groupQuantity = 0;
            int.TryParse(GroupQuantity.Text.Trim(), out _groupQuantity);
            product.GroupQuantity = _groupQuantity < 0 ? 0 : _groupQuantity;
            product.GroupPhoto    = GroupPhoto.Text;
            #endregion

            //是否启用不限库存
            product.UnlimitedStorage = RequestHelper.GetForm <int>("ctl00$ContentPlaceHolder$UnlimitedStorage");
            #region 虚拟库存
            //是否启用虚拟销量
            product.UseVirtualOrder = RequestHelper.GetForm <int>("ctl00$ContentPlaceHolder$UseVirtualOrder") <= 0 ? 0 : 1;
            //虚拟销量数
            product.VirtualOrderCount = Convert.ToInt32(VirtualOrderCount.Text) <= 0 ? 0 : Convert.ToInt32(VirtualOrderCount.Text);
            #endregion

            string alertMessage = ShopLanguage.ReadLanguage("AddOK");
            if (id <= 0)
            {
                CheckAdminPower("AddProduct", PowerCheckType.Single);
                int pid = ProductBLL.Add(product);
                AddProductPhoto(pid);
                #region 添加时生成手机网站二维码
                //string ewmName = string.Empty;//二维码路径
                //CreateQRcode("http://" + HttpContext.Current.Request.Url.Host + (HttpContext.Current.Request.Url.Port > 0 ? ":" + HttpContext.Current.Request.Url.Port : "") + "/mobile/ProductDetail-i" + pid + ".html", "pro_" + pid.ToString(), ref ewmName);
                //Dictionary<string, object> dict = new Dictionary<string, object>();
                //dict.Add("[Qrcode]", ewmName);
                //ProductBLL.UpdatePart("[Product]", dict, pid);
                #endregion
                #region 添加时生成小程序商品推广码(扫码进入小程序商品详情页)
                string product_miniProramCode = string.Empty;
                CreateMiniProgramCode(pid, ref product_miniProramCode, product.Qrcode);
                Dictionary <string, object> dict = new Dictionary <string, object>();
                dict.Add("[Qrcode]", product_miniProramCode);
                ProductBLL.UpdatePart("[Product]", dict, pid);
                #endregion
                AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Product"), pid);
            }
            else
            {
                CheckAdminPower("UpdateProduct", PowerCheckType.Single);
                #region 添加时生成小程序商品推广码(扫码进入小程序商品详情页)
                string product_miniProramCode = string.Empty;
                CreateMiniProgramCode(id, ref product_miniProramCode, product.Qrcode);
                product.Qrcode = product_miniProramCode;
                #endregion
                ProductBLL.Update(product);
                AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Product"), product.Id);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            HanderAttribute(product);
            //HanderMemberPrice(product.ID);
            HanderProductStandard(product);
            ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl);
        }
Exemple #4
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            ProductInfo product = new ProductInfo();

            product.ID        = RequestHelper.GetQueryString <int>("ID");
            product.CompanyID = companyID;
            product.Name      = this.Name.Text;
            product.Spelling  = ChineseCharacterHelper.GetFirstLetter(this.Name.Text);
            product.Color     = RequestHelper.GetForm <string>("ProductColor");
            //product.FontStyle = this.FontStyle.Text;
            product.ProductNumber = this.ProductNumber.Text;
            product.ClassID       = this.ProductClass.ClassIDList;
            product.Keywords      = this.Keywords.Text;
            if (string.IsNullOrEmpty(RequestHelper.GetForm <string>("AllBrandID")))
            {
                product.BrandID = RequestHelper.GetIntsForm("BrandID");
            }
            else
            {
                product.BrandID = RequestHelper.GetIntsForm("AllBrandID");
            }
            product.MarketPrice      = Convert.ToDecimal(this.MarketPrice.Text);
            product.Photo            = this.Photo.Text;
            product.Summary          = this.Summary.Text;
            product.Introduction     = this.Introduction.Value;
            product.IsSpecial        = Convert.ToInt32(this.IsSpecial.Text);
            product.IsNew            = Convert.ToInt32(this.IsNew.Text);
            product.IsHot            = Convert.ToInt32(this.IsHot.Text);
            product.IsSale           = Convert.ToInt32(this.IsSale.Text);
            product.IsTop            = Convert.ToInt32(this.IsTop.Text);
            product.Remark           = this.Remark.Text;
            product.Accessory        = RequestHelper.GetForm <string>("RelationAccessoryID");
            product.RelationProduct  = RequestHelper.GetForm <string>("RelationProductID");
            product.RelationArticle  = RequestHelper.GetForm <string>("RelationArticleID");
            product.AllowComment     = Convert.ToInt32(this.AllowComment.Text);
            product.AttributeClassID = Convert.ToInt32(this.AttributeClassID.Text);
            product.StandardType     = Convert.ToInt32(this.StandardType.Text);
            product.AddDate          = RequestHelper.DateNow;
            product.Sort             = Convert.ToInt32(Sort.Text);
            product.Editor           = Editor.Text;
            int    productID    = 0;
            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (product.ID == -2147483648)
            {
                base.CheckAdminPower("AddProduct", PowerCheckType.Single);
                productID = ProductBLL.AddProduct(product);
                this.AddProductPhoto(productID);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Product"), productID);
            }
            else
            {
                base.CheckAdminPower("UpdateProduct", PowerCheckType.Single);
                //公司发生变化,删除旧的考试设置
                ProductInfo oldProduct = ProductBLL.ReadProduct(product.ID);
                if (product.CompanyID != ProductBLL.ReadProduct(product.ID).CompanyID)
                {
                    try
                    {
                        TestSettingBLL.DeleteTestSetting(TestSettingBLL.ReadCompanyTestSetting(oldProduct.CompanyID, product.ID).Id);
                    }
                    catch (Exception ex)
                    { }
                }
                ProductBLL.UpdateProduct(product);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Product"), product.ID);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            this.HanderAttribute(product);
            //this.HanderMemberPrice(product.ID);
            this.HanderProductStandard(product);
            if (product.ID == int.MinValue)
            {
                product.ID = productID;
            }
            this.HanderTestSetting(product);
            AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
        }
        /// <summary>
        /// 提交按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            int         id      = RequestHelper.GetQueryString <int>("ID");
            ProductInfo product = new ProductInfo();

            //if (id > 0) product = ProductBLL.Read(id);
            product.Name          = Name.Text;
            product.SellPoint     = SellPoint.Text;
            product.Spelling      = ChineseCharacterHelper.GetFirstLetter(Name.Text);
            product.Color         = RequestHelper.GetForm <string>("ProductColor");
            product.FontStyle     = FontStyle.Text;
            product.ProductNumber = ProductNumber.Text;
            //product.ClassId = ProductClass.ClassID;
            product.ClassId       = string.IsNullOrEmpty(RequestHelper.GetQueryString <string>("classId")) ? ProductBLL.Read(id).ClassId : RequestHelper.GetQueryString <string>("classId");
            product.Keywords      = Keywords.Text;
            product.BrandId       = RequestHelper.GetForm <int>("ctl00$ContentPlaceHolder$BrandID");
            product.MarketPrice   = Convert.ToDecimal(MarketPrice.Text);
            product.SendPoint     = Convert.ToInt32(SendPoint.Text);
            product.Photo         = Photo.Text;
            product.Summary       = Summary.Text;
            product.Introduction1 = Introduction.Value;
            product.Weight        = Convert.ToDecimal(Weight.Text);
            product.IsSpecial     = Convert.ToInt32(IsSpecial.Checked);
            product.IsNew         = Convert.ToInt32(IsNew.Checked);
            product.IsHot         = Convert.ToInt32(IsHot.Checked);
            product.IsSale        = Convert.ToInt32(IsSale.Checked);
            product.IsTop         = Convert.ToInt32(IsTop.Checked);
            //保存时如果售后服务为空则自动获取所属分类的售后服务并保存
            product.Remark            = string.IsNullOrEmpty(StringHelper.KillHTML(Remark.Value)) ? GetProductClassRemark(product.ClassId) : Remark.Value;
            product.Accessory         = RequestHelper.GetForm <string>("RelationAccessoryID");
            product.RelationProduct   = RequestHelper.GetForm <string>("RelationProductID");
            product.RelationArticle   = RequestHelper.GetForm <string>("RelationArticleID");
            product.AllowComment      = Convert.ToInt32(AllowComment.Checked);
            product.TotalStorageCount = Convert.ToInt32(TotalStorageCount.Text);
            if (TotalStorageCount.ReadOnly)
            {
                product.TotalStorageCount = Convert.ToInt32(HidTotalStorageCount.Value);
            }
            product.LowerCount   = 0;
            product.UpperCount   = 0;
            product.StandardType = Convert.ToInt32(RequestHelper.GetForm <string>("StandardType"));
            product.AddDate      = RequestHelper.DateNow;


            product.OrderId = Convert.ToInt32(OrderID.Text.Trim());

            product.SalePrice            = Convert.ToDecimal(SalePrice.Text);
            product.Unit                 = Units.Text;
            product.Introduction1_Mobile = Introduction_Mobile.Value;
            product.SubTitle             = Sub_Title.Text;

            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            CheckAdminPower("AddProduct", PowerCheckType.Single);
            int pid = ProductBLL.Add(product);

            AddProductPhoto(pid);
            #region 添加时生成二维码
            string ewmName = string.Empty;//二维码路径
            CreateQRcode("http://" + HttpContext.Current.Request.Url.Host + (HttpContext.Current.Request.Url.Port > 0 ? ":" + HttpContext.Current.Request.Url.Port : "") + "/mobile/ProductDetail-i" + pid + ".html", "pro_" + pid.ToString(), ref ewmName);
            ProductInfo tmpProduct = ProductBLL.Read(pid);
            tmpProduct.Qrcode = ewmName;
            ProductBLL.Update(tmpProduct);
            #endregion
            AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Product"), pid);

            HanderAttribute(product);
            HanderProductStandard(product);
            ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl);
        }
Exemple #6
0
        protected void ImportProducts(object sender, EventArgs e)
        {
            string categoryId    = ProductClass.ClassID;
            int    saleStatus    = Convert.ToInt32(IsSale.SelectedValue);
            string selectedValue = dropFiles.SelectedValue;

            selectedValue = Path.Combine(_dataPath, selectedValue);

            if (!File.Exists(selectedValue))
            {
                ScriptHelper.Alert("选择的数据包文件有问题!");
            }
            else
            {
                PrepareDataFiles(new object[] { selectedValue });
                string    path        = Path.Combine(_dataPath, Path.GetFileNameWithoutExtension(selectedValue));
                DataTable productData = (DataTable)ProductBLL.ParseProductData(new object[] { path })[0];
                if ((productData != null) && (productData.Rows.Count > 0))
                {
                    foreach (DataRow row in productData.Rows)
                    {
                        ProductInfo product = new ProductInfo
                        {
                            ClassId       = categoryId,
                            Name          = (string)row["ProductName"],
                            ProductNumber = (string)row["SKU"],
                            BrandId       = 0
                        };
                        if (row["Description"] != DBNull.Value)
                        {
                            product.Introduction1 = (string)row["Description"];
                        }
                        product.AddDate           = DateTime.Now;
                        product.IsSale            = saleStatus;
                        product.MarketPrice       = (decimal)row["SalePrice"];
                        product.TotalStorageCount = (int)row["Stock"];

                        product.Spelling  = ChineseCharacterHelper.GetFirstLetter((string)row["ProductName"]);
                        product.SendPoint = 0;
                        product.Weight    = 0;
                        product.IsSpecial = 0;
                        product.IsNew     = 0;
                        product.IsHot     = 0;
                        if (row["Has_ShowCase"] != DBNull.Value)
                        {
                            product.IsTop = Convert.ToInt32(row["Has_ShowCase"]);
                        }
                        product.AllowComment = 0;
                        product.LowerCount   = 0;
                        product.UpperCount   = 0;
                        product.StandardType = 0;
                        product.AddDate      = RequestHelper.DateNow;

                        product.OrderId   = 0;
                        product.SalePrice = (decimal)row["SalePrice"];

                        if (row["ImageUrl1"] != DBNull.Value)
                        {
                            product.Photo = (string)row["ImageUrl1"];
                        }

                        int proID = ProductBLL.Add(product);
                        #region 生成缩略图和产品相册图
                        if (!(string.IsNullOrEmpty(product.Photo) || (product.Photo.Length <= 0)))
                        {
                            UploadImage(product.Photo, PhotoType.Product);
                        }

                        if (row["ImageUrl2"] != DBNull.Value)
                        {
                            ProductPhotoInfo tempPhoto = new ProductPhotoInfo()
                            {
                                ProductId = proID,
                                Name      = "ImageUrl2",
                                ImageUrl  = (string)row["ImageUrl2"],
                                AddDate   = DateTime.Now
                            };
                            ProductPhotoBLL.Add(tempPhoto);
                            UploadImage(tempPhoto.ImageUrl, PhotoType.ProductPhoto);
                        }
                        if (row["ImageUrl3"] != DBNull.Value)
                        {
                            ProductPhotoInfo tempPhoto = new ProductPhotoInfo()
                            {
                                ProductId = proID,
                                Name      = "ImageUrl3",
                                ImageUrl  = (string)row["ImageUrl3"],
                                AddDate   = DateTime.Now
                            };
                            ProductPhotoBLL.Add(tempPhoto);
                            UploadImage(tempPhoto.ImageUrl, PhotoType.ProductPhoto);
                        }
                        if (row["ImageUrl4"] != DBNull.Value)
                        {
                            ProductPhotoInfo tempPhoto = new ProductPhotoInfo()
                            {
                                ProductId = proID,
                                Name      = "ImageUrl4",
                                ImageUrl  = (string)row["ImageUrl4"],
                                AddDate   = DateTime.Now
                            };
                            ProductPhotoBLL.Add(tempPhoto);
                            UploadImage(tempPhoto.ImageUrl, PhotoType.ProductPhoto);
                        }
                        if (row["ImageUrl5"] != DBNull.Value)
                        {
                            ProductPhotoInfo tempPhoto = new ProductPhotoInfo()
                            {
                                ProductId = proID,
                                Name      = "ImageUrl5",
                                ImageUrl  = (string)row["ImageUrl5"],
                                AddDate   = DateTime.Now
                            };
                            ProductPhotoBLL.Add(tempPhoto);
                            UploadImage(tempPhoto.ImageUrl, PhotoType.ProductPhoto);
                        }
                        #endregion
                    }

                    File.Delete(selectedValue);
                    Directory.Delete(path, true);
                    BindFiles();
                    ScriptHelper.Alert("此次商品批量导入操作已成功!", RequestHelper.RawUrl);
                }
            }
        }
Exemple #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string appKey    = ShopConfig.ReadConfigInfo().AppKey;
            string appSecret = ShopConfig.ReadConfigInfo().AppSecret;

            if ((RequestHelper.GetQueryString <string>("code") != string.Empty) || (RequestHelper.GetQueryString <string>("error") != string.Empty))
            {
                string queryString = RequestHelper.GetQueryString <string>("code");
                string content     = string.Empty;
                try
                {
                    string     url        = "https://oauth.taobao.com/token";
                    string     postData   = "grant_type=authorization_code&code=" + queryString + "&redirect_uri=http://" + base.Request.ServerVariables["Http_Host"] + "&client_id=" + appKey + "&client_secret=" + appSecret;
                    AccessData data       = (AccessData)JavaScriptConvert.DeserializeObject(HttpHelper.WebRequestPost(url, postData), typeof(AccessData));
                    string     str8       = data.access_token;
                    string     str9       = string.Empty;
                    int        totalCount = 0;
                    int        pageSize   = 200;
                    str9 = this.GetProductID(str8, appKey, appSecret, pageSize, 1, ref totalCount);
                    int num3        = (int)Math.Ceiling((decimal)(totalCount / pageSize));
                    int currentPage = 2;
                    while (currentPage <= num3)
                    {
                        str9 = str9 + "," + this.GetProductID(str8, appKey, appSecret, pageSize, currentPage, ref totalCount);
                        currentPage++;
                    }
                    decimal discount = UserGradeBLL.ReadUserGradeByMoney(0M).Discount;
                    foreach (string str10 in str9.Split(new char[] { ',' }))
                    {
                        ProductInfo info;
                        string      str11     = "http://gw.api.taobao.com/router/rest?";
                        string[]    strArray2 = StringHelper.BubbleSortASC(new string[] { "method=taobao.item.get", "timestamp=" + RequestHelper.DateNow.ToString("yyyy-MM-dd HH:mm:ss"), "app_key=" + appKey, "v=2.0", "sign_method=md5", "fields=title,desc,created,seller_cids,pic_url,num,price", "num_iid=" + str10 });
                        string      str12     = string.Empty;
                        string      str13     = string.Empty;
                        for (currentPage = 0; currentPage < strArray2.Length; currentPage++)
                        {
                            str13 = str13 + strArray2[currentPage].Replace("=", string.Empty);
                            str12 = str12 + "&" + strArray2[currentPage];
                        }
                        string      xml      = HttpHelper.WebRequestGet(str11 + "sign=" + FormsAuthentication.HashPasswordForStoringInConfigFile(appSecret + str13 + appSecret, "MD5") + str12);
                        XmlDocument document = new XmlDocument();
                        document.LoadXml(xml);
                        info                   = new ProductInfo();
                        info.Name              = document.SelectSingleNode("item_get_response/item/title").InnerText;
                        info.Spelling          = ChineseCharacterHelper.GetFirstLetter(info.Name);
                        info.Introduction      = document.SelectSingleNode("item_get_response/item/desc").InnerText;
                        info.Summary           = StringHelper.Substring(StringHelper.KillHTML(info.Introduction), 200);
                        info.AddDate           = Convert.ToDateTime(document.SelectSingleNode("item_get_response/item/created").InnerText);
                        info.ClassID           = this.ReadSystemClassID(document.SelectSingleNode("item_get_response/item/seller_cids").InnerText);
                        info.Photo             = document.SelectSingleNode("item_get_response/item/pic_url").InnerText;
                        info.TotalStorageCount = Convert.ToInt32(document.SelectSingleNode("item_get_response/item/num").InnerText);
                        info.MarketPrice       = (100M * Convert.ToDecimal(document.SelectSingleNode("item_get_response/item/price").InnerText)) / discount;
                        info.TaobaoID          = Convert.ToInt64(str10);
                        ProductBLL.TaobaoProduct(info);
                    }
                    string str15 = "<script language='javascript'>window.close();</script>";
                    ResponseHelper.Write(str15);
                    ResponseHelper.End();
                }
                catch (Exception exception)
                {
                    content = exception.Message.ToString();
                }
                if (content == string.Empty)
                {
                    content = RequestHelper.GetQueryString <string>("error");
                }
                if (content != string.Empty)
                {
                    ResponseHelper.Write(content);
                }
            }
            else
            {
                ResponseHelper.Redirect("https://oauth.taobao.com/authorize?response_type=code&client_id=" + appKey + "&redirect_uri=" + ("http://" + base.Request.ServerVariables["Http_Host"] + "/Admin/TaobaoProductAdd.aspx"));
            }
        }