public void Subscribe(WX_EventQueue info) { var app = appBLL.GetByPK(info.AppId); if (app != null) { CustomService customSvr = new CustomService(app.AppId, app.AppSecret); customSvr.SendText(info.OpenID, "欢迎您关注公众号"); GetUserInfo(info.OpenID, app.AppId, app.AppSecret); } }
public void UnSubscribe(WX_EventQueue info) { WX_User modal = userBLL.GetByPK(info.OpenID); if (modal != null) { WX_User modal1 = new WX_User(); EntityUntility.CopyProperty(modal, modal1); modal1.UnSubscribeTime = DateTime.Now; modal1.UserState = "退订"; userBLL.Update(modal1); } }
public void Scan(WX_EventQueue info) { string eventKey = XmlUtility.GetSingleNodeInnerText(info.XmlContent, "/xml/EventKey"); WX_User modal = userBLL.GetByPK(info.OpenID); if (modal != null) { WX_User modal1 = new WX_User(); EntityUntility.CopyProperty(modal, modal1); modal1.UserId = GetUserIdByScene(eventKey); userBLL.Update(modal1); } else { var app = appBLL.GetByPK(info.AppId); if (app != null) { GetUserInfo(info.OpenID, app.AppId, app.AppSecret); } } }
public ActionResult Index(string id) { if (this.Request.RequestType.ToLower() == "get") { string signature = Request.QueryString["signature"]; string timestamp = Request.QueryString["timestamp"]; string nonce = Request.QueryString["nonce"]; string echostr = Request.QueryString["echostr"]; return(Content(echostr)); } else { string xml = MyHttpUtility.ReadRequest(this.Request); int createTime = Convert.ToInt32(XmlUtility.GetSingleNodeInnerText(xml, "/xml/CreateTime")); string fromUserName = XmlUtility.GetSingleNodeInnerText(xml, "/xml/FromUserName"); string toUserName = XmlUtility.GetSingleNodeInnerText(xml, "/xml/ToUserName"); string msgType = XmlUtility.GetSingleNodeInnerText(xml, "/xml/MsgType"); if (msgType == "event") {//事件 WX_EventQueue info = new WX_EventQueue() { CreateTime = DateTimeUtility.Parse(createTime), Event = XmlUtility.GetSingleNodeInnerText(xml, "/xml/Event"), MsgState = 1, MsgType = msgType, XmlContent = xml, OpenID = XmlUtility.GetSingleNodeInnerText(xml, "/xml/FromUserName"), AppId = id }; new WX_EventQueueManager().Add(info); //回复消息 string key = XmlUtility.GetSingleNodeInnerText(xml, "/xml/EventKey"); WX_MenuEventManager manager = new WX_MenuEventManager(); var eve = manager.Where(e => e.MenuKey.Equals(key)).FirstOrDefault(); if (eve != null) { string respXml = eve.GetXML(toUserName, fromUserName); return(Content(respXml)); } } else { //消息 WX_Queue info = new WX_Queue() { MsgState = 1, MsgId = XmlUtility.GetSingleNodeInnerText(xml, "/xml/MsgId"), CreateTime = DateTimeUtility.Parse(createTime), XmlContent = xml, OpenID = XmlUtility.GetSingleNodeInnerText(xml, "/xml/FromUserName"), MsgType = msgType, AppId = id }; WX_QueueManager manager = new WX_QueueManager(); if (manager.GetByPK(info.MsgId) == null) { var r = manager.Add(info); } } return(Content("success")); } }