/// <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) { string Rhid = HttpContext.Current.Request.Cookies[teaCookieNname].Values["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 FtpPwd = LearnSite.Common.WordProcess.GetMD5_Nbit(Rhid, 18); string ThisTerm = LearnSite.Common.XmlHelp.GetTerm(); HttpCookie StuCookie = new HttpCookie(stuCookieNname); StuCookie.Values.Add("Sid", sModel.Sid.ToString()); StuCookie.Values.Add("Snum", UrlEncode(sModel.Snum)); StuCookie.Values.Add("Syear", sModel.Syear.ToString()); StuCookie.Values.Add("Sgrade", sModel.Sgrade.ToString()); StuCookie.Values.Add("Sclass", sModel.Sclass.ToString()); StuCookie.Values.Add("Sname", UrlEncode(sModel.Sname)); StuCookie.Values.Add("Spwd", sModel.Spwd.ToString()); StuCookie.Values.Add("Sex", UrlEncode(sModel.Sex)); StuCookie.Values.Add("Sscore", sModel.Sscore.ToString()); StuCookie.Values.Add("Squiz", sModel.Squiz.ToString()); StuCookie.Values.Add("Sattitude", sModel.Sattitude.ToString()); StuCookie.Values.Add("Sape", sModel.Sape.ToString()); StuCookie.Values.Add("Sgroup", sModel.Sgroup.ToString()); StuCookie.Values.Add("LoginTime", LoginTime.ToString()); StuCookie.Values.Add("LoginIp", LoginIp); StuCookie.Values.Add("Ftppwd", FtpPwd); StuCookie.Values.Add("ThisTerm", ThisTerm); StuCookie.Values.Add("Rhid", Rhid); StuCookie.Values.Add("RankImage", UrlEncode(LearnSite.Common.Rank.RankImage(sModel.Sscore.Value + sModel.Sattitude.Value, true))); StuCookie.Values.Add("Ss", Common.WordProcess.GetMD5_8bit(sModel.Snum)); 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); } }
/// <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); } }