Exemple #1
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);
        }
Exemple #2
0
        MRoleProfile populateProfile(MUIRoleProfile profile)
        {
            MRoleProfile mRetVal = new MRoleProfile();

            mRetVal.Name             = profile.Name;
            mRetVal.Description      = profile.Description;
            mRetVal.Id               = profile.Id;
            mRetVal.IsSystem         = profile.IsSystem;
            mRetVal.IsSystemOnly     = profile.IsSystemOnly;
            mRetVal.SecurityEntityId = SecurityEntityUtility.CurrentProfile().Id;
            return(mRetVal);
        }
Exemple #3
0
 /// <summary>
 /// Deletes the role.
 /// </summary>
 /// <param name="profile">The profile.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
 public void DeleteRole(MRoleProfile profile)
 {
     if (profile == null)
     {
         throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!!");
     }
     m_DRoles.Profile = profile;
     if (DatabaseIsOnline())
     {
         m_DRoles.DeleteRole();
     }
 }
Exemple #4
0
        public IHttpActionResult Save(MUIRoleProfile profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("uiProfile", "uiProfile cannot be a null reference (Nothing in Visual Basic)!");
            }
            string        mRetVal        = "false";
            MRoleProfile  mProfileToSave = new MRoleProfile();
            MSecurityInfo mSecurityInfo  = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditRoles", true)), AccountUtility.CurrentProfile());
            Logger        mLog           = Logger.Instance();

            if (HttpContext.Current.Items["EditId"] != null)
            {
                if (profile.Id == -1)
                {
                    if (!mSecurityInfo.MayAdd)
                    {
                        Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add");
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                    mProfileToSave.AddedBy   = AccountUtility.CurrentProfile().Id;
                    mProfileToSave.AddedDate = DateTime.Now;
                }
                else
                {
                    if (!mSecurityInfo.MayAdd)
                    {
                        Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to edit");
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                    if (profile.IsSystem)
                    {
                        mProfileToSave.IsSystem = true;
                    }
                    if (profile.IsSystemOnly)
                    {
                        mProfileToSave.IsSystemOnly = true;
                    }
                    mProfileToSave = RoleUtility.GetProfile(profile.Id);

                    mProfileToSave.UpdatedBy   = AccountUtility.CurrentProfile().Id;
                    mProfileToSave.UpdatedDate = DateTime.Now;
                }
            }
            mProfileToSave = populateProfile(profile);
            RoleUtility.Save(mProfileToSave);
            return(Ok(mRetVal));
        }
Exemple #5
0
        /// <summary>
        /// Gets the accounts not in role.
        /// </summary>
        /// <param name="profile">The profile.</param>
        /// <returns>DataTable.</returns>
        public DataTable GetAccountsNotInRole(MRoleProfile profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!!");
            }
            DataTable mRetVal = null;

            m_DRoles.Profile = profile;
            if (DatabaseIsOnline())
            {
                mRetVal = m_DRoles.AccountsNotInRole();
            }
            return(mRetVal);
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MRoleProfile  myProfile           = new MRoleProfile();
            MSecurityInfo accountSecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());

            txtEditID.Text = Request.QueryString[GWWebHelper.RoleDataKeyField].ToString();
            //HttpContext.Current.Session.Remove(AppConstants.ROLE_DATA_KEY_FIELD);
            myProfile.Id = int.Parse(txtEditID.Text);
            HttpContext.Current.Session.Add("EditId", myProfile.Id);
            myProfile    = RoleUtility.GetProfile(myProfile.Id);
            litRole.Text = myProfile.Name;
            myProfile.SecurityEntityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString());
            ctlMembers.DataSource      = RoleUtility.GetAccountsNotInRole(myProfile).ToArray(Type.GetType("System.String"));
            ctlMembers.SelectedItems   = (string[])RoleUtility.GetAccountsInRole(myProfile).ToArray(Type.GetType("System.String"));
            ctlMembers.DataBind();
        }
Exemple #7
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);
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string mRoleSeqId = GWWebHelper.GetQueryValue(Request, "RoleSeqID");

            if (!String.IsNullOrEmpty(mRoleSeqId))
            {
                int mRoleID = int.Parse(mRoleSeqId);
                if (mRoleID != -1)
                {
                    m_Profile = RoleUtility.GetProfile(mRoleID);
                }
                else
                {
                    m_Profile = new MRoleProfile();
                }
                HttpContext.Current.Session.Add("EditId", m_Profile.Id);
                populatePage();
            }
        }
Exemple #9
0
        public IHttpActionResult Delete([FromUri] int roleSeqId)
        {
            string        mRetVal       = "false";
            MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditRoles", true)), AccountUtility.CurrentProfile());

            if (!mSecurityInfo.MayDelete)
            {
                Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to delete");
                Logger    mLog   = Logger.Instance();
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }
            else
            {
                if (HttpContext.Current.Items["EditId"] != null)
                {
                    int mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString());
                    if (mEditId == roleSeqId)
                    {
                        MRoleProfile mProfile = RoleUtility.GetProfile(roleSeqId);
                        RoleUtility.DeleteRole(mProfile);
                    }
                    else
                    {
                        Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                        Logger    mLog   = Logger.Instance();
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                }
                else
                {
                    Exception mError = new Exception("The identifier unknown and nothing has been saved!!!!");
                    Logger    mLog   = Logger.Instance();
                    mLog.Error(mError);
                    return(this.InternalServerError(mError));
                }
            }

            return(Ok(mRetVal));
        }
Exemple #10
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();
        }