/// <summary> /// 报平安Post /// </summary> /// <param name="user"></param> public bool PostReport(Global.User user) { try { var name = user.Name; user = Global.GetUserInfo(user.Cookie);//刷新一次账号信息 if (user.TodayTaskState == "未填报") { var rows = user.GetTodayJb; //开始整理表单参数 Invoke(new Action(() => { NutDebug("开始自动报平安!"); })); String PostData = CreatePostdate(user); var postUrl = "http://ehall.sicnu.edu.cn/qljfwapp/sys/lwReportEpidemicUndergraduate/modules/application/T_REPORT_UNDERGRADUATE_CHECKIN_SAVE.do"; var PostResult = NutWeb.Nut_Post(postUrl, PostData, user.Cookie, null); user = Global.GetUserInfo(user.Cookie);//刷新一次账号信息 AddToListView(user); return(true); } user.Name = name; AddToListView(user); return(false); } catch { Invoke(new Action(() => { NutDebug("未知错误-PostReport"); })); return(false); } }
/// <summary> /// 检查更新 /// </summary> public void CheckUpdate() { String Version = "1.1"; Form1.MainForm.Text = "四川师范大学自动报平安 v" + Version + " by CrazyNut [L.C.G]"; var serverVersion = NutWeb.Nut_Get("47.103.197.183/software/sicnu/version", null); if (serverVersion != null) { if (Version != serverVersion.Html) { NutDebug("\r\n\r\n当前软件版本:" + Version + " 服务器最新版本:" + serverVersion.Html + " \r\n\r\n请到下方链接下载更新\r\n\r\nhttp://47.103.197.183/software/sicnu/川师自动报平安.zip"); } } }
/// <summary> /// 根据cookie获取最新的账号信息 /// </summary> /// <param name="Cookie"></param> /// <returns>完成返回null 没完成返回表单wid参数</returns> public static Global.User GetUserInfo(String Cookie) { try { var GetUrl = "http://ehall.sicnu.edu.cn/qljfwapp/sys/lwReportEpidemicUndergraduate/modules/application/getMyTodayReportWid.do"; var GetResult = NutWeb.Nut_Get(GetUrl, null, Cookie); var GetUrl2 = "http://ehall.sicnu.edu.cn/qljfwapp/sys/lwReportEpidemicUndergraduate/modules/application/getLatestDailyReportData.do"; var GetResult2 = NutWeb.Nut_Get(GetUrl2, null, Cookie); var returnUser = new Global.User(); if (GetResult != null && GetResult2 != null) { JObject JsonObj = (JObject)JsonConvert.DeserializeObject(GetResult.Html); var rows = JsonObj["datas"]["getMyTodayReportWid"]["rows"].First; JObject JsonObj2 = (JObject)JsonConvert.DeserializeObject(GetResult2.Html); var rows2 = JsonObj2["datas"]["getLatestDailyReportData"]["rows"].First; if (rows != null && rows2 != null) { returnUser.Cookie = Cookie; returnUser.TodayTaskState = rows["CHECKED_DISPLAY"].ToString(); returnUser.Name = rows["USER_NAME"].ToString(); returnUser.TodayWid = rows["WID"].ToString(); returnUser.GetTodayJb = rows; returnUser.LatestDailyJb = rows2; Form1.MainForm.NutDebug("获取成功! 当前用户--->" + returnUser.Name); Form1.MainForm.NutDebug("今日填报状态--->" + returnUser.TodayTaskState); return(returnUser); } } Form1.MainForm.NutDebug("当前账号Cookie已经失效"); returnUser.TodayTaskState = "账号失效"; return(returnUser); } catch { Form1.MainForm.NutDebug("当前账号Cookie已经失效"); var returnUser = new Global.User(); returnUser.TodayTaskState = "账号失效"; return(returnUser); } }