コード例 #1
0
        public ApiMessage CreateProperty()
        {
            BProperty           property    = new BProperty();
            ApiMessage          message     = new ApiMessage();
            string              user_id     = User.Identity.Name;
            UserManager         userMgr     = new UserManager(int.Parse(user_id), null);
            BUser               user        = userMgr.CurrentUser;
            Shop                currentShop = userMgr.Shop;
            ShopCategoryManager cateMgr     = new ShopCategoryManager(userMgr.CurrentUser, currentShop, userMgr.CurrentUserPermission);
            HttpContextBase     context     = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase     request     = context.Request;
            string              categoryId  = request["category_id"];
            string              propName    = request["prop_name"];
            string              propValue   = request["prop_value"];
            List <string>       propValues  = new List <string>();

            if (!string.IsNullOrEmpty(propValue))
            {
                string[] vs = propValue.Split(',');
                if (vs != null && vs.Length > 0)
                {
                    for (int i = 0; i < vs.Length; i++)
                    {
                        propValues.Add(vs[i]);
                    }
                }
            }

            try
            {
                property       = cateMgr.CreateProperty(int.Parse(categoryId), propName, propValues);
                message.Item   = property;
                message.Status = "ok";
            }
            catch (KM.JXC.Common.KMException.KMJXCException ex)
            {
                message.Status  = "failed";
                message.Message = ex.Message;
                message.Item    = null;
            }
            catch (Exception nex)
            {
            }

            return(message);
        }
コード例 #2
0
        public BProperty GetProperty()
        {
            BProperty           property = new BProperty();
            string              user_id  = User.Identity.Name;
            UserManager         userMgr  = new UserManager(int.Parse(user_id), null);
            BUser               user     = userMgr.CurrentUser;
            Shop                MainShop = userMgr.Main_Shop;
            ShopCategoryManager cateMgr  = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);
            HttpContextBase     context  = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase     request  = context.Request;
            int propId = 0;

            int.TryParse(request["prop_id"], out propId);
            List <BProperty> properties = cateMgr.GetProperties(0, propId);

            if (properties.Count == 1)
            {
                property = properties[0];
            }

            return(property);
        }
コード例 #3
0
ファイル: TaobaoShopManager.cs プロジェクト: 21ki/kuanmai
        /// <summary>
        ///
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public List <BProperty> GetProperities(Product_Class category, Shop shop)
        {
            List <BProperty>    properities = new List <BProperty>();
            ItempropsGetRequest req         = new ItempropsGetRequest();

            req.Fields = "pid,name,must,multi,prop_values";
            if (category != null && !string.IsNullOrEmpty(category.Mall_CID))
            {
                req.Cid = long.Parse(category.Mall_CID);
            }
            else
            {
                req.Cid = 0;
            }
            //req.IsKeyProp = true;
            req.IsSaleProp  = true;
            req.IsColorProp = true;
            req.IsEnumProp  = true;
            req.IsInputProp = true;
            req.IsItemProp  = true;
            //1=>Taobao
            //2=>TMall, need to check Mall Type from Shop object
            req.Type = 1L;

            ItempropsGetResponse response = client.Execute(req);

            if (response.IsError)
            {
                throw new KMJXCException(response.ErrMsg);
            }

            if (response.ItemProps != null)
            {
                foreach (TB.ItemProp prop in response.ItemProps)
                {
                    BProperty pro = new BProperty();
                    pro.Created    = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                    pro.MID        = prop.Pid.ToString();
                    pro.Name       = prop.Name;
                    pro.CategoryId = category.Product_Class_ID;
                    pro.ID         = 0;
                    pro.Shop       = new BShop()
                    {
                        ID = category.Shop_ID
                    };
                    pro.Created_By = new BUser()
                    {
                        ID = category.Create_User_ID
                    };
                    properities.Add(pro);
                    if (prop.PropValues != null)
                    {
                        foreach (TB.PropValue pv in prop.PropValues)
                        {
                            Product_Spec_Value psv = new Product_Spec_Value();
                            psv.Name = pv.Name;
                            pro.Values.Add(psv);
                        }
                    }
                }
            }

            return(properities);
        }