Exemplo n.º 1
0
 private void AccountManageToolStripMenuItem_Click(object sender, EventArgs e)
 {
     AccountManage pm = new AccountManage();
     pm.ShowDialog();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 提交试卷内容
        /// </summary>
        private void PostPaper(string paper)
        {
            XmlDocument xmldocc = new XmlDocument();
            xmldocc.Load(Application.StartupPath + "/LoginConfig.xml");
            XmlNode access_token = xmldocc.SelectSingleNode("//access_token");
            XmlNode refresh_token = xmldocc.SelectSingleNode("//refresh_token");

            if (string.IsNullOrEmpty(access_token.InnerText) || string.IsNullOrEmpty(refresh_token.InnerText))
            {
                AccountManage pm = new AccountManage();
                DialogResult dr= pm.ShowDialog();
                if (dr.Equals(DialogResult.Cancel))
                {
                    return;
                }
                xmldocc.Load(Application.StartupPath + "/LoginConfig.xml");
                access_token = xmldocc.SelectSingleNode("//access_token");
                refresh_token = xmldocc.SelectSingleNode("//refresh_token");
            }
            XmlNode address = xmldocc.SelectSingleNode("//address");
            XmlNode account = xmldocc.SelectSingleNode("//account");
            XmlNode password = xmldocc.SelectSingleNode("//password");
            XmlNode token_type = xmldocc.SelectSingleNode("//token_type");
            XmlNode openid = xmldocc.SelectSingleNode("//openid");
            XmlNode postpaper = xmldocc.SelectSingleNode("//postpaper");

            HttpHelper httphelper = new HttpHelper();
            NameValueCollection namevaluec = new NameValueCollection();
            namevaluec.Add("access_token", access_token.InnerText);
            namevaluec.Add("refresh_token", refresh_token.InnerText);
            namevaluec.Add("token_type", token_type.InnerText);
            namevaluec.Add("openid", openid.InnerText);
            namevaluec.Add("userid", account.InnerText);
            namevaluec.Add("client_id", "100006");
            namevaluec.Add("clientip", "127.0.0.1");
            //namevaluec.Add("oauth_version", "2.a");
            namevaluec.Add("paper", System.Web.HttpUtility.UrlEncode(paper, System.Text.Encoding.UTF8));
            string postpaperrequest = httphelper.postHttpRequest(postpaper.InnerText, namevaluec);

            using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(postpaperrequest)))
            {
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(UploadImgResp));
                UploadImgResp uploadimgresp = (UploadImgResp)serializer.ReadObject(ms);
                if (uploadimgresp.ret.Equals("1"))
                {
                    MessageBox.Show(uploadimgresp.msg, "提示");
                }
                else
                {
                    this.progressBarSpot.Value = 100;
                    this.progressBarSpot.Visible = false;
                    UploadSuccess uploadSuccess = new UploadSuccess();
                    uploadSuccess.ExamId = uploadimgresp.data.examId;
                    uploadSuccess.ShowDialog();
                }
            }
        }