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 static RequestApiResult <WeixinTag> Create(DomainContext domainContext, WeixinCreateTagArgs args) { string accessToken = domainContext.AccessToken; RequestApiResult <WeixinTag> result = TagsApi.Create(accessToken, args); if (result.Success == false) { if (result.Retry) { if (result.ApiError.ErrorCode == 40001) { accessToken = AccessTokenGetter.Refresh(domainContext.AppId, accessToken); } result = TagsApi.Create(accessToken, args); if (result.Success == false) { _log.Write("TagsApi.Create 失败", result.GetDetail(), TraceEventType.Warning); } } else { _log.Write("TagsApi.Create 失败", result.GetDetail(), TraceEventType.Warning); } } return(result); }