public JsonResult classtable(string openid) { StudentInfo info = DBManual.SelectUser(openid); JWCHttpHelper.Login(info.studentnum, info.pwd); return(JWCHttpHelper.jwc_classtable <JsonResult>()); }
// GET: API public static string CrawlerFromJwc(string studentnum, string pwd, JWCHttpHelper.CrawlerDetail <string> detail) { JWCHttpHelper.Login(studentnum, pwd); if (JWCHttpHelper.IsLogin) { string answer = detail(); JWCHttpHelper.ClearCookies(); return(answer); } else { JWCHttpHelper.ClearCookies(); return(JWCHttpHelper.ErrorMsg); } }
public static string UpdateJWC() { string result = ""; string path; FileStream fs; StreamWriter sw; List <StudentInfo> alluser = DBManual.SelectAll(); foreach (StudentInfo item in alluser) { Regex regex = new Regex(@"^\d+$"); if (regex.IsMatch(item.pwd)) { continue; } if (IsExist(item.wechatid)) { result += item.studentnum + ":existed<br>"; continue; } JWCHttpHelper.Login(item.studentnum, item.pwd); if (JWCHttpHelper.IsLogin) { foreach (var del in BufferSubdirectory.events) { path = root + del.Key + @"\" + item.wechatid; string now; now = del.Value(); fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite); sw = new StreamWriter(fs); sw.WriteLine(now); sw.Flush(); sw.Close(); fs.Close(); result += del.Key + " of " + item.studentnum + ":success<br>"; } JWCHttpHelper.ClearCookies(); } else { result += item.studentnum + ":" + JWCHttpHelper.ErrorMsg + "<br>"; } } return(result); }
public static string Select(string detail, UserRequest userrequest) { string result = ""; string path = root + detail + "/" + userrequest.FromUserName; if (System.IO.File.Exists(path)) { FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); result = sr.ReadToEnd(); if (detail != BufferSubdirectory.ClassTable) { return(userrequest.Get_Reply(result)); } else { return(userrequest.Get_Reply(JWCHttpHelper.ClassTableFromHtml <string>(result))); } } else { return(userrequest.Get_Reply(isnotexist(userrequest.FromUserName))); } }
// GET: WeChat public string Index() //回复全都是xml格式的string { if (IsFromTencent("961016") && Request.HttpMethod == "GET") { return(Request["echostr"]); } if (IsFromTencent("961016") && Request.HttpMethod == "POST") { WechatRequest = new WechatRequest(Request.InputStream); #region wechatpost if (WechatRequest.IsClick()) { #region ButtonEvent switch (WechatRequest.EventKey) { case "elearning_wordlearn": return(WechatRequest.Get_Reply(WechatRequest.elearning_wordlearn)); case "elearning_textlearn": return(WechatRequest.Get_Reply(WechatRequest.elearning_textlearn)); case "elearning_nextword": string nextword = DataBaseController.GetNextWord(WechatRequest.FromUserName); if (nextword != null) { return(WechatRequest.Get_Reply(nextword)); } else { return(WechatRequest.Get_Reply("当前未设立测试范围或已经学习完全部内容")); } case "elearning_oraltrain": return(WechatRequest.Get_Reply("It was two weeks before the Spring Festival.")); default: return(WechatRequest.Get_Reply("功能还在开发中,敬请期待")); } #endregion } else if (WechatRequest.IsSubscribe()) { #region FollowEvent DataBaseController.AddIntoWechatIds(WechatRequest.FromUserName); return(WechatRequest.Get_Reply(WechatRequest.elearn_welcome)); #endregion } else if (WechatRequest.IsVoice()) { #region VoiceEvent Thread t = new Thread(new ThreadStart(task_voicemanager)); t.Start(); return(WechatRequest.Get_Reply("提交成功,请等待一段时间后输入Get查看结果!")); #endregion } else { #region MessageEvent string message = WechatRequest.Content; if (Regex.IsMatch(message, "^xh.+")) { DataBaseController.UpdateStudents(WechatRequest.FromUserName, message.Substring(2), null); return(WechatRequest.Get_Reply("学号已修改,现在您绑定的学号为:" + message.Substring(2) + "请输入jwc + 您的教务处密码来绑定,如jwc123456")); } else if (Regex.IsMatch(message, "^jwc.+")) { string studentnum = DataBaseController.GetStudentNum(WechatRequest.FromUserName); string jwcpassword = message.Substring(3); if (JWCHttpHelper.isPasswordTrue(studentnum, jwcpassword)) { DataBaseController.UpdateStudents(WechatRequest.FromUserName, studentnum, jwcpassword); return(WechatRequest.Get_Reply("验证成功!")); } else { return(WechatRequest.Get_Reply($"输入的密码{ jwcpassword }不正确")); } } else { if (Regex.IsMatch(message, "\\d{4,4}")) { if (message.Substring(0, 1) == "0") { if (DataBaseController.tryUpdateProcesses(WechatRequest.FromUserName, message)) { return(WechatRequest.Get_Reply("选择成功!按next开始学习")); } else { return(WechatRequest.Get_Reply("选择失败,请确认是否绑定学号及输入代码是否正确")); } } else if (message.Substring(0, 1) == "2") { return(WechatRequest.Get_ImgText()); } } if (!DataBaseController.HaveBinding(WechatRequest.FromUserName)) { return(WechatRequest.Get_Reply(WechatRequest.elearn_welcome)); } switch (message) { case "001": return(WechatRequest.Get_Reply(WechatRequest.elearning_testmsg1)); case "201": return(WechatRequest.Get_Reply(WechatRequest.elearning_testmsg2)); case "speak": string word = DataBaseController.GetNowWord(WechatRequest.FromUserName); if (word == null) { return(WechatRequest.Get_Reply("请先选择学习内容")); } WeChatHttpHelper.GetToken(); string mediaid = WeChatHttpHelper.GetMediaID(SpeecherController.mytts("读音:" + word), "voice"); return(WechatRequest.Get_Voice(mediaid)); case "Get": string path = $@"C:\Users\Administrator\Desktop\ElearnOralResult\{WechatRequest.FromUserName}\result.txt"; using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { StreamReader sr = new StreamReader(fs); return(WechatRequest.Get_Reply(sr.ReadToEnd())); } default: return(WechatRequest.Get_Reply("识别错误,请重试")); } } #endregion } #endregion } else//不是腾讯发来的post { return("Do not touch this server,guy!"); } }