//--------------------------------------------------------------------------------------------------------------------------------------------------------------- public static List <MGGroup> AllGroups() { // Get all the Groups List <MGGroup> allGroups = null; GroupOperations groupOps = null; try { groupOps = new GroupOperations(MGLApplicationSecurityInterface.Instance().DatabaseConfig); allGroups = groupOps.GetAllGroups(); } catch (Exception ex) { Logger.LogError(5, "Problem getting all groups at " + ex); return(null); } finally { if (groupOps != null) { groupOps.Finish(); } } return(allGroups); }
/// <summary> /// Gets list of all groups from database. /// </summary> /// <returns>List of MG Groups</returns> public List <MGGroup> GetAllGroups(bool isFilterOutSuperGroup) { List <MGGroup> allGroups = null; GroupOperations groupHelper = null; try { groupHelper = new GroupOperations(Lcf); allGroups = groupHelper.GetAllGroups(isFilterOutSuperGroup); if (allGroups == null) { Logger.LogError(5, "Error getting all groups from system where Filter Super Group is: " + isFilterOutSuperGroup); } if (allGroups.Count == 0) { Logger.LogWarning("No group found in system. Please check it...! "); } } catch (Exception ex) { Logger.LogError(5, "Error getting all groups from database at: " + ex); return(null); } finally { if (groupHelper != null) { groupHelper.Finish(); } } return(allGroups); }
public GroupPermissions GetUnassignedAnyGroupPermissions() { GroupPermissions groupPermissions = null; GroupOperations groupOps = null; try { groupOps = new GroupOperations(Lcf); Logger.Log("Getting group security permission key value pairs ..."); List <MGSecurityTag> groupContentList = groupOps.GetUnassignedAnyGroupContentDictionary(); if (groupContentList == null) { Logger.LogError(5, "Got NULL or empty list for group permissions that aren't assigned to to ANY group!"); return(null); } Logger.Log("Finished getting group security permission key value pairs."); groupPermissions = GetGroupPermissions(MGGroup.NO_GROUP, groupContentList); if (groupPermissions == null) { Logger.LogError(5, "Failed to get group permissions that aren't assigned to ANY group!"); return(null); } Logger.Log("Finished getting group permissions that aren't assigned to ANY group."); } catch (Exception ex) { Logger.LogError(5, "Error getting all group permissions at " + ex.StackTrace); groupPermissions = null; } finally { if (groupOps != null) { groupOps.Finish(); } } return(groupPermissions); }
public MGGroup GetGroup(int id) { MGGroup result = null; GroupOperations groupHelper = null; try { groupHelper = new GroupOperations(Lcf); result = groupHelper.GetGroup(id); if (result == null) { Logger.LogWarning("Null Group found in the database for group ID = " + id.ToString()); } } catch (Exception ex) { Logger.LogError(5, "Error getting a group given its ID from database at: " + ex); return(null); } finally { if (groupHelper != null) { groupHelper.Finish(); } } return(result); }
public MGGroup GetGroup(string name) { MGGroup result = null; GroupOperations groupHelper = null; Logger.Log("Start getting a group from databas where name of group is '" + name + "'."); try { groupHelper = new GroupOperations(Lcf); result = groupHelper.GetGroup(name); if (result == null) { Logger.LogWarning("Null Group found in the database for group Name = " + name); } } catch (Exception ex) { Logger.LogError(5, "Error getting a group from databas where name of group is '" + name + "'." + "at: " + ex); return(null); } finally { if (groupHelper != null) { groupHelper.Finish(); } } return(result); }
public Dictionary <int, GroupPermissions> GetAllGroupPermissions() { Logger.Log("Getting all group permissions ..."); Dictionary <int, GroupPermissions> allGroupPermissions = null; GroupOperations groupOps = null; try { // Extract the Application Level list of groups, along with the relevant cross references to Users and the content etc ... groupOps = new GroupOperations(Lcf); Logger.Log("Getting all groups ..."); List <MGGroup> allGroups = groupOps.GetAllGroups(); if (allGroups == null) { Logger.LogError(5, "Got NULL list for all groups, abandoning getting group permissions!"); return(null); } if (allGroups.Count == 0) { Logger.LogWarning("Got empty list for all groups, returning empty group permissions ..."); return(new Dictionary <int, GroupPermissions>()); } Logger.Log("Got all " + allGroups.Count + " groups."); Logger.Log("Getting group security permission key value pairs ..."); Dictionary <int, List <MGSecurityTag> > groupContentDict = groupOps.GroupContentDictionary(); if (groupContentDict == null) { Logger.LogError(5, "Got NULL list for groups->content lookup, abandoning getting group permissions!"); return(null); } Dictionary <int, List <MGSecurityTag> > groupDisplayDict = groupOps.GroupDisplayDictionary(); if (groupDisplayDict == null) { Logger.LogError(5, "Got NULL list for groups->display lookup, abandoning getting group permissions!"); return(null); } Dictionary <int, List <MGSecurityTag> > groupFunctionalityDict = groupOps.GroupFunctionalityDictionary(); if (groupFunctionalityDict == null) { Logger.LogError(5, "Got NULL list for groups->functionality lookup, abandoning getting group permissions!"); return(null); } Logger.Log("Finished getting group security permission key value pairs."); allGroupPermissions = GetAllGroupPermissions(allGroups, groupContentDict, groupDisplayDict, groupFunctionalityDict); Logger.Log("Finished getting all group permissions."); } catch (Exception ex) { Logger.LogError(5, "Error getting all group permissions at " + ex.StackTrace); allGroupPermissions = null; } finally { if (groupOps != null) { groupOps.Finish(); } } return(allGroupPermissions); }
public GroupPermissions GetGroupPermissions(MGGroup group, GroupAdministration.AssociationTypes associationType) { if (group == null) { Logger.LogError(5, "NULL group found can not find permissions."); return(null); } GroupPermissions groupPermissions = null; GroupOperations groupOps = null; Logger.Log("Getting group permissions for group with ID " + group.ID + " and name " + group.Name + "..."); try { Logger.Log("Getting group security permission key value pairs ..."); // Extract the Application Level list of groups, along with the relevant cross references to Users and the content etc ... groupOps = new GroupOperations(Lcf); Logger.Log("Start getting groups->content lookup..."); List <MGSecurityTag> groupContentList = groupOps.GetGroupContentDictionary(group.ID, associationType); if (groupContentList == null) { Logger.LogError(5, "Got NULL list for group with name " + group.Name + " and ID " + group.ID + " groups->content lookup, abandoning getting group permissions!"); return(null); } Logger.Log("Start getting groups->display lookup..."); List <MGSecurityTag> groupDisplayList = groupOps.GetGroupDisplayDictionary(group.ID, associationType); if (groupDisplayList == null) { Logger.LogError(5, "Got NULL list for group with name " + group.Name + " and ID " + group.ID + " groups->display lookup, abandoning getting group permissions!"); return(null); } Logger.Log("Start getting groups->functionality lookup..."); List <MGSecurityTag> groupFunctionalityList = groupOps.GetGroupFunctionalityDictionary(group.ID, associationType); if (groupFunctionalityList == null) { Logger.LogError(5, "Got NULL list for group with name " + group.Name + " and ID " + group.ID + " groups->functionality lookup, abandoning getting group permissions!"); return(null); } Logger.Log("Finished getting group security permission key value pairs."); groupPermissions = GetGroupPermissions(group, groupContentList, groupDisplayList, groupFunctionalityList); if (groupPermissions == null) { Logger.LogError(5, "Failed to get group permissions for group with name " + group.Name + " and ID " + group.ID + "!"); return(null); } Logger.Log("Finished getting group permissions for group with name " + group.Name + " and ID " + group.ID + "."); } catch (Exception ex) { Logger.LogError(5, "Error getting all group permissions at " + ex.StackTrace); groupPermissions = null; } finally { if (groupOps != null) { groupOps.Finish(); } } return(groupPermissions); }
public List <MGGroup> GetUserGroups(MGUser user, bool isFilterOutSuperGroup) { if (user == null) { Logger.LogError(5, "Cannot GetUserGroups for NULL user!"); return(null); } else if (user.ID < 1) { Logger.LogError(5, "Cannot GetUserGroups for invalid user.ID (" + user.ID + ")!"); return(null); } List <MGGroup> userGroups = null; UserOperations userHelper = null; GroupOperations groupHelper = null; try { userHelper = new UserOperations(Lcf); List <int> userGroupIDs = userHelper.GetUserGroupsIDs(user.ID); if (userGroupIDs == null) { Logger.LogError(5, "Cannot GetUserGroups as retrieved NULL list of userGroupIDs for user.ID (" + user.ID + ")!"); return(null); } userGroups = new List <MGGroup>(userGroupIDs.Count); groupHelper = new GroupOperations(Lcf); MGGroup group; foreach (int groupID in userGroupIDs) { if (groupID < 1) { Logger.LogError(5, "Invalid groupID detected, skipping it ..."); continue; } group = groupHelper.GetGroup(groupID); if (group == null) { Logger.LogError(5, "NULL MGGroup detected, skipping it ..."); continue; } if (isFilterOutSuperGroup) { if (group.Name != null && group.Name.Equals(GroupAdministration.SUPER_USER_GROUP_NAME, StringComparison.CurrentCultureIgnoreCase)) { continue; } } userGroups.Add(group); } } catch (Exception ex) { Logger.LogError(5, "Failure getting UserGroups for user.ID (" + user.ID + ") at " + ex.StackTrace); return(null); } finally { if (userHelper != null) { userHelper.Finish(); } if (groupHelper != null) { groupHelper.Finish(); } } return(userGroups); }