private void GetPlan() { try { string postData = "ZY={0}&NJ={1}&Submit=" + HttpUtility.UrlEncode("查询", Encoding.GetEncoding("GB2312")); //string[] department = File.ReadAllLines(Department_Path); string[] data = sm.ParsePlanID( web.getPage("http://xscj.hit.edu.cn/hitjwgl/xs/kcxx/ZXJH.asp", Encoding.GetEncoding("GB2312"), null, true) ); if (data == null) { throw new Exception("提取执行计划页面个人信息出错!!!"); } postData = String.Format(postData, data[0], data[1]); string ret = web.postData("http://xscj.hit.edu.cn/hitjwgl/xs/kcxx/ZXJH.asp", postData, Encoding.GetEncoding("GB2312"), null, true ); sm.ParsePlan(ret); } catch (Exception excp) { Error.RecordLog(excp, "Opps,出现错误了!建议将相同目录下的helper.ini删除再试试!"); return; } }
private void login_Click(object sender, EventArgs e) { string postData = "uid={0}&pwd={1}&yzm={2}&Submit2.x=18&Submit2.y=18&Submit2=%CC%E1%BD%BB"; postData = String.Format(postData, stuNum.Text.ToString(), pwd.Text.ToString(), code.Text.ToString()); string ret = web.postData(loginUrl, postData, Encoding.GetEncoding("GB2312"), refer, true); if (ret.Contains("验证码输入错误")) { MessageBox.Show("验证码错误"); codeImg.Image = web.getCodeImg(codeImgUrl, refer); } else if (ret.Contains("学号或密码错误")) { MessageBox.Show("学号或密码错误"); codeImg.Image = web.getCodeImg(codeImgUrl, refer); } else { if (remember.Checked) { INI.WriteIniData("user", "uid", stuNum.Text.ToString(), @".\helper.ini"); string password = pwd.Text.ToString(); password = Crypt.Encrypt(password); INI.WriteIniData("user", "pwd", password, @".\helper.ini"); } else { // 取消记忆 INI.WriteIniData("user", "uid", "", @".\helper.ini"); INI.WriteIniData("user", "pwd", "", @".\helper.ini"); } username = Regex.Match(ret, "<SPAN>欢迎您:([^<]+)", RegexOptions.Multiline | RegexOptions.IgnoreCase).Groups[1].ToString(); this.DialogResult = DialogResult.OK; } }