Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if((Request.UrlReferrer!=null) && Request.UrlReferrer.ToString().ToLower().IndexOf("enroll.sse.ustc.edu.cn")!=-1 && Request.UrlReferrer.ToString().ToLower().IndexOf("sseweb")!=-1)
        //{
        string USID = string.Empty;
        if (Request["USID"] == null)
        {
            Response.Redirect("http://enroll.sse.ustc.edu.cn/sseweb/", false);
            return;
        }

        USID = Request["USID"].Trim();

        DalOperationAboutUser DalOperationAboutUser = new DalOperationAboutUser();

        UserCookiesInfo UserCookiesInfoTeacher = null;
        UserCookiesInfo UserCookiesInfoStudent = null;

        CheckUserLogin CheckUserLoginTeacher = BllOperationAboutUser.ReturnSqlJudgeByUserType(1, USID);
        UserCookiesInfoTeacher = DalOperationAboutUser.CheckUserLogin(CheckUserLoginTeacher);

        CheckUserLogin CheckUserLoginStudent = BllOperationAboutUser.ReturnSqlJudgeByUserType(3, USID);
        UserCookiesInfoStudent = DalOperationAboutUser.CheckUserLogin(CheckUserLoginStudent);

        //1:教师(isAssistant值为1表示有助教身份,isAdmin值为1表示为管理员);3:学生;

        UserCookiesInfo UserCookiesInformation = null;//登陆的用户Cookie对象

        if (UserCookiesInfoTeacher != null)
        {
            UserCookiesInformation = UserCookiesInfoTeacher;
        }
        else if (UserCookiesInfoStudent != null)
        {
            UserCookiesInformation = UserCookiesInfoStudent;
        }

        if (UserCookiesInformation != null)
        {
            //FormsAuthenticationTicket Ticket;

            //Ticket = new FormsAuthenticationTicket(3, UserCookiesInformation.userType.ToString().Trim(), DateTime.Now, DateTime.Now.AddMinutes(1440), false, SerializeCookies.SerializeCookiesMethod<UserCookiesInfo>(UserCookiesInformation)); //建立身份验证票对象

            Session[ConfigurationManager.AppSettings["sessionKey"]] = SerializeCookies.SerializeCookiesMethod<UserCookiesInfo>(UserCookiesInformation);

            //string HashTicket = FormsAuthentication.Encrypt(Ticket); //加密序列化验证票为字符串

            //HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket);
            //UserCookie.HttpOnly = true;
            ////生成Cookie
            //Context.Response.Cookies.Add(UserCookie); //输出Cookie
            // 定位到管理页面
            Response.Redirect("/Common/NotifyList.aspx", false);
        }
        else
        {
            Javascript.AlertAndRedirect("用户名或密码错误!请重新填写再登陆!","http://enroll.sse.ustc.edu.cn/sseweb/", Page);
        }
    }
Example #2
0
        public int CheckLogin(string userName,string userPwd)
        {
            int isLoginSuccess = 0;

            DalOperationAboutUser DalOperationAboutUser = new DalOperationAboutUser();

            //0:管理员;1:教师;2:助教;3:学生;
            CheckUserLogin CheckUserLoginAdmin = BllOperationAboutUser.ReturnSqlJudgeByUserType(0, userName, CommonUtility.EncodeUsingMD5(userPwd));
            CheckUserLogin CheckUserLoginTeacher = BllOperationAboutUser.ReturnSqlJudgeByUserType(1, userName, CommonUtility.EncodeUsingMD5(userPwd));
            CheckUserLogin CheckUserLoginAssistant = BllOperationAboutUser.ReturnSqlJudgeByUserType(2, userName, CommonUtility.EncodeUsingMD5(userPwd));
            CheckUserLogin CheckUserLoginStudent = BllOperationAboutUser.ReturnSqlJudgeByUserType(3, userName, CommonUtility.EncodeUsingMD5(userPwd));

            UserCookiesInfo UserCookiesInfoAdmin = DalOperationAboutUser.CheckUserLogin(CheckUserLoginAdmin);
            UserCookiesInfo UserCookiesInfoTeacher = DalOperationAboutUser.CheckUserLogin(CheckUserLoginTeacher);
            UserCookiesInfo UserCookiesInfoAssistant = DalOperationAboutUser.CheckUserLogin(CheckUserLoginAssistant);
            UserCookiesInfo UserCookiesInfoStudent = DalOperationAboutUser.CheckUserLogin(CheckUserLoginStudent);

            UserCookiesInfo UserCookiesInformation = null;//登陆的用户Cookie对象

            if (UserCookiesInfoAdmin != null)
            {
                UserCookiesInformation = UserCookiesInfoAdmin;
            }
            else if (UserCookiesInfoTeacher != null)
            {
                UserCookiesInformation = UserCookiesInfoTeacher;
            }
            else if (UserCookiesInfoAssistant != null)
            {
                UserCookiesInformation = UserCookiesInfoAssistant;
            }
            else if (UserCookiesInfoStudent != null)
            {
                UserCookiesInformation = UserCookiesInfoStudent;
            }

            if (UserCookiesInformation != null)
            {
                FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(3, UserCookiesInformation.userType.ToString().Trim(), DateTime.Now, DateTime.Now.AddMinutes(1440), false, SerializeCookies.SerializeCookiesMethod<UserCookiesInfo>(UserCookiesInformation)); //建立身份验证票对象
                string HashTicket = FormsAuthentication.Encrypt(Ticket); //加密序列化验证票为字符串
                HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket);
                UserCookie.HttpOnly = true;
                //生成Cookie
                HttpContext.Current.Response.Cookies.Add(UserCookie); //输出Cookie
                //// 定位到管理页面
                //HttpContext.Current.Response.Redirect("/Common/NotifyList.aspx", false);
                isLoginSuccess = 1;
            }
            return isLoginSuccess;
        }
Example #3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            FileUpload1.SaveAs(Server.MapPath("/" + FileUpload1.FileName));
            DalOperationAboutUser DalOperationAboutUser = new DalOperationAboutUser();

            //按顺序设定每个工作薄的字段数目

            int[] sheetFiledsCount = { 5, 5, 7, 1, 6, 2, 2, 2 };

            //读取要导入的Excel文件的全部数据
            ExcelData excelData = BllOperationAboutExcel.BllImportExcelData(Server.MapPath("/" + FileUpload1.FileName), sheetFiledsCount,FileUpload1);
            //Response.Write(excelData.excelPasswordMapping.Count);
            //Response.End();
            //将获取的导入数据存入数据库
            DalOperationAboutUser.ImportExcelData(excelData);
        }
        else
        {
            Javascript.GoHistory(-1, "请先选择Excel文件!", Page);
        }
    }