/// <summary> /// 登陆至教务系统 /// </summary> /// <param name="account"></param> /// <param name="password"></param> /// <param name="secertcode"></param> private void LoginToEA(string account, string password, string secertcode) { Login loginfc = new Login(account, password, secertcode); LoginInfo.UserAccount = account; if (loginfc.GetLoginStatus() == "OK") { LoginInfo.GetUserName(); LoginInfo.InitYearOfTerm(); LoginInfo.InitGradeRange(); Action <string> InitTermItems = (x) => { if (TermYear.Items.IndexOf(x) == -1) { TermYear.Items.Add(x); } }; for (int i = 0; i < LoginInfo.YearsOfTerm.Count; i++) { TermYear.BeginInvoke(InitTermItems, LoginInfo.YearsOfTerm[i]); } Action <string> InitGradeItems = (x) => { YearOfGrade.Items.Add(x); }; for (int i = 0; i < LoginInfo.YearsOfGrade.Count; i++) { YearOfGrade.BeginInvoke(InitGradeItems, LoginInfo.YearsOfGrade[i]); } IsLogin = 1; } else if (loginfc.GetLoginStatus() == "InvalidCode") { MessageBox.Show("验证码输入错误,请检查后重新输入!", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (loginfc.GetLoginStatus() == "InvalidPassword") { MessageBox.Show("密码输入错误,请确认密码后重新输入!", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (loginfc.GetLoginStatus() == "InvalidAccount") { MessageBox.Show("帐号不存在或者未按规定参加教学活动,请检查帐号是否输入正确或联系教务处!", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("因未知错误而导致登陆失败,请检查网络后重启程序再试!", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (loginfc.GetLoginStatus() != "OK") { RequestCode(); IsLogin = 0; return; } }
private void ClassYearInit() { lists.Clear(); Regex SelectForm = new Regex("<select name=\"xnd\".+?</select>", RegexOptions.Singleline); Regex Time = new Regex("\\d{4}-\\d{4}", RegexOptions.Singleline); string GetData = ""; string url = SetUrl(ModeList[0]); GetData = Send_Get(url); GetData = SelectForm.Match(GetData).Value; MatchCollection TimeCollect = Time.Matches(GetData); for (int i = 0; i < TimeCollect.Count; i += 2) { lists.Add(TimeCollect[i].Value + "学年"); } lists.Sort(); Action <string> InitTermItems = (x) => { TermYear.Items.Add(x); }; for (int i = 0; i < lists.Count; i++) { TermYear.BeginInvoke(InitTermItems, lists[i]); } }