Ejemplo n.º 1
0
        /// <summary>
        /// 尝试将使用用户名密码登陆系统
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="passWord">密码</param>
        /// <param name="userip">用户IP</param>
        /// <returns>返回是否成功登陆,若失败则返回出错信息</returns>
        public static IMethodResult SignIn(String userName, String passWord, String userip)
        {
            UserEntity user  = null;
            String     error = TryGetUserByUsernameAndPassword(userName, passWord, out user);

            if (!String.IsNullOrEmpty(error))
            {
                return(MethodResult.FailedAndLog(error));
            }

            if (AdminManager.InternalCheckPermission(user.Permission, PermissionType.HttpJudge))
            {
                return(MethodResult.FailedAndLog("You can not login a httpjudge account!"));
            }

            try
            {
                Int32 unreadMailCount = UserMailManager.InternalCountUserUnReadMails(user.UserName);

                UserBrowserStatus.SetCurrentUserBrowserStatus(user.UserName, user.Permission, unreadMailCount);
                UserSubmitStatus.InitLastSubmitTime(user.UserName);
                UserCurrentStatus.SetCurrentUserStatus(user);

                UpdateLoginInfomation(userName, userip);
            }
            catch (System.Exception ex)
            {
                return(MethodResult.Failed(ex.Message));
            }

            return(MethodResult.SuccessAndLog("User sign in"));
        }