public void ProcessRequest(HttpContext context) { wxmessage wxGlobal = new wxmessage(); FunctionAll fuc = new FunctionAll(); XmlDocument doc = new XmlDocument(); try { fuc.MyMenu(); string postXmlStr = PostInput(); if (!string.IsNullOrEmpty(postXmlStr)) { doc.LoadXml(postXmlStr); XmlElement root = doc.DocumentElement; wxGlobal = fuc.GetWxMessage(doc); string result = ""; string requestContent = ""; if (wxGlobal.MsgType == null) { return; } else { //获取用户发来的信息 switch (wxGlobal.MsgType) { case "text": //文本 requestContent = WeiXinXML.CreateTextMsg(doc, wxGlobal.Content); LogHelper.WriteLog(requestContent); string[] openids = { "oSsyq09bnj5hSW7lcaMS5R2gHmnk", "oSsyq07cxXuYW8FnCP1-MYt_B_5o", "oSsyq0weqN9UK8JoTpDyht1-TlyU", "oSsyq06MZ7HZmG3Q4gckkHGSLMWE", "oZTyM02MtDG3IeLJn2RcMO7U4pws", "oZTyM07BSndJcyK9dRx6YgJqko1s", "oZTyM04WHKk60iaxtieCLTtzNw6I" }; string[] types = { "1", "2", "3", "4", "5", "6", "7" }; if (openids.Contains(wxGlobal.FromUserName)) { string str = string.Empty; string Title = string.Empty; if (types.Contains(wxGlobal.Content)) { DataTable dt = OrderQuery.getOrder(wxGlobal.Content); str = OrderQuery.test(dt); switch (wxGlobal.Content) { case "1": Title = "全程陪诊"; break; case "2": Title = "检查代预约"; break; case "3": Title = "专家号源预约"; break; case "4": Title = "专家诊疗建议"; break; case "5": Title = "手术直通车"; break; case "6": Title = "病床预约"; break; case "7": Title = "代领代寄代解读报告单"; break; default: Title = ""; break; } } else { str = OrderQuery.test(); } switch (wxGlobal.Content) { case "1": result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "您有一条新的" + Title + "消息!", str, "http://119.29.20.29/image/单车.jpg", "http://www.guahao.com"); break; case "2": result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "您有一条新的" + Title + "消息!", str, "http://119.29.20.29/image/单车.jpg", "http://www.guahao.com"); break; case "3": result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "您有一条新的" + Title + "消息!", str, "http://119.29.20.29/image/单车.jpg", "http://www.guahao.com"); break; case "4": result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "您有一条新的" + Title + "消息!", str, "http://119.29.20.29/image/单车.jpg", "http://www.guahao.com"); break; case "5": result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "您有一条新的" + Title + "消息!", str, "http://119.29.20.29/image/单车.jpg", "http://www.guahao.com"); break; case "6": result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "您有一条新的" + Title + "消息!", str, "http://119.29.20.29/image/单车.jpg", "http://www.guahao.com"); break; case "7": result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "您有一条新的" + Title + "消息!", str, "http://119.29.20.29/image/单车.jpg", "http://www.guahao.com"); break; default: result = WeiXinXML.CreateTextMsg(doc, str); break; } } else { result = WeiXinXML.CreateTextMsg(doc, TuLing.GetTulingMsg(wxGlobal.Content)); } break; case "location": //文本 result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "您附近的XXX", "XXXXXXXX", "http://119.29.20.29/image/test.jpg", FunctionAll.GetCodeUrl(null)); break; case "event": switch (wxGlobal.EventName) { case "subscribe": //订阅 result = WeiXinXML.subscribeRes(doc); break; case "unsubscribe": //取消订阅 break; case "CLICK": if (wxGlobal.EventKey == "HELLO") { result = WeiXinXML.CreateTextMsg(doc, "微医app - 原名 挂号网,用手机挂号,十分方便!更有医生咨询、智能分诊、院外候诊、病历管理等强大功能。\r\n" + "预约挂号 聚合全国超过900家重点医院的预约挂号资源\r\n" + "咨询医生 支持医患之间随时随地图文、语音、视频方式的沟通交流\r\n" + "智能分诊 根据分诊自测系统分析疾病类型,提供就诊建议\r\n" + "院外候诊 时间自由可控,不再无谓浪费\r\n" + "病历管理 病历信息统一管理,个人健康及时监测\r\n" + "贴心服务 医疗支付、报告提取、医院地图\r\n" + "权威保障 国家卫计委(原卫生部)指定的全国健康咨询及就医指导平台\r\n" + "[微医] 目前用户量大,有些不足我们正加班加点的努力完善,希望大家用宽容的心给 [微医] 一点好评,给我们一点激励,让 [微医] 和大家的健康诊疗共成长。"); } if (wxGlobal.EventKey == "myprofile") { result = WeiXinXML.CreateTextMsg(doc, "功能测试中,敬请期待!"); } if (wxGlobal.EventKey == "jkzx") { result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "点击图片查看您附近的疾控中心", @"测试测试测试测试", "http://119.29.20.29/image/navi.jpg", "http://m.amap.com/around/?locations=&keywords=疾控中心&defaultIndex=3&defaultView=map&searchRadius=5000&key=33fe5b1e0fc0023eb1cd28b392d5e70f"); } break; case "LOCATION": //获取地理位置 Lat = wxGlobal.Latitude; Lon = wxGlobal.Longitude; break; } break; } } context.Response.Write(result); context.Response.Flush(); LogHelper.WriteLog("系统回复的明文" + result); } else { valid(context); return; } } catch (Exception ex) { LogHelper.WriteLog(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Access_token mode = FunctionAll.GetAccessToken(); Session["accessToken"] = mode.access_token; Session.Timeout = 120; } Valid(); wxmessage wxGlobal = new wxmessage(); FunctionAll fuc = new FunctionAll(); XmlDocument doc = new XmlDocument(); try { fuc.MyMenu(); string postXmlStr = PostInput(); if (!string.IsNullOrEmpty(postXmlStr)) { doc.LoadXml(postXmlStr); XmlElement root = doc.DocumentElement; wxGlobal = fuc.GetWxMessage(doc); string result = ""; string requestContent = ""; //var rootElement = doc.DocumentElement; if (wxGlobal.MsgType == null) { return; } else { //获取用户发来的信息 switch (wxGlobal.MsgType) { case "text": //文本 requestContent = WeiXinXML.CreateTextMsg(doc, wxGlobal.Content); if (wxGlobal.Content.Contains("¥")) { decimal req = Convert.ToDecimal(wxGlobal.Content.Replace("¥", "")); result = WeiXinXML.CreateTextMsg(doc, fuc.ConvertToChinese(req)); } else { result = WeiXinXML.CreateTextMsg(doc, TuLing.GetTulingMsg(wxGlobal.Content)); LogHelper.WriteLog(requestContent); LogHelper.WriteLog(result); } break; case "location": //文本 result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "您附近的XXX", "XXXXXXXX", "http://119.29.20.29/image/test.jpg", FunctionAll.GetCodeUrl(Server.UrlEncode("http://q4chvj.natappfree.cc/index.aspx"))); break; case "event": switch (wxGlobal.EventName) { case "subscribe": //订阅 result = WeiXinXML.subscribeRes(doc); break; case "unsubscribe": //取消订阅 break; case "CLICK": if (wxGlobal.EventKey == "myprofile") { result = WeiXinXML.CreateTextMsg(doc, "微医app - 原名 挂号网,用手机挂号,十分方便!更有医生咨询、智能分诊、院外候诊、病历管理等强大功能。\r\n" + "预约挂号 聚合全国超过900家重点医院的预约挂号资源\r\n" + "咨询医生 支持医患之间随时随地图文、语音、视频方式的沟通交流\r\n" + "智能分诊 根据分诊自测系统分析疾病类型,提供就诊建议\r\n" + "院外候诊 时间自由可控,不再无谓浪费\r\n" + "病历管理 病历信息统一管理,个人健康及时监测\r\n" + "贴心服务 医疗支付、报告提取、医院地图\r\n" + "权威保障 国家卫计委(原卫生部)指定的全国健康咨询及就医指导平台\r\n" + "[微医] 目前用户量大,有些不足我们正加班加点的努力完善,希望大家用宽容的心给 [微医] 一点好评,给我们一点激励,让 [微医] 和大家的健康诊疗共成长。"); } if (wxGlobal.EventKey == "morefunction") { // result = WeiXinXML.CreateTextMsg(doc, "更多功能正在开发中,敬请期待!"); //if (wxGlobal.EventKey == "jkzx") result = WeiXinXML.ReArticle(wxGlobal.FromUserName, wxGlobal.ToUserName, "点击图片查看您附近的疾控中心", @"测试测试测试测试", "http://119.29.20.29/image/navi.jpg", ConfigurationManager.AppSettings["redirect_uri"].ToString()); } break; case "LOCATION": //获取地理位置 //string city = fuc.GetLocation(wxGlobal.Latitude,wxGlobal.Longitude); //result = WeiXinXML.CreateTextMsg(doc,city); break; } break; } //if (!string.IsNullOrWhiteSpace(sAppId)) //根据appid解密字符串 //{ // WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(sToken, AESKey, sAppId); // string signature = context.Request["msg_signature"]; // string timestamp = context.Request["timestamp"]; // string nonce = context.Request["nonce"]; // string stmp = ""; // int ret = wxcpt.DecryptMsg(signature, timestamp, nonce, postXmlStr, ref stmp); // if (ret == 0) // { // doc = new XmlDocument(); // doc.LoadXml(stmp); // } //} } Response.Write(result); } else { Valid(); return; } } //context.Response.Write(result); //context.Response.Flush(); //LogHelper.WriteLog("系统回复的明文" + result); // else // { // valid(context); // return; //} catch (Exception ex) { throw; } }