Exemple #1
0
        public ActionResult StartUser(string id)
        {
            bool   success = false;
            string msg     = "";

            try
            {
                SYS_LOGIN_BLL loginbll = SYS_LOGIN_BLL.getInstance();
                SYS_LOGIN     model    = loginbll.GetByUserID(id);
                if (model.State == 2)
                {
                    model.State = 1;
                    success     = loginbll.Edit(model);
                }
                else if (model.State == 0)
                {
                    msg = "用户尚未授权,无法启用";
                }
                else if (true)
                {
                    msg = "用户已启用,请勿重复启用";
                }
            }
            catch (Exception ex)
            {
                Common.Helper.Logger.Info(string.Format("启用用户保存异常,异常信息:{0}", ex.ToString()));
                msg = "启用用户发生异常";
            }
            return(this.Json(new
            {
                success = success,
                msg = msg
            }));
        }
Exemple #2
0
        public ActionResult Delet(string id)
        {
            bool   success = false;
            string msg     = "";

            try
            {
                SYS_LOGIN loginmodel = SYS_LOGIN_BLL.getInstance().GetByUserID(id);
                if (loginmodel.State == 0)
                {
                    success = bll.Remove(id, loginmodel.ID);
                }
                else
                {
                    msg = "用户已在使用中,不能删除";
                }
            }
            catch (Exception ex)
            {
                Common.Helper.Logger.Info(string.Format("删除用户,删除异常,UserID-【0】异常信息:{1}", id, ex.ToString()));
                msg = "删除异常";
            }

            return(this.Json(new
            {
                success = success,
                msg = msg
            }));
        }
Exemple #3
0
        public ActionResult Edit(SYS_USER usermodel, SYS_LOGIN loginmodel)
        {
            bool   success = false;
            string msg     = "";

            try
            {
                SYS_USER  editmodel      = SYS_USER_BLL.getInstance().GetById(usermodel.UserID.ToString());
                SYS_LOGIN logineditmodel = SYS_LOGIN_BLL.getInstance().GetByUserID(usermodel.UserID.ToString());
                //输入密码
                if (!string.IsNullOrWhiteSpace(loginmodel.UserPassword))
                {
                    loginmodel.UpdateDate   = DateTime.Now;
                    loginmodel.UpdateUserID = UserSession.AccountInfo.UserID;
                    loginmodel.CreateUserID = logineditmodel.CreateUserID;
                    loginmodel.CreateDate   = loginmodel.CreateDate;
                    loginmodel.UserPassword = EncryptHelper.MD5DecryptString(loginmodel.UserPassword);
                }
                usermodel.UpdateDate   = DateTime.Now;
                usermodel.UpdateUserID = UserSession.AccountInfo.UserID;
                usermodel.CreateDate   = editmodel.CreateDate;
                usermodel.CreateUserID = editmodel.CreateUserID;
                success = bll.EditUser(usermodel, loginmodel);
            }
            catch (Exception ex)
            {
                Common.Helper.Logger.Info(string.Format("保存用户信息,保存异常,异常信息:{0}", ex.ToString()));
                msg = "保存异常";
            }
            return(this.Json(new
            {
                success = success,
                msg = msg
            }));
        }
        /// <summary>
        /// 验证登录
        /// </summary>
        /// <param name="username"></param>
        /// <param name="pwd"></param>
        /// <param name="usercode"></param>
        /// <param name="remember"></param>
        /// <returns></returns>
        public ActionResult CheckLogin(string username, string pwd, string usercode, bool remember)
        {
            // 验证码如果不为空,则需要验证码判断
            if (!string.IsNullOrEmpty(usercode))
            {
                string valerror = string.Empty;
                //if (!ValiDateCode(0, usercode.ToUpper(), out valerror))
                //{
                //    return this.Json(new
                //    {
                //        success = false,
                //        error = valerror
                //    });
                //}
            }

            SYS_LOGIN para = new SYS_LOGIN();

            para.UserName     = username;
            para.UserPassword = pwd;

            try
            {
                // 1.返回用户信息,权限信息,菜单信息等
                LoginState state = SYS_LOGIN_BLL.getInstance().CheckLogin(para);

                // 2.密码错误
                if (state == LoginState.PwdError)
                {
                    return(this.Json(new
                    {
                        success = false,
                        error = "密码输入错误"
                    }));
                }

                // 3.用户被禁用
                if (state == LoginState.AccountLock)
                {
                    return(this.Json(new
                    {
                        success = false,
                        error = "用户已被禁用,请联系管理员"
                    }));
                }

                // 4.账户不存在
                if (state == LoginState.AccountNoExist)
                {
                    return(this.Json(new
                    {
                        success = false,
                        error = "账号不存在"
                    }));
                }

                // 5.账户未授权
                if (state == LoginState.NoAuthorize)
                {
                    return(this.Json(new
                    {
                        success = false,
                        error = "账号未经授权,请联系管理员"
                    }));
                }

                // 用户选择记住账号
                if (remember)
                {
                    CookieHelper.SetCookie("username", username);
                }

                return(this.Json(new
                {
                    success = true,
                }));
            }
            catch (Exception ex)
            {
                Logger.Error(string.Format("【账号】-{0},登录异常,异常信息:{1}", username, ex.ToString()));
                return(Json(new
                {
                    success = false,
                    error = ex.Message
                }));
            }
        }