コード例 #1
0
        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));
        }
コード例 #2
0
        /// <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));
        }