Exemplo n.º 1
0
 public int AddLoginLog(LoginLog model)
 {
     string cmdText = @"
     INSERT INTO [LoginLog]  (Uid,LoginIP,LoginDate,Status)  values (@Uid,@LoginIP,GETDATE(),@Status)";
     SqlParameter[] parameters =
     {
         SqlParamHelper.MakeInParam("@Uid",SqlDbType.Int,4,model.Uid),
         SqlParamHelper.MakeInParam("@LoginIP",SqlDbType.Char,15,model.LoginIP),
         SqlParamHelper.MakeInParam("@Status",SqlDbType.Char,1,model.Status)
     };
     return SqlHelper.ExecuteNonQuery(WriteConnectionString,CommandType.Text,cmdText,parameters);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="passWord">密码</param>
        public void SignIn(string userName,string passWord)
        {
            UserInfo user = _UserService.GetUserInfo(userName,CryptoHelper.MD5_Encrypt(passWord));
            if(user != null){
                UserLogin loginInfo = _UserService.GetUserLogin(user.Uid);
                if(loginInfo.Status == 0){
                    ExceptionHelper.ThrowUserError("账号未启用,请联系管理员!");
                }

                if(loginInfo.Status == 2){
                    ExceptionHelper.ThrowUserError("账号禁止登陆,请联系管理员!");
                }

                loginInfo.LastLoginDate = DateTime.Now;
                loginInfo.LastLoginIP = HttpContext.Current.Request.UserHostAddress;
                _UserService.EditUserLogin(loginInfo);
                SignIn(user.Uid);
                //todo:插入登陆日志
                LoginLog logmodel = new LoginLog();
                logmodel.Uid = user.Uid;
                logmodel.LoginDate = DateTime.Now;
                logmodel.LoginIP = HttpContext.Current.Request.UserHostAddress;
                logmodel.Status = loginInfo.Status;
                _UserService.AddLoginLog(logmodel);
            }
            else{
                ExceptionHelper.ThrowUserError("用户验证失败,密码不正确!");
            }
        }
Exemplo n.º 3
0
 public int AddLoginLog(LoginLog model)
 {
     return _UserRepository.AddLoginLog(model);
 }