private IList<TokenRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount) { Array tokenRowData = null; Array tokenRowDataRange = Array.CreateInstance(typeof(TokenRowData), maximumRows); resultCount = 0; if (maximumRows == 0) return new List<TokenRowData>(); using(AuthorityManagement service = new AuthorityManagement()) { IList<AuthorityTokenSummary> tokens = service.ListAuthorityTokens(); List<TokenRowData> tokenRows = CollectionUtils.Map<AuthorityTokenSummary, TokenRowData>( tokens, delegate(AuthorityTokenSummary token) { TokenRowData row = new TokenRowData(token); return row; }); tokenRowData = CollectionUtils.ToArray(tokenRows); int copyLength = adjustCopyLength(startRowIndex, maximumRows, tokenRowData.Length); Array.Copy(tokenRowData, startRowIndex, tokenRowDataRange, 0, copyLength); if(copyLength < tokenRowDataRange.Length) { tokenRowDataRange = resizeArray(tokenRowDataRange, copyLength); } }; if (tokenRowData != null) { resultCount = tokenRowData.Length; } return CollectionUtils.Cast<TokenRowData>(tokenRowDataRange); }
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); }
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; } }
protected void Page_Load(object sender, EventArgs e) { PasswordConfirmDialog.OKClicked += PasswordConfirmDialog_OKClicked; if (Page.IsPostBack == false) { using (AuthorityManagement service = new AuthorityManagement()) { IList<AuthorityTokenSummary> tokens = service.ListAuthorityTokens(); IList<ListItem> items = CollectionUtils.Map<AuthorityTokenSummary, ListItem>( tokens, delegate(AuthorityTokenSummary token) { return new ListItem(token.Description, token.Name); }); TokenCheckBoxList.Items.AddRange(CollectionUtils.ToArray(items)); }; } else { if (ViewState["SaveDataGroup"] != null) _saveDataGroup = (bool)ViewState["SaveDataGroup"]; if (ViewState["EditMode"] != null) _editMode = (bool) ViewState[ "EditMode"]; if (ViewState[ "EditedUserGroup"] != null) _userGroup = ViewState[ "EditedUserGroup"] as UserGroupRowData; } }
private DataAccessGroupInfoCollection LoadDataAccessGroupInfo() { using (AuthorityManagement service = new AuthorityManagement()) { var dataGroups = service.ListDataAccessAuthorityGroupDetails(); // Include those that are not data access groups but have access to all partitions var accessToAllPartitionGroups = CollectionUtils.Select(service.ListAllAuthorityGroupDetails(), g => HasToken(g.AuthorityTokens, ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllPartitions)); var combinedGroups = new List<AuthorityGroupDetail>(); combinedGroups.AddRange(dataGroups); foreach(var g in accessToAllPartitionGroups){ if (combinedGroups.Find(item=>item.AuthorityGroupRef.Equals(g.AuthorityGroupRef, true))==null) { combinedGroups.Add(g); } } //convert to DataAccessGroupInfo for sorting var list = new DataAccessGroupInfoCollection(CollectionUtils.Map<AuthorityGroupDetail, DataAccessGroupInfo>(combinedGroups, (group) => { var authorityRecordRef = group.AuthorityGroupRef.ToString(false, false); var fullServerPartitionAccess = HasToken(group.AuthorityTokens, ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllPartitions); var allStudiesAccess = HasToken(group.AuthorityTokens, ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllStudies); return new DataAccessGroupInfo(authorityRecordRef, group.Name) { Description = group.Description, HasAccessToCurrentPartition = fullServerPartitionAccess || (Partition != null && Partition.Key != null && Partition.IsAuthorityGroupAllowed(authorityRecordRef)), CanAccessAllPartitions = fullServerPartitionAccess, CanAccessAllStudies = allStudiesAccess }; })); list.Sort(new DatagroupComparer()); return list; } }
public bool UpdateTokens(List<TokenRowData> tokens) { bool success; using(AuthorityManagement service = new AuthorityManagement()) { List<AuthorityTokenSummary> tokenList = new List<AuthorityTokenSummary>(); foreach(TokenRowData token in tokens) { tokenList.Add(new AuthorityTokenSummary(token.Name, token.Description)); } service.ImportAuthorityTokens(tokenList); success = true; } //TODO: Catch exception? return success; }
public void DeleteUserGroup(UserGroupRowData userGroup, bool checkIfGroupIsEmpty) { using (AuthorityManagement service = new AuthorityManagement()) { try { EntityRef entityRef = new EntityRef(userGroup.Ref); service.DeleteAuthorityGroup(entityRef, checkIfGroupIsEmpty); } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "Unexpected exception deleting user group: {0}.", userGroup.Name); throw; } } }
public bool UpdateUserGroup(UserGroupRowData userGroup) { bool success; using(AuthorityManagement service = new AuthorityManagement()) { AuthorityGroupDetail detail = new AuthorityGroupDetail { AuthorityGroupRef = new EntityRef(userGroup.Ref), Name = userGroup.Name, Description = userGroup.Description, DataGroup = userGroup.DataGroup }; foreach(TokenSummary token in userGroup.Tokens) { detail.AuthorityTokens.Add(new AuthorityTokenSummary(token.Name, token.Description)); } service.UpdateAuthorityGroup(detail, userGroup.Password); success = true; } //TODO: Catch exception? return success; }
public bool AddUserGroup(UserGroupRowData userGroup) { bool success; using(AuthorityManagement service = new AuthorityManagement()) { List<AuthorityTokenSummary> tokens = new List<AuthorityTokenSummary>(); foreach (TokenSummary token in userGroup.Tokens) { tokens.Add(new AuthorityTokenSummary(token.Name, token.Description)); } service.AddAuthorityGroup(userGroup.Name, userGroup.Description, userGroup.DataGroup, tokens); success = true; } //TODO: Catch exception? return success; }
public bool ExistsUsergroup(string usergroupName) { bool exists = false; using (AuthorityManagement 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; }