コード例 #1
0
        public void SetData(Entities objectContext, User searchUser, UserOrRoleRights currUserRights)
        {
            Tools.CheckObjectContext(objectContext);

            if (searchUser == null)
            {
                throw new ArgumentNullException("searchUser");
            }
            if (currUserRights == null)
            {
                throw new ArgumentNullException("currUserRights");
            }

            BRoles bRoles = new BRoles();

            user = searchUser;

            lblUserName.Text = searchUser.name;

            searchUser.Reports.Load();
            lblReports.Text = string.Format("Доклади: {0}", searchUser.Reports.Count);

            if (searchUser.isAdmin == true)
            {
                lblRole.Text      = "Администратор";
                lblRole.ForeColor = Color.Red;
            }
            else
            {
                Role userRole = bRoles.GetUserRole(objectContext, searchUser);

                lblRole.Text = string.Format("Роля: {0}", userRole.name);
            }

            btnSeeReports.Visible = currUserRights.SeeVisibleReportsVisible;
            btnSeeReports.Enabled = currUserRights.SeeVisibleReportsEnabled;

            btnSeeDeletedReports.Visible = currUserRights.SeeDeletedReportVisible;
            btnSeeDeletedReports.Enabled = currUserRights.SeeDeletedReportsEnabled;

            if (currUserRights.IsAdmin == true && searchUser.isAdmin == false)
            {
                btnChangeRole.Visible = true;

                List <Role> allRoles = bRoles.GetRoles(objectContext);
                if (allRoles.Count > 1)
                {
                    btnChangeRole.Enabled = true;
                }
                else
                {
                    btnChangeRole.Enabled = false;
                }
            }
            else
            {
                btnChangeRole.Visible = false;
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the profile.
        /// </summary>
        /// <param name="roleId">The role ID.</param>
        /// <returns>MRoleProfile.</returns>
        public static MRoleProfile GetProfile(int roleId)
        {
            MRoleProfile mProfile = new MRoleProfile();

            mProfile.Id = roleId;
            BRoles mBRoles = new BRoles(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement);

            mProfile = mBRoles.GetProfile(mProfile);
            return(mProfile);
        }
コード例 #3
0
        /// <summary>
        /// Searches the specified search critera.
        /// </summary>
        /// <param name="searchCriteria">The search critera.</param>
        /// <returns>DataTable.</returns>
        public static DataTable Search(MSearchCriteria searchCriteria)
        {
            if (searchCriteria == null)
            {
                throw new ArgumentNullException("searchCriteria", "searchCriteria cannot be blank or a null reference (Nothing in Visual Basic)");
            }
            BRoles mBRoles = new BRoles(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement);

            return(mBRoles.Search(searchCriteria));
        }
コード例 #4
0
        /// <summary>
        /// Gets all roles by BU.
        /// </summary>
        /// <param name="securityEntitySeqId">The SECURIT y_ ENTIT y_ SE q_ ID.</param>
        /// <returns>DataTable.</returns>
        public static DataTable GetAllRolesBySecurityEntity(int securityEntitySeqId)
        {
            DataTable mySecurityEntityRoles = null;

            // attempt to retrieve the information from cache
            mySecurityEntityRoles = (DataTable)HttpContext.Current.Cache[SecurityEntitiesRolesCacheName(securityEntitySeqId)];
            // if the information was not avalible in cache
            // then retieve the information from the DB and put it into
            // cache for subsequent use.
            if (mySecurityEntityRoles == null)
            {
                BRoles myBRoles = new BRoles(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement);
                mySecurityEntityRoles = myBRoles.GetRolesBySecurityEntity(securityEntitySeqId);
                CacheController.AddToCacheDependency(SecurityEntitiesRolesCacheName(securityEntitySeqId), mySecurityEntityRoles);
            }
            return(mySecurityEntityRoles);
        }
コード例 #5
0
        public void CreateOrUpdate(BRoles role)
        {
            if (role.Id == 0)
            {
                Roles drole = new Roles()
                {
                    Name = role.Name
                };
                Database.Roles.Create(drole);
            }
            else
            {
                Roles editRole = AutoMapper <BRoles, Roles> .Map(role);

                Database.Roles.Update(editRole);
            }
            Database.Save();
        }
コード例 #6
0
        /// <summary>
        /// Gets the accounts in role.
        /// </summary>
        /// <param name="profile">The profile.</param>
        /// <returns>ArrayList.</returns>
        public static ArrayList GetAccountsInRole(MRoleProfile profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile", "profile cannot be blank or a null reference (Nothing in Visual Basic)");
            }
            ArrayList colAccounts = new ArrayList();
            DataRow   accountsRow = null;
            BRoles    myBRoles    = new BRoles(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement);
            DataTable myDataTable = myBRoles.GetAccountsInRole(profile);

            foreach (DataRow accountsRow_loopVariable in myDataTable.Rows)
            {
                accountsRow = accountsRow_loopVariable;
                colAccounts.Add((string)accountsRow["ACCT"]);
            }
            return(colAccounts);
        }
コード例 #7
0
        public string CheckRoles(string roles, string title)
        {
            if (roles == null || "".Equals(roles))
            {
                return(title + ERROR_NULL);
            }
            if (_rolesTable[roles.ToString()] != null)
            {
                return("");
            }
            BRoles bRoles = new BRoles();

            if (bRoles.Exists(roles))
            {
                _rolesTable.Add(roles, roles);
                return("");
            }
            return(title + ERROR_EXIST);
        }
コード例 #8
0
        /// <summary>
        /// Deletes the role.
        /// </summary>
        /// <param name="profile">The profile.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        public static void DeleteRole(MRoleProfile profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile", "profile cannot be blank or a null reference (Nothing in Visual Basic)");
            }
            BRoles myBRoles = new BRoles(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement);

            try
            {
                myBRoles.DeleteRole(profile);
            }
            catch (DataAccessLayerException ex)
            {
                WebSupportException mEx = new WebSupportException("Could not save the information due to database error please have your administrator check the logs for details.");
                Logger mLog             = Logger.Instance();
                mLog.Error(ex);
                throw mEx;
            }
            RemoveRoleCache(profile.SecurityEntityId);
            FunctionUtility.RemoveCachedFunctions();
        }
コード例 #9
0
        /// <summary>
        /// Updates all accounts for role.
        /// </summary>
        /// <param name="roleId">The role ID.</param>
        /// <param name="securityEntitySeqId">The security entity Seq ID.</param>
        /// <param name="accounts">The accounts.</param>
        /// <param name="accountId">The account ID.</param>
        /// <returns><c>true</c> if no errors, <c>true</c> otherwise false</returns>
        public static bool UpdateAllAccountsForRole(int roleId, int securityEntitySeqId, string[] accounts, int accountId)
        {
            if (accounts == null)
            {
                throw new ArgumentNullException("accounts", "accounts cannot be blank or a null reference (Nothing in Visual Basic)");
            }
            bool   success  = false;
            BRoles myBRoles = new BRoles(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement);

            try
            {
                success = myBRoles.UpdateAllAccountsForRole(roleId, securityEntitySeqId, accounts, accountId);
            }
            catch (DataAccessLayerException ex)
            {
                WebSupportException mEx = new WebSupportException("Could not save the information due to database error please have your administrator check the logs for details.");
                Logger mLog             = Logger.Instance();
                mLog.Error(ex);
                throw mEx;
            }
            return(success);
        }