//�õ��Ա���������Ʒ��Ŀ /// <summary> /// �õ��Ա���������Ʒ��Ŀ /// taobao.itemcats.get ��ȡ��̨����ҷ�����Ʒ�ı���Ʒ��Ŀ /// </summary> /// <returns></returns> public List<ItemCat> GetAllItemCatByApi(long parentCid) { ItemcatsGetRequest req = new ItemcatsGetRequest(); req.Fields = "cid,parent_cid,name,is_parent"; req.ParentCid = parentCid; ItemcatsGetResponse response = client.Execute(req); return response.ItemCats; }
/// <summary> /// 类目的取得 /// </summary> /// <param name="cid">属性编号</param> /// <returns>类目</returns> private ItemcatsGetResponse TaobaoItemcatsGet(long cid) { var req = new ItemcatsGetRequest { Fields = "cid,parent_cid,name,is_parent", Cids = cid.ToString() + "," }; var response = _client.Execute(req); return(response); }
//得到淘宝的所有商品类目 /// <summary> /// 得到淘宝的所有商品类目 /// taobao.itemcats.get 获取后台供卖家发布商品的标准商品类目 /// </summary> /// <returns></returns> public List <ItemCat> GetAllItemCatByApi(long parentCid) { ItemcatsGetRequest req = new ItemcatsGetRequest(); req.Fields = "cid,parent_cid,name,is_parent"; req.ParentCid = parentCid; ItemcatsGetResponse response = client.Execute(req); return(response.ItemCats); }
/// <summary> /// 获取后台供卖家发布商品的标准商品类目 /// </summary> internal List <ItemCat> GetItemcats(string Cids, string ParentCid) { ITopClient client = new DefaultTopClient(StaticSystemConfig.soft.ApiURL, StaticSystemConfig.soft.AppKey, StaticSystemConfig.soft.AppSecret, "json"); ItemcatsGetRequest req = new ItemcatsGetRequest(); req.Fields = "features,taosir_cat,cid,parent_cid,name,is_parent,status,sort_order"; if (ParentCid != null) { req.ParentCid = long.Parse(ParentCid); } if (Cids != null) { req.Cids = Cids; } ItemcatsGetResponse response = client.Execute(req); List <ItemCat> ListItemCat = new List <ItemCat>(); ItemCat newitem; if (response.ItemCats == null) { return(null); } foreach (Top.Api.Domain.ItemCat item in response.ItemCats) { newitem = new ItemCat(); newitem.Cid = item.Cid; newitem.Features = new List <Feature>(); newitem.IsParent = item.IsParent; newitem.Name = item.Name; newitem.ParentCid = item.ParentCid; newitem.SortOrder = item.SortOrder; newitem.Status = item.Status; if (!item.IsParent) { List <Feature> ListFeature = new List <Feature>(); Feature newfea; if (item.Features != null) { foreach (Top.Api.Domain.Feature itemchid in item.Features) { newfea = new Feature(); newfea.AttrKey = itemchid.AttrKey; newfea.AttrValue = itemchid.AttrValue; ListFeature.Add(newfea); } } } ListItemCat.Add(newitem); } return(ListItemCat); }
/// <summary> /// taobao.itemcats.get /// 获取后台供卖家发布商品的标准商品类目 /// </summary> /// <param name="fields">需要返回的字段列表,ItemCat中所有字段</param> /// <param name="parentcid">父商品类目 id,0表示根节点, 传输该参数返回所有子类目。 (cids、parent_cid至少传一个) </param> /// <param name="cids">商品所属类目ID列表,用半角逗号(,)分隔 例如:(18957,19562,) (cids、parent_cid至少传一个) </param> /// <returns></returns> public static List<ItemCat> GetItemcats(string fields, long? parentcid, string cids) { ITopClient client = TopClientService.GetTopClient(); ItemcatsGetRequest req = new ItemcatsGetRequest(); req.Fields = fields; req.ParentCid = parentcid; req.Cids = cids; ItemcatsGetResponse response = client.Execute(req); return response.ItemCats; }
public void CategoryLoop(long CategoryId, string Path, int Depth) { string valueByCache = Maticsoft.BLL.SysManage.ConfigSystem.GetValueByCache("OpenAPI_TaoBaoAppkey"); string appSecret = Maticsoft.BLL.SysManage.ConfigSystem.GetValueByCache("OpenAPI_TaobaoAppsecret"); string serverUrl = Maticsoft.BLL.SysManage.ConfigSystem.GetValueByCache("OpenAPI_TaobaoApiUrl"); Maticsoft.Model.SNS.CategorySource model = new Maticsoft.Model.SNS.CategorySource(); ITopClient client = new DefaultTopClient(serverUrl, valueByCache, appSecret); ItemcatsGetRequest request = new ItemcatsGetRequest { Fields = "cid,parent_cid,name,is_parent", ParentCid = new long?(CategoryId) }; ItemcatsGetResponse response = client.Execute<ItemcatsGetResponse>(request); if (response.ItemCats.Count > 0) { foreach (ItemCat cat in response.ItemCats) { model.CategoryId = Globals.SafeInt(cat.Cid.ToString(), 0); model.ParentID = Globals.SafeInt(cat.ParentCid.ToString(), 0); if (!this.Exists(3, model.CategoryId)) { if (string.IsNullOrEmpty(Path)) { model.Path = cat.Cid.ToString(); } else { model.Path = Path + "|" + cat.Cid.ToString(); } model.Depth = Depth + 1; model.CreatedDate = DateTime.Now; model.CreatedUserID = 1; model.Description = "暂无描述"; model.HasChildren = cat.IsParent; model.IsMenu = false; model.MenuIsShow = false; model.MenuSequence = 0; model.Name = cat.Name; model.Status = 1; model.Type = 0; model.SourceId = 3; this.Add(model); this.AddCount++; } else if (this.IsUpdate((long) model.CategoryId, cat.Name, 3, model.ParentID)) { if (string.IsNullOrEmpty(Path)) { model.Path = cat.Cid.ToString(); } else { model.Path = Path + "|" + cat.Cid.ToString(); } model.Depth = Depth + 1; model.CreatedDate = DateTime.Now; model.CreatedUserID = 1; model.Description = "暂无描述"; model.HasChildren = cat.IsParent; model.IsMenu = false; model.MenuIsShow = false; model.MenuSequence = 0; model.Name = cat.Name; model.Status = 1; model.Type = 0; model.SourceId = 3; this.Update(model); this.UpdateCount++; } Thread currentThread = Thread.CurrentThread; Thread.Sleep(500); if (cat.IsParent) { this.CategoryLoop(cat.Cid, model.Path, model.Depth); } } } }