Ejemplo n.º 1
0
        public static string GetRolesHtml(string userName)
        {
            var isConsoleAdministrator = false;
            var isSystemAdministrator  = false;
            var arraylist = new ArrayList();
            var roles     = DataProvider.AdministratorsInRolesDao.GetRolesForUser(userName);

            foreach (var role in roles)
            {
                if (!EPredefinedRoleUtils.IsPredefinedRole(role))
                {
                    arraylist.Add(role);
                }
                else
                {
                    if (EPredefinedRoleUtils.Equals(EPredefinedRole.ConsoleAdministrator, role))
                    {
                        isConsoleAdministrator = true;
                        break;
                    }
                    if (EPredefinedRoleUtils.Equals(EPredefinedRole.SystemAdministrator, role))
                    {
                        isSystemAdministrator = true;
                        break;
                    }
                }
            }

            var retval = string.Empty;

            if (isConsoleAdministrator)
            {
                retval += EPredefinedRoleUtils.GetText(EPredefinedRole.ConsoleAdministrator);
            }
            else if (isSystemAdministrator)
            {
                retval += EPredefinedRoleUtils.GetText(EPredefinedRole.SystemAdministrator);
            }
            else
            {
                retval += TranslateUtils.ObjectCollectionToString(arraylist);
            }
            return(retval);
        }
Ejemplo n.º 2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var pageNum                = AuthRequest.GetQueryInt("pageNum") == 0 ? 30 : AuthRequest.GetQueryInt("pageNum");
            var keyword                = AuthRequest.GetQueryString("keyword");
            var roleName               = AuthRequest.GetQueryString("roleName");
            var lastActivityDate       = AuthRequest.GetQueryInt("lastActivityDate");
            var isConsoleAdministrator = AuthRequest.AdminPermissions.IsConsoleAdministrator;
            var adminName              = AuthRequest.AdminName;
            var order        = AuthRequest.IsQueryExists("order") ? AuthRequest.GetQueryString("order") : nameof(AdministratorInfo.UserName);
            var departmentId = AuthRequest.GetQueryInt("departmentId");
            var areaId       = AuthRequest.GetQueryInt("areaId");

            if (AuthRequest.IsQueryExists("Delete"))
            {
                var userNameCollection = AuthRequest.GetQueryString("UserNameCollection");
                try
                {
                    var userNameArrayList = TranslateUtils.StringCollectionToStringList(userNameCollection);
                    foreach (var userName in userNameArrayList)
                    {
                        DataProvider.AdministratorDao.Delete(userName);
                    }

                    AuthRequest.AddAdminLog("删除管理员", $"管理员:{userNameCollection}");

                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }
            else if (AuthRequest.IsQueryExists("Lock"))
            {
                var userNameCollection = AuthRequest.GetQueryString("UserNameCollection");
                try
                {
                    var userNameList = TranslateUtils.StringCollectionToStringList(userNameCollection);
                    DataProvider.AdministratorDao.Lock(userNameList);

                    AuthRequest.AddAdminLog("锁定管理员", $"管理员:{userNameCollection}");

                    SuccessMessage("成功锁定所选管理员!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "锁定所选管理员失败!");
                }
            }
            else if (AuthRequest.IsQueryExists("UnLock"))
            {
                var userNameCollection = AuthRequest.GetQueryString("UserNameCollection");
                try
                {
                    var userNameList = TranslateUtils.StringCollectionToStringList(userNameCollection);
                    DataProvider.AdministratorDao.UnLock(userNameList);

                    AuthRequest.AddAdminLog("解除锁定管理员", $"管理员:{userNameCollection}");

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

            PgContents.Param = new PagerParam
            {
                ControlToPaginate = RptContents,
                TableName         = DataProvider.AdministratorDao.TableName,
                PageSize          = pageNum,
                Page              = AuthRequest.GetQueryInt(Pager.QueryNamePage, 1),
                OrderSqlString    = DataProvider.AdministratorDao.GetOrderSqlString(order),
                ReturnColumnNames = SqlUtils.Asterisk,
                WhereSqlString    = DataProvider.AdministratorDao.GetWhereSqlString(isConsoleAdministrator, adminName, keyword, roleName, lastActivityDate, departmentId, areaId)
            };

            PgContents.Param.TotalCount =
                DataProvider.DatabaseDao.GetPageTotalCount(DataProvider.AdministratorDao.TableName, PgContents.Param.WhereSqlString);

            RptContents.ItemDataBound += RptContents_ItemDataBound;

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

            if (IsPostBack)
            {
                return;
            }

            VerifySystemPermissions(ConfigManager.SettingsPermissions.Admin);

            var theListItem = new ListItem("全部", string.Empty)
            {
                Selected = true
            };

            DdlRoleName.Items.Add(theListItem);

            var allRoles = AuthRequest.AdminPermissions.IsConsoleAdministrator ? DataProvider.RoleDao.GetRoleNameList() : DataProvider.RoleDao.GetRoleNameListByCreatorUserName(AuthRequest.AdminName);

            var allPredefinedRoles = EPredefinedRoleUtils.GetAllPredefinedRoleName();

            foreach (var theRoleName in allRoles)
            {
                if (allPredefinedRoles.Contains(theRoleName))
                {
                    var listitem = new ListItem(EPredefinedRoleUtils.GetText(EPredefinedRoleUtils.GetEnumType(theRoleName)), theRoleName);
                    DdlRoleName.Items.Add(listitem);
                }
                else
                {
                    var listitem = new ListItem(theRoleName, theRoleName);
                    DdlRoleName.Items.Add(listitem);
                }
            }

            DdlDepartmentId.Items.Add(new ListItem("<所有部门>", "0"));
            var departmentIdList = DepartmentManager.GetDepartmentIdList();

            foreach (var theDepartmentId in departmentIdList)
            {
                var departmentInfo = DepartmentManager.GetDepartmentInfo(theDepartmentId);
                DdlDepartmentId.Items.Add(new ListItem(GetTreeItem(departmentInfo.DepartmentName, departmentInfo.ParentsCount, departmentInfo.IsLastNode, _parentsCountDictOfDepartment), theDepartmentId.ToString()));
            }
            ControlUtils.SelectSingleItem(DdlDepartmentId, departmentId.ToString());

            DdlAreaId.Items.Add(new ListItem("<全部区域>", "0"));
            var areaIdList = AreaManager.GetAreaIdList();

            foreach (var theAreaId in areaIdList)
            {
                var areaInfo = AreaManager.GetAreaInfo(theAreaId);
                DdlAreaId.Items.Add(new ListItem(GetTreeItem(areaInfo.AreaName, areaInfo.ParentsCount, areaInfo.IsLastNode, _parentsCountDictOfArea), theAreaId.ToString()));
            }
            ControlUtils.SelectSingleItem(DdlAreaId, areaId.ToString());

            ControlUtils.SelectSingleItem(DdlRoleName, roleName);
            ControlUtils.SelectSingleItem(DdlPageNum, pageNum.ToString());
            TbKeyword.Text = keyword;
            ControlUtils.SelectSingleItem(DdlDepartmentId, departmentId.ToString());
            ControlUtils.SelectSingleItem(DdlAreaId, areaId.ToString());
            ControlUtils.SelectSingleItem(DdlLastActivityDate, lastActivityDate.ToString());
            ControlUtils.SelectSingleItem(DdlOrder, order);

            PgContents.DataBind();

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

            var urlAdministrator = GetRedirectUrl();

            BtnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "?Lock=True", "UserNameCollection", "UserNameCollection", "请选择需要锁定的管理员!", "此操作将锁定所选管理员,确认吗?"));

            BtnUnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "?UnLock=True", "UserNameCollection", "UserNameCollection", "请选择需要解除锁定的管理员!", "此操作将解除锁定所选管理员,确认吗?"));

            BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "?Delete=True", "UserNameCollection", "UserNameCollection", "请选择需要删除的管理员!", "此操作将删除所选管理员,确认吗?"));
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.Admin))
                {
                    return(Unauthorized());
                }

                var roles = new List <KeyValuePair <string, string> >();

                var roleNameList = request.AdminPermissionsImpl.IsConsoleAdministrator ? DataProvider.RoleDao.GetRoleNameList() : DataProvider.RoleDao.GetRoleNameListByCreatorUserName(request.AdminName);

                var predefinedRoles = EPredefinedRoleUtils.GetAllPredefinedRoleName();
                foreach (var predefinedRole in predefinedRoles)
                {
                    roles.Add(new KeyValuePair <string, string>(predefinedRole, EPredefinedRoleUtils.GetText(EPredefinedRoleUtils.GetEnumType(predefinedRole))));
                }
                foreach (var roleName in roleNameList)
                {
                    if (!predefinedRoles.Contains(roleName))
                    {
                        roles.Add(new KeyValuePair <string, string>(roleName, roleName));
                    }
                }

                var role             = request.GetQueryString("role");
                var order            = request.GetQueryString("order");
                var lastActivityDate = request.GetQueryInt("lastActivityDate");
                var keyword          = request.GetQueryString("keyword");
                var offset           = request.GetQueryInt("offset");
                var limit            = request.GetQueryInt("limit");

                var isSuperAdmin    = request.AdminPermissions.IsSuperAdmin();
                var creatorUserName = isSuperAdmin ? string.Empty : request.AdminName;
                var count           = DataProvider.AdministratorDao.GetCount(creatorUserName, role, order, lastActivityDate,
                                                                             keyword);
                var administratorInfoList = DataProvider.AdministratorDao.GetAdministrators(creatorUserName, role, order, lastActivityDate, keyword, offset, limit);
                var administrators        = new List <object>();
                foreach (var administratorInfo in administratorInfoList)
                {
                    administrators.Add(new
                    {
                        administratorInfo.Id,
                        administratorInfo.AvatarUrl,
                        administratorInfo.UserName,
                        DisplayName = string.IsNullOrEmpty(administratorInfo.DisplayName)
                            ? administratorInfo.UserName
                            : administratorInfo.DisplayName,
                        administratorInfo.Mobile,
                        administratorInfo.LastActivityDate,
                        administratorInfo.CountOfLogin,
                        administratorInfo.Locked,
                        Roles = AdminManager.GetRoles(administratorInfo.UserName)
                    });
                }

                return(Ok(new
                {
                    Value = administrators,
                    Count = count,
                    Roles = roles,
                    IsSuperAdmin = request.AdminPermissions.IsSuperAdmin(),
                    request.AdminId
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 4
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var permissioins = PermissionsManager.GetPermissions(Body.AdministratorName);


            _departmentId = Body.GetQueryInt("departmentID");
            var areaId = Body.GetQueryInt("areaID");

            if (_departmentId > 0)
            {
                _departmentInfo = DepartmentManager.GetDepartmentInfo(_departmentId);
            }

            if (Body.IsQueryExists("Delete"))
            {
                var userNameCollection = Body.GetQueryString("UserNameCollection");
                try
                {
                    var userNameArrayList = TranslateUtils.StringCollectionToStringList(userNameCollection);
                    foreach (var userName in userNameArrayList)
                    {
                        BaiRongDataProvider.AdministratorDao.Delete(userName);
                    }

                    Body.AddAdminLog("删除管理员", $"管理员:{userNameCollection}");

                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }
            else if (Body.IsQueryExists("Lock"))
            {
                var userNameCollection = Body.GetQueryString("UserNameCollection");
                try
                {
                    var userNameList = TranslateUtils.StringCollectionToStringList(userNameCollection);
                    BaiRongDataProvider.AdministratorDao.Lock(userNameList);

                    Body.AddAdminLog("锁定管理员", $"管理员:{userNameCollection}");

                    SuccessMessage("成功锁定所选管理员!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "锁定所选管理员失败!");
                }
            }
            else if (Body.IsQueryExists("UnLock"))
            {
                var userNameCollection = Body.GetQueryString("UserNameCollection");
                try
                {
                    var userNameList = TranslateUtils.StringCollectionToStringList(userNameCollection);
                    BaiRongDataProvider.AdministratorDao.UnLock(userNameList);

                    Body.AddAdminLog("解除锁定管理员", $"管理员:{userNameCollection}");

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

            spContents.ControlToPaginate = rptContents;
            spContents.ItemsPerPage      = StringUtils.Constants.PageSize;

            if (string.IsNullOrEmpty(Body.GetQueryString("PageNum")))
            {
                spContents.ItemsPerPage = TranslateUtils.ToInt(PageNum.SelectedValue) == 0 ? StringUtils.Constants.PageSize : TranslateUtils.ToInt(PageNum.SelectedValue);

                spContents.SelectCommand = BaiRongDataProvider.AdministratorDao.GetSelectCommandSite(permissioins.IsConsoleAdministrator, Body.AdministratorName, _departmentId, Body.AdministratorInfo.PublishmentSystemId);
                spContents.SortField     = BaiRongDataProvider.AdministratorDao.GetSortFieldName();
                spContents.SortMode      = SortMode.ASC;
            }
            else
            {
                spContents.ItemsPerPage  = Body.GetQueryInt("PageNum") == 0 ? StringUtils.Constants.PageSize : Body.GetQueryInt("PageNum");
                spContents.SelectCommand = BaiRongDataProvider.AdministratorDao.GetSelectCommand(Body.GetQueryString("Keyword"), Body.GetQueryString("RoleName"), Body.GetQueryInt("LastActivityDate"), permissioins.IsConsoleAdministrator, Body.AdministratorName, _departmentId, Body.GetQueryInt("AreaID"));
                spContents.SortField     = Body.GetQueryString("Order");
                spContents.SortMode      = StringUtils.EqualsIgnoreCase(spContents.SortField, "UserName") ? SortMode.ASC : SortMode.DESC;
            }

            rptContents.ItemDataBound += rptContents_ItemDataBound;

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

            if (IsPostBack)
            {
                return;
            }

            BreadCrumbAdmin(AppManager.Admin.LeftMenu.AdminManagement, "管理员管理", AppManager.Admin.Permission.AdminManagement);

            var theListItem = new ListItem("全部", string.Empty)
            {
                Selected = true
            };

            RoleName.Items.Add(theListItem);

            var allRoles = permissioins.IsConsoleAdministrator ? BaiRongDataProvider.RoleDao.GetAllRoles() : BaiRongDataProvider.RoleDao.GetAllRolesByCreatorUserName(Body.AdministratorName);

            var allPredefinedRoles = EPredefinedRoleUtils.GetAllPredefinedRoleName();

            foreach (var roleName in allRoles)
            {
                if (allPredefinedRoles.Contains(roleName))
                {
                    var listitem = new ListItem(EPredefinedRoleUtils.GetText(EPredefinedRoleUtils.GetEnumType(roleName)), roleName);
                    RoleName.Items.Add(listitem);
                }
            }
            foreach (var roleName in allRoles)
            {
                if (!allPredefinedRoles.Contains(roleName))
                {
                    var listitem = new ListItem(roleName, roleName);
                    RoleName.Items.Add(listitem);
                }
            }

            ddlAreaID.Items.Add(new ListItem("<全部区域>", "0"));
            var areaIdList = AreaManager.GetAreaIdList();
            var count      = areaIdList.Count;

            _isLastNodeArrayOfArea = new bool[count];
            foreach (var theAreaId in areaIdList)
            {
                var areaInfo = AreaManager.GetAreaInfo(theAreaId);
                var listitem = new ListItem(GetArea(areaInfo.AreaId, areaInfo.AreaName, areaInfo.ParentsCount, areaInfo.IsLastNode), theAreaId.ToString());
                if (areaId == theAreaId)
                {
                    listitem.Selected = true;
                }
                ddlAreaID.Items.Add(listitem);
            }

            if (Body.IsQueryExists("PageNum"))
            {
                ControlUtils.SelectListItems(RoleName, Body.GetQueryString("RoleName"));
                ControlUtils.SelectListItems(PageNum, Body.GetQueryString("PageNum"));
                Keyword.Text = Body.GetQueryString("Keyword");
                ControlUtils.SelectListItems(ddlAreaID, Body.GetQueryString("AreaID"));
                ControlUtils.SelectListItems(LastActivityDate, Body.GetQueryString("LastActivityDate"));
                ControlUtils.SelectListItems(Order, Body.GetQueryString("Order"));
            }

            var urlAdd = PageAdministratorAdd.GetRedirectUrlToAdd(_departmentId);

            AddButton.Attributes.Add("onclick", $@"location.href='{urlAdd}';return false;");

            var urlAdministrator = GetRedirectUrl(_departmentId);

            Lock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "&Lock=True", "UserNameCollection", "UserNameCollection", "请选择需要锁定的管理员!", "此操作将锁定所选管理员,确认吗?"));

            UnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "&UnLock=True", "UserNameCollection", "UserNameCollection", "请选择需要解除锁定的管理员!", "此操作将解除锁定所选管理员,确认吗?"));

            Delete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "&Delete=True", "UserNameCollection", "UserNameCollection", "请选择需要删除的管理员!", "此操作将删除所选管理员,确认吗?"));

            spContents.DataBind();
        }
Ejemplo n.º 5
0
        public static void CreatePredefinedRoles()
        {
            var allPredefinedRoles = EPredefinedRoleUtils.GetAllPredefinedRole();

            foreach (EPredefinedRole enumRole in allPredefinedRoles)
            {
                BaiRongDataProvider.RoleDao.InsertRole(EPredefinedRoleUtils.GetValue(enumRole), string.Empty, EPredefinedRoleUtils.GetText(enumRole));
            }
        }
Ejemplo n.º 6
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var permissioins = PermissionsManager.GetPermissions(Body.AdminName);

            var departmentId = Body.GetQueryInt("departmentId");
            var areaId       = Body.GetQueryInt("areaId");

            if (Body.IsQueryExists("Delete"))
            {
                var userNameCollection = Body.GetQueryString("UserNameCollection");
                try
                {
                    var userNameArrayList = TranslateUtils.StringCollectionToStringList(userNameCollection);
                    foreach (var userName in userNameArrayList)
                    {
                        DataProvider.AdministratorDao.Delete(userName);
                    }

                    Body.AddAdminLog("删除管理员", $"管理员:{userNameCollection}");

                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }
            else if (Body.IsQueryExists("Lock"))
            {
                var userNameCollection = Body.GetQueryString("UserNameCollection");
                try
                {
                    var userNameList = TranslateUtils.StringCollectionToStringList(userNameCollection);
                    DataProvider.AdministratorDao.Lock(userNameList);

                    Body.AddAdminLog("锁定管理员", $"管理员:{userNameCollection}");

                    SuccessMessage("成功锁定所选管理员!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "锁定所选管理员失败!");
                }
            }
            else if (Body.IsQueryExists("UnLock"))
            {
                var userNameCollection = Body.GetQueryString("UserNameCollection");
                try
                {
                    var userNameList = TranslateUtils.StringCollectionToStringList(userNameCollection);
                    DataProvider.AdministratorDao.UnLock(userNameList);

                    Body.AddAdminLog("解除锁定管理员", $"管理员:{userNameCollection}");

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

            SpContents.ControlToPaginate = RptContents;
            SpContents.ItemsPerPage      = StringUtils.Constants.PageSize;

            if (string.IsNullOrEmpty(Body.GetQueryString("pageNum")))
            {
                SpContents.ItemsPerPage = TranslateUtils.ToInt(DdlPageNum.SelectedValue) == 0 ? StringUtils.Constants.PageSize : TranslateUtils.ToInt(DdlPageNum.SelectedValue);

                SpContents.SelectCommand = DataProvider.AdministratorDao.GetSelectCommand(permissioins.IsConsoleAdministrator, Body.AdminName);
                SpContents.SortField     = DataProvider.AdministratorDao.GetSortFieldName();
                SpContents.SortMode      = SortMode.ASC;
            }
            else
            {
                SpContents.ItemsPerPage  = Body.GetQueryInt("pageNum") == 0 ? StringUtils.Constants.PageSize : Body.GetQueryInt("pageNum");
                SpContents.SelectCommand = DataProvider.AdministratorDao.GetSelectCommand(Body.GetQueryString("keyword"), Body.GetQueryString("roleName"), Body.GetQueryInt("lastActivityDate"), permissioins.IsConsoleAdministrator, Body.AdminName, Body.GetQueryInt("departmentId"), Body.GetQueryInt("areaId"));
                SpContents.SortField     = Body.GetQueryString("order");
                SpContents.SortMode      = StringUtils.EqualsIgnoreCase(SpContents.SortField, nameof(AdministratorInfo.UserName)) ? SortMode.ASC : SortMode.DESC;
            }

            RptContents.ItemDataBound += RptContents_ItemDataBound;

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

            if (IsPostBack)
            {
                return;
            }

            VerifyAdministratorPermissions(ConfigManager.Permissions.Settings.Admin);

            var theListItem = new ListItem("全部", string.Empty)
            {
                Selected = true
            };

            DdlRoleName.Items.Add(theListItem);

            var allRoles = permissioins.IsConsoleAdministrator ? DataProvider.RoleDao.GetAllRoles() : DataProvider.RoleDao.GetAllRolesByCreatorUserName(Body.AdminName);

            var allPredefinedRoles = EPredefinedRoleUtils.GetAllPredefinedRoleName();

            foreach (var roleName in allRoles)
            {
                if (allPredefinedRoles.Contains(roleName))
                {
                    var listitem = new ListItem(EPredefinedRoleUtils.GetText(EPredefinedRoleUtils.GetEnumType(roleName)), roleName);
                    DdlRoleName.Items.Add(listitem);
                }
            }
            foreach (var roleName in allRoles)
            {
                if (!allPredefinedRoles.Contains(roleName))
                {
                    var listitem = new ListItem(roleName, roleName);
                    DdlRoleName.Items.Add(listitem);
                }
            }

            DdlDepartmentId.Items.Add(new ListItem("<所有部门>", "0"));
            var departmentIdList = DepartmentManager.GetDepartmentIdList();
            var count            = departmentIdList.Count;

            _isLastNodeArrayOfDepartment = new bool[count];
            foreach (var theDepartmentId in departmentIdList)
            {
                var departmentInfo = DepartmentManager.GetDepartmentInfo(theDepartmentId);
                DdlDepartmentId.Items.Add(new ListItem(GetTreeItem(departmentInfo.Id, departmentInfo.DepartmentName, departmentInfo.ParentsCount, departmentInfo.IsLastNode, _isLastNodeArrayOfDepartment), theDepartmentId.ToString()));
            }
            ControlUtils.SelectSingleItem(DdlDepartmentId, departmentId.ToString());

            DdlAreaId.Items.Add(new ListItem("<全部区域>", "0"));
            var areaIdList = AreaManager.GetAreaIdList();

            count = areaIdList.Count;
            _isLastNodeArrayOfArea = new bool[count];
            foreach (var theAreaId in areaIdList)
            {
                var areaInfo = AreaManager.GetAreaInfo(theAreaId);
                DdlAreaId.Items.Add(new ListItem(GetTreeItem(areaInfo.Id, areaInfo.AreaName, areaInfo.ParentsCount, areaInfo.IsLastNode, _isLastNodeArrayOfArea), theAreaId.ToString()));
            }
            ControlUtils.SelectSingleItem(DdlAreaId, areaId.ToString());

            if (Body.IsQueryExists("pageNum"))
            {
                ControlUtils.SelectSingleItem(DdlRoleName, Body.GetQueryString("roleName"));
                ControlUtils.SelectSingleItem(DdlPageNum, Body.GetQueryString("pageNum"));
                TbKeyword.Text = Body.GetQueryString("keyword");
                ControlUtils.SelectSingleItem(DdlDepartmentId, Body.GetQueryString("departmentId"));
                ControlUtils.SelectSingleItem(DdlAreaId, Body.GetQueryString("areaId"));
                ControlUtils.SelectSingleItem(DdlLastActivityDate, Body.GetQueryString("lastActivityDate"));
                ControlUtils.SelectSingleItem(DdlOrder, Body.GetQueryString("order"));
            }

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

            var urlAdministrator = GetRedirectUrl();

            BtnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "?Lock=True", "UserNameCollection", "UserNameCollection", "请选择需要锁定的管理员!", "此操作将锁定所选管理员,确认吗?"));

            BtnUnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "?UnLock=True", "UserNameCollection", "UserNameCollection", "请选择需要解除锁定的管理员!", "此操作将解除锁定所选管理员,确认吗?"));

            BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "?Delete=True", "UserNameCollection", "UserNameCollection", "请选择需要删除的管理员!", "此操作将删除所选管理员,确认吗?"));

            SpContents.DataBind();
        }
Ejemplo n.º 7
0
        public static void CreatePredefinedRolesIfNotExists()
        {
            var allPredefinedRoles = EPredefinedRoleUtils.GetAllPredefinedRole();

            foreach (var enumRole in allPredefinedRoles)
            {
                if (!DataProvider.RoleDao.IsRoleExists(EPredefinedRoleUtils.GetValue(enumRole)))
                {
                    DataProvider.RoleDao.InsertRole(EPredefinedRoleUtils.GetValue(enumRole), string.Empty, EPredefinedRoleUtils.GetText(enumRole));
                }
            }
        }