Esempio n. 1
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();
        }
Esempio n. 2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            if (Body.IsQueryExists("Delete"))
            {
                var userIdList = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("UserIDCollection"));
                try
                {
                    foreach (var userId in userIdList)
                    {
                        DataProvider.UserDao.Delete(userId);
                    }

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

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

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

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

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

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

            SpContents.ControlToPaginate = RptContents;

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

                SpContents.SelectCommand = DataProvider.UserDao.GetSelectCommand(true);
            }
            else
            {
                SpContents.ItemsPerPage  = Body.GetQueryInt("PageNum") == 0 ? StringUtils.Constants.PageSize : Body.GetQueryInt("PageNum");
                SpContents.SelectCommand = DataProvider.UserDao.GetSelectCommand(Body.GetQueryString("Keyword"), Body.GetQueryInt("CreationDate"), Body.GetQueryInt("LastActivityDate"), true, Body.GetQueryInt("LoginCount"), Body.GetQueryString("SearchType"));
            }

            RptContents.ItemDataBound += rptContents_ItemDataBound;
            SpContents.SortField       = DataProvider.UserDao.GetSortFieldName();
            SpContents.SortMode        = SortMode.DESC;

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

            if (IsPostBack)
            {
                return;
            }

            VerifyAdministratorPermissions(ConfigManager.Permissions.Settings.User);

            //添加隐藏属性
            DdlSearchType.Items.Add(new ListItem("用户ID", "userID"));
            DdlSearchType.Items.Add(new ListItem("用户名", "userName"));
            DdlSearchType.Items.Add(new ListItem("邮箱", "email"));
            DdlSearchType.Items.Add(new ListItem("手机", "mobile"));

            //默认选择用户名
            DdlSearchType.SelectedValue = "userName";

            if (!string.IsNullOrEmpty(Body.GetQueryString("SearchType")))
            {
                ControlUtils.SelectSingleItem(DdlSearchType, Body.GetQueryString("SearchType"));
            }
            if (!string.IsNullOrEmpty(Body.GetQueryString("PageNum")))
            {
                ControlUtils.SelectSingleItem(DdlPageNum, Body.GetQueryString("PageNum"));
            }
            if (!string.IsNullOrEmpty(Body.GetQueryString("LoginCount")))
            {
                ControlUtils.SelectSingleItem(DdlLoginCount, Body.GetQueryString("LoginCount"));
            }
            if (!string.IsNullOrEmpty(Body.GetQueryString("Keyword")))
            {
                TbKeyword.Text = Body.GetQueryString("Keyword");
            }
            if (!string.IsNullOrEmpty(Body.GetQueryString("CreationDate")))
            {
                ControlUtils.SelectSingleItem(DdlCreationDate, Body.GetQueryString("CreationDate"));
            }
            if (!string.IsNullOrEmpty(Body.GetQueryString("LastActivityDate")))
            {
                ControlUtils.SelectSingleItem(DdlLastActivityDate, Body.GetQueryString("LastActivityDate"));
            }

            var backgroundUrl = GetRedirectUrl();

            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();
        }