示例#1
0
        /// <summary>
        /// load the modules available to the given user
        /// </summary>
        /// <param name="AUserID"></param>
        /// <param name="ATransaction">Instantiated DB Transaction.</param>
        /// <returns></returns>
        public static string[] LoadUserModules(String AUserID, TDBTransaction ATransaction)
        {
            string[] ReturnValue;
            SUserModuleAccessPermissionTable UserModuleAccessPermissionsDT;
            Int32     CounterOverall;
            Int32     CounterAdded;
            ArrayList UserModuleAccessPermissions;

            if (SUserModuleAccessPermissionAccess.CountViaSUser(AUserID, ATransaction) > 0)
            {
                UserModuleAccessPermissionsDT = SUserModuleAccessPermissionAccess.LoadViaSUser(AUserID, ATransaction);

//TLogging.Log("UserModuleAccessPermissionsDT.Rows.Count - 1: " + (UserModuleAccessPermissionsDT.Rows.Count - 1).ToString());

                // Dimension the ArrayList with the maximum number of ModuleAccessPermissions first
                UserModuleAccessPermissions = new ArrayList(UserModuleAccessPermissionsDT.Rows.Count - 1);

                CounterAdded = 0;

                for (CounterOverall = 0; CounterOverall <= UserModuleAccessPermissionsDT.Rows.Count - 1; CounterOverall += 1)
                {
                    if (UserModuleAccessPermissionsDT[CounterOverall].CanAccess)
                    {
//TLogging.Log("UserModuleAccessPermissionsDT[" + CounterOverall.ToString() + "].ModuleId: " + UserModuleAccessPermissionsDT[CounterOverall].ModuleId + ": CounterAdded: " + CounterAdded.ToString());

                        UserModuleAccessPermissions.Add(UserModuleAccessPermissionsDT[CounterOverall].ModuleId);
                        CounterAdded = CounterAdded + 1;
                    }
                }

                if (CounterAdded != 0)
                {
                    // Copy contents of the ArrayList into the ReturnValue
                    ReturnValue = new string[CounterAdded];
                    Array.Copy(UserModuleAccessPermissions.ToArray(), ReturnValue, CounterAdded);

                    // ModulesList := '';
                    //
                    // for Counter := 0 to CounterAdded  1 do
                    // begin
                    // Console.WriteLine('ModulesList: working on Counter ' + Counter.ToString());
                    // ModulesList := ModulesList + UserModuleAccessPermissionsArray[Counter].ToString() + #10#13;
                    // end;
                    // Console.WriteLine(ModulesList);
                }
                else
                {
                    ReturnValue = new string[0];
                }
            }
            else
            {
                ReturnValue = new string[0];
            }

            return(ReturnValue);
        }
示例#2
0
        /// <summary>
        /// load the modules available to the given user
        /// </summary>
        /// <param name="AUserID"></param>
        /// <param name="ATransaction">Instantiated DB Transaction.</param>
        /// <returns></returns>
        public static string[] LoadUserModules(String AUserID, TDBTransaction ATransaction)
        {
            string[] ReturnValue;
            SUserModuleAccessPermissionTable UserModuleAccessPermissionsDT;
            Int32     CounterOverall;
            Int32     CounterAdded;
            ArrayList UserModuleAccessPermissions;

            if (SUserModuleAccessPermissionAccess.CountViaSUser(AUserID, ATransaction) > 0)
            {
                UserModuleAccessPermissionsDT = SUserModuleAccessPermissionAccess.LoadViaSUser(AUserID, ATransaction);

                // Dimension the ArrayList with the maximum number of ModuleAccessPermissions first
                UserModuleAccessPermissions = new ArrayList(UserModuleAccessPermissionsDT.Rows.Count - 1);

                CounterAdded = 0;

                for (CounterOverall = 0; CounterOverall <= UserModuleAccessPermissionsDT.Rows.Count - 1; CounterOverall += 1)
                {
                    if (UserModuleAccessPermissionsDT[CounterOverall].CanAccess)
                    {
                        UserModuleAccessPermissions.Add(UserModuleAccessPermissionsDT[CounterOverall].ModuleId);
                        CounterAdded = CounterAdded + 1;
                    }
                }

                if (CounterAdded != 0)
                {
                    // Copy contents of the ArrayList into the ReturnValue
                    ReturnValue = new string[CounterAdded];
                    Array.Copy(UserModuleAccessPermissions.ToArray(), ReturnValue, CounterAdded);
                }
                else
                {
                    ReturnValue = new string[0];
                }
            }
            else
            {
                ReturnValue = new string[0];
            }

            return(ReturnValue);
        }
        /// <summary>
        /// load the modules available to the given user
        /// </summary>
        /// <param name="AUserID"></param>
        /// <returns></returns>
        public static string[] LoadUserModules(String AUserID)
        {
            string[]       ReturnValue;
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction = false;
            SUserModuleAccessPermissionTable UserModuleAccessPermissionsDT;
            Int32     CounterOverall;
            Int32     CounterAdded;
            ArrayList UserModuleAccessPermissions;

            // ModulesList: string;
            // Counter: Int32;
            try
            {
                ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction);

                if (SUserModuleAccessPermissionAccess.CountViaSUser(AUserID, ReadTransaction) > 0)
                {
                    UserModuleAccessPermissionsDT = SUserModuleAccessPermissionAccess.LoadViaSUser(AUserID, ReadTransaction);

//TLogging.Log("UserModuleAccessPermissionsDT.Rows.Count - 1: " + (UserModuleAccessPermissionsDT.Rows.Count - 1).ToString());

                    // Dimension the ArrayList with the maximum number of ModuleAccessPermissions first
                    UserModuleAccessPermissions = new ArrayList(UserModuleAccessPermissionsDT.Rows.Count - 1);

                    CounterAdded = 0;

                    for (CounterOverall = 0; CounterOverall <= UserModuleAccessPermissionsDT.Rows.Count - 1; CounterOverall += 1)
                    {
                        if (UserModuleAccessPermissionsDT[CounterOverall].CanAccess)
                        {
//TLogging.Log("UserModuleAccessPermissionsDT[" + CounterOverall.ToString() + "].ModuleId: " + UserModuleAccessPermissionsDT[CounterOverall].ModuleId + ": CounterAdded: " + CounterAdded.ToString());

                            UserModuleAccessPermissions.Add(UserModuleAccessPermissionsDT[CounterOverall].ModuleId);
                            CounterAdded = CounterAdded + 1;
                        }
                    }

                    if (CounterAdded != 0)
                    {
                        // Copy contents of the ArrayList into the ReturnValue
                        ReturnValue = new string[CounterAdded];
                        Array.Copy(UserModuleAccessPermissions.ToArray(), ReturnValue, CounterAdded);

                        // ModulesList := '';
                        //
                        // for Counter := 0 to CounterAdded  1 do
                        // begin
                        // Console.WriteLine('ModulesList: working on Counter ' + Counter.ToString());
                        // ModulesList := ModulesList + UserModuleAccessPermissionsArray[Counter].ToString() + #10#13;
                        // end;
                        // Console.WriteLine(ModulesList);
                    }
                    else
                    {
                        ReturnValue = new string[0];
                    }
                }
                else
                {
                    ReturnValue = new string[0];
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(8, "TModuleAccessManager.LoadUserModules: committed own transaction.");
                }
            }
            return(ReturnValue);
        }