public override string Handle() { UserInfoService UserBLL = new UserInfoService(); WechatMsgInfoService WechatMsgBLL = new WechatMsgInfoService(); if (WechatMsgBLL.GetList(p => p.MsgId == MsgId).Count() != 0) { return("success"); } WechatMsgInfo info = new WechatMsgInfo(); info.CreateUserID = UserBLL.GetList(p => p.Name == DicInfo.Admin).FirstOrDefault().ID; info.AddDate = DateTime.Now; info.Status = 1; info.ToUserName = ToUserName; info.FromUserName = FromUserName; info.CreateTime = CreateTime; info.MsgType = MsgType; info.Content = PicUrl; info.MsgId = MsgId; info.XMLDom = XmlDom; WechatMsgBLL.Create(info); return("success"); }
public ActionResult Create(WechatMsgInfo info) { string Result = WeiXin.APIClient.WechatService.ResponseSendMsgText(info.ToUserName, info.Content); if (string.IsNullOrEmpty(Result)) { info.CreateUserID = CurrentUser.ID; info.AddDate = DateTime.Now; info.Status = -1; info.FromUserName = string.Empty; info.CreateTime = 0; info.MsgType = "text"; info.MsgId = 0; info.XMLDom = string.Empty; WechatMsgBLL.Create(info); return(Json(new APIJson(0, "回复成功"))); } return(Json(new APIJson(-1, Result))); }
public override string Handle() { UserInfoService UserBLL = new UserInfoService(); WechatMsgInfoService WechatMsgBLL = new WechatMsgInfoService(); UserInfo infoUser = UserBLL.GetList(p => p.WechatOpenID == FromUserName).FirstOrDefault(); if (infoUser == null) { infoUser = UserBLL.GetList(p => p.Name == DicInfo.Admin).FirstOrDefault(); } if (WechatMsgBLL.GetList(p => p.MsgId == MsgId).Count() != 0) { return("success"); } WechatMsgInfo info = new WechatMsgInfo(); info.CreateUserID = infoUser.ID; info.AddDate = DateTime.Now; info.Status = 1; info.ToUserName = ToUserName; info.FromUserName = FromUserName; info.CreateTime = CreateTime; info.MsgType = MsgType; info.Content = Content; info.MsgId = MsgId; info.XMLDom = XmlDom; WechatMsgBLL.Create(info); var PowerKey = string.Empty;// PowerInfo.P_通知管理.PP微信消息.PPP微信会话管理.接口新消息推送; var listUser = UserBLL.GetList(p => p.RuleInfo.Any(r => r.PowerActionInfo.Any(pa => pa.NewID == PowerKey))); foreach (var item in listUser) { if (string.IsNullOrEmpty(item.WechatOpenID)) { continue; } new Eval.BLL.WechatService.TemplateMsg().ResponseTemplateMsgNewWechatMsg(info, item.WechatOpenID); } return(ResponseText("消息收到,相关人员将稍候回复您")); }
/// <summary> /// 有用户向公众号发送消息时,通知相应的管理员 /// </summary> /// <returns></returns> public int ResponseTemplateMsgNewWechatMsg(WechatMsgInfo infoWechatMsg, string TargetOpenID) { WechatTemplateMsgInfo infoTemplateMsg = new WechatTemplateMsgInfo(); infoTemplateMsg.TouserOpenID = string.Empty; infoTemplateMsg.Template_id = WechatTemplateMsgInfo.GetTemplateMsgID工作提醒(WeiXinConst.AppId); infoTemplateMsg.URL = ConfigHelper.GetAppendSettingValue(ConfigHelper.WEBDoMain) + "/Wechat/WechatMsg/Talk?FromUserName="******"first"; info.DataValue = "收到新消息"; infoTemplateMsg.Data.Add(info); info = new WechatTemplateMsgItemInfo(); info.DataKey = "keyword1"; //任务编号 info.DataValue = infoWechatMsg.ID.ToString(); infoTemplateMsg.Data.Add(info); info = new WechatTemplateMsgItemInfo(); info.DataKey = "keyword2"; //任务类型 info.DataValue = "消息跟进处理"; infoTemplateMsg.Data.Add(info); info = new WechatTemplateMsgItemInfo(); info.DataKey = "keyword3"; //任务描述 info.DataValue = infoWechatMsg.Content; infoTemplateMsg.Data.Add(info); info = new WechatTemplateMsgItemInfo(); info.DataKey = "remark"; //remark info.DataValue = "请参阅消息详细,如果回复,请在收到消息48小时内进行。"; infoTemplateMsg.Data.Add(info); infoTemplateMsg.TouserOpenID = TargetOpenID; int Result = ResponseTemplateMsg(infoTemplateMsg); return(Result); }