/// <summary> /// 插入授权目录信息 /// </summary> /// <returns>大于0成功,否则失败</returns> /// <remarks> /// <list type="bullet"> /// </list> /// </remarks> public int Insert(int connectorId, string ids) { ClearCache(); int val = 0; //检查信息是否存在 Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("ConnectorId", connectorId); dic.Add("Status", 1); AuthCategoryEntity entConnector = DbAccess.GetEntity <AuthCategoryEntity>(TableName, dic); if (entConnector != null && entConnector.Id > 0) { entConnector.UpdateTime = DateTime.Now; entConnector.CategoryIds = ids; val = DbAccess.ExecuteUpdate(TableName, entConnector, new string[] { "Id" }); } else { AuthCategoryEntity ent = new AuthCategoryEntity(); ent.Status = 1; ent.ConnectorId = connectorId; ent.CategoryIds = ids; ent.AddTime = DateTime.Now; ent.UpdateTime = DateTime.Now; val = DbAccess.ExecuteInsert(TableName, ent); } return(val); }
/// <summary> /// 通过条件获取授权商品信息 /// </summary> /// <remarks> /// <list type="bullet"> /// <item></item> /// </list> /// </remarks> public PagingResult GetAuthProductList(PagingQuery pagingQuery, int connectorId, bool auth = true) { PagingResult result = new PagingResult() { PageIndex = pagingQuery.PageIndex, PageSize = pagingQuery.PageSize }; result.PageIndex = pagingQuery.PageIndex; result.PageSize = pagingQuery.PageSize; result.Data = new DataTable(); ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness().GetEntity("Id=" + connectorId); if (connector == null) { return(result); } GroupEntity group = (GroupEntity) new GroupBusiness().GetEntity("Id=" + connector.GroupId); if (group == null) { return(result); } AuthBrandEntity brands = (AuthBrandEntity) new AuthBrandBusiness().GetEntity("ConnectorId=" + connectorId); AuthCategoryEntity categorys = (AuthCategoryEntity) new AuthCategoryBusiness().GetEntity("ConnectorId=" + connectorId); DataTable dt = DBTable("ConnectorId=" + connectorId); string ids; if (dt == null || dt.Rows.Count == 0) { ids = ""; } ids = string.Join(",", dt.AsEnumerable().Select(dr => Utils.ToString(dr["ProductId"]))); string condition = ""; if (auth) { condition += "<ProductId Oper=\"notin\">" + ids + "</ProductId><droitbrandids>" + brands.BrandIds + "</droitbrandids><droitcategoryids>" + categorys.CategoryIds + "</droitcategoryids>"; } else { if (string.IsNullOrWhiteSpace(ids)) { return(result); } //未授权商品 condition += "<ProductId>" + ids + "</ProductId>"; } Dictionary <string, string> dic = new Dictionary <string, string>(); //遍历所有子节点 foreach (Condition c in pagingQuery.Condition) { if (!string.IsNullOrEmpty(c.Value)) { switch (c.Name.ToLower()) { case "keywords": dic.Add("Keywords", c.Value); break; case "brandid": dic.Add("brandId", c.Value); break; case "categoryid": dic.Add("cid", c.Value); break; case "productcode": condition += "<ProductCode>" + c.Value + "</ProductCode>"; break; case "productname": condition += "<ProductName>" + c.Value + "</ProductName>"; break; case "Bbarcode": condition += "<BarCode>" + c.Value + "</BarCode>"; break; } } } dic.Add("FKId", connector.SellerId.ToString()); dic.Add("ProprietorId", connector.SellerId.ToString()); dic.Add("Proprietor", "2"); //dic.Add("UserId", connector.SellerId.ToString()); dic.Add("FKFlag", "2"); dic.Add("Condition", HttpUtility.UrlEncode(condition)); dic.Add("PageIndex", pagingQuery.PageIndex.ToString()); dic.Add("PageSize", pagingQuery.PageSize.ToString()); string msg = ""; string datajson = ApiRequest.GetRemoteContent(group.Domain + "/Route.axd", "vast.mall.product.page", dic, out msg); var jss = new JavaScriptSerializer(); var dict = jss.Deserialize <Dictionary <string, object> >(datajson); if (!Utils.ToBool(dict["Success"])) { return(null); } Dictionary <string, object> content = dict["Content"] as Dictionary <string, object>; if (content == null || content.Count <= 0) { return(result); } result.TotalCount = Utils.ToInt(content["TotalCount"]); if (content["Data"] != null) { result.Data = content["Data"]; } return(result); }