/// <summary> /// load the groups of the given user /// </summary> /// <param name="AUserID"></param> /// <returns></returns> public static SUserGroupTable LoadUserGroups(String AUserID) { SUserGroupTable ReturnValue; TDBTransaction ReadTransaction; Boolean NewTransaction = false; try { ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction); if (SUserGroupAccess.CountViaSUser(AUserID, ReadTransaction) > 0) { ReturnValue = SUserGroupAccess.LoadViaSUser(AUserID, ReadTransaction); } else { ReturnValue = new SUserGroupTable(); } } finally { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(9, "TGroupManager.LoadUserGroups: committed own transaction."); } } return(ReturnValue); }
/// <summary> /// load the groups of the given user /// </summary> /// <param name="AUserID"></param> /// <param name="ATransaction">Instantiated DB Transaction.</param> /// <returns></returns> public static SUserGroupTable LoadUserGroups(String AUserID, TDBTransaction ATransaction) { SUserGroupTable ReturnValue; if (SUserGroupAccess.CountViaSUser(AUserID, ATransaction) > 0) { ReturnValue = SUserGroupAccess.LoadViaSUser(AUserID, ATransaction); } else { ReturnValue = new SUserGroupTable(); } return(ReturnValue); }
/// <summary> /// load the groups of the given user /// </summary> /// <param name="AUserID"></param> /// <param name="ATransaction">Instantiated DB Transaction.</param> /// <returns></returns> public static string[] LoadUserGroups(String AUserID, TDBTransaction ATransaction) { string[] ReturnValue; SUserGroupTable table; Int32 Counter; ArrayList groups; if (SUserGroupAccess.CountViaSUser(AUserID, ATransaction) > 0) { table = SUserGroupAccess.LoadViaSUser(AUserID, ATransaction); // Dimension the ArrayList with the maximum number of Groups first groups = new ArrayList(table.Rows.Count - 1); for (Counter = 0; Counter <= table.Rows.Count - 1; Counter += 1) { groups.Add(table[Counter].GroupId); } if (table.Rows.Count != 0) { // Copy contents of the ArrayList into the ReturnValue ReturnValue = new string[table.Rows.Count]; Array.Copy(groups.ToArray(), ReturnValue, table.Rows.Count); } else { ReturnValue = new string[0]; } } else { ReturnValue = new string[0]; } return(ReturnValue); }