/// <summary> /// Event事件类型请求之CLICK /// </summary> public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Click requestMessage) { log.Debug("Entering Event事件类型请求之CLICK - " + requestMessage.EventKey); string errorMessage; if (!SmartphoneMenuPermissionManager.PermissionCheck(requestMessage.EventKey, requestMessage.FromUserName, requestMessage.AgentID, out errorMessage)) { return(NoPermissionResponse(errorMessage)); } // 记录用户行为 _wr.CallUserBehavior(requestMessage.EventKey, requestMessage.FromUserName, requestMessage.AgentID.ToString(CultureInfo.InvariantCulture), "", "", 4); var objConfig = WeChatCommonService.GetWeChatConfig(requestMessage.AgentID); switch (requestMessage.AgentID) { default: { LogManager.GetLogger(this.GetType()).Debug("Entering default2"); var menu = Infrastructure.Web.Domain.Service.CommonService.lstCategory.FirstOrDefault(a => a.CategoryCode == requestMessage.EventKey); if (menu == null) { return(null); } LogManager.GetLogger(this.GetType()).Debug("menu is ready"); AppMenuView appMenu = new AppMenuView(); appMenu.ButtonReturnType = JsonHelper.FromJson <ButtonReturnType>(menu.Function); if (appMenu == null || appMenu.ButtonReturnType == null || string.IsNullOrEmpty(appMenu.ButtonReturnType.ResponseMsgType)) { LogManager.GetLogger(this.GetType()).Debug("appMenu parsed is NULL"); return(null); } switch (appMenu.ButtonReturnType.ResponseMsgType.ToLower()) { case "text": var textMessage = this.CreateResponseMessage <ResponseMessageText>(); LogManager.GetLogger(this.GetType()).Debug("appMenu.ButtonReturnType = " + appMenu.ButtonReturnType); LogManager.GetLogger(this.GetType()).Debug("appMenu.ButtonReturnType.Content = " + appMenu.ButtonReturnType.Content); textMessage.Content = appMenu.ButtonReturnType.Content; return(textMessage); case "news": LogManager.GetLogger(this.GetType()).Debug("appMenu.ButtonReturnType.NewsPushNumber= " + appMenu.ButtonReturnType.NewsPushNumber); var articles = (appMenu.ButtonReturnType.NewsPushNumber != null && appMenu.ButtonReturnType.NewsPushNumber != 0) ? GetPushArticles(requestMessage.EventKey, appMenu.ButtonReturnType.NewsPushNumber) : GetPushArticles(requestMessage.EventKey); return(CreateResponse(articles, objConfig.WXHost, "/News/ArticleInfo/wxdetail/")); } break; } } return(DefaultResponseMessage(requestMessage)); }
public override IResponseMessageBase OnTextRequest(RequestMessageText requestMessage) { //记录用户行为 _wr.CallUserBehavior("TEXT_EVENT", requestMessage.FromUserName, requestMessage.AgentID.ToString(CultureInfo.InvariantCulture), requestMessage.Content, "", 8); LogManager.GetLogger(this.GetType()).Debug("NO TEXT behavior1 "); if (requestMessage.Content == "优行" && requestMessage.AgentID == 27) { LogManager.GetLogger(this.GetType()).Debug("get LCCP in appid=27"); string errorMessage; var pushtitle = ""; var pictureUrl = ""; var content = ""; var URL = ""; var Desc = ""; var menukey = ""; object jsonResult = null; var jsonString = Infrastructure.Web.Domain.Service.CommonService.GetSysConfig("DIALCCP", ""); LogManager.GetLogger(this.GetType()).Debug("request DIALCCP1"); JavaScriptSerializer js = new JavaScriptSerializer(); jsonResult = js.Deserialize <object>(jsonString); var fullResult = jsonResult as Dictionary <string, object>; if (fullResult != null) { pushtitle = fullResult["title"] as string; pictureUrl = fullResult["pictureUrl"] as string; content = fullResult["content"] as string; URL = fullResult["URL"] as string; Desc = fullResult["Desc"] as string; menukey = fullResult["menukey"] as string; } if (SmartphoneMenuPermissionManager.PermissionCheck(menukey, requestMessage.FromUserName, requestMessage.AgentID, out errorMessage)) { LogManager.GetLogger(this.GetType()).Debug("access TextPermissionCheck1"); var responseMessage = this.CreateResponseMessage <ResponseMessageNews>(); LogManager.GetLogger(this.GetType()).Debug("request article"); responseMessage.Articles.Add(new Article() { Title = pushtitle, Url = URL, PicUrl = pictureUrl, Description = Desc, }); LogManager.GetLogger(this.GetType()).Debug("push history article to app1"); return(responseMessage); } else { log.Debug("lccp接受但是没有权限"); return(CreateNoResponseMessage(requestMessage.AgentID)); } } return(CreateNoResponseMessage(requestMessage.AgentID)); }