Esempio n. 1
0
        /// <summary>
        /// 双击打开文件,若不存在,则自动下载,双击ID显示用户基本信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mydata_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if ((e.ColumnIndex >= 1) && (e.ColumnIndex < 2))
            {
                string id = mydata.Rows[e.RowIndex].Cells["id"].Value.ToString();
                foreach (var item in jsonlist)
                {
                    if (id == item.id)
                    {
                        userInfo user = new userInfo();
                        user = usermessage(item.use_id);
                        MessageBox.Show("用户:" + user.name + "  手机号:" + user.phone);
                    }
                }
            }

            else
            {
                string id = mydata.Rows[e.RowIndex].Cells["id"].Value.ToString();
                foreach (var item in jsonlist)
                {
                    if (id == item.id)
                    {
                        string filename = "";
                        filename = path + "\\" + item.id + "_" + item.copies + "_" + item.double_side + "_" + item.student_number + "_" + item.name;
                        if (File.Exists(@filename))
                        {
                            //filename = path + filename;
                            System.Diagnostics.Process.Start(filename);
                            break;
                        }
                        else
                        {
                            filename = item.id + "_" + item.copies + "_" + item.double_side + "_" + item.student_number + "_" + item.name;
                            //get 文件详细信息 URI操作示意: GET /File/1234
                            string jsonUrl = API.GetMethod("/File/" + item.id);
                            JObject jo = JObject.Parse(jsonUrl);
                            ToJsonMy thisOne = new ToJsonMy();
                            thisOne.url = (jo)["url"].ToString();
                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            WebClient webClient = new WebClient();
                            String pathDoc = path + "/" + filename;

                            webClient.DownloadFileAsync(new Uri(thisOne.url), pathDoc, id);

                            //fileDownload(thisOne.url, filename, item.id);
                            MessageBox.Show("正在下载该文件!\n等待会儿再打开");
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 获得用户信息
 /// </summary>
 /// <param name="use_id"></param>
 /// <returns></returns>
 public userInfo usermessage(string use_id)
 {
     string jsonUrl = API.GetMethod("/User/" + use_id);
     JObject jo = JObject.Parse(jsonUrl);
     userInfo user = new userInfo();
     user.name = jo["name"].ToString();
     user.phone = jo["phone"].ToString();
     user.email = jo["email"].ToString();
     return user;
 }