/// <summary> /// 获取登录到现在相隔过去的时间(以分钟为单位),返回int值 /// </summary> /// <returns></returns> public static int TimePassed() { int passtime = 0; LearnSite.Model.Cook scook = new Model.Cook(); DateTime time1 = DateTime.Parse(scook.LoginTime); DateTime time2 = DateTime.Now; passtime = Int32.Parse(DatagoneMinute(time1, time2)); return(passtime); }
public static void KickStudent() { if (HttpContext.Current.Request.Cookies[stuCookieNname] != null) //增加cookies判斷 (2011-9-27修) { if (LearnSite.Common.XmlHelp.GetSingleLogin()) //如果是单点登录 { Model.Cook cook = new Model.Cook(); string mySnum = cook.Snum; if (LearnSite.Common.App.Iskick(mySnum)) //如果学生学号在踢除全局变量中 { LearnSite.Common.App.AppKickUserRemove(mySnum); //将踢除列表中的学号去掉(2011-9-15修) ClearStudentCookies(); //则清除该项学生的页面cookies,要求重登录。 int millsed = DateTime.Now.Millisecond; string rurl = "~/index.aspx?kick=" + mySnum + "&mill=" + millsed.ToString(); System.Threading.Thread.Sleep(300); HttpContext.Current.Response.Redirect(rurl, false); } } } }
public static bool IsStudentLogin() { if (HttpContext.Current.Request.Cookies[stuCookieNname] != null) { Model.Cook cook = new Model.Cook(); if (cook.Ss == stuCookieNname) { return(true); } else { ClearStudentCookies(); return(false); } } else { return(false); } }
/// <summary> /// 设置学生的cookies值 /// </summary> /// <param name="stmodel"></param> ///Snum,Syear,Sgrade,Sclass,Sname,Spwd,Sex,Saddress,Sphone,Sparents,Sheadtheacher,Sscore,Sattitude,Sape public static bool SetStuCookie(LearnSite.Model.Students stmodel, string LoginIp) { if (stmodel != null) { LearnSite.BLL.Room rm = new LearnSite.BLL.Room(); string Rhid = rm.GetRoomRhid(stmodel.Sgrade.Value, stmodel.Sclass.Value); DateTime LoginTime = DateTime.Now; string ThisTerm = LearnSite.Common.XmlHelp.GetTerm(); HttpCookie StuCookie = new HttpCookie(stuCookieNname); if (stmodel.Sex == null) { stmodel.Sex = "无"; } if (stmodel.Sscore == null) { stmodel.Sscore = 0; } if (stmodel.Squiz == null) { stmodel.Squiz = 0; } if (stmodel.Sattitude == null) { stmodel.Sattitude = 0; } if (stmodel.Sape == null) { stmodel.Sape = "无"; } if (stmodel.Sgroup == null) { stmodel.Sgroup = 0; } if (String.IsNullOrEmpty(Rhid)) { Rhid = "0"; } Model.Cook Cook = new Model.Cook(); Cook.Sid = stmodel.Sid; Cook.Snum = UrlEncode(stmodel.Snum); Cook.Syear = stmodel.Syear.Value; Cook.Sgrade = stmodel.Sgrade.Value; Cook.Sclass = stmodel.Sclass.Value; Cook.Sname = UrlEncode(stmodel.Sname.Trim()); Cook.Spwd = Common.WordProcess.GetMD5_8bit(stmodel.Spwd); Cook.Sex = UrlEncode(stmodel.Sex); Cook.Sscore = stmodel.Sscore.Value; Cook.Squiz = stmodel.Squiz.Value; Cook.Sattitude = stmodel.Sattitude.Value; Cook.Sape = UrlEncode(stmodel.Sape); Cook.Sgroup = stmodel.Sgroup.Value; Cook.LoginTime = LoginTime.ToString(); Cook.LoginIp = LoginIp; Cook.ThisTerm = Int32.Parse(ThisTerm); Cook.Rhid = Int32.Parse(Rhid); Cook.RankImage = UrlEncode(LearnSite.Common.Rank.RankImage(stmodel.Sscore.Value + stmodel.Sattitude.Value, true)); Cook.Ss = stuCookieNname;//cookie名称校验 Cook.SessionId = ""; StuCookie.Value = Cook.ToStr(); string str = LearnSite.Common.XmlHelp.GetStudentCookiesPeriod(); StuCookie.Expires = StudentCookiesPeriod(str); StuCookie.Path = "/"; StuCookie.HttpOnly = true; HttpContext.Current.Response.AppendCookie(StuCookie); return(true); } else { return(false); } }
/// <summary> /// 模拟该班级学生登录cookies设置 /// </summary> /// <param name="Sgrade"></param> /// <param name="Sclass"></param> public static void SimulationStudentCookies(int Sgrade, int Sclass) { if (HttpContext.Current.Request.Cookies[teaCookieNname] != null) { Model.TeaCook tcook = new Model.TeaCook(); string Rhid = tcook.Hid.ToString(); LearnSite.BLL.Students stubll = new BLL.Students(); LearnSite.Model.Students sModel = new LearnSite.Model.Students(); string sss = Rhid + Sgrade.ToString() + Sclass.ToString(); sModel.Sid = 0 - Int32.Parse(sss); string Syear = stubll.GetYear(Sgrade); sModel.Syear = Int32.Parse(Syear); sModel.Snum = "s" + Rhid + Syear.ToString() + Sgrade.ToString() + Sclass.ToString(); sModel.Sgrade = Sgrade; sModel.Sclass = Sclass; sModel.Sname = "学生" + Sgrade.ToString() + Sclass.ToString(); sModel.Spwd = "12345678"; sModel.Sex = "男"; sModel.Sscore = 100; sModel.Squiz = 50; sModel.Sattitude = 25; sModel.Sape = "A"; sModel.Sgroup = 0; DateTime LoginTime = DateTime.Now; string LoginIp = LearnSite.Common.Computer.GetGuestIP(); string ThisTerm = LearnSite.Common.XmlHelp.GetTerm(); HttpCookie StuCookie = new HttpCookie(stuCookieNname); Model.Cook Cook = new Model.Cook(); Cook.Sid = sModel.Sid; Cook.Snum = UrlEncode(sModel.Snum); Cook.Syear = sModel.Syear.Value; Cook.Sgrade = sModel.Sgrade.Value; Cook.Sclass = sModel.Sclass.Value; Cook.Sname = UrlEncode(sModel.Sname.Trim()); Cook.Spwd = Common.WordProcess.GetMD5_8bit(sModel.Spwd); Cook.Sex = UrlEncode(sModel.Sex); Cook.Sscore = sModel.Sscore.Value; Cook.Squiz = sModel.Squiz.Value; Cook.Sattitude = sModel.Sattitude.Value; Cook.Sape = UrlEncode(sModel.Sape); Cook.Sgroup = sModel.Sgroup.Value; Cook.LoginTime = LoginTime.ToString(); Cook.LoginIp = LoginIp; Cook.ThisTerm = Int32.Parse(ThisTerm); Cook.Rhid = Int32.Parse(Rhid); Cook.RankImage = UrlEncode(LearnSite.Common.Rank.RankImage(sModel.Sscore.Value + sModel.Sattitude.Value, true)); Cook.Ss = stuCookieNname;//cookie名称校验 Cook.SessionId = ""; StuCookie.Value = Cook.ToStr(); string str = LearnSite.Common.XmlHelp.GetStudentCookiesPeriod(); if (str != "0") { StuCookie.Expires = StudentCookiesPeriod(str); StuCookie.Path = "/"; StuCookie.HttpOnly = true; } HttpContext.Current.Response.AppendCookie(StuCookie); LearnSite.Common.App.AppUserAdd(sModel.Snum); } }