Exemplo n.º 1
0
        public static bool SetStudentCookies(LearnSite.Model.Students stumod, string logip)
        {
            bool isset = false;

            if (stumod != null)
            {
                LearnSite.BLL.Signin gbll = new BLL.Signin();
                LearnSite.BLL.Room   rm   = new LearnSite.BLL.Room();
                if (rm.IsLoginLock(stumod.Sgrade.Value, stumod.Sclass.Value))
                {
                    if (gbll.IsSameIp(stumod.Snum, logip))
                    {
                        //如果全班IP登录锁定,如果IP不变 写cookies
                        isset = SetStuCookie(stumod, logip);
                    }
                }
                else
                {
                    //如果全班IP不锁定,写cookies
                    isset = SetStuCookie(stumod, logip);
                }
            }
            return(isset);
        }
Exemplo n.º 2
0
        /// <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;
                LearnSite.BLL.Webstudy wbll = new LearnSite.BLL.Webstudy();
                string FtpPwd               = wbll.FindWebFtpPwd(stmodel.Snum);

                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;
                }

                StuCookie.Values.Add("Sid", stmodel.Sid.ToString());
                StuCookie.Values.Add("Snum", UrlEncode(stmodel.Snum));
                StuCookie.Values.Add("Syear", stmodel.Syear.ToString());
                StuCookie.Values.Add("Sgrade", stmodel.Sgrade.ToString());
                StuCookie.Values.Add("Sclass", stmodel.Sclass.ToString());
                StuCookie.Values.Add("Sname", UrlEncode(stmodel.Sname.Trim()));
                StuCookie.Values.Add("Spwd", Common.WordProcess.GetMD5_8bit(stmodel.Spwd));
                StuCookie.Values.Add("Sex", UrlEncode(stmodel.Sex));
                StuCookie.Values.Add("Sscore", stmodel.Sscore.ToString());
                StuCookie.Values.Add("Squiz", stmodel.Squiz.ToString());
                StuCookie.Values.Add("Sattitude", stmodel.Sattitude.ToString());
                StuCookie.Values.Add("Sape", UrlEncode(stmodel.Sape));
                StuCookie.Values.Add("Sgroup", stmodel.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(stmodel.Sscore.Value + stmodel.Sattitude.Value, true)));
                StuCookie.Values.Add("Ss", Common.WordProcess.GetMD5_8bit(stmodel.Snum));

                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);
            }
        }
Exemplo n.º 3
0
        /// <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);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// ����ѧ�ţ��õ�һ������ʵ��
        /// </summary>
        public LearnSite.Model.Students SnumGetModel(string Snum)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Sid,Snum,Syear,Sgrade,Sclass,Sname,Spwd,Sex,Saddress,Sphone,Sparents,Sheadtheacher,Sscore,Squiz,Sattitude,Sape from Students ");
            strSql.Append(" where Snum=@Snum ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Snum", SqlDbType.NVarChar,50)};
            parameters[0].Value = Snum;

            LearnSite.Model.Students model = new LearnSite.Model.Students();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Sid"].ToString() != "")
                {
                    model.Sid = int.Parse(ds.Tables[0].Rows[0]["Sid"].ToString());
                }
                model.Snum = ds.Tables[0].Rows[0]["Snum"].ToString();
                if (ds.Tables[0].Rows[0]["Syear"].ToString() != "")
                {
                    model.Syear = int.Parse(ds.Tables[0].Rows[0]["Syear"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sgrade"].ToString() != "")
                {
                    model.Sgrade = int.Parse(ds.Tables[0].Rows[0]["Sgrade"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sclass"].ToString() != "")
                {
                    model.Sclass = int.Parse(ds.Tables[0].Rows[0]["Sclass"].ToString());
                }
                model.Sname = ds.Tables[0].Rows[0]["Sname"].ToString();
                model.Spwd = ds.Tables[0].Rows[0]["Spwd"].ToString();
                model.Sex = ds.Tables[0].Rows[0]["Sex"].ToString();
                model.Saddress = ds.Tables[0].Rows[0]["Saddress"].ToString();
                model.Sphone = ds.Tables[0].Rows[0]["Sphone"].ToString();
                model.Sparents = ds.Tables[0].Rows[0]["Sparents"].ToString();
                model.Sheadtheacher = ds.Tables[0].Rows[0]["Sheadtheacher"].ToString();
                if (ds.Tables[0].Rows[0]["Sscore"].ToString() != "")
                {
                    model.Sscore = int.Parse(ds.Tables[0].Rows[0]["Sscore"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Squiz"].ToString() != "")
                {
                    model.Squiz = int.Parse(ds.Tables[0].Rows[0]["Squiz"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sattitude"].ToString() != "")
                {
                    model.Sattitude = int.Parse(ds.Tables[0].Rows[0]["Sattitude"].ToString());
                }
                model.Sape = ds.Tables[0].Rows[0]["Sape"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 5
0
        /// <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);
            }
        }
Exemplo n.º 6
0
        /// <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);
            }
        }