public void loaddata()
        {
            Maticsoft.BLL.weixin wx_bll = new BLL.weixin();
            string open_id = "";

            if (Session["open_id"] == null)
            {
                string code = Request.QueryString["code"];
                if (code != null && code != "")
                {
                    open_id = wx_bll.get_openid(code);
                    if (open_id != null && open_id != "")
                    {
                        Session["open_id"] = open_id;
                        loadinfo(open_id);
                    }
                    else
                    {
                        Response.Write(@"<script>alert('无法获取您的微信信息,返回首页');window.location='m_weixin\index.aspx'</script>");
                    }
                }
                else
                {
                    Response.Write(@"<script>alert('无法获取您的微信信息,返回首页');window.location='m_weixin\index.aspx'</script>");
                }
            }
            else
            {
                open_id = Session["open_id"].ToString();
                loadinfo(open_id);
            }
        }
        public void loadinfo(string open_id)
        {
            Maticsoft.BLL.weixin            wx_bll = new BLL.weixin();
            Maticsoft.Model.weixin_userinfo wx_mod = new Model.weixin_userinfo();
            wx_mod = wx_bll.get_userinfo(open_id, wx_bll.get_accesstoken())[0];
            Maticsoft.BLL.member mem_b = new BLL.member();
            string name = mem_b.get_name(open_id);

            if (name != null && name != "空")
            {
                huanyingci.Text   = "您好," + name + "(" + wx_mod.nickname + "),欢迎进入温氏培训系统测试版";
                touxiang.ImageUrl = wx_mod.headimgurl;
            }
            else
            {
                Response.Write(@"<script>alert('无法获取您的培训信息,返回首页');window.location='m_weixin\index.aspx'</script>");
            }
        }
Esempio n. 3
0
        public void loaddata()
        {
            Maticsoft.BLL.member mem_bll = new BLL.member();
            DataTable            dt      = mem_bll.GetList("fenzu_id is null and style='2'").Tables[0];

            if (dt.Rows.Count > 0)
            {
                openid.Text    = dt.Rows[0]["openid"].ToString();
                name.Text      = dt.Rows[0]["name"].ToString();
                date_time.Text = dt.Rows[0]["time"].ToString();
                Maticsoft.BLL.weixin wx_bll = new BLL.weixin();
                weixn_nickname.Text = wx_bll.get_userinfo(dt.Rows[0]["openid"].ToString(), wx_bll.get_accesstoken())[0].nickname;
                Maticsoft.BLL.teacher tea_bll = new BLL.teacher();
                DataSet ds = tea_bll.GetList("");
                DropDownList1.DataSource     = ds;
                DropDownList1.DataTextField  = "name";
                DropDownList1.DataValueField = "id";
                DropDownList1.DataBind();
            }
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            //JavaScriptSerializer json = new JavaScriptSerializer();
            //List<acc_token> list = json.Deserialize<List<acc_token>>("[" + responseStr + "]");
            //WebClient requestClinet = new WebClient();
            //string str = requestClinet.DownloadString("https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + list[0].access_token + "&openid=oPFZYwbAiqy5APlJiaFB-i8N068Y&lang=zh_CN");
            ////System.Text.Encoding iso_8859_1 = System.Text.Encoding.GetEncoding("iso-8859-1");
            ////System.Text.Encoding utf_8 = System.Text.Encoding.UTF8;
            ////byte[] isoBytes = iso_8859_1.GetBytes(str);
            ////byte[] utf8Bytes = System.Text.Encoding.Convert(iso_8859_1, utf_8, isoBytes);
            // byte[] sourcebytes = System.Text.Encoding.Default.GetBytes(str);
            //  Label2.Text = Encoding.UTF8.GetString(sourcebytes);

            Maticsoft.BLL.weixin weixin = new BLL.weixin();
            string accesstoken          = weixin.get_accesstoken();
            List <Maticsoft.Model.weixin_userinfo> list = weixin.get_userinfo("oPFZYwanSioNrWovMwut_W_cy0h8", accesstoken);

            Label1.Text          = list[0].ToString();
            GridView1.DataSource = list;
            GridView1.DataBind();
        }
        protected void Button5_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.weixin wx_bll = new BLL.weixin();

            //Label1.Text = wx_bll.get_web_accesstoken("021a3Ip90X21gu11Vsq90tcDp90a3Ip6");
        }
Esempio n. 6
0
        public void loaddata1()
        {
            if (Session["userinfo"] == null)
            {
                code = Request.QueryString["code"];
                if (string.IsNullOrEmpty(code))
                {
                    Response.Write("<script>alert('请从微信端登陆系统!')</script>");
                }
                else
                {
                    Response.Write("<script>alert('感谢您进入温氏学院系统!')</script>");
                    Maticsoft.BLL.weixin             wx_bll  = new BLL.weixin();
                    Maticsoft.Model.access_web_token awt_mod = new Model.access_web_token();
                    awt_mod = wx_bll.get_web_accesstoken(code)[0];
                    if (awt_mod == null || string.IsNullOrEmpty(awt_mod.openid))
                    {
                        Response.Write("<script>alert('无法获取你的识别号!')</script>");
                    }
                    else
                    {
                        string opend_id     = awt_mod.openid;
                        string accesstonken = awt_mod.access_token;
                        Maticsoft.Model.weixin_userinfo wx_u_mod = wx_bll.get_userinfo(opend_id, accesstonken)[0];

                        if (wx_u_mod == null)
                        {
                            Response.Write("<script>alert('无法获取你的微信信息!')</script>");
                        }
                        else
                        {
                            openid.Text         = "您好," + wx_u_mod.remark + "(" + wx_u_mod.nickname + "),欢迎进入温氏学院测试系统";
                            touxiang.ImageUrl   = wx_u_mod.headimgurl;
                            Session["userinfo"] = wx_u_mod;
                            //if(string.IsNullOrEmpty(wx_u_mod.remark))
                            //{
                            //    Response.Write("<script>alert('请录入个人信息');window.location='mem_info_fill.aspx'</script>");
                            //}
                        }
                    }
                }
            }
            else
            {
                Maticsoft.Model.weixin_userinfo wx_u_mod = (Maticsoft.Model.weixin_userinfo)Session["userinfo"];
                Maticsoft.BLL.member            mem_bll  = new BLL.member();
                wx_u_mod.remark     = mem_bll.get_name(wx_u_mod.openid);
                openid.Text         = "您好," + wx_u_mod.remark + "(" + wx_u_mod.nickname + "),欢迎进入温氏学院测试系统";
                touxiang.ImageUrl   = wx_u_mod.headimgurl;
                Session["userinfo"] = wx_u_mod;
            }
            // code = Request.QueryString["code"];
            // //WebClient requestClinet1 = new WebClient();
            // //string jsonArray1 = requestClinet1.DownloadString("https://api.weixin.qq.com/sns/oauth2/access_token?appid=zheshiyigejiadeid&secret=zhendemimazaibendibaocun&code=" + code + "&grant_type=authorization_code");


            // Maticsoft.BLL.weixin wx_bll = new BLL.weixin();

            // Maticsoft.Model.access_web_token awt_mod = new Model.access_web_token();
            // awt_mod = wx_bll.get_web_accesstoken(code)[0];
            //string  opend_id=  awt_mod.openid;
            // string accesstonken=awt_mod.access_token;
            //Literal1.Text = code + "色打发士大夫大师傅个" +opend_id+"士大夫士大夫" +accesstonken;
            //Maticsoft.Model.weixin_userinfo wx_u_mod = wx_bll.get_userinfo(opend_id, accesstonken)[0];
            //openid.Text = wx_u_mod.nickname;
            //touxiang.ImageUrl = wx_u_mod.headimgurl;
        }