예제 #1
0
파일: MainForm.cs 프로젝트: Kristd/backup
        public bool ShowPaperInfo()
        {
            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))
            {
                LoginForm pm = new LoginForm();
                DialogResult dr = pm.ShowDialog();
                if (dr.Equals(DialogResult.Cancel))
                {
                    return false;
                }
            }

            if (!SetPaperInfo("确认并上传"))
            {
                return false;
            }

            return true;
        }
예제 #2
0
파일: MainForm.cs 프로젝트: Kristd/backup
        /// <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))
            {
                LoginForm pm = new LoginForm();
                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);      //postHttpRequest: 上传xml流

            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.progressBar.Value = 100;
                    this.groupBox1.Visible = false;
                    UploadSuccess uploadSuccess = new UploadSuccess();
                    uploadSuccess.ExamId = uploadimgresp.data.examId;
                    uploadSuccess.ShowDialog();
                }
            }
        }
예제 #3
0
파일: MainForm.cs 프로젝트: Kristd/backup
 private void toolStripMenuItemLogin_Click(object sender, EventArgs e)
 {
     LoginForm loginform = new LoginForm();
     DialogResult dialogresult = loginform.ShowDialog();
 }
예제 #4
0
 public LoginProgress(LoginForm loginFrm)
 {
     m_loginFrm = loginFrm;
     InitializeComponent();
 }