private string getBalance() { string page = web.getDocument("http://portal.ecnu.edu.cn/eapdomain/neudcp/sso/sso_ecard_xxcx.jsp", Encoding.Default); string[] bal = HtmlParse.getBalance(page); return(bal[1]); }
private void init() { string mainPage = web.doRedict(); // 首次进入需要重定向一次 string[] info = HtmlParse.getInfo(mainPage); Dispatcher.Invoke((Action) delegate { nameLbl.Content = info[0]; ipLbl.Content = info[1]; }); string html = web.getDocument("http://applicationidc.ecnu.edu.cn/ecnuidc/sso/ssoemailchh.jsp", Encoding.Default); info = HtmlParse.getEmail(html); Dispatcher.Invoke((Action) delegate { mailCntLbl.Content = info[0]; unreadCntLbl.Content = info[1]; }); string balance = getBalance(); if (double.Parse(balance) < 10) { Dispatcher.Invoke((Action) delegate { balanceMainLbl.Content = "你的校园卡余额不足10元,请及时充值!"; }); } }
private void semesterTimeChanged(object sender, SelectionChangedEventArgs e) { if (!onInit) { examTimeGrid.Children.RemoveRange(6, examTimeGrid.Children.Count - 6); int semeId = semesterId[yearExamCombo.SelectedIndex, semesterExamCombo.SelectedIndex]; int typeId = examType[typeExamCombo.SelectedIndex]; string url = String.Format("http://applicationnewjw.ecnu.edu.cn/eams/stdExamTable!examTable.action?semester.id={0}&examType.id={1}", semeId, typeId); string page = web.getDocument(url, Encoding.UTF8); string[] exam = HtmlParse.getExam(page); for (int i = 0; i < exam.Length; i++) { string[] cur = exam[i].Split(' '); examTimeGrid.RowDefinitions.Add(new RowDefinition()); for (int j = 1; j < cur.Length; j++) { Label lbl = new Label(); lbl.FontSize = 16; if (cur[j].Contains("尚未发布")) { cur[j] = "[未发布]"; } lbl.Content = cur[j]; examTimeGrid.Children.Add(lbl); Grid.SetRow(lbl, i + 1); Grid.SetColumn(lbl, j - 1); } } } }
private void semesterChanged(object sender, SelectionChangedEventArgs e) { if (!onInit) { examGrid.Children.RemoveRange(6, examGrid.Children.Count - 6); int semeId = 0; semeId = semesterId[yearCombo.SelectedIndex, semesterCombo.SelectedIndex]; string url = String.Format("http://applicationnewjw.ecnu.edu.cn/eams/teach/grade/course/person!search.action?semesterId={0}", semeId); string page = web.getDocument(url, Encoding.UTF8); string[] exam = HtmlParse.getScores(page); for (int i = 0; i < exam.Length; i++) { string[] cur = exam[i].Split(' '); examGrid.RowDefinitions.Add(new RowDefinition()); for (int j = 0; j < cur.Length; j++) { Label lbl = new Label(); lbl.FontSize = 16; lbl.Content = cur[j]; examGrid.Children.Add(lbl); Grid.SetRow(lbl, i + 1); Grid.SetColumn(lbl, j); } } } }
private void threadClass() { int semeId = 0, ids = 0, week = 0; Dispatcher.Invoke((Action) delegate { classGrid.Children.RemoveRange(17, classGrid.Children.Count - 17); semeId = semesterId[yearClassCombo.SelectedIndex, semesterClassCombo.SelectedIndex]; week = weekCombo.SelectedIndex + 1; }); ids = 260366 - 39 + int.Parse(username.Substring(9)); string url = String.Format("http://applicationnewjw.ecnu.edu.cn/eams/courseTableForStd!courseTable.action?ignoreHead=1&setting.kind=std&semester.id={0}&ids={1}&startWeek={2}", semeId, ids, week); string page = web.getDocument(url, Encoding.UTF8); string[] schedule = HtmlParse.getSchedule(page, week); Dispatcher.Invoke((Action) delegate { for (int i = 0; i < schedule.Length; i++) { string[] cur = schedule[i].Split('|'); if (cur.Length == 7) { continue; } TextBlock lbl = new TextBlock(); lbl.Text = string.Format("{0}\n({1} {2})", cur[0], cur[1], cur[2]); lbl.FontSize = 20; lbl.Background = new SolidColorBrush(Color.FromRgb(color[i % 8, 0], color[i % 8, 1], color[i % 8, 2])); lbl.TextWrapping = TextWrapping.Wrap; classGrid.Children.Add(lbl); int y = int.Parse(cur[3]); int x = int.Parse(cur[4]); int d = int.Parse(cur[5]); if (onInit && y == weekToday) { classLbl.Content += string.Format("第{0}节-第{1}节 {2} ({3})\n", x, x + d - 1, cur[0], cur[2]); } Grid.SetRow(lbl, x); Grid.SetColumn(lbl, y); Grid.SetRowSpan(lbl, d); } }); onInit = false; }
private void updateBalanceRecord() { string page = web.getDocument("http://portal.ecnu.edu.cn/eapdomain/neudcp/sso/sso_ecard_xxcx.jsp", Encoding.Default); string[] bal = HtmlParse.getBalance(page); Dispatcher.Invoke((Action) delegate { balanceLbl.Content = bal[1]; statusLbl.Content = bal[0]; }); page = web.getDocument("http://www.ecard.ecnu.edu.cn/Ecard/cqmoney.aspx", Encoding.Default); string[] consume = HtmlParse.getConsume(page); Dispatcher.Invoke((Action) delegate { recordProcessLbl.Content = "[正在获取中...]"; }); Dispatcher.Invoke((Action) delegate { costGrid.Children.RemoveRange(6, costGrid.Children.Count - 6); for (int i = 0; i < consume.Length; i++) { string[] cur = consume[i].Split(' '); costGrid.RowDefinitions.Add(new RowDefinition()); for (int j = 0; j < 6; j++) { Label lbl = new Label(); lbl.FontSize = 16; lbl.Content = cur[j]; costGrid.Children.Add(lbl); Grid.SetRow(lbl, i + 1); Grid.SetColumn(lbl, j); } } recordProcessLbl.Content = ""; }); }
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.Source is TabControl) { string page; switch (tabControl.SelectedIndex) { // 教务通知 case 1: announcementGrid.Children.RemoveRange(2, announcementGrid.Children.Count - 2); // 抓整个网页已经封装宰了web.getDocument中 直接调用即可获取整个网页 page = web.getDocument("http://www.jwc.ecnu.edu.cn/", Encoding.UTF8); // 用已经实现好的HtmlParse中的相关函数获取需要的信息, 请参考HtmlParse string[] info = HtmlParse.getAnnounce(page); // 动态向announcementGrid添加元素 for (int i = 0; i < info.Length; i++) { Label lbl = new Label(); string[] cur = info[i].Split(' '); lbl.Content = cur[0]; // 添加新的一行 RowDefinition rd = new RowDefinition(); announcementGrid.RowDefinitions.Add(rd); // 添加元素 announcementGrid.Children.Add(lbl); //指定行与列 Grid.SetRow(lbl, i + 1); Grid.SetColumn(lbl, 0); lbl = new Label(); lbl.Foreground = Brushes.Blue; lbl.Content = cur[1]; announcementGrid.Children.Add(lbl); Grid.SetRow(lbl, i + 1); Grid.SetColumn(lbl, 1); } break; // 课程表 case 3: semesterClassChanged(null, null); break; // 成绩 case 4: semesterChanged(null, null); break; // 考试安排 case 5: semesterTimeChanged(null, null); break; // 校园卡信息 case 6: Thread balanceThread = new Thread(updateBalanceRecord); balanceThread.Start(); break; } } }