/// <summary> /// 刷新指定域下面分组信息,将调用微信API获取最新分组信息 /// </summary> /// <param name="domainContext"></param> public void SyncTagList(DomainContext domainContext) { RequestApiResult <WeixinGetTagListResult> result = TagsApiWrapper.GetTagList(domainContext); if (result.Success) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@domain", domainContext.Domain.Id)); parameterList.Add(new CommandParameter("@appId", domainContext.AppId)); _dataBase.ExecuteNonQuery("DELETE FROM [MemberTag] WHERE [Domain] = @domain AND [AppId] = @appId", parameterList); foreach (WeixinGetTagListResult_Tag item in result.ApiResult.TagList) { MemberTagEntity tag = new MemberTagEntity(); tag.TagId = item.Id; tag.Name = item.Name; tag.Domain = domainContext.Domain.Id; tag.AppId = domainContext.AppId; _dataBase.Insert(tag); } //过滤用户,将已不存在的分组置为0 } else { _log.Write("RefreshTagList 失败", result.Message, TraceEventType.Warning); } }
public ActionResult UpdateMemberTag() { MemberTagEntity memberTag = RequestArgs <MemberTagEntity>(); if (memberTag == null) { return(RespondResult(false, "参数无效。")); } memberTag.Domain = UserContext.User.Domain; memberTag.AppId = DomainContext.AppId; NormalResult result = _memberTagManager.UpdateMemberTag(DomainContext, memberTag); #region 操作日志 _operatedLogManager.Create(new OperatedLogEntity() { Domain = DomainContext.Domain.Id, AppId = DomainContext.AppId, User = UserContext.User.Id, IP = Request.UserHostAddress, Module = EnumModule.Member, Description = "更新用户标签" }); #endregion return(RespondResult(result.Success, result.Message)); }
public NormalResult UpdateMemberTag(DomainContext domainContext, MemberTagEntity tag) { NormalResult result = new NormalResult(false); if (tag == null) { result.Message = "参数错误。"; return(result); } //先往微信后台更新,成功后写数据库 WeixinTag apiArgs = new WeixinTag(); apiArgs.Tag.Id = tag.TagId; apiArgs.Tag.Name = tag.Name; RequestApiResult updateResult = TagsApiWrapper.Update(domainContext, apiArgs); if (updateResult.Success == false) { result.Message = updateResult.Message; return(result); } _dataBase.Update(tag); result.Success = true; return(result); }
public NormalResult CreateMemberTag(DomainContext domainContext, MemberTagEntity tag) { NormalResult result = new NormalResult(false); if (tag == null) { result.Message = "参数错误。"; return(result); } //先往微信后台添加,成功后写数据库 WeixinCreateTagArgs apiArgs = new WeixinCreateTagArgs(); apiArgs.Tag.Name = tag.Name; RequestApiResult <WeixinTag> createResult = TagsApiWrapper.Create(domainContext, apiArgs); if (createResult.Success == false) { result.Message = createResult.Message; return(result); } tag.Domain = domainContext.Domain.Id; tag.TagId = createResult.ApiResult.Tag.Id; _dataBase.Insert(tag); result.Success = true; return(result); }
public ActionResult GetMemberTag() { string strId = Request.QueryString["id"]; Guid id = Guid.Empty; if (String.IsNullOrEmpty(strId) || Guid.TryParse(strId, out id) == false) { return(RespondResult(false, "参数无效。")); } MemberTagEntity memberTag = _memberTagManager.GetMemberTag(id); return(RespondDataResult(memberTag)); }
public MemberTagEntity GetMemberTag(Guid id) { MemberTagEntity memberTag = new MemberTagEntity(); memberTag.Id = id; if (_dataBase.Fill <MemberTagEntity>(memberTag)) { return(memberTag); } else { return(null); } }
public NormalResult RemoveMemberTag(DomainContext domainContext, Guid id) { NormalResult result = new NormalResult(false); MemberTagEntity memberTag = GetMemberTag(id); if (memberTag == null) { result.Message = "分组不存在。"; return(result); } //先往微信后台更新,成功后写数据库 RequestApiResult removeResult = TagsApiWrapper.Remove(domainContext, memberTag.TagId); if (removeResult.Success == false) { result.Message = removeResult.Message; return(result); } //移除此标签下的用户的这个标签 List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@domain", domainContext.Domain.Id)); parameterList.Add(new CommandParameter("@appId", domainContext.AppId)); parameterList.Add(new CommandParameter("@tagId", memberTag.TagId.ToString() + ",")); _dataBase.ExecuteNonQuery( "UPDATE [Member] SET [TagList] = REPLACE([TagList],@tagId,'') WHERE [Domain] = @domain AND [AppId] = @appId AND CHARINDEX(@tagId,[TagList]) > 0", parameterList); _dataBase.Remove(memberTag); result.Success = true; return(result); }