Exemple #1
0
    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>");
        }
    }
Exemple #2
0
    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>");
        }
    }
Exemple #3
0
    public void Bind()
    {
        Cms.BLL.wx_info   wx  = new Cms.BLL.wx_info();
        Cms.Model.wx_info mwx = new Cms.Model.wx_info();
        DataTable         dt  = wx.GetList("").Tables[0];

        if (dt.Rows.Count > 0)
        {
            mwx = wx.GetModel(1);
            if (mwx != null)
            {
                AppId.Text     = mwx.AppId;
                AppSecret.Text = mwx.AppSecret;
                hdid.Text      = mwx.access_token;
                wurl.Text      = mwx.url;
                WxId.Text      = mwx.wxid;
            }
        }
    }
Exemple #4
0
    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);
    }
Exemple #5
0
    public void Bind()
    {
        // Response.Write(setmenu());
        Cms.BLL.wx_info   wx  = new Cms.BLL.wx_info();
        Cms.Model.wx_info mwx = new Cms.Model.wx_info();
        DataTable         dt  = wx.GetList("").Tables[0];

        if (dt.Rows.Count > 0)
        {
            mwx = wx.GetModel(1);
            if (mwx != null)
            {
                AppId.Text     = mwx.AppId;
                AppSecret.Text = mwx.AppSecret;
                hdid.Text      = mwx.access_token;
            }
            mwx = wx.GetModel(2);
            if (mwx != null)
            {
                tbid.Text   = mwx.AppId;
                tburls.Text = mwx.AppSecret;
            }
        }
        Cms.BLL.wx_menu   wm  = new Cms.BLL.wx_menu();
        Cms.Model.wx_menu wmd = new Cms.Model.wx_menu();
        dt = wm.GetList("pid=0").Tables[0];

        foreach (DataRow dr in dt.Rows)
        {
            int    id   = int.Parse(dr["id"].ToString());
            string name = dr["name"].ToString();
            int    pid  = int.Parse(dr["pid"].ToString());
            if (id == 1)
            {
                DataTable dts = wm.GetList("pid=" + id).Tables[0];


                ListBox1.DataSource     = dts.DefaultView;
                ListBox1.DataTextField  = "name";
                ListBox1.DataValueField = "id";
                ListBox1.DataBind();
                ListBox1.Items.Insert(0, new ListItem(name, id.ToString()));
            }
            if (id == 2)
            {
                DataTable dts = wm.GetList("pid=" + id).Tables[0];

                ListBox2.DataSource     = dts.DefaultView;
                ListBox2.DataTextField  = "name";
                ListBox2.DataValueField = "id";
                ListBox2.DataBind();
                ListBox2.Items.Insert(0, new ListItem(name, id.ToString()));
            }
            if (id == 3)
            {
                DataTable dts = wm.GetList("pid=" + id).Tables[0];

                ListBox3.DataSource     = dts.DefaultView;
                ListBox3.DataTextField  = "name";
                ListBox3.DataValueField = "id";
                ListBox3.DataBind();
                ListBox3.Items.Insert(0, new ListItem(name, id.ToString()));
            }
        }
    }