protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { using (var service = new AuthorityManagement()) { IList <AuthorityGroupSummary> list = service.ListAllAuthorityGroups(); IList <ListItem> items = CollectionUtils.Map( list, delegate(AuthorityGroupSummary summary) { return(new ListItem(summary.Name, summary.AuthorityGroupRef.Serialize())); } ); UserGroupListBox.Items.AddRange(CollectionUtils.ToArray(items)); }; } else { if (ViewState["EditMode"] != null) { _editMode = (bool)ViewState["EditMode"]; } if (ViewState["EditedUser"] != null) { _user = ViewState["EditedUser"] as UserRowData; } } }
public bool ExistsUsergroup(string usergroupName) { bool exists = false; using (var service = new AuthorityManagement()) { IList <AuthorityGroupSummary> list = service.ListAllAuthorityGroups(); if (usergroupName != null) { foreach (AuthorityGroupSummary group in list) { if (group.Name.ToLower().Equals(usergroupName.ToLower())) { exists = true; break; } } } } return(exists); }
private IList <UserGroupRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount) { Array authorityRowData; Array authorityRowDataRange = Array.CreateInstance(typeof(UserGroupRowData), maximumRows); resultCount = 0; if (maximumRows == 0) { return(new List <UserGroupRowData>()); } using (AuthorityManagement service = new AuthorityManagement()) { IList <AuthorityGroupSummary> list = service.ListAllAuthorityGroups(); IList <AuthorityGroupSummary> filteredList = new List <AuthorityGroupSummary>(); if (!string.IsNullOrEmpty(GroupName)) { string matchString = GroupName; while (matchString.StartsWith("*") || matchString.StartsWith("?")) { matchString = matchString.Substring(1); } while (matchString.EndsWith("*") || matchString.EndsWith("?")) { matchString = matchString.Substring(0, matchString.Length - 1); } matchString = matchString.Replace("*", "[A-Za-z0-9]*"); matchString = matchString.Replace("?", "."); foreach (AuthorityGroupSummary group in list) { if (Regex.IsMatch(group.Name, matchString, RegexOptions.IgnoreCase)) { filteredList.Add(group); } } } else { filteredList = list; } List <UserGroupRowData> rows = CollectionUtils.Map <AuthorityGroupSummary, UserGroupRowData>( filteredList, delegate(AuthorityGroupSummary group) { UserGroupRowData row = new UserGroupRowData(service.LoadAuthorityGroupDetail(group.AuthorityGroupRef)); return(row); }); authorityRowData = CollectionUtils.ToArray(rows); int copyLength = adjustCopyLength(startRowIndex, maximumRows, authorityRowData.Length); Array.Copy(authorityRowData, startRowIndex, authorityRowDataRange, 0, copyLength); if (copyLength < authorityRowDataRange.Length) { authorityRowDataRange = resizeArray(authorityRowDataRange, copyLength); } }; resultCount = authorityRowData.Length; return(CollectionUtils.Cast <UserGroupRowData>(authorityRowDataRange)); }