Inheritance: System.Web.UI.Page
Exemplo n.º 1
0
        //获取登录信息 by SNumber
        public SLogin LoginBySNumber(string loginid)
        {
            //sql连接字符串
            string sql = "select * from SLogin where SNumber=@loginid";

            //参数赋值
            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@loginid", loginid),
            };
            //执行sql
            SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, sql, para);
            SLogin        slogin = null;

            if (reader.Read())
            {
                SBasicService sBasicService = new SBasicService();
                StateService  stateServer   = new StateService();

                slogin           = new SLogin();
                slogin.id        = (int)reader["id"];
                slogin.SNumber   = sBasicService.GetStudentBsaicBySNumber((string)reader["SNumber"]);
                slogin.SPassword = (string)reader["SPassword"];
                slogin.State     = stateServer.GetStateById((int)reader["State"]);
                slogin.LastIP    = reader["LastIP"] != DBNull.Value ? (string)reader["LastIP"] : null;
                slogin.LastTime  = reader["LastTime"] != DBNull.Value ? (DateTime?)reader["LastTime"] : null;
            }
            return(slogin);
        }
Exemplo n.º 2
0
        public override int ProcessCLogin(CLogin protocol)
        {
            Session session = Session.Get(protocol);

            SLogin result = new SLogin();

            result.Argument.RoleId = protocol.Argument.RoleId;

            BAccount account = _taccount.Get(session.Account);

            if (null == account)
            {
                result.ResultCode = 1;
                session.SendResponse(result);
                return(Zeze.Transaction.Procedure.LogicError);
            }
            account.LastLoginRoleId = protocol.Argument.RoleId;
            BRoleData role = _trole.Get(protocol.Argument.RoleId);

            if (null == role)
            {
                result.ResultCode = 2;
                session.SendResponse(result);
                return(Zeze.Transaction.Procedure.LogicError);
            }

            BOnline online = _tonline.GetOrAdd(protocol.Argument.RoleId);

            online.RoleId       = protocol.Argument.RoleId; // 对于同一个 session,允许重复登录 role,直接覆盖
            online.SessionId    = session.SessionId;
            session.LoginRoleId = protocol.Argument.RoleId;
            session.SendResponse(result);
            return(Zeze.Transaction.Procedure.Success);
        }
Exemplo n.º 3
0
    ///<summary>
    /// Connect client to the API with.
    ///</summary>
    ///<param name="_input">Login credentials given by CLI</param>
    private async void Login(string _input)
    {
        SLogin logData = JsonConvert.DeserializeObject <SLogin>(_input);

        GameManager.gm.configLoader.RegisterApi(logData.api_url, logData.api_token);
        await GameManager.gm.ConnectToApi();
    }
Exemplo n.º 4
0
        //添加学生
        public string AddStudent(SLogin slogin)
        {
            string number = "0";

            if (!new SBasicService().SelectIDCardisLogin(slogin.SNumber.SIDNumber))
            {
                number = new SBasicService().AddStudent(slogin);
                new SLoginService().AddStudent(slogin);
                return(number);
            }
            else
            {
                return(number);
            }
        }
Exemplo n.º 5
0
        //添加学生信息
        public string AddStudent(SLogin slogin)
        {
            //1.sql语句
            string sql = "insert into SBasic(SNumber,SName,SIDNumber,SCollege,SMajor,SEnrollment,SStatus,SSex,SPhone,SBirthday,SAddress,SPicAddress)"
                         + " values(@SNumber,@SName,@SIDNumber,@SCollege,@SMajor,@SEnrollment,@SStatus,@SSex,@SPhone,@SBirthday,@SAddress,@SPicAddress)";

            sql += " select @@identity";
            //2.参数赋值
            SBasic sbasic = new SBasic();

            sbasic = slogin.SNumber;

            College college = new College();

            college = sbasic.SCollege;
            Major major = new Major();

            major = sbasic.SMajor;
            Status status = new Status();

            status = sbasic.SStatus;
            State state = new State();

            state = slogin.State;

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@SNumber", sbasic.SNumber),
                new SqlParameter("@SName", sbasic.SName),
                new SqlParameter("@SIDNumber", sbasic.SIDNumber),
                new SqlParameter("@SCollege", college.CollegeId),
                new SqlParameter("@SMajor", major.MajorId),
                new SqlParameter("@SEnrollment", sbasic.SEnrollment),
                new SqlParameter("@SStatus", status.StatusId),
                new SqlParameter("@SSex", sbasic.SSex),
                new SqlParameter("@SPhone", sbasic.SPhone),
                new SqlParameter("@SBirthday", sbasic.SBirthday),
                new SqlParameter("@SAddress", sbasic.SAddress),
                new SqlParameter("@SPicAddress", sbasic.SPicAddress),
            };
            //3、执行sql语句
            SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, sql, para);
            return(sbasic.SNumber);
        }
Exemplo n.º 6
0
        //学生登录
        public bool SLogin(string LoginId, string LoginPwd, out SLogin S)
        {
            SLogin s = new SLoginService().LoginBySNumber(LoginId);

            if (s == null)
            {
                S = null;//用户名不存在
                return(false);
            }
            if (s.SPassword == LoginPwd)
            {
                S = s;//登录成功
                return(true);
            }
            else
            {
                S = null;//登录失败
                return(false);
            }
        }
Exemplo n.º 7
0
        //获取冻结用户信息
        public List <SLogin> GetLocked()
        {
            List <SLogin> sloginlist = new List <SLogin>();
            string        sql        = "select * from SLogin,SBasic where SLogin.SNumber=SBasic.SNumber and SLogin.State=0";
            DataSet       ds         = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, sql);

            if (ds.Tables.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                foreach (DataRow row in dt.Rows)
                {
                    SLogin slogin = new SLogin();
                    SBasic sbasic = new SBasic();
                    sbasic.SNumber   = (string)row["SNumber"];
                    slogin.SNumber   = sbasic;
                    slogin.SPassword = (string)row["SName"];
                    /*此时spassword代表姓名数据*/
                    sloginlist.Add(slogin);
                }
            }
            return(sloginlist);
        }
Exemplo n.º 8
0
        //添加学生用户登录信息
        public bool AddStudent(SLogin slogin)
        { //1.sql语句
            string sql = "insert into SLogin(SNumber,SPassword,State,LastIP,LastTime)"
                         + " values(@SNumber,@SPassword,@State,@LastIP,@LastTime)";
            //2.参数赋值
            SBasic sbasic = new SBasic();

            sbasic = slogin.SNumber;
            State state = new State();

            state = slogin.State;

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@SNumber", sbasic.SNumber),
                new SqlParameter("@SPassword", slogin.SPassword),
                new SqlParameter("@State", state.StateId),
                new SqlParameter("@LastIP", "192.168.1.1"),
                new SqlParameter("@LastTime", "1900-01-01 08:00:00"),
            };
            //3、执行sql语句
            return(Convert.ToInt32(SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, sql, para)) > 0);
        }
Exemplo n.º 9
0
        /*Admin/AddStudent
         * 1、获取学生信息(url参数)
         * 2、利用UserManager-AddStudent添加学生并返回学号、
         * 2、返回添加结果*/
        public ActionResult AddStudent(string name, string phone, string idcard, string sex, DateTime birthday, string address, string college_id, string major_id)
        {
            DateTime datetime     = new IPManager().GetDateTime();
            string   year         = datetime.ToString("yyyy");
            string   date         = datetime.ToString("yyyy-MM-dd");
            string   latestnumber = new UserManager().SelectTheLatestData(major_id, year);
            string   newnumber    = "";

            if (latestnumber == "0")
            {
                newnumber = year + major_id + "001";
            }
            else
            {
                string start = latestnumber.Substring(0, 8);
                string end   = latestnumber.Remove(0, 8);
                newnumber = start + Convert.ToString(string.Format("{0:d3}", Convert.ToInt32(end) + 1));
            }

            string password = phone.Substring(3, 8);

            SLogin slogin = new SLogin();
            SBasic sbasic = new SBasic();

            College college = new College();

            college.CollegeId = college_id;
            Major major = new Major();

            major.MajorId = major_id;
            Status status = new Status();

            status.StatusId = 0;
            State state = new State();

            state.StateId = 1;

            sbasic.SNumber     = newnumber;
            sbasic.SName       = name;
            sbasic.SIDNumber   = idcard;
            sbasic.SCollege    = college;
            sbasic.SMajor      = major;
            sbasic.SEnrollment = Convert.ToDateTime(date);
            sbasic.SStatus     = status;
            sbasic.SSex        = sex;
            sbasic.SPhone      = phone;
            sbasic.SBirthday   = birthday;
            sbasic.SAddress    = address;
            sbasic.SPicAddress = "default";

            slogin.SNumber   = sbasic;
            slogin.SPassword = password;
            slogin.State     = state;

            if (new UserManager().AddStudent(slogin) == newnumber)
            {
                return(Content(newnumber));
            }
            else
            {
                return(Content("0"));
            }
        }
Exemplo n.º 10
0
        /*Account/UserLogin(用户登录事件)
         * 1、获取界面信息(用户名、密码、是否记住密码-cookie)
         * 2、检测登录用户分类(学生11位纯数字--教师t+9位纯数字)
         * 3、执行登录过程(业务逻辑层UserManager)
         * 4、学生-UserManager-SLogin
         * 5、教师-UserManager-Tlogin
         * 6、返回登录信息
         * 7、成功后跳转到Home/Index(主界面)*/
        public ActionResult UserLogin()
        {
            string loginid  = Request.Form["number"];   //获取用户名
            string loginpwd = Request.Form["password"]; //获取密码
            string recordMe = Request.Form["RecordMe"]; //是否记住密码
            bool   record   = false;

            if (!string.IsNullOrEmpty(recordMe))
            {
                record = true;
            }

            if (Regex.IsMatch(loginid, @"^t|T"))
            {
                #region 教师登录
                TLogin T = new TLogin();
                if (new UserManager().TLogin(loginid, loginpwd, out T))
                {
                    if (record)
                    {
                        //添加cookie,设置用户过期。
                        HttpCookie idCookie = new HttpCookie("id", T.TNumber.TNumber);
                        idCookie.Expires = DateTime.MaxValue;
                        Response.Cookies.Add(idCookie);
                        HttpCookie pwdCookie = new HttpCookie("pwd", T.TPassword);
                        pwdCookie.Expires = DateTime.MaxValue;
                        Response.Cookies.Add(pwdCookie);
                    }
                    else
                    {
                        //删除cookie(失效)
                        Response.Cookies["id"].Expires  = DateTime.Now.AddDays(-1);
                        Response.Cookies["pwd"].Expires = DateTime.Now.AddDays(-1);
                    }
                    if (T.State.StateName == "正常")
                    {
                        //保存用户的状态(sesion)
                        Session["user"] = T;

                        new IPManager().AddTIP(T.TNumber.TNumber);

                        return(View("../Home/Index"));
                    }
                    else
                    {
                        Response.Write("<script>alert('你的账号已被冻结,请联系管理员!')</script>");
                        return(View("../Account/Index"));
                    }
                }
                else
                {
                    Response.Write("<script>alert('用户名与密码不匹配,请重试!')</script>");
                    return(View("../Account/Index"));
                }
                #endregion
            }
            else
            {
                #region 学生登录
                SLogin S = new SLogin();
                if (new UserManager().SLogin(loginid, loginpwd, out S))
                {
                    if (record)
                    {
                        //添加cookie,设置用户过期。
                        HttpCookie idCookie = new HttpCookie("id", S.SNumber.SNumber);
                        idCookie.Expires = DateTime.MaxValue;
                        Response.Cookies.Add(idCookie);
                        HttpCookie pwdCookie = new HttpCookie("pwd", S.SPassword);
                        pwdCookie.Expires = DateTime.MaxValue;
                        Response.Cookies.Add(pwdCookie);
                    }
                    else
                    {
                        //删除cookie(失效)
                        Response.Cookies["id"].Expires  = DateTime.Now.AddDays(-1);
                        Response.Cookies["pwd"].Expires = DateTime.Now.AddDays(-1);
                    }
                    if (S.State.StateName == "正常")
                    {
                        //保存用户的状态(sesion)
                        Session["user"] = S;

                        new IPManager().AddSIP(S.SNumber.SNumber);

                        return(View("../Home/Index"));
                    }
                    else
                    {
                        Response.Write("<script>alert('你的账号已被冻结,请联系管理员!')</script>");
                        return(View("../Account/Index"));
                    }
                }
                else
                {
                    Response.Write("<script>alert('用户名与密码不匹配,请重试!')</script>");
                    return(View("../Account/Index"));
                }
                #endregion
            }
        }