Beispiel #1
0
        //private OrgAccess[] _orgAccess = null;
        public static Role GetRole(MRole role)
        {
            Role r = new Role();

            r.IsAccessAllOrgs     = role.IsAccessAllOrgs();
            r.IsAdministrator     = role.IsAdministrator();
            r.AD_Client_ID        = role.GetAD_Client_ID();
            r.AD_User_ID          = role.GetAD_User_ID();
            r.UserLevel           = role.GetUserLevel();
            r.IsCanExport         = role.IsCanExport();
            r.IsCanReport         = role.IsCanReport();
            r.IsUseBPRestrictions = role.IsUseBPRestrictions();
            r.IsPersonalAccess    = role.IsPersonalAccess();
            r.Name             = role.GetName();
            r.IsShowPreference = role.IsShowPreference();
            r.PreferenceType   = role.GetPreferenceType();

            r.IsDisplayClient        = role.IsDisplayClient();
            r.IsDisplayOrg           = role.IsDisplayOrg();
            r.IsPersonalLock         = role.IsPersonalLock();
            r.IsOverwritePriceLimit  = role.IsOverwritePriceLimit();
            r.IsOverrideReturnPolicy = role.IsOverrideReturnPolicy();

            r.tableAccessLevel = role.GetTableAccessLevel();
            r.tableName        = role.GetTableNames();
            r.orgAccess        = role.GetOrgAccess();
            r.windowAccess     = role.GetWindowAccess();
            r.formAccess       = role.GetFormAccess();
            r.processAccess    = role.GetProcessAccess();

            r.tableAccess           = TableAccess.Get(role.GetTableAccess());
            r.columnAccess          = ColumnAccess.Get(role.GetColumnAccess());
            r.recordAccess          = RecordAccess.Get(role.GetRecordAccess());
            r.recordDependentAccess = RecordAccess.Get(role.GetRecordDependentAccess());

            r.MaxQueryRecords = role.GetMaxQueryRecords();
            r.IsShowAcct      = role.IsShowAcct();
            r.IsDisableMenu   = role.IsDisableMenu();
            r.HomePage        = role.GetHomePage_ID();

            /* Prepare Pre Setting of Table*/

            r.tableData = TableData.Get();


            return(r);
        }
Beispiel #2
0
        /// <summary>
        /// Validate the organization access of users according to the role.
        /// </summary>
        /// <param name="_ds"></param>
        /// <returns></returns>
        private List <int> validateUsers(DataSet _ds)
        {
            List <int> users     = new List <int>();
            MRole      role      = new MRole(GetCtx(), Util.GetValueOfInt(_ds.Tables[0].Rows[0]["AD_Role_ID"]), null);
            bool       isAllUser = false;

            // if access all organization
            if (role.IsAccessAllOrgs())
            {
                isAllUser = true;
            }
            // if not access user organization access.
            if (!isAllUser && !role.IsUseUserOrgAccess())
            {
                if (Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_Org_ID) FROm AD_Role_OrgAccess WHERE IsActive='Y' AND  AD_Role_ID=" + role.GetAD_Role_ID() + " AND AD_Org_ID IN (" + _req.GetAD_Org_ID() + ",0)")) > 0)
                {
                    isAllUser = true;
                }
                else
                {
                    return(users);
                }
            }
            for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
            {
                if (isAllUser)
                {
                    users.Add(Util.GetValueOfInt(_ds.Tables[0].Rows[i]["AD_User_ID"]));
                }
                else
                {
                    if (Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_Org_ID) FROm AD_User_OrgAccess WHERE AD_User_ID=" + Util.GetValueOfInt(_ds.Tables[0].Rows[i]["AD_User_ID"]) + " AND  IsActive='Y' AND  AD_Org_ID IN (" + _req.GetAD_Org_ID() + ",0)")) > 0)
                    {
                        users.Add(Util.GetValueOfInt(_ds.Tables[0].Rows[i]["AD_User_ID"]));
                    }
                }
            }
            return(users);
        }