public async Task <string> GetSpecificSchedule(Service.HttpBaseService _httpService, string name, string username, string year, int term) { string re; re = await _httpService.SendRequst("http://gdjwgl.bjut.edu.cn/xskbcx.aspx?xh=" + username + "&xm=" + name + "&gnmkdm=N121603", HttpMethod.Get, referUri : "http://gdjwgl.bjut.edu.cn/xs_main.aspx?xh=" + username); //re = await _httpService.SendRequst("http://gdjwgl.bjut.edu.cn/xs_main.aspx?xh=" + username, HttpMethod.Get); string __VIEWSTATEString; __VIEWSTATEString = Service.BJUTEduCenterService.GetViewstate(re); var __EVENTVALIDATION = Service.BJUTEduCenterService.GetValidation(re); IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("__EVENTVALIDATION", __EVENTVALIDATION); parameters.Add("__EVENTTARGET", ""); parameters.Add("__EVENTARGUMENT", ""); parameters.Add("__VIEWSTATE", __VIEWSTATEString); parameters.Add("xnd", year); parameters.Add("xqd", term.ToString()); re = await _httpService.SendRequst("http://gdjwgl.bjut.edu.cn/xskbcx.aspx?xh=" + username + "&xm=" + name + "&gnmkdm=N121603", HttpMethod.Post, parameters); return(re); }
//获取成绩 public async Task <string> GetGrade(Service.HttpBaseService _httpService, string name, string username) { string re; re = await _httpService.SendRequst("http://gdjwgl.bjut.edu.cn/xscjcx.aspx?xh=" + username + "&xm=" + name + "&gnmkdm=N121605", HttpMethod.Get, referUri : "http://gdjwgl.bjut.edu.cn/xscjcx.aspx?xh=" + username + "&xm=" + "" + "&gnmkdm=N121605"); string __VIEWSTATEString; __VIEWSTATEString = Service.BJUTEduCenterService.GetViewstate(re); var __EVENTVALIDATION = Service.BJUTEduCenterService.GetValidation(re); IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("__EVENTTARGET", ""); parameters.Add("__EVENTVALIDATION", __EVENTVALIDATION); parameters.Add("__EVENTARGUMENT", ""); parameters.Add("__VIEWSTATE", __VIEWSTATEString); parameters.Add("hidLanguage", ""); parameters.Add("ddlXN", ""); parameters.Add("ddlXQ", ""); parameters.Add("ddl_kcxz", ""); parameters.Add("btn_zcj", "历年成绩"); re = await _httpService.SendRequst("http://gdjwgl.bjut.edu.cn/xscjcx.aspx?xh=" + username + "&xm=" + "" + "&gnmkdm=N121605", HttpMethod.Post, parameters); return(re); }
//登录教务管理中心 public async Task <string> LoginEduCenter(Service.HttpBaseService _httpService, string username, string password, string checkCode) { try { var str = await _httpService.SendRequst(educenterUri, HttpMethod.Get); var __VIEWSTATEString = Service.BJUTEduCenterService.GetViewstate(str); if (__VIEWSTATEString == "") { return(null); } var validation = Service.BJUTEduCenterService.GetValidation(str); if (validation == null) { return(null); } IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("__VIEWSTATE", __VIEWSTATEString); parameters.Add("__EVENTVALIDATION", validation); parameters.Add("txtUserName", username); parameters.Add("TextBox2", password); parameters.Add("txtSecretCode", checkCode); parameters.Add("RadioButtonList1", "学生"); parameters.Add("Button1", ""); parameters.Add("lbLanguage", ""); parameters.Add("hidPdrs", ""); parameters.Add("hidsc", ""); var reStr = await _httpService.SendRequst("http://gdjwgl.bjut.edu.cn/default2.aspx", HttpMethod.Post, parameters); var name = Service.BJUTEduCenterService.GetName(reStr); if (string.IsNullOrEmpty(name)) { string messageRegex = @"(?<=defer\>alert\(')\w.+(?='\);)"; var message = Regex.Match(reStr, messageRegex).Value; if (message.Contains("验证")) { throw new InvalidCheckcodeException(message); } else { throw new InvalidUserInfoException(message); } } return(name); } catch (HttpRequestException requestException) { throw; } catch (Exception ex) { throw; } }
//获取信息门户到一卡通中心的filter public async Task GetCardCenterClient(Service.HttpBaseService _httpSerice) { try { var re = await _httpSerice.SendRequst(campusCardLoginUri, HttpMethod.Get); re = await _httpSerice.SendRequst(campusCardAjaxLoginUri, HttpMethod.Get); } catch (Exception ex) { throw; } }
//登录信息门户 public async Task LoginInfoCenter(Service.HttpBaseService _httpService, string username, string password) { try { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("Login.Token1", username); parameters.Add("Login.Token2", password); parameters.Add("goto", "http://my.bjut.edu.cn/loginSuccess.portal"); parameters.Add("gotoOnFail", "http://my.bjut.edu.cn/loginFailure.portal"); var re = await _httpService.SendRequst(loginUri, HttpMethod.Post, parameters); if (re.Contains("handleLoginSuccessed")) { } else { throw new BJUTDUHelperlException.InvalidUserInfoException("用户名或密码错误"); //登录失败 } } catch (Exception e) { throw; //其他异常 } }
public async Task <Model.CampusCardInfoModel> GetCampusCardSalaryInfo(Service.HttpBaseService _httpService) { var re = await _httpService.SendRequst(cardSalaryInfoUri, HttpMethod.Get); var info = PraseCampusCardSalaryInfo(re); return(info); }
//获取课程表数据 public async Task <string> GetCurrentSchedule(Service.HttpBaseService _httpService, string name, string username) { string re; re = await _httpService.SendRequst("http://gdjwgl.bjut.edu.cn/xskbcx.aspx?xh=" + username + "&xm=" + name + "&gnmkdm=N121603", HttpMethod.Get, referUri : "http://gdjwgl.bjut.edu.cn/xs_main.aspx?xh=" + username); return(re); }
public async Task <Model.EduTimeModel> GetEduTime(Service.HttpBaseService _httpService) { var re = await _httpService.SendRequst(edutimeUri, HttpMethod.Get); var model = Newtonsoft.Json.JsonConvert.DeserializeObject <Model.EduTimeModel>(re); return(model); }
//获取考试信息 public async Task <string> GetExamInfo(Service.HttpBaseService _httpService, string name, string username) { //http://gdjwgl.bjut.edu.cn/xskscx.aspx?xh=14024238&xm=%B3%C2%BC%D1%CE%C0&gnmkdm=N121604 string re; re = await _httpService.SendRequst("http://gdjwgl.bjut.edu.cn/xskscx.aspx?xh=" + username + "&xm=" + name + "&gnmkdm=N121604", HttpMethod.Get, referUri : "http://gdjwgl.bjut.edu.cn/xs_main.aspx?xh=" + username); return(re); }
//获取学年学期信息 public async Task <Model.EduTimeModel> GetEduBasicInfo(Service.HttpBaseService _httpService) { var re = await _httpService.SendRequst(calendarUri, HttpMethod.Get); var p = Regex.Match(re, @"<.*weekteaching.*\s*.*\s*</p>").Value; var year = Regex.Match(p, @"\d+-\d+").Value; var term = Regex.Match(p, @".(?=学期)").Value == "二" ? 2 : 1; var week = Regex.Match(p, @"\d*(?=\s*教学)").Value; Model.EduTimeModel model = new Model.EduTimeModel(); model.SchoolYear = year; model.Term = term; model.Week = int.Parse(week); return(model); }
public async Task <Model.CampusCardInfoModel> GetCampusCardBasicInfo(Service.HttpBaseService _httpService) { var re = await _httpService.SendRequst(cardBasicInfoUri, HttpMethod.Get); var info = PraseCampusCardBasicInfo(re); using (var stream = await _httpService.SendRequstForStream(personImageUri, HttpMethod.Get)) { stream.Seek(0, SeekOrigin.Begin); using (var ras = stream.AsRandomAccessStream()) { WriteableBitmap bitmap = new WriteableBitmap(1, 1); bitmap.SetSource(ras); info.PersonImage = bitmap; } } return(info); }
public async Task <string> FundCampusCard(Service.HttpBaseService _httpService, string smtCardid) { try { var parameters = new Dictionary <string, string>(); parameters.Add("lg_smtCardid", smtCardid); var re = await _httpService.SendRequst(foundCampusUri, HttpMethod.Post, parameters); var json = JsonObject.Parse(re); var messageObject = json["message"]; return(messageObject.ValueType == JsonValueType.Null ?"解挂成功,注意保存一卡通":messageObject.GetString()); } catch (HttpRequestException requestException) { return("网络错误"); } catch { return("其他错误"); } }
public async Task <IList <Model.CampusCardTransactionItemModel> > GetTransactionInfo(Service.HttpBaseService _httpService) { try { #region 获取消费记录 IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("int_start", "0"); parameters.Add("int_maxSize", "15"); var re = await _httpService.SendRequst(campusCardTransactionUri, HttpMethod.Post, parameters); var list = PraseTransactionInfo(re); return(list); #endregion } catch { return(null); } }
public async Task Authenticate(string username, string password) { cancellationTokenSource = new CancellationTokenSource(); IDictionary <string, string> parameters = new Dictionary <string, string>(); if (SelectIndex < 0) { GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("选择一个WIFI"); return; } switch (WIFIService.WifiList[SelectIndex].Ssid) { case "bjut_wifi": { parameters.Clear(); parameters.Add("0MKKey", "123"); parameters.Add("DDDDD", username); parameters.Add("upass", password); var responseString = await _httpService.SendRequst(authUri, HttpMethod.Post, parameters, cancellation : cancellationTokenSource.Token); #region 针对其他认证方式的结果判断逻辑 if (responseString.Contains("1.htm")) { } else { int statusCode; string flagString = "Msg="; string status = string.Empty; int index = responseString.IndexOf(flagString); for (int i = index + flagString.Length + 1; i < index + flagString.Length + 10; i++) { var t = responseString[i]; if (t != ';') { status += t; } else { break; } } statusCode = int.Parse(status); if (statusCode == 1) { throw new InvalidUserInfoException("账号或密码不正确"); } else if (statusCode == 2) { //GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("该账号正在使用中", messageToken); throw new LoginTipException("该账号正在使用中"); } else if (statusCode == 3) { throw new LoginTipException("用户名无效,可能已从本系统注销"); //GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("用户名无效,可能已从本系统注销", messageToken); } else if (statusCode == 4) { throw new LoginTipException("本账号费用超支或时长流量超过限制"); //GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("本账号费用超支或时长流量超过限制", messageToken); } else if (statusCode == 5) { throw new LoginTipException("本账号暂停使用"); //GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("本账号暂停使用", messageToken); } else if (statusCode == 15) { //throw new LoginTipException("本账号暂停使用"); //GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("认证成功", messageToken); } } #endregion } break; case "Tushuguan": { parameters.Clear(); parameters.Add("PtUser", username); parameters.Add("PtPwd", password); parameters.Add("PtButton", "登录"); try { string responseString = await _httpService.SendRequst(libPostUri, HttpMethod.Post, cancellation : cancellationTokenSource.Token); responseString = await _httpService.SendRequst(libLoginUri, HttpMethod.Get); if (responseString.Contains("value='Logoff'")) { } else { throw new InvalidUserInfoException("认证失败,请检查用户名或密码"); //GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("认证失败,请检查用户名或密码", messageToken); } } catch (Exception ex) { //GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("认证失败", messageToken); throw; } } break; default: break; } }