示例#1
0
        public IHttpActionResult Delete()
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.User))
                {
                    return(Unauthorized());
                }

                var id = request.GetPostInt("id");

                DataProvider.UserGroupDao.Delete(id);

                return(Ok(new
                {
                    Value = UserGroupManager.GetUserGroupInfoList()
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
示例#2
0
        public IHttpActionResult Get()
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.User))
                {
                    return(Unauthorized());
                }

                var adminNames = DataProvider.AdministratorDao.GetUserNameList();
                adminNames.Insert(0, string.Empty);

                return(Ok(new
                {
                    Value = UserGroupManager.GetUserGroupInfoList(),
                    AdminNames = adminNames
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
示例#3
0
 public object GetRegister(RequestImpl request)
 {
     return(new
     {
         Value = request.UserInfo,
         Config = ConfigManager.Instance.SystemConfigInfo,
         Styles = TableStyleManager.GetUserStyleInfoList(),
         Groups = UserGroupManager.GetUserGroupInfoList()
     });
 }
示例#4
0
 private object GetRegister(AuthenticatedRequest request)
 {
     return(new
     {
         Value = request.UserInfo,
         Config = ConfigManager.Instance.SystemConfigInfo,
         Styles = TableStyleManager.GetUserStyleInfoList(),
         Groups = UserGroupManager.GetUserGroupInfoList()
     });
 }
示例#5
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _userId    = AuthRequest.GetQueryInt("userID");
            _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl"));

            if (IsPostBack)
            {
                return;
            }

            VerifySystemPermissions(ConfigManager.AppPermissions.SettingsUser);

            LtlPageTitle.Text = _userId == 0 ? "添加用户" : "编辑用户";

            foreach (var groupInfo in UserGroupManager.GetUserGroupInfoList())
            {
                DdlGroupId.Items.Add(new ListItem(groupInfo.GroupName, groupInfo.Id.ToString()));
            }

            if (_userId > 0)
            {
                var userInfo = UserManager.GetUserInfoByUserId(_userId);
                if (userInfo != null)
                {
                    TbUserName.Text = userInfo.UserName;
                    ControlUtils.SelectSingleItem(DdlGroupId, userInfo.GroupId.ToString());
                    TbUserName.Enabled = false;
                    TbDisplayName.Text = userInfo.DisplayName;
                    PhPassword.Visible = false;
                    TbEmail.Text       = userInfo.Email;
                    TbMobile.Text      = userInfo.Mobile;
                }
            }

            if (!EUserPasswordRestrictionUtils.Equals(ConfigManager.SystemConfigInfo.UserPasswordRestriction, EUserPasswordRestriction.None))
            {
                LtlPasswordTips.Text = $"请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.UserPasswordRestriction))}";
            }

            if (!string.IsNullOrEmpty(_returnUrl))
            {
                BtnReturn.Attributes.Add("onclick", $"window.location.href='{_returnUrl}';return false;");
            }
            else
            {
                BtnReturn.Visible = false;
            }
        }
        public IHttpActionResult Get()
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.AppPermissions.SettingsConfigHomeMenu))
                {
                    return(Unauthorized());
                }

                return(Ok(new
                {
                    Value = UserMenuManager.GetAllUserMenuInfoList(),
                    Groups = UserGroupManager.GetUserGroupInfoList()
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
示例#7
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            if (AuthRequest.IsQueryExists("Check"))
            {
                var userIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("UserIDCollection"));
                DataProvider.UserDao.Check(userIdList);

                SuccessCheckMessage();
            }
            else if (AuthRequest.IsQueryExists("Delete"))
            {
                var userIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("UserIDCollection"));
                try
                {
                    foreach (var userId in userIdList)
                    {
                        var userInfo = UserManager.GetUserInfoByUserId(userId);
                        DataProvider.UserDao.Delete(userInfo);
                    }

                    AuthRequest.AddAdminLog("删除用户", string.Empty);

                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }
            else if (AuthRequest.IsQueryExists("Lock"))
            {
                var userIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("UserIDCollection"));
                try
                {
                    DataProvider.UserDao.Lock(userIdList);

                    AuthRequest.AddAdminLog("锁定用户", string.Empty);

                    SuccessMessage("成功锁定所选会员!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "锁定所选会员失败!");
                }
            }
            else if (AuthRequest.IsQueryExists("UnLock"))
            {
                var userIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("UserIDCollection"));
                try
                {
                    DataProvider.UserDao.UnLock(userIdList);

                    AuthRequest.AddAdminLog("解除锁定用户", string.Empty);

                    SuccessMessage("成功解除锁定所选会员!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "解除锁定所选会员失败!");
                }
            }

            SpContents.ControlToPaginate = RptContents;

            if (string.IsNullOrEmpty(AuthRequest.GetQueryString("PageNum")))
            {
                SpContents.ItemsPerPage = TranslateUtils.ToInt(DdlPageNum.SelectedValue) == 0 ? 25 : TranslateUtils.ToInt(DdlPageNum.SelectedValue);

                SpContents.SelectCommand = DataProvider.UserDao.GetSelectCommand();
            }
            else
            {
                SpContents.ItemsPerPage = AuthRequest.GetQueryInt("PageNum") == 0 ? Constants.PageSize : AuthRequest.GetQueryInt("PageNum");

                SpContents.SelectCommand = DataProvider.UserDao.GetSelectCommand(AuthRequest.GetQueryInt("groupId"), AuthRequest.GetQueryString("keyword"), AuthRequest.GetQueryInt("creationDate"), AuthRequest.GetQueryInt("lastActivityDate"), AuthRequest.GetQueryInt("loginCount"), AuthRequest.GetQueryString("searchType"));
            }

            RptContents.ItemDataBound += rptContents_ItemDataBound;
            SpContents.OrderByString   = "ORDER BY IsChecked, Id DESC";

            _lockType = EUserLockTypeUtils.GetEnumType(ConfigManager.SystemConfigInfo.UserLockLoginType);

            if (IsPostBack)
            {
                return;
            }

            VerifySystemPermissions(ConfigManager.SettingsPermissions.User);

            DdlGroupId.Items.Add(new ListItem("<全部用户组>", "-1"));
            foreach (var groupInfo in UserGroupManager.GetUserGroupInfoList())
            {
                DdlGroupId.Items.Add(new ListItem(groupInfo.GroupName, groupInfo.Id.ToString()));
            }

            //添加隐藏属性
            DdlSearchType.Items.Add(new ListItem("用户Id", UserAttribute.Id));
            DdlSearchType.Items.Add(new ListItem("用户名", UserAttribute.UserName));
            DdlSearchType.Items.Add(new ListItem("邮箱", UserAttribute.Email));
            DdlSearchType.Items.Add(new ListItem("手机", UserAttribute.Mobile));

            //默认选择用户名
            DdlSearchType.SelectedValue = UserAttribute.UserName;

            if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("groupId")))
            {
                ControlUtils.SelectSingleItem(DdlGroupId, AuthRequest.GetQueryString("groupId"));
            }
            if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("searchType")))
            {
                ControlUtils.SelectSingleItem(DdlSearchType, AuthRequest.GetQueryString("searchType"));
            }
            if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("pageNum")))
            {
                ControlUtils.SelectSingleItem(DdlPageNum, AuthRequest.GetQueryString("pageNum"));
            }
            if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("loginCount")))
            {
                ControlUtils.SelectSingleItem(DdlLoginCount, AuthRequest.GetQueryString("loginCount"));
            }
            if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("keyword")))
            {
                TbKeyword.Text = AuthRequest.GetQueryString("keyword");
            }
            if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("creationDate")))
            {
                ControlUtils.SelectSingleItem(DdlCreationDate, AuthRequest.GetQueryString("creationDate"));
            }
            if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("lastActivityDate")))
            {
                ControlUtils.SelectSingleItem(DdlLastActivityDate, AuthRequest.GetQueryString("lastActivityDate"));
            }

            var backgroundUrl = GetRedirectUrl();

            BtnCheck.Attributes.Add("onclick",
                                    PageUtils.GetRedirectStringWithCheckBoxValueAndAlert($"{backgroundUrl}?Check=True", "UserIDCollection",
                                                                                         "UserIDCollection", "请选择需要审核的会员!", "此操作将审核通过所选会员,确认吗?"));

            BtnAdd.Attributes.Add("onclick",
                                  $"location.href='{PageUserAdd.GetRedirectUrlToAdd(PageUrl)}';return false;");

            BtnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
                                       $"{backgroundUrl}?Lock=True", "UserIDCollection", "UserIDCollection", "请选择需要锁定的会员!", "此操作将锁定所选会员,确认吗?"));

            BtnUnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
                                         $"{backgroundUrl}?UnLock=True", "UserIDCollection", "UserIDCollection", "请选择需要解除锁定的会员!", "此操作将解除锁定所选会员,确认吗?"));

            BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
                                         $"{backgroundUrl}?Delete=True", "UserIDCollection", "UserIDCollection", "请选择需要删除的会员!", "此操作将删除所选会员,确认吗?"));

            BtnExport.Attributes.Add("onclick", ModalUserExport.GetOpenWindowString());

            SpContents.DataBind();
        }
示例#8
0
        public IHttpActionResult Submit([FromBody] UserGroupInfo itemObj)
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.User))
                {
                    return(Unauthorized());
                }

                if (itemObj.Id == -1)
                {
                    if (UserGroupManager.IsExists(itemObj.GroupName))
                    {
                        return(BadRequest("保存失败,已存在相同名称的用户组!"));
                    }

                    var groupInfo = new UserGroupInfo
                    {
                        GroupName = itemObj.GroupName,
                        AdminName = itemObj.AdminName
                    };

                    DataProvider.UserGroupDao.Insert(groupInfo);

                    request.AddAdminLog("新增用户组", $"用户组:{groupInfo.GroupName}");
                }
                else if (itemObj.Id == 0)
                {
                    ConfigManager.SystemConfigInfo.UserDefaultGroupAdminName = itemObj.AdminName;

                    DataProvider.ConfigDao.Update(ConfigManager.Instance);

                    UserGroupManager.ClearCache();

                    request.AddAdminLog("修改用户组", "用户组:默认用户组");
                }
                else if (itemObj.Id > 0)
                {
                    var groupInfo = UserGroupManager.GetUserGroupInfo(itemObj.Id);

                    if (groupInfo.GroupName != itemObj.GroupName && UserGroupManager.IsExists(itemObj.GroupName))
                    {
                        return(BadRequest("保存失败,已存在相同名称的用户组!"));
                    }

                    groupInfo.GroupName = itemObj.GroupName;
                    groupInfo.AdminName = itemObj.AdminName;

                    DataProvider.UserGroupDao.Update(groupInfo);

                    request.AddAdminLog("修改用户组", $"用户组:{groupInfo.GroupName}");
                }

                return(Ok(new
                {
                    Value = UserGroupManager.GetUserGroupInfoList()
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }