示例#1
0
        protected Boolean ApplyChanges()
        {
            Boolean isModified = false;

            Boolean success = true;


            Client.Environment.Role unmodifiedEnvironmentRole = (Client.Environment.Role)Session[SessionCachePrefix + "EnvironmentRoleUnmodified" + SessionCacheSuffix];


            if (!ValidatedValues())
            {
                return(false);
            }


            #region General Properties

            if (environmentRole.RoleId == 0)
            {
                isModified = true;
            }


            environmentRole.Name = EnvironmentRoleName.Text;

            environmentRole.Description = EnvironmentRoleDescription.Text;


            #region Role Environment Permission Changes

            environmentRole.Permissions.Clear();

            foreach (Telerik.Web.UI.GridEditableItem currentItem in EnvironmentPermissionsGrid.EditItems)
            {
                System.Collections.Hashtable newValues = new Hashtable();

                currentItem.ExtractValues(newValues);

                if (((Boolean)newValues ["IsGranted"]) || ((Boolean)newValues ["IsDenied"]))
                {
                    String permissionIdText = currentItem.KeyValues.Split(',')[0].Split('\"')[1];

                    Int64 permissionId = Int64.Parse(permissionIdText);

                    environmentRole.AddPermission(permissionId, (Boolean)newValues["IsGranted"], (Boolean)newValues["IsDenied"]);
                }
            }

            #endregion


            isModified = !environmentRole.IsEqual(unmodifiedEnvironmentRole);


            if (isModified)
            {
                success = application.EnvironmentRoleSave(environment.Name, environmentRole.ToServerObject());

                if (success)
                {
                    environmentRole = application.EnvironmentRoleGet(environment.Name, environmentRole.Name);

                    Session[SessionCachePrefix + "EnvironmentRole" + SessionCacheSuffix] = environmentRole;

                    SaveResponseLabel.Text = "Save Successful.";

                    Initialize_All();
                }

                else
                {
                    SaveResponseLabel.Text = "Unable to Save Role.";

                    if (application.LastException != null)
                    {
                        SaveResponseLabel.Text = SaveResponseLabel.Text + " [" + application.LastException.Message + "]";
                    }

                    success = false;
                }
            }

            else
            {
                success = true;
            }

            #endregion


            return(success);
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String environmentName;

            String roleName;


            if (Session["Mercury.Application"] == null)
            {
                Response.RedirectLocation = "/SessionExpired.aspx"; return;
            }

            application = (Mercury.Client.Application)Session["Mercury.Application"];

            if (!application.HasEnterprisePermission(Mercury.Server.EnterprisePermissions.EnvironmentReview))
            {
                if (!IsPostBack)
                {
                    Server.Transfer("/PermissionDenied.aspx");
                }

                else
                {
                    Response.RedirectLocation = "/PermissionDenied.aspx";
                }

                return;
            }

            ButtonApply.Click += new EventHandler(this.ButtonApply_OnClick);

            ButtonOk.Click += new EventHandler(this.ButtonOk_OnClick);

            ButtonCancel.Click += new EventHandler(this.ButtonCancel_OnClick);

            if ((application != null) && (!Page.IsPostBack))
            {
                #region Initial Page Load

                SessionCachePrefix = Form.Name;

                PageInstanceId.Text = Guid.NewGuid().ToString().Replace("-", "");

                SessionCacheSuffix = PageInstanceId.Text;


                environmentName = Request.QueryString["EnvironmentName"];

                roleName = Request.QueryString["RoleName"];


                environment = application.EnvironmentGet(environmentName);

                environmentRole = application.EnvironmentRoleGet(environmentName, roleName);

                if ((environmentRole == null) && !(roleName == String.Empty))
                {
                    Server.Transfer("/PermissionDenied.aspx");
                }

                else if (environmentRole == null)
                {
                    environmentRole = new Mercury.Client.Environment.Role(application);

                    environmentRole.Name = String.Empty;

                    environmentRole.Description = String.Empty;

                    environmentRole.CreateAccountInfo = new Mercury.Server.Application.AuthorityAccountStamp();

                    environmentRole.CreateAccountInfo.ActionDate = EnvironmentRoleCreateDate.MinDate;

                    environmentRole.ModifiedAccountInfo = new Mercury.Server.Application.AuthorityAccountStamp();

                    environmentRole.ModifiedAccountInfo.ActionDate = EnvironmentRoleModifiedDate.MinDate;
                }


                Session.Add(SessionCachePrefix + "Environment" + SessionCacheSuffix, environment);

                Session.Add(SessionCachePrefix + "EnvironmentRole" + SessionCacheSuffix, environmentRole);

                Session.Add(SessionCachePrefix + "EnvironmentRoleUnmodified" + SessionCacheSuffix, environmentRole.Copy());


                Initialize_GeneralPage();

                if (application.HasEnvironmentPermission(environment.Name, Mercury.Server.EnvironmentPermissions.RoleReview))
                {
                    // Initialize Enterprise Permission and Environment Access

                    Initialize_RolePermissions();

                    Initialize_RoleMembership();

                    Initialize_SecurityAuthoritySelection();

                    Initialize_SecurityGroupSelection();
                }

                else
                {
                    PropertiesTab.Tabs[1].Visible = false;

                    PropertiesContent.PageViews[1].Visible = false;

                    PropertiesTab.Tabs[2].Visible = false;

                    PropertiesContent.PageViews[2].Visible = false;
                }

                #endregion
            } // Initial Page Load

            else   // Postback

            {
                SessionCachePrefix = Form.Name;

                SessionCacheSuffix = PageInstanceId.Text;

                environment = (Mercury.Server.Application.Environment)Session[SessionCachePrefix + "Environment" + SessionCacheSuffix];

                environmentRole = (Client.Environment.Role)Session[SessionCachePrefix + "EnvironmentRole" + SessionCacheSuffix];
            }

            return;
        }