Exemplo n.º 1
0
        /// <summary>
        /// 用户登录验证
        /// </summary>
        /// <param name="userLoginName"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public static UserLoginData Login(string userLoginName, string pwd)
        {
            UserLoginData  loginData = new UserLoginData();
            SQLHelper      helper    = new SQLHelper("select * from XT_USER where USER_NAME=@0 and PWD=@1", userLoginName, MD5Ulits.GetMd5Hash(pwd));
            XT_UserService service   = ServiceManage.GetService <XT_UserService>();
            XT_USER        user      = service.SelectFirstOrDefault(helper);

            if (user == null && userLoginName == AppConfigManage.GetSysUserInfo()[0])
            {
                user = service.SelectByLoginName(userLoginName);
                if (user != null)
                {
                    loginData.Message    = "用户名或密码错误";
                    loginData.LoginState = false;
                    return(loginData);
                }
                user = new XT_USER()
                {
                    USER_NAME   = userLoginName,
                    PWD         = MD5Ulits.GetMd5Hash(pwd),
                    CREATE_BY   = "system_",
                    CREATE_TIME = DateTime.Now,
                    LOGIN_NAME  = userLoginName,
                    MODIFY_BY   = "system_",
                    MODIFY_TIME = DateTime.Now,
                    PING_YIN    = ""
                };
                service.Insert(user);
            }
            else
            {
                if (user == null)
                {
                    loginData.Message    = "用户名或密码错误";
                    loginData.LoginState = false;
                    return(loginData);
                }
            }

            loginData.Message    = "登录成功";
            loginData.LoginState = true;
            loginData.Data       = user;
            return(loginData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取当前用户信息
        /// </summary>
        /// <returns></returns>
        public static XT_USER GetCurrentUserInfo()
        {
            XT_LOGIN_INFO info = GetLoginInfo();

            if (info == null)
            {
                return(null);
            }
            XT_USER        user    = null;
            XT_UserService service = ServiceManage.GetService <XT_UserService>();
            SQLHelper      helper  = new SQLHelper("select * from XT_USER where ID=@0", info.USER_ID);

            user = service.SelectFirstOrDefault(helper);
            if (user != null)
            {
                return(user);
            }
            XT_TempUserService tempService = ServiceManage.GetService <XT_TempUserService>();

            helper = new SQLHelper("select * from XT_TEMP_PORARY_USER  where  ID=@0", info.ID);
            XT_TEMP_PORARY_USER tempUser = tempService.SelectFirstOrDefault(helper);

            if (tempUser == null)
            {
                return(null);
            }
            user = new XT_USER()
            {
                USER_NAME   = tempUser.USER_NAME,
                CREATE_BY   = tempUser.CREATE_BY,
                CREATE_TIME = tempUser.CREATE_TIME,
                LOGIN_NAME  = null,
                MODIFY_BY   = tempUser.MODIFY_BY,
                MODIFY_TIME = tempUser.MODIFY_TIME,
            };

            return(user);
        }