Example #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);
        }
Example #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);
            }
        }
Example #3
0
        /// <summary>
        /// �ս�������
        /// </summary>
        /// <param name="SgradeMin"></param>
        /// <param name="SgradeMax"></param>
        /// <param name="SclassMin"></param>
        /// <param name="SclassMax"></param>
        public void TermAPE()
        {
            string strSql = "UPDATE Students SET Sape='P'";
            DbHelperSQL.ExecuteSql(strSql);

            LearnSite.BLL.Room rm = new LearnSite.BLL.Room();
            int SgradeMin = rm.GetMinRgrade();
            int SgradeMax = rm.GetMaxRgrade();
            int SclassMin = rm.GetMinRclass();
            int SclassMax = rm.GetMaxRclass();
            for (int i = SgradeMin; i < SgradeMax+1; i++)
            {
                for (int j = SclassMin; j < SclassMax+1; j++)
                {
                    int Sgrade = i;
                    int Sclass = j;
                    int Scount=0;
                    string strcount = "SELECT COUNT(*) From Students WHERE Sgrade=" + Sgrade + " AND Sclass=" + Sclass ;
                    object objcount= DbHelperSQL.GetSingle(strcount);
                    if (objcount != null)
                        Scount = Int32.Parse(objcount.ToString());
                    else
                    {
                        break;
                    }
                    int setA = Scount * 40 / 100;
                    int setE = Scount * 10 / 100;

                    string strA = "UPDATE Students SET Sape='A' WHERE  Sid IN (SELECT TOP " + setA + " Sid FROM Students WHERE Sgrade='" + Sgrade + "' AND Sclass='" + Sclass + "' ORDER BY Sscore DESC) ";
                    DbHelperSQL.ExecuteSql(strA);
                    string strE = "UPDATE Students SET Sape='E' WHERE  Sid IN (SELECT TOP " + setE + " Sid FROM Students WHERE Sgrade='" + Sgrade + "' AND Sclass='" + Sclass + "' ORDER BY Sscore ASC) ";
                    DbHelperSQL.ExecuteSql(strE);

                }
            }
        }
Example #4
0
        /// <summary>
        /// 设置学生的cookies值
        /// </summary>
        /// <param name="Model"></param>
        ///Snum,Syear,Sgrade,Sclass,Sname,Spwd,Sex,Saddress,Sphone,Sparents,Sheadtheacher,Sscore,Sattitude,Sape
        public static bool SetStudentCookies(LearnSite.Model.Students Model)
        {
            if (Model != null)
            {
                try
                {
                    DateTime LoginTime = DateTime.Now;
                    string LoginIp = LearnSite.Common.Computer.GetGuestIP();
                    LearnSite.BLL.Webstudy wbll = new LearnSite.BLL.Webstudy();
                    string FtpPwd = wbll.FindWebFtpPwd(Model.Snum);
                    LearnSite.BLL.Room rm = new LearnSite.BLL.Room();
                    string Rhid = rm.GetRoomRhid(Model.Sgrade.Value, Model.Sclass.Value);
                    string ThisTerm = LearnSite.Common.XmlHelp.GetTerm();
                    HttpCookie StuCookie = new HttpCookie("StudentCookies");
                    if (Model.Sex == null)
                        Model.Sex = "无";
                    if (Model.Saddress == null)
                        Model.Saddress = "无";
                    if (Model.Sphone == null)
                        Model.Sphone = "无";
                    if (Model.Sparents == null)
                        Model.Sparents = "无";
                    if (Model.Sheadtheacher == null)
                        Model.Sheadtheacher = "无";
                    if (Model.Sscore == null)
                        Model.Sscore = 0;
                    if (Model.Squiz == null)
                        Model.Squiz = 0;
                    if (Model.Sattitude == null)
                        Model.Sattitude = 0;
                    if (Model.Sape == null)
                        Model.Sape = "无";

                    StuCookie.Values.Add("Sid", Model.Sid.ToString());
                    StuCookie.Values.Add("Snum", UrlEncode(Model.Snum));
                    StuCookie.Values.Add("Syear", Model.Syear.ToString());
                    StuCookie.Values.Add("Sgrade", Model.Sgrade.ToString());
                    StuCookie.Values.Add("Sclass", Model.Sclass.ToString());
                    StuCookie.Values.Add("Sname", UrlEncode(Model.Sname));
                    StuCookie.Values.Add("Spwd", Model.Spwd.ToString());
                    StuCookie.Values.Add("Sex", UrlEncode(Model.Sex));
                    StuCookie.Values.Add("Saddress", UrlEncode(Model.Saddress));
                    StuCookie.Values.Add("Sphone", Model.Sphone.ToString());
                    StuCookie.Values.Add("Sparents", UrlEncode(Model.Sparents));
                    StuCookie.Values.Add("Sheadtheacher", UrlEncode(Model.Sheadtheacher));
                    StuCookie.Values.Add("Sscore", Model.Sscore.ToString());
                    StuCookie.Values.Add("Squiz", Model.Squiz.ToString());
                    StuCookie.Values.Add("Sattitude", Model.Sattitude.ToString());
                    StuCookie.Values.Add("Sape", Model.Sape.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);

                    string str = LearnSite.Common.XmlHelp.GetStudentCookiesPeriod();
                    if (str != "0")
                    {
                        StuCookie.Expires = StudentCookiesPeriod(str);
                        StuCookie.Path = "/";
                    }
                    HttpContext.Current.Response.AppendCookie(StuCookie);
                    return true;
                }
                catch
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
Example #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);
            }
        }