コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //刚开始判断一下session,如果过期了就退出了,重新登录
            if (Session["login"] == null)
            {
                MessageBox.Show("登录已过期");
                Response.Redirect("Login.aspx");
            }
            CheckOtherLogin();

            //如果没有过期就显示出来登录的用户名
            if (!Page.IsPostBack)
            {
                //因为无法级联查询,所以只能这种方式
                string roleid      = (string)Session["roleid"];
                string envid       = ConfigurationManager.AppSettings["envid"];
                string queryString = "{\"env\":\"" + envid + "\", \"query\": \"db.collection(\\\"role_func\\\").where({roleid:\\\"" + roleid + "\\\"}).limit(10).get()\"}";

                string  access_token = (string)Session["access_token"];
                string  url          = "https://api.weixin.qq.com/tcb/databasequery?access_token=" + access_token; //POST到网站
                string  Message      = OperateCloud.Query(queryString, url);
                JObject jo           = OperateCloud.GetJson(Message);
                int     length       = int.Parse(jo["pager"]["Total"].ToString());
                //MessageBox.Show(length+"");

                //this.TreeView1.ShowLines = true;//在控件中显示网格线

                for (int i = 0; i < length; i++)
                {
                    string   temp     = jo["data"][i].ToString(); //data里面第一个列表里面的json数据
                    JObject  jo1      = OperateCloud.GetJson(temp);
                    TreeNode rootNode = new TreeNode();           //定义根节点
                    //获得了funcid之后,从function数据库中取出功能名称
                    string funcid = jo1["funcid"].ToString();
                    queryString = "{\"env\":\"" + envid + "\", \"query\": \"db.collection(\\\"func\\\").where({id:\\\"" + funcid + "\\\"}).limit(10).get()\"}";
                    url         = "https://api.weixin.qq.com/tcb/databasequery?access_token=" + access_token; //POST到网站
                    Message     = OperateCloud.Query(queryString, url);
                    JObject jo2      = OperateCloud.GetJson(Message);
                    string  function = jo2["data"][0].ToString();//data里面第一个列表里面的json数据
                    JObject jo22     = OperateCloud.GetJson(function);
                    rootNode.Text = jo22["func"].ToString();
                    //MessageBox.Show(jo22["func"].ToString());
                    //成功取出
                    rootNode.NavigateUrl = "~/" + jo22["func"].ToString() + ".aspx";
                    //rootNode.ChildNodes.Add(tr1);//把子节点添加到根节点
                    TreeView1.Nodes.Add(rootNode);   //把根节点添加到TreeView控件中
                }
                TreeNode rootNode1 = new TreeNode(); //定义根节点
                rootNode1.Text = "返回首页";

                rootNode1.NavigateUrl = "~/Search.aspx";
                TreeView1.Nodes.Add(rootNode1);//把根节点添加到TreeView控件中
                showPersonInfo();
            }
        }
コード例 #2
0
        public void GetBook(string name)
        {
            string envid   = ConfigurationManager.AppSettings["envid"];
            int    booknum = int.Parse(ConfigurationManager.AppSettings["booknum"]);
            //string name = Request.QueryString["BookName"];

            int    skip        = booknum * ((int)Session["CurrentPage"] - 1);
            string queryString = "";

            if (name == "")
            {
                queryString = "{\"env\":\"" + envid + "\", \"query\": \"db.collection(\\\"library\\\").where({}).limit(" + booknum + ").skip(" + skip + ").get()\"}";
            }
            else
            {
                queryString = "{\"env\":\"" + envid + "\", \"query\": \"db.collection(\\\"library\\\").where({name:db.RegExp({regexp:\\\"" + name + "\\\" ,option:\\\"i\\\"})}).limit(" + booknum + ").skip(" + skip + ").get()\"}";
            }
            //access_token
            //MessageBox.Show(queryString);
            string  access_token = (string)Session["access_token"];
            string  url          = "https://api.weixin.qq.com/tcb/databasequery?access_token=" + access_token; //POST到网站
            string  Message      = OperateCloud.Query(queryString, url);
            JObject jo           = OperateCloud.GetJson(Message);
            //MessageBox.Show("errcode:" + jo["errcode"].ToString());
            int limit = int.Parse(jo["pager"]["Limit"].ToString());
            int total = int.Parse(jo["pager"]["Total"].ToString());

            //MessageBox.Show("total"+total+"limit"+limit);
            if (total % booknum != 0)
            {
                Session["Count"] = total / booknum + 1;
                count.Text       = Session["Count"] + "";
            }
            else
            {
                Session["Count"] = total / booknum;
                count.Text       = Session["Count"] + "";
            }
            //MessageBox.Show("count:"+Session["Count"]);
            //List<string> filelist = new List<string>();
            int loop = 0;

            if (limit < total - skip)
            {
                loop = limit;
            }
            else
            {
                loop = total - skip;
            }
            for (int i = 0; i < loop; i++)
            {
                string  temp = jo["data"][i].ToString();
                JObject jo1  = OperateCloud.GetJson(temp);
                //MessageBox.Show(jo1["name"].ToString());

                queryString = "{\"env\":\"" + envid + "\", \"file_list\": [{\"fileid\":\"" + jo1["fileIDs"][0].ToString() + "\",\"max_age\":7200}]}";

                //access_token
                url     = "https://api.weixin.qq.com/tcb/batchdownloadfile?access_token=" + access_token; //POST到网站
                Message = OperateCloud.Query(queryString, url);
                JObject jo2       = OperateCloud.GetJson(Message);
                int     errorcode = int.Parse(jo2["errcode"].ToString());
                if (errorcode == 0)
                {
                    /*MessageBox.Show("获取图片成功");
                     * MessageBox.Show(jo2["file_list"][0]["download_url"].ToString());*/
                    TableRow row = new TableRow();

                    TableCell cell3 = new TableCell();
                    cell3.Text = "<p style='width:100px;padding-left:30px' class='overline'>" + jo1["remain"].ToString() + "</ p>";
                    row.Cells.Add(cell3);

                    TableCell cell1 = new TableCell();
                    cell1.Text = "<p style='width:100px;padding:10px' class='overline'>" + jo1["name"].ToString() + "</ p>";
                    row.Cells.Add(cell1);

                    TableCell cell0 = new TableCell();
                    cell0.Text = "<img style='width:120px;height:160px' src='" + jo2["file_list"][0]["download_url"].ToString() + "'/>";
                    row.Cells.Add(cell0);

                    TableCell cell6 = new TableCell();
                    cell6.Text = "<p style='width:500px;padding:40px' class='overline'>" + jo1["description"].ToString() + "</ p>";
                    row.Cells.Add(cell6);

                    TableCell cell2 = new TableCell();
                    cell2.Text = "<p style='width:200px;padding:10px' class='overline'>" + jo1["author"].ToString() + "</ p>";
                    row.Cells.Add(cell2);

                    TableCell cell4 = new TableCell();
                    cell4.Text = "<p style='width:100px;padding:10px' class='overline'>" + jo1["library"].ToString() + "</ p>";
                    row.Cells.Add(cell4);

                    TableCell cell5 = new TableCell();
                    cell5.Text = "<p style='width:100px;padding:10px' class='overline'>" + jo1["place"].ToString() + ":" + jo1["label"].ToString() + "</ p>";
                    row.Cells.Add(cell5);
                    MyTable.Rows.Add(row);
                }
            }

            /*foreach(string i in filelist)
             * {
             *  MessageBox.Show(i);
             * }*/
        }