protected void btnsave_Click(object sender, EventArgs e) { Cms.BLL.wx_info wx = new Cms.BLL.wx_info(); Cms.Model.wx_info mwx = new Cms.Model.wx_info(); DataTable dt = wx.GetList("id=1").Tables[0]; bool bl = false; if (dt.Rows.Count > 0) { mwx = wx.GetModel(1); mwx.AppId = AppId.Text.Trim(); mwx.AppSecret = AppSecret.Text.Trim(); mwx.access_token = hdid.Text.Trim(); bl = wx.Update(mwx); } else { mwx.AppId = AppId.Text.Trim(); mwx.AppSecret = AppSecret.Text.Trim(); mwx.access_token = Gettoken(); if (wx.Add(mwx) > 0) { bl = true; } } if (bl) { Bind(); ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('设置成功!')</script>"); } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('设置失败!')</script>"); } }
protected void btnsave_Click(object sender, EventArgs e) { Cms.BLL.wx_info wx = new Cms.BLL.wx_info(); Cms.Model.wx_info mwx = new Cms.Model.wx_info(); DataTable dt = wx.GetList("id=1").Tables[0]; bool bl = false; if (dt.Rows.Count > 0) { mwx = wx.GetModel(1); mwx.AppId = AppId.Text.Trim(); mwx.AppSecret = AppSecret.Text.Trim(); mwx.access_token = hdid.Text.Trim(); mwx.url = wurl.Text.Trim(); mwx.wxid = WxId.Text.Trim(); adminUser.AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), mwx.AppId); //记录日志 bl = wx.Update(mwx); } else { mwx.AppId = AppId.Text.Trim(); mwx.AppSecret = AppSecret.Text.Trim(); mwx.access_token = hdid.Text.Trim(); mwx.url = wurl.Text.Trim(); mwx.wxid = WxId.Text.Trim(); if (wx.Add(mwx) > 0) { adminUser.AddAdminLog(DTEnums.ActionEnum.Add.ToString(), mwx.AppId); //记录日志 bl = true; } } if (bl) { Bind(); ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('设置成功!');", true); // ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('设置成功!')</script>"); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('设置失败!');", true); //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('设置失败!')</script>"); } }
protected void btnts_Click(object sender, EventArgs e) { Cms.BLL.C_article cb = new Cms.BLL.C_article(); int id = int.Parse(tbid.Text.Trim() == ""?"0":tbid.Text.Trim()); if (id == 0) { return; } DataTable dt = cb.GetList("articleId=" + id).Tables[0]; if (dt.Rows.Count == 0) { ScriptManager.RegisterStartupScript(UpdatePanel2, UpdatePanel2.GetType(), "", "alert('文章不存在!');", true); return; } DataRow dr = dt.Rows[0]; string strurl = tburls.Text.Trim(); if (strurl == "") { ScriptManager.RegisterStartupScript(UpdatePanel2, UpdatePanel2.GetType(), "", "alert('请输入文章路径!');", true); return; } string[] suser = GetPage4("https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + hdid.Text, "").Split(','); //string str = UploadMultimedia(hdid.Text, "image"); string surl = "http://" + HttpContext.Current.Request.Url.Host.ToString(); string spic = surl + dr["photourl"].ToString(); foreach (string s in suser) { if (s == "") { continue; } StringBuilder sb = new StringBuilder(); //sb.Append("{"); //sb.Append("\"touser\":"+s+","); //sb.Append("\"msgtype\":\"image\","); //sb.Append("\"image\":"); //sb.Append("{"); //sb.Append("\"media_id\":\"" + str + "\""); //sb.Append("}"); //sb.Append("}"); sb.Append("{"); sb.Append("\"touser\":" + s + ","); sb.Append("\"msgtype\":\"news\","); sb.Append("\"news\":{"); sb.Append("\"articles\":["); sb.Append("{"); sb.Append("\"title\":\"" + dr["title"].ToString() + "\","); sb.Append("\"description\":\"" + dr["intro"].ToString() + "\","); sb.Append("\"url\":\"" + strurl + "\","); sb.Append("\"picurl\":\"" + spic + "\""); sb.Append(" }"); sb.Append("]"); sb.Append("}"); sb.Append("}"); setinfo("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + hdid.Text.Trim(), sb.ToString()); } //StringBuilder sb = new StringBuilder(); //string str = UploadMultimedia(hdid.Text, "image"); //sb.Append("{"); //sb.Append("\"articles\": ["); //sb.Append("{"); //sb.Append("\"thumb_media_id\":\"" + str + "\","); //sb.Append("\"author\":\"\","); //sb.Append("\"title\":\"小额贷款审计我之见\","); //sb.Append("\"content_source_url\":\"http://www.muhn.org.cn/contents9.html\","); //sb.Append("\"content\":\"自2008年银监会、央行发布《关于小额贷款公司试点的指导意见》以来\","); //sb.Append("\"digest\":\"digest\","); //sb.Append("\"show_cover_pic\":\"1\""); //sb.Append("}"); //sb.Append("]"); //sb.Append("}"); //GetPage3("https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token="+hdid.Text, sb.ToString(), 1); Cms.BLL.wx_info wx = new Cms.BLL.wx_info(); Cms.Model.wx_info mwx = new Cms.Model.wx_info(); dt = wx.GetList("id=2").Tables[0]; bool bl = false; if (dt.Rows.Count > 0) { mwx = wx.GetModel(2); mwx.AppId = tbid.Text.Trim(); mwx.AppSecret = tburls.Text.Trim(); bl = wx.Update(mwx); } else { mwx.AppId = tbid.Text.Trim(); mwx.AppSecret = tburls.Text.Trim(); if (wx.Add(mwx) > 0) { bl = true; } } ScriptManager.RegisterStartupScript(UpdatePanel2, UpdatePanel2.GetType(), "", "alert('推送成功!');", true); }