Exemplo n.º 1
0
 private void populateGeneral(MNameValuePair profile)
 {
     txtNVP_SEQ_ID.Text  = profile.Id.ToString();
     txtSchemaName.Text  = profile.SchemaName;
     litSchemaName.Text  = profile.SchemaName;
     txtSTATIC_NAME.Text = profile.StaticName;
     litStaticName.Text  = profile.StaticName;
     txtDisplay.Text     = profile.Display;
     txtDescription.Text = profile.Description;
     if (!String.IsNullOrEmpty(profile.SchemaName))
     {
         lblTableName.InnerHtml = profile.SchemaName + "." + profile.StaticName;
     }
     if (profile.Id > -1)
     {
         txtSchemaName.Style.Add("display", "none");
         RequiredFieldValidator1.Enabled = false;
         Alphanumeric.Enabled            = false;
         txtSTATIC_NAME.Style.Add("display", "none");
         RequiredFieldValidator2.Enabled = false;
         Alphanumeric2.Enabled           = false;
         litSchemaName.Visible           = true;
         litStaticName.Visible           = true;
     }
     else
     {
         txtSchemaName.Style.Add("display", "");
         txtSTATIC_NAME.Style.Add("display", "");
         litSchemaName.Visible = false;
         litStaticName.Visible = false;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the specified profile.
        /// </summary>
        /// <param name="nameValuePairProfile">The profile.</param>
        /// <returns>System.Int32.</returns>
        public int Save(MNameValuePair nameValuePairProfile)
        {
            int mRetVal = -1;

            m_DNameValuePair.NameValuePairProfile = nameValuePairProfile;
            if (DatabaseIsOnline())
            {
                mRetVal = m_DNameValuePair.Save();
            }
            return(mRetVal);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Inserts or updates a name value pair given a NameValuePair profile
        /// </summary>
        /// <param name="profile">Details of the profile to added or updated</param>
        /// <returns>The Primary sequence ID</returns>
        /// <remarks></remarks>
        public static int Save(MNameValuePair profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!");
            }
            int mRetVal = -1;
            MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile();
            BNameValuePairs        myNameValuePair  = new BNameValuePairs(mSecurityProfile);

            CacheController.RemoveFromCache(CachedNameValuePairTableName);
            CacheController.RemoveFromCache(CachedNameValuePairDetailsTableName);
            mRetVal = myNameValuePair.Save(profile);
            return(mRetVal);
        }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["NVP_SEQ_ID"]))
     {
         int mNameValuePairSeqID = int.Parse((HttpContext.Current.Request.QueryString["NVP_SEQ_ID"]).ToString());
         if (mNameValuePairSeqID != -1)
         {
             m_NVPToUpdate = NameValuePairUtility.GetNameValuePair(mNameValuePairSeqID);
         }
         else
         {
             m_NVPToUpdate = new MNameValuePair();
         }
         HttpContext.Current.Session.Add("EditId", m_NVPToUpdate.Id);
     }
     else
     {
         tdStatus.Style.Add("display", "none");
         dropStatus.Style.Add("display", "none");
     }
     populatePage(m_NVPToUpdate);
 }
Exemplo n.º 5
0
        private void populateRolesAndGroups(MNameValuePair profile)
        {
            int      mSecurityEntityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString());
            DataView mDVRoles          = RoleUtility.GetAllRolesBySecurityEntity(mSecurityEntityId).DefaultView;
            DataView mDVGroups         = GroupUtility.GetAllGroupsBySecurityEntity(mSecurityEntityId).DefaultView;

            try
            {
                ctlGroups.SelectedItems = NameValuePairUtility.GetSelectedGroups(m_NVPToUpdate.Id);
                ctlRoles.SelectedItems  = NameValuePairUtility.GetSelectedRoles(m_NVPToUpdate.Id);
            }
            catch (Exception ex)
            {
                Logger mLog = Logger.Instance();
                mLog.Debug(ex);
            }
            ctlGroups.DataSource = mDVGroups;
            ctlGroups.DataField  = "Name";
            ctlGroups.DataBind();
            ctlRoles.DataSource = mDVRoles;
            ctlRoles.DataField  = "Name";
            ctlRoles.DataBind();
        }
Exemplo n.º 6
0
        public IHttpActionResult SaveNameValuePair(UINVPProfile uiProfile)
        {
            string         mRetVal  = false.ToString();
            MNameValuePair mProfile = new MNameValuePair();
            String         mAction  = GWWebHelper.GetQueryValue(HttpContext.Current.Request, "Action");
            int            mEditId  = int.Parse(HttpContext.Current.Items["EditId"].ToString());
            Logger         mLog     = Logger.Instance();

            if (mEditId != uiProfile.NVP_SEQ_ID)
            {
                Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }

            MAccountProfile        mUpdatingAccount       = AccountUtility.CurrentProfile();
            MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile();
            MSecurityInfo          mSecurityInfo          = new MSecurityInfo(FunctionUtility.GetProfile(mAction), mUpdatingAccount);
            String mGroups        = String.Join(",", uiProfile.Groups);
            String mRoles         = String.Join(",", uiProfile.Roles);
            String mCommaSepRoles = mUpdatingAccount.GetCommaSeparatedAssignedRoles;

            if (uiProfile.NVP_SEQ_ID != -1)
            {
                if (!mSecurityInfo.MayAdd)
                {
                    Exception mError = new Exception("The account (" + mUpdatingAccount.Account + ") being used does not have the correct permissions to add");
                    mLog.Error(mError);
                    return(this.InternalServerError(mError));
                }
            }
            else
            {
                if (!mSecurityInfo.MayAdd)
                {
                    Exception mError = new Exception("The account (" + mUpdatingAccount.Account + ") being used does not have the correct permissions to edit");
                    mLog.Error(mError);
                    return(this.InternalServerError(mError));
                }
            }
            if (uiProfile.NVP_SEQ_ID != -1)
            {
                mProfile = NameValuePairUtility.GetNameValuePair(uiProfile.NVP_SEQ_ID);
            }
            else
            {
                mProfile.AddedBy   = mUpdatingAccount.Id;
                mProfile.AddedDate = DateTime.Today;
            }

            mProfile.UpdatedBy   = mUpdatingAccount.Id;
            mProfile.UpdatedDate = DateTime.Today;
            mProfile.StaticName  = uiProfile.STATIC_NAME;
            mProfile.SchemaName  = uiProfile.SchemaName;
            mProfile.Display     = uiProfile.Display;
            mProfile.Description = uiProfile.Description;
            mProfile.Status      = uiProfile.Status;
            int mID         = NameValuePairUtility.Save(mProfile);
            int mSecurityId = mSecurityEntityProfile.Id;

            NameValuePairUtility.UpdateRoles(mID, mSecurityId, mRoles, mProfile);
            NameValuePairUtility.UpdateGroups(mID, mSecurityId, mGroups, mProfile);
            return(this.Ok(mRetVal));
        }
Exemplo n.º 7
0
 private void populatePage(MNameValuePair profile)
 {
     populateGeneral(profile);
     populateRolesAndGroups(profile);
 }
Exemplo n.º 8
0
        void IDNameValuePair.UpdateGroups(int NVP_ID, int SecurityEntityID, string CommaSeparatedGroups, MNameValuePair nvpProfile)
        {
            string myStoreProcedure = "ZGWSecurity.Set_Name_Value_Pair_Groups";

            SqlParameter[] mParameters = { new SqlParameter("@P_NVP_SeqID", NVP_ID), new SqlParameter("@P_Security_Entity_SeqID", SecurityEntityID), new SqlParameter("@P_Groups", CommaSeparatedGroups), new SqlParameter("@P_Permissions_NVP_Detail_SeqID", m_PermissionSeqId), new SqlParameter("@P_Added_Updated_By", GetAddedUpdatedBy(nvpProfile)) };
            base.ExecuteNonQuery(myStoreProcedure, mParameters);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Updates the roles.
        /// </summary>
        /// <param name="nameValuePairId">The NV p_ ID.</param>
        /// <param name="securityEntityId">The security entity ID.</param>
        /// <param name="commaSeparatedRoles">The comma separated roles.</param>
        /// <param name="nameValuePairProfile">MNameValuePair.</param>
        public static void UpdateRoles(int nameValuePairId, int securityEntityId, string commaSeparatedRoles, MNameValuePair nameValuePairProfile)
        {
            if (nameValuePairProfile == null)
            {
                throw new ArgumentNullException("nameValuePairProfile", "nameValuePairProfile cannot be a null reference (Nothing in Visual Basic)!");
            }
            MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile();
            BNameValuePairs        myNameValuePair  = new BNameValuePairs(mSecurityProfile);

            myNameValuePair.UpdateRoles(nameValuePairId, securityEntityId, commaSeparatedRoles, nameValuePairProfile);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Updates the roles.
 /// </summary>
 /// <param name="nameValuePairId">The NV p_ ID.</param>
 /// <param name="securityEntityId">The security entity ID.</param>
 /// <param name="commaSeparatedRoles">The comma separated roles.</param>
 /// <param name="nameValuePairProfile">MNameValuePair.</param>
 public void UpdateRoles(int nameValuePairId, int securityEntityId, string commaSeparatedRoles, MNameValuePair nameValuePairProfile)
 {
     if (DatabaseIsOnline())
     {
         m_DNameValuePair.UpdateRoles(nameValuePairId, securityEntityId, commaSeparatedRoles, nameValuePairProfile);
     }
 }