Ejemplo n.º 1
0
        public void showBookDetail(string isbn)
        {
            string access_token = OperateCloud.get();
            detail item         = BookADO.getBookByISBN(isbn, access_token);

            if (item == null)
            {
                MessageBox.Show("出错了");
            }
            else
            {
                //display(temp);
                string imageUrl = BookADO.getUrl(item.fileIDs[0], access_token);

                /* queryString = "{\"env\":\"" + envid + "\", \"file_list\": [{\"fileid\":\"" + item.fileIDs[0] + "\",\"max_age\":7200}]}";
                 * url = "https://api.weixin.qq.com/tcb/batchdownloadfile?access_token=" + access_token; //POST到网站
                 * Message = OperateCloud.Query(queryString, url);
                 * JObject jo2 = OperateCloud.GetJson(Message);
                 * pic.ImageUrl = jo2["file_list"][0]["download_url"].ToString();*/
                pic.ImageUrl     = imageUrl;
                ISBN.Text        = item._id;
                book_name.Text   = item.name;
                author.Text      = item.author;
                description.Text = item.description;
                remain.Text      = item.remain.ToString();
                type.Text        = item.type;
                price.Text       = item.price;
                language.Text    = item.language;
                publisher.Text   = item.publisher;
                date.Text        = item.date;
                library.Text     = item.library;
                place.Text       = item.place;
                label.Text       = item.label;
            }
        }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["access_token"] == null)
     {
         string access_token = OperateCloud.get();
         //MessageBox.Show(access_token);
         Session["access_token"] = access_token;
     }
 }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //必须判断IsPostBack
     //否则会出现无法修改用户名的错误(修改之后相当于没有修改)
     if (Session["login"] != null)
     {
         MessageBox.Show("已登录,请先退出");
         Response.Redirect("Search.aspx");
     }
     else
     {
         envid = ConfigurationManager.AppSettings["envid"];
         //MessageBox.Show("未登录状态");
     }
     if (!IsPostBack)
     {
         shouji.Style.Add("display", "none");    //隐藏
         zhanghao.Style.Add("display", "bolck"); //显示
         //获取cookies看一下有没有登陆过
         if (Request.Cookies["UserName"] == null || Request.Cookies["PassWord"] == null)
         {
             login_name.Text = "";
         }
         else
         {
             //有cookies就直接显示用户名,不显示密码防止他人使用电脑登入
             login_name.Text = Request.Cookies["UserName"].Value;
             //pwd.Value = Request.Cookies["PassWord"].Value;
         }
         if (Request.Cookies["Phone"] == null)
         {
             phone.Text = "";
         }
         else
         {
             phone.Text = Request.Cookies["Phone"].Value;
         }
     }
     //获取access_token来操作数据库
     if (Session["access_token"] == null)
     {
         string access_token = OperateCloud.get();
         //MessageBox.Show(access_token);
         Session["access_token"] = access_token;
     }
 }
Ejemplo n.º 5
0
        protected void role_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = reserve.SelectedIndex;
            //MessageBox.Show(index+"");
            string str = reserve.Rows[index].Cells[1].Text;
            //MessageBox.Show(str);//书号


            string str1 = reserve.Rows[index].Cells[7].Text;
            //MessageBox.Show(str1);//which哪一本
            string str2 = reserve.Rows[index].Cells[6].Text;

            //MessageBox.Show(str2);//状态
            if (str2 == "-1" || str2 == "1")
            {
                MessageBox.Show("该预约不可取消");
                return;
            }

            string access_token = (string)Session["access_token"];

            //获取图书信息并修改
            if (OperateCloud.cancelReserve(str, str1, access_token) == true)
            {
                if (ReserveADO.cancelRes(str, str1, access_token) == "0")
                {
                    MessageBox.Show("取消预约成功");
                }
                else
                {
                    MessageBox.Show("取消预约失败");
                }
                //将图书数据库的数据恢复调用云函数即可
                GetReserve(isbn.Text);
            }
            else
            {
                MessageBox.Show("取消预约失败");
            }
        }
Ejemplo n.º 6
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);
             * }*/
        }