public void ArticleSummaryTest() { var accessToken = AccessTokenContainer.GetAccessToken(_appId); var result = AutoReplyApi.GetCurrentAutoreplyInfo(accessToken); Assert.IsNotNull(result); Assert.AreEqual(result.errcode, ReturnCode.请求成功); }
public override void OnExecuting() { string accessTokenOrAppId = AccessTokenContainer.TryGetAccessToken(this.appId, this.appSecret, false); this.rules = AutoReplyApi.GetCurrentAutoreplyInfo(accessTokenOrAppId); if (this.CurrentMessageContext.StorageData == null) { this.CurrentMessageContext.StorageData = ""; } base.OnExecuting(); }
public override void OnExecuting() { try { string accessTokenOrAppId = AccessTokenContainer.TryGetAccessToken(this.appId, this.appSecret, false); this.rules = AutoReplyApi.GetCurrentAutoreplyInfo(accessTokenOrAppId); } catch (Exception ex) { } //测试MessageContext.StorageData if (CurrentMessageContext.StorageData == null) { CurrentMessageContext.StorageData = 0; } base.OnExecuting(); }
public bool SaveMsgReplyData() { var mpMsgData = AutoReplyApi.GetCurrentAutoreplyInfo(BaseClass.AppId); if (mpMsgData.errcode == 0) { //初始化关注回复 if (mpMsgData.add_friend_autoreply_info != null) { var sereply = mpMsgData.add_friend_autoreply_info; if (sereply.type.ToString() == "text") { sereply.content = EConvert.DConvertEmojiHtml(sereply.content).UrlEncode().Replace("+", "%20"); } MpEventBll.SaveEventInfo(new mpeventreply() { EventType = WxEventTypeEnum.subscribe.ToString(), EventKey = "ych_subscribe", ReplyType = sereply.type.ToString(), ReplyContent = sereply.content, }); } //初始化自动消息回复 if (mpMsgData.message_default_autoreply_info != null) { var autoreply = mpMsgData.message_default_autoreply_info; if (autoreply.type.ToString() == "text") { autoreply.content = EConvert.DConvertEmojiHtml(autoreply.content).UrlEncode().Replace("+", "%20"); } MpEventBll.SaveEventInfo(new mpeventreply() { EventType = WxEventTypeEnum.automsg.ToString(), EventKey = "ych_automsg", ReplyType = autoreply.type.ToString(), ReplyContent = autoreply.content }); } //初始化关键字回复 if (mpMsgData.keyword_autoreply_info?.list != null && mpMsgData.keyword_autoreply_info.list.Count > 0) { mpMsgData.keyword_autoreply_info.list.Reverse(); foreach (var ruleItem in mpMsgData.keyword_autoreply_info.list) { var dto = new MsgReplyResult { Msg = { RuleName = ruleItem.rule_name, ReplyMode = ruleItem.reply_mode.ToString() } }; if (ruleItem.keyword_list_info != null && ruleItem.keyword_list_info.Count > 0) { foreach (var keyItem in ruleItem.keyword_list_info) { mpmsgreplykey key = new mpmsgreplykey { KeyVal = keyItem.content, MatchMode = keyItem.match_mode.ToString() }; dto.Keys.Add(key); } } if (ruleItem.reply_list_info != null && ruleItem.reply_list_info.Count > 0) { foreach (var contentItem in ruleItem.reply_list_info) { if (contentItem.type.ToString() == "text") { contentItem.content = EConvert.DConvertEmojiHtml(contentItem.content).UrlEncode().Replace("+", "%20"); } mpmsgreplycontent content = new mpmsgreplycontent { ReplyType = contentItem.type.ToString(), ReplyContent = contentItem.content }; dto.Contents.Add(content); } } MsgReplyBll.SaveMsgRule(dto); } } } return(true); }