/// <summary> /// 获取用户OpenID /// </summary> void GetUserOpenID() { if (null == Request.QueryString["state"]) { //return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } else { strOpenID = code; } } if (strOpenID == null || strOpenID == "") { if (Session["customerID"] != null && Session["customerID"].ToString() != "") { MSCustomersDAL CustomerDal = new MSCustomersDAL(); try { strOpenID = CustomerDal.GetCustomerValueByID("OpenID", Session["customerID"].ToString()).ToString(); } catch (Exception) { } } } if (strOpenID != null && strOpenID != "") { Session["OpenID"] = strOpenID; } }
protected void Button1_Click(object sender, EventArgs e) { WXConfigDAL wcdal = new WXConfigDAL(); //Model.WeiXin.WXConfig wxConfig = wcdal.GetWXConfigBySiteCode("QJTV"); //Model.WeiXin.WXConfig wxConfig = wcdal.GetWXConfigBySiteCode("KM_HLF"); //Model.WeiXin.WXConfig wxConfig = wcdal.GetWXConfigBySiteCode("yn-zhbm"); Model.WeiXin.WXConfig wxConfig = wcdal.GetWXConfigBySiteCode("VYIGO"); MenuDAL.CreateWeiXinMenu(wxConfig.ID); }
protected void Page_Load(object sender, EventArgs e) { string strSiteCode = string.Empty; string strOpenID = string.Empty; //if (null == Request["state"] || Request["state"] == "") if (null == Request.QueryString["state"]) { return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } else { strOpenID = code; } } Session["OpenID"] = strOpenID; string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/ChargeFee.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["OpenID"] = strOpenID; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
/// <summary> /// 发送微信消息 /// </summary> /// <param name="strSiteCode">SiteCode</param> /// <param name="strOpenID">OpenID</param> /// <param name="strMsg">消息内容</param> public static void SendWeiXinMsg(string strSiteCode, string strOpenID, string strMsg) { string strAppID = string.Empty; string strSecret = string.Empty; if (strSiteCode != null && strSiteCode != "") { Model.WeiXin.WXConfig wc = new Model.WeiXin.WXConfig(); WXConfigDAL wcdal = new WXConfigDAL(); wc = wcdal.GetWXConfigBySiteCode(strSiteCode); if (null != wc) { strAppID = wc.WXAppID; strSecret = wc.WXAppSecret; } string strToken = WeiXinHelper.GetAccessToken(strAppID, strSecret); var KeyToken = new { access_token = "" }; var b = JsonConvert.DeserializeAnonymousType(strToken, KeyToken); string strRToken = b.access_token; WeiXinHelper.SendCustomTextMessage(strRToken, strOpenID, strMsg); } }
protected override bool BeforeLoad() { if (null == Request["state"] || Request["state"] == "") { return(false); } else { SiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(SiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { OpenID = oauth2AccessToken.OpenID; } } } Session["OpenID"] = OpenID; return(base.BeforeLoad()); }
protected void Button2_Click(object sender, EventArgs e) { #region 消费完成发生消息 string strAppID = string.Empty; string strSecret = string.Empty; Model.WeiXin.WXConfig wc = new Model.WeiXin.WXConfig(); WXConfigDAL wcdal = new WXConfigDAL(); //wc = wcdal.GetWXConfigBySiteCode("QJTV"); wc = wcdal.GetWXConfigBySiteCode("vyigo"); if (null != wc) { strAppID = wc.WXAppID; strSecret = wc.WXAppSecret; } string strToken = WeiXinHelper.GetAccessToken(strAppID, strSecret); var KeyToken = new { access_token = "" }; var b = JsonConvert.DeserializeAnonymousType(strToken, KeyToken); string strRToken = b.access_token; //WeiXinHelper.SendCustomTextMessage(strRToken, "oScaMjtue4NyANx0xQzNvGYxAs8U", "测试功能"); WeiXinHelper.SendCustomTextMessage(strRToken, "okNacjt93Jsmr84P9EbR66pIt-sc", "回复测试功,能看到消息吗?"); #endregion }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //--菜单功能 if (null == Request["state"] || Request["state"] == "") { return; } else { strSiteCode = Common.Common.NoHtml(Request["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } } //-- if (Request["actid"] == null || Request["actid"] == "") { return; } //strSiteCode = Common.Common.NoHtml(Request["sitecode"]); strActID = Common.Common.NoHtml(Request["actid"]); //GetOpenID(); if (Request["action"] != null && Request["action"] != "") { strAction = Common.Common.NoHtml(Request["action"]); switch (strAction.ToLower().Trim()) { case "saveuser": //Response.Write("{\"success\":true}"); saveUserinfo(); break; case "setphone": setPhone(); break; } Response.End(); } else { GetAwardList(); } } }
protected void btnCreateMenu_Click(object sender, EventArgs e) { string strAppID = string.Empty; string strSecret = string.Empty; Model.WeiXin.WXConfig wc = new Model.WeiXin.WXConfig(); WXConfigDAL wcdal = new WXConfigDAL(); //wc = wcdal.GetWXConfigBySiteCode("KM_HLF"); wc = wcdal.GetWXConfigBySiteCode("QJTV"); if (null != wc) { strAppID = wc.WXAppID; strSecret = wc.WXAppSecret; } //http://116.52.251.251/Default //662DC897E4C9195AB3B0DEDEB5575782 //string acc_token = this.txtAccessToken.Text;//此部分设置你的access_token //自助服务:余额查询-充值缴费-业务受理-水电缴费-Q币充值 //网上商城:号码商城-手机商城 //精彩无限:号码绑定-最新活动-天气资讯-帮助 //string strAppID = string.Empty; //string strSecret = string.Empty; string acc_token = getAccToken(strAppID, strSecret); //acc_token = "DVYt4jXMDPGyE6gwm62LXQ0dmgxm8wTaW_5a1Bp6WoOWC5PwJUvE5ElkCyLpTfIiqOH_gZkUzyZk7Lz8Y2wnVSQMkyPd4CmLSLXDVvb3sXYpKgKZg7JTBBE4dAJ3pEqtPTYgw14jQM8ZLNBWiCpmLQ"; string url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + acc_token; //奥琦便民服务 //String responeJsonStr = "{\"button\":[" + // "{\"name\":\"自助服务\",\"sub_button\":[" + // "{\"type\":\"view\",\"name\":\"Q币充值\",\"url\":\"http://115.29.141.99:8080/ChargeFee/QQPayFee\"}," + // "{\"type\":\"view\",\"name\":\"水电缴费\",\"url\":\"http://115.29.141.99:8080/ChargeFee/OtherPayFee\"}," + // "{\"type\":\"click\",\"name\":\"业务受理\",\"key\":\".\"}," + // "{\"type\":\"click\",\"name\":\"余额查询\",\"key\":\"menu_service_queryFee\"}," + // "{\"type\":\"view\",\"name\":\"充值缴费\",\"url\":\"http://115.29.141.99:8080/ChargeFee/MobilePayFee\"}" + // "]}," + // "{\"name\":\"网上商城\",\"sub_button\":[" + // "{\"type\":\"view\",\"name\":\"手机商城\",\"url\":\"http://115.29.141.99:8080/MobileSell/MobileSell\"}," + // "{\"type\":\"view\",\"name\":\"号码商城\",\"url\":\"http://115.29.141.99:8080/NumberSell/NumberSell\"}" + // "]}," + // "{\"name\":\"更多\",\"sub_button\":[" + // "{\"type\":\"click\",\"name\":\"号码绑定\",\"key\":\"menu_my_binding\"}," + // "{\"type\":\"click\",\"name\":\"最新活动\",\"key\":\"menu_my_activity\"}," + // "{\"type\":\"view\",\"name\":\"天气资讯\",\"url\":\"http://115.29.141.99:8080/OtherService/GetWeather\"}," + // "{\"type\":\"click\",\"name\":\"帮助\",\"key\":\"menu_my_help\"}" + // "]}" + // "]}"; // /*奥琦便民服务 //{"menu":{ // "button":[ // {"name":"自助服务","sub_button":[ // {"type":"view","name":"Q币充值","url":"http://115.29.147.37:8080/ChargeFee/QQPayFee","sub_button":[]}, // {"type":"view","name":"水电缴费","url":"http://115.29.147.37:8080/ChargeFee/OtherPayFee","sub_button":[]}, // {"type":"click","name":"业务受理","key":".","sub_button":[]}, // {"type":"click","name":"余额查询","key":"menu_service_queryFee","sub_button":[]}, // {"type":"view","name":"充值缴费","url":"http://115.29.147.37:8080/ChargeFee/MobilePayFee","sub_button":[]}]}, // {"name":"网上商城","sub_button":[ // {"type":"view","name":"手机商城","url":"http://115.29.147.37:8080/MobileSell/MobileSell","sub_button":[]}, // {"type":"view","name":"号码商城","url":"http://115.29.147.37:8080/NumberSell/NumberSell","sub_button":[]}]}, // {"name":"更多","sub_button":[ // {"type":"click","name":"号码绑定","key":"menu_my_binding","sub_button":[]}, // {"type":"click","name":"最新活动","key":"menu_my_activity","sub_button":[]}, // {"type":"view","name":"天气资讯","url":"http://115.29.147.37:8080/OtherService/GetWeather","sub_button":[]}, // {"type":"click","name":"帮助","key":"menu_my_help","sub_button":[]}]}]}} // * / //海立方 //String responeJsonStr = "{\"button\":[" + // "{\"name\":\"海立方\",\"sub_button\":[" + // "{\"type\":\"click\",\"name\":\"公司介绍\",\"key\":\"xh_jieshao\"}," + // "{\"type\":\"click\",\"name\":\"SPA美甲\",\"key\":\"xh_anmo\"}," + // "{\"type\":\"click\",\"name\":\"餐饮娱乐\",\"key\":\"xh_chanyu\"}," + // "{\"type\":\"click\",\"name\":\"洗浴保健\",\"key\":\"xh_xiyu\"}," + // "{\"type\":\"click\",\"name\":\"酒店客房\",\"key\":\"xh_kefang\"}" + // "]}," + // "{\"name\":\"酒店预订\",\"sub_button\":[" + // "{\"type\":\"click\",\"name\":\"小海促销\",\"key\":\"xh_chuxiao\"}," + // "{\"type\":\"view\",\"name\":\"水汇预订\",\"url\":\"http://114.215.108.27/MicroSite/ProductList.aspx?SiteCode=KM_HLF&CatID=02F25D571BA6438AB965428160A0AA68\"}," + // "{\"type\":\"view\",\"name\":\"客房预订\",\"url\":\"http://114.215.108.27/MicroSite/ProductList.aspx?SiteCode=KM_HLF&CatID=31A10FB143C248A3A2BA5B451DE13276\"}" + // "]}," + // "{\"name\":\"我的海立方\",\"sub_button\":[" + // "{\"type\":\"click\",\"name\":\"便利服务\",\"key\":\"xh_chuxiao\"}," + // "{\"type\":\"click\",\"name\":\"我的优惠\",\"key\":\"my_coupon\"}," + // "{\"type\":\"view\",\"name\":\"我的订单\",\"url\":\"http://114.215.108.27/MicroSite/MyOrder.aspx?SiteCode=KM_HLF\"}," + // "{\"type\":\"view\",\"name\":\"我要注册\",\"url\":\"http://114.215.108.27/MicroSite/Reg.aspx?SiteCode=KM_HLF\"}," + // "{\"type\":\"click\",\"name\":\"我的会员卡\",\"key\":\"my_membership\"}" + // "]}" + // "]}"; String responeJsonStr = "{\"button\":[" + "{\"name\":\"海立方\",\"sub_button\":[" + "{\"type\":\"click\",\"name\":\"公司介绍\",\"key\":\"xh_jieshao\"}," + "{\"type\":\"click\",\"name\":\"SPA美甲\",\"key\":\"xh_anmo\"}," + "{\"type\":\"click\",\"name\":\"餐饮娱乐\",\"key\":\"xh_chanyu\"}," + "{\"type\":\"click\",\"name\":\"洗浴保健\",\"key\":\"xh_xiyu\"}," + "{\"type\":\"click\",\"name\":\"酒店客房\",\"key\":\"xh_kefang\"}" + "]}," + "{\"name\":\"世界杯活动\",\"sub_button\":[" + "{\"type\":\"view\",\"name\":\"水汇预订\",\"url\":\"http://114.215.108.27/MicroSite/ProductList.aspx?SiteCode=KM_HLF&CatID=02F25D571BA6438AB965428160A0AA68\"}," + "{\"type\":\"view\",\"name\":\"客房预订\",\"url\":\"http://114.215.108.27/MicroSite/ProductList.aspx?SiteCode=KM_HLF&CatID=31A10FB143C248A3A2BA5B451DE13276\"}" + "{\"type\":\"view\",\"name\":\"球赛竞猜\",\"url\":\"http://114.215.108.27/MicroSite/JCQuizDetail.aspx?OpenID=1111&SiteCode=KM_HLF\"}" + "{\"type\":\"view\",\"name\":\"赛程魔方\",\"url\":\"http://114.215.108.27/MicroSite/themes/Quiz/WorldCupMoFang.html\"}" + "]}," + "{\"name\":\"我的海立方\",\"sub_button\":[" + "{\"type\":\"click\",\"name\":\"便利服务\",\"key\":\"xh_chuxiao\"}," + "{\"type\":\"click\",\"name\":\"我的优惠\",\"key\":\"my_coupon\"}," + "{\"type\":\"view\",\"name\":\"我的订单\",\"url\":\"http://114.215.108.27/MicroSite/MyOrder.aspx?SiteCode=KM_HLF\"}," + "{\"type\":\"view\",\"name\":\"我要注册\",\"url\":\"http://114.215.108.27/MicroSite/Reg.aspx?SiteCode=KM_HLF\"}," + "{\"type\":\"click\",\"name\":\"我的会员卡\",\"key\":\"my_membership\"}" + "]}" + "]}"; ////曲靖电视台 //String responeJsonStr = "{\"button\":[" + // "{\"type\":\"view\",\"name\":\"节目展示\",\"url\":\"http://114.215.108.27/MicroSite/ArticleList.aspx?sitecode=QJTV&Catid=4E43448EADB844819AED5523A2C13F03\"}," + // "{\"name\":\"观众互动\",\"sub_button\":[" + // "{\"type\":\"view\",\"name\":\"观众热线\",\"url\":\"http://114.215.108.27/MicroSite/Guestbook.aspx?ID=F9671002614D4A6CBEA6BFC8B1F281FC\"}," + // "{\"type\":\"view\",\"name\":\"观众投票\",\"url\":\"http://114.215.108.27/MicroSite/Vote.aspx?ID=F9671002614D4A6CBEA6BFC8B1F281FC\"}" + // "]}," + // "{\"name\":\"第三方合作\",\"sub_button\":[" + // "{\"type\":\"click\",\"name\":\"便利服务\",\"key\":\"ps_service\"}," + // "{\"type\":\"click\",\"name\":\"关注有奖\",\"key\":\"my_coupon\"}" + // "]}" + // "]}"; txtResult.Text = PostWebRequest(url, responeJsonStr, Encoding.UTF8); }
protected void Page_Load(object sender, EventArgs e) { //if (null == Request.QueryString["sitecode"]) //{ // return; //} //else //{ // strSiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString()); //} //Session["strSiteCode"] = strSiteID; if (Request["subid"] != null && Request["subid"] != "") { strSubjectID = Common.Common.NoHtml(Request["subid"]); } else { //strSubjectID = "2D883507972847CBAE20C692093F9394"; return; } if (null == Request["state"] || Request["state"] == "") { return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } } if (Request["action"] != null && Request["action"] != "" && Request["action"] == "save") { votesave(); } else { getvoteDetail(); } }
protected void Page_Load(object sender, EventArgs e) { string strSiteCode = string.Empty; string strOpenID = string.Empty; if (null == Request.QueryString["state"]) { return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } else { strOpenID = code; } } strOpenID = code; List <Model.MiniShop.MSVProduct> liProduct = new List <Model.MiniShop.MSVProduct>(); DAL.MiniShop.MSProductDAL dalProduct = new DAL.MiniShop.MSProductDAL(); DataSet ds = dalProduct.GetProductListBySiteCode(strSiteCode); foreach (DataRow row in ds.Tables[0].Rows) { Model.MiniShop.MSVProduct model = DataConvert.DataRowToModel <Model.MiniShop.MSVProduct>(row); liProduct.Add(model); } //读取模板内容 string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Default/VProductList.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["sitecode"] = strSiteCode; context.TempData["openid"] = strOpenID; context.TempData["product_list"] = liProduct; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
protected override void AddTempData(JinianNet.JNTemplate.TemplateContext context) { base.AddTempData(context); CouponDAL dal = new CouponDAL(); DataSet ds = dal.GetCouponInfo(CouponID); MyCouponInfo model = new MyCouponInfo(); if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { model = DataConvert.DataRowToModel <MyCouponInfo>(ds.Tables[0].Rows[0]); } //读取模板内容 //string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Default/" + strReHtml)); //JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); if (strReHtml == "RushBuyOK.html" || strReHtml == "QJTVRushBuyOK.html") { this.SetQRCode(context, model.ID); context.TempData["pDetail"] = model; if (model.CouponStatus == "已经使用") { context.TempData["RemainDay"] = ""; } else { if (int.Parse(model.RemainDay) > -1) { context.TempData["RemainDay"] = "有效期:还剩" + model.RemainDay + "天"; } else { context.TempData["RemainDay"] = "有效期:此券已经过期!"; } } } else { #region 消费完成发生消息 string strAppID = string.Empty; string strSecret = string.Empty; Model.WeiXin.WXConfig wc = new Model.WeiXin.WXConfig(); WXConfigDAL wcdal = new WXConfigDAL(); wc = wcdal.GetWXConfigBySiteCode(SiteCode); if (null != wc) { strAppID = wc.WXAppID; strSecret = wc.WXAppSecret; } string strToken = WeiXinHelper.GetAccessToken(strAppID, strSecret); var KeyToken = new { access_token = "" }; var b = JsonConvert.DeserializeAnonymousType(strToken, KeyToken); string strRToken = b.access_token; WeiXinHelper.SendCustomTextMessage(strRToken, OpenID, strMessage); #endregion //Response.Write("<script>document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() { WeixinJSBridge.call('closeWindow');});</script>"); //Response.Redirect("MyCoupon.aspx?SiteCode=" + strSiteCode + "&OpenID=" + strOpenID); //return; } context.TempData["strmsg"] = strMessage; context.TempData["OpenID"] = OpenID; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (null == Request["state"] || Request["state"] == "") { return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } } //if (string.IsNullOrEmpty(strOpenID)) //{ // return; //} if (Request["action"] != null && Request["action"] != "") { if (Request["openid"] != null && Request["openid"] != "") { strOpenID = Request.QueryString["openid"].ToString(); Session["openid"] = strOpenID; } } else { if (null != Session["openid"]) { strOpenID = Session["openid"].ToString(); } } if (Request["openid"] != null && Request["openid"] != "") { strOpenID = Request.QueryString["openid"].ToString(); Session["openid"] = strOpenID; } //取有效竞猜ID DataSet dsQuiz = dalQuiz.GetJCQuizDataList(" DATEDIFF(MI,GETDATE(),StartTime) > 15 "); if (Request["id"] != null && Request["id"] != "") { strQuizID = Common.Common.NoHtml(Request["id"].ToString()); } else if (null != dsQuiz && dsQuiz.Tables.Count > 0 && dsQuiz.Tables[0].Rows.Count > 0) { strQuizID = dalQuiz.GetJCQuizDataList(" DATEDIFF(MI,GETDATE(),StartTime) > 15 ").Tables[0].Rows[0]["ID"].ToString(); } else { #region 消费完成发生消息 string strAppID = string.Empty; string strSecret = string.Empty; Model.WeiXin.WXConfig wc = new Model.WeiXin.WXConfig(); WXConfigDAL wcdal = new WXConfigDAL(); wc = wcdal.GetWXConfigBySiteCode(strSiteCode); if (null != wc) { strAppID = wc.WXAppID; strSecret = wc.WXAppSecret; } string strToken = WeiXinHelper.GetAccessToken(strAppID, strSecret); var KeyToken = new { access_token = "" }; var b = JsonConvert.DeserializeAnonymousType(strToken, KeyToken); string strRToken = b.access_token; WeiXinHelper.SendCustomTextMessage(strRToken, strOpenID, "当前没有竞猜场次!<a href='http://114.215.108.27/MicroSite/MyQuiz.aspx?sitecode=" + strSiteCode + "&openid=" + strOpenID + "'>查看所有参加的竞猜</a>"); #endregion Response.Write("<script>document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() { WeixinJSBridge.call('closeWindow');});</script>"); return; } if (Request["action"] != null && Request["action"] != "") { strAction = Common.Common.NoHtml(Request.QueryString["action"].ToString()); } if (strAction.Trim() != null && strAction.Trim() != "" && strAction.Trim().ToLower() == "save") { SaveJCGScore(); } else { GetDetailList(); } } }
protected void Page_Load(object sender, EventArgs e) { string strSiteID = string.Empty; string strSiteCode = string.Empty; string strTitle = string.Empty; string strTheme = string.Empty; string strAlbumTypeID = string.Empty; string strOpenID = string.Empty; //if (null == Request.QueryString["ID"]) //{ // return; //} //if (null == Request.QueryString["OpenID"]) //{ // return; //} //strSiteCode = Common.Common.NoHtml(Request.QueryString["ID"].ToString()); //if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25) //{ // strOpenID = Common.Common.NoHtml(Request.QueryString["openid"].ToString()); //} //else //{ // strOpenID = Request.QueryString["openid"].ToString(); //} if (null == Request["state"] || Request["state"] == "") { return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } } Session["OpenID"] = strOpenID; //取站点信息 DAL.SYS.AccountDAL dalAccount = new DAL.SYS.AccountDAL(); DAL.Album.PhotoList dalPhotoList = new DAL.Album.PhotoList(); DataSet dsAccount = dalAccount.GetAExtDataBySiteCode(strSiteCode); if (null != dsAccount && dsAccount.Tables.Count > 0 && dsAccount.Tables[0].Rows.Count > 0) { strTheme = dsAccount.Tables[0].Rows[0]["Themes"].ToString(); strTitle = dsAccount.Tables[0].Rows[0]["Name"].ToString(); strSiteCode = dsAccount.Tables[0].Rows[0]["SiteCode"].ToString(); strSiteID = dsAccount.Tables[0].Rows[0]["ID"].ToString(); Session["strSiteCode"] = dsAccount.Tables[0].Rows[0]["SiteCode"].ToString(); } //取站点相册列表 DataSet dsPhotoList = dalPhotoList.GetPhotoList(strSiteCode); List <Model.Album.PhotoList> liPhotoList = new List <Model.Album.PhotoList>(); if (null != dsPhotoList && dsPhotoList.Tables.Count > 0 && dsPhotoList.Tables[0].Rows.Count > 0) { foreach (DataRow row in dsPhotoList.Tables[0].Rows) { Model.Album.PhotoList model = DataConvert.DataRowToModel <Model.Album.PhotoList>(row); liPhotoList.Add(model); } } //读取模板内容 string text = string.Empty; if (!File.Exists(Server.MapPath("Themes/" + strTheme + "/PhotoWall.html"))) { text = System.IO.File.ReadAllText(Server.MapPath("Themes/PhotoWall/PhotoWall.html")); } else { text = System.IO.File.ReadAllText(Server.MapPath("Themes/" + strTheme + "/PhotoWall.html")); } JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["title"] = strTitle; context.TempData["siteid"] = strSiteID; context.TempData["footer"] = "奥琦微商易"; context.TempData["sitecode"] = strSiteCode; context.TempData["AlbumTypelist"] = liPhotoList; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strSiteCode = string.Empty; string strOpenID = string.Empty; //if (null == Request["state"] || Request["state"] == "") if (null == Request.QueryString["state"]) { return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } else { strOpenID = code; } } Session["OpenID"] = strOpenID; //取所有参加的活动列表 List <MyCouponInfo> liCoupon = new List <MyCouponInfo>(); CouponDAL dalCoup = new CouponDAL(); DataSet ds = dalCoup.GetCouponInfoList(strSiteCode, strOpenID); if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { MyCouponInfo model = DataConvert.DataRowToModel <MyCouponInfo>(row); liCoupon.Add(model); } } string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/ActiveList.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["coupon_list"] = liCoupon; context.TempData["OpenID"] = strOpenID; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); } }
void GetHtmlpage() { #region --------------------------判断是否为手机端浏览-------------------------- //判断是否为手机端浏览 //string u = Request.ServerVariables["HTTP_USER_AGENT"]; //Regex b = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline); //Regex v = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-", RegexOptions.IgnoreCase | RegexOptions.Multiline); //if (!(b.IsMatch(u) || v.IsMatch(u.Substring(0, 4)))) //{ // return; //} #endregion string strSiteCode = string.Empty; string strOpenID = string.Empty; #region -------------------获取用户OpenID--------------- if (Request["state"] != null && Request["state"] != "") { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } else { strOpenID = code; } } #endregion List <MSShop> shoplist = new List <MSShop>(); #region -------------获取最新店铺列表----------------- MSShopDAL shopDal = new MSShopDAL(); DataSet shopds = shopDal.GetShopList(20, ""); if (shopds != null && shopds.Tables.Count > 0 && shopds.Tables[0].Rows.Count > 0) { foreach (DataRow row in shopds.Tables[0].Rows) { MSShop shopModel = DataConvert.DataRowToModel <MSShop>(row); shoplist.Add(shopModel); } } #endregion if (strOpenID != null && strOpenID != "") { Session["OpenID"] = strOpenID; } string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/index.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["shoplist"] = shoplist; context.TempData["uid"] = uid; context.TempData["OpenID"] = strOpenID; context.TempData["errormsg"] = errowmsg; context.TempData["title"] = "最新店铺"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
protected void Page_Load(object sender, EventArgs e) { string strSiteID = string.Empty; string strSiteCode = string.Empty; string strTitle = string.Empty; string strTheme = string.Empty; string strOpenID = string.Empty; //订阅号 //if (null == Request.QueryString["openid"]) //{ // return; //} //if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25) //{ // strOpenID = Common.Common.NoHtml(Request.QueryString["openid"].ToString()); //} //else //{ // strOpenID = Request.QueryString["openid"].ToString(); //} //if (null == Request.QueryString["sitecode"]) //{ // return; //} //strSiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString()); if (null == Request["state"] || Request["state"] == "") { return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } } Session["OpenID"] = strOpenID; //取站点相册列表 DAL.Album.UserPhotoDAL dalUserPhoto = new DAL.Album.UserPhotoDAL(); DataSet dsThumbList = dalUserPhoto.GetMyPhoto(strSiteCode, strOpenID); List <Model.Album.UserPhoto> lstThumb = new List <Model.Album.UserPhoto>(); foreach (DataRow row in dsThumbList.Tables[0].Rows) { Model.Album.UserPhoto model = DataConvert.DataRowToModel <Model.Album.UserPhoto>(row); lstThumb.Add(model); } //读取模板内容 string text = System.IO.File.ReadAllText(Server.MapPath("Themes/PhotoWall/MyThumbList.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["sitecode"] = strSiteCode; context.TempData["title"] = "我的照片"; context.TempData["lstThumb"] = lstThumb; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }