Ejemplo n.º 1
0
        public JsonResult Login(string username, string password, string remember_me, string returnUrl)
        {
            TempData[ApplicationConstant.Parameter.RETURN_URL] = returnUrl;
            string captchaErrorMess = string.Empty;

            bool result = false;

            bool isOnlyAcceptAdmin = CommonConstants.IS_ONLY_ACCEPT_ADMIN;

            if (isOnlyAcceptAdmin)
            {
                if (username != "admin")
                {
                    return(Json(new { IsSuccess = result, CaptchaErrorMess = captchaErrorMess }));
                }
            }

            try
            {
                if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
                {
                    result = false;
                }

                ICOCore.Repositories.UserInfo user = _accountService.Login(username, password);
                if (null == user || user.ReferralStatus == (int)UserReferralStatusEnum.INACTIVE)
                {
                    ApplicationContext.IncreaseLoginFailCount();
                    result = false;
                }
                else
                {
                    ViewBag.Success = true;
                    // save cookie
                    if (remember_me == "on")
                    {
                        FormsAuthentication.SetAuthCookie(username, true);
                    }
                    else
                    {
                        FormsAuthentication.SetAuthCookie(username, false);
                    }

                    result = true;

                    //Lưu Application Context
                    var userLevelService = new UserLevelService();
                    user.LevelName = userLevelService.GetByCode(user.LevelCode).Name;
                    ApplicationContext.CurrentUser = user;
                    var accountService = new AccountService();
                    ApplicationContext.CurrentAccount = accountService.GetAccount(username);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }

            return(Json(new { IsSuccess = result }));
        }
Ejemplo n.º 2
0
        public JsonResult AddLevel([DataSourceRequest] DataSourceRequest request, UserLevelModel userLevelModel)
        {
            try
            {
                if (userLevelModel != null)
                {
                    this.userlevelService = new UserLevelService();
                    var userLevel = DataTransfer.Transfer<User_Level>(userLevelModel, typeof(UserLevelModel));
                    userLevelModel.ID = this.userlevelService.AddUserLevel(userLevel);
                    LogUtils.Log("用户" + this.SystemUserSession.LoginName + "成功添加会员等级", "AddLevel", Category.Info, Session.SessionID);
                    return this.Json(new[] { userLevelModel }.ToDataSourceResult(request, this.ModelState));
                }

                return this.Json(string.Empty);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 查询会员列表.
 /// </summary>
 /// <returns>
 /// The <see cref="JsonResult"/>.
 /// </returns>
 public JsonResult QueryLevelSelectListItems()
 {
     try
     {
         this.userlevelService = new UserLevelService();
         var list = this.userlevelService.QueryAll();
         return this.Json(list, JsonRequestBehavior.AllowGet);
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message, exception);
     }
 }
Ejemplo n.º 4
0
        public void RemoveLevel(int id)
        {
            try
            {
                this.userService = new UserService();
                var list = this.userService.QueryUserByUserLevelID(id);
                if (list != null)
                {
                    Response.Write("请确认没有会员在此等级内!");
                    return;
                }

                this.userlevelService = new UserLevelService();
                this.userlevelService.RemoveByID(id);
                LogUtils.Log("用户" + this.SystemUserSession.LoginName + "成功删除会员等级", "RemoveLevel", Category.Info, Session.SessionID);
                Response.Write("成功删除!");
            }
            catch (Exception exception)
            {
                Response.Write("删除失败!");
                throw new Exception(exception.Message, exception);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 会员等级列表数据源.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public JsonResult QueryLevel([DataSourceRequest] DataSourceRequest request)
        {
            try
            {
                this.userlevelService = new UserLevelService();
                var list = this.userlevelService.QueryAll();
                if (list != null)
                {
                    var modelList = new List<UserLevelModel>();
                    foreach (var user in list)
                    {
                        modelList.Add(DataTransfer.Transfer<UserLevelModel>(user, typeof(User_Level)));
                    }

                    return this.Json(modelList.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
                }

                return this.Json(string.Empty);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }
        }