public JsonResult delTagmember(string userId, string tagId, string mType) { string accessToken = GetToken(); string[] userlist = null; int[] partylist = null; using (var transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = IsolationLevel.RepeatableRead })) { if (mType.Equals("Person", StringComparison.CurrentCultureIgnoreCase)) { userlist = new string[] { userId }; _addressBookService.delMemberTag(userId, Int32.Parse(tagId)); } else { partylist = new int[] { Int32.Parse(userId) }; } var ret = MailListApi.DelTagMember(accessToken, Int32.Parse(tagId), userlist, partylist); if (ret.errcode == Weixin.ReturnCode_QY.请求成功) { transactionScope.Complete(); } } WeChatCommonService.ClearDepartmentTagMapCache(this.AccountManageID); WeChatCommonService.ClearTagCache(int.Parse(tagId)); return(Json(doJson(null), JsonRequestBehavior.AllowGet)); }
/// <summary> /// 添加标签成员 /// </summary> /// <returns></returns> public JsonResult addTagMember(string[] userlist, int[] partylist, string tagId) { string accessToken = GetToken(); using (var transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = IsolationLevel.RepeatableRead })) { if (userlist != null) { foreach (var userId in userlist) { _addressBookService.addMemberTag(userId, Int32.Parse(tagId)); } } var ret = MailListApi.AddTagMember(accessToken, Int32.Parse(tagId), userlist, partylist); if (ret.errcode == Weixin.ReturnCode_QY.请求成功) { transactionScope.Complete(); } } WeChatCommonService.ClearDepartmentTagMapCache(this.AccountManageID); WeChatCommonService.ClearTagCache(int.Parse(tagId)); return(Json(doJson(null), JsonRequestBehavior.AllowGet)); }
public JsonResult renameTag(string Id, string tagName) { string accessToken = GetToken(); MailListApi.UpdateTag(accessToken, Int32.Parse(Id), tagName); WeChatCommonService.ClearDepartmentTagMapCache(this.AccountManageID); return(Json(doJson(null), JsonRequestBehavior.AllowGet)); }
public JsonResult delTag(string Id) { try { string accessToken = GetToken(); var memberResult = MailListApi.GetTagMember(accessToken, Int32.Parse(Id)); string[] userList = null; if (memberResult.userlist != null && memberResult.userlist.Count > 0) { userList = memberResult.userlist.Select(a => a.userid).ToArray(); } if ((userList != null && userList.Count() > 0) || (memberResult.partylist != null && memberResult.partylist.Count() > 0)) { MailListApi.DelTagMember(accessToken, Int32.Parse(Id), userList, memberResult.partylist); foreach (var userId in userList) { _addressBookService.delMemberTag(userId, Int32.Parse(Id)); } } MailListApi.DeleteTag(accessToken, Int32.Parse(Id)); } catch (ErrorJsonResultException ex) { if ((int)ex.JsonResult.errcode == 60018) { var e = new Exception("请在微信企业号管理平台中,取消各应用对此标签的可见范围,再进行删除操作。"); throw e; } } finally { WeChatCommonService.ClearDepartmentTagMapCache(this.AccountManageID); } return(Json(doJson(null), JsonRequestBehavior.AllowGet)); }