protected void PopulateEnvironmentAccessGrid(String environmentName, String securityAuthorityName)
        {
            System.Collections.Generic.Dictionary <String, String> groupDictionary = application.SecurityAuthoritySecurityGroupDictionary(securityAuthorityName);

            List <Mercury.Server.Application.EnvironmentAccess> environmentAccessCollection = application.EnvironmentAccessGetByEnvironmentName(environmentName, false);

            System.Data.DataTable accessTable = new DataTable();

            Boolean accessExists = false;


            accessTable.Columns.Add("EnvironmentId");
            accessTable.Columns.Add("SecurityAuthorityId");
            accessTable.Columns.Add("SecurityGroupId");

            accessTable.Columns.Add("GroupName");
            accessTable.Columns.Add("Is Granted");
            accessTable.Columns.Add("Is Denied");

            EnvironmentAccessGrid.DataSource = accessTable;

            EnvironmentAccessGrid.Rebind();


            foreach (String currentGroupKey in groupDictionary.Keys)
            {
                // DETERMINE IF ALREADY DEFINED

                accessExists = false;

                foreach (Mercury.Server.Application.EnvironmentAccess currentAccess in environmentAccessCollection)
                {
                    if (currentAccess.SecurityGroupId == currentGroupKey)
                    {
                        accessExists = true;

                        accessTable.Rows.Add(currentAccess.EnvironmentId, currentAccess.SecurityAuthorityId, currentGroupKey, groupDictionary[currentGroupKey], currentAccess.IsGranted, currentAccess.IsDenied);

                        break;
                    }
                } // foreach currentAccess in environmentAccessCollection


                if (!accessExists)
                {
                    accessTable.Rows.Add(EnvironmentSelection.SelectedValue, SecurityAuthoritySelection.SelectedValue, currentGroupKey, groupDictionary[currentGroupKey], false, false);
                }
            }

            EnvironmentAccessGrid.DataSource = accessTable;

            EnvironmentAccessGrid.Rebind();

            foreach (Telerik.Web.UI.GridDataItem currentItem in EnvironmentAccessGrid.Items)
            {
                currentItem.Edit = true;
            }

            EnvironmentAccessGrid.Rebind();

            Session["EnterpriseManagement.EnvironmentAccessManage.EnvironmentAccessGrid"] = EnvironmentAccessGrid.DataSource;
        }
Example #2
0
        protected void Initialize_EnvironmentAccessPage()
        {
            List <Mercury.Server.Application.EnvironmentAccess> environmentAccessCollection = application.SecurityGroupEnvironmentAccessGet(securityGroup.SecurityAuthorityName, securityGroup.SecurityGroupId);

            System.Collections.Generic.Dictionary <Int64, String> environmentDictionary = application.EnvironmentDictionary(false);

            System.Data.DataTable environmentTable = new DataTable();

            Boolean environmentExists = false;


            environmentTable.Columns.Add("EnvironmentId");

            environmentTable.Columns.Add("EnvironmentName");

            environmentTable.Columns.Add("IsGranted");

            environmentTable.Columns.Add("IsDenied");

            foreach (Int64 currentEnvironmentId in environmentDictionary.Keys)
            {
                environmentExists = false;

                foreach (Mercury.Server.Application.EnvironmentAccess currentEnvironmentAccess in environmentAccessCollection)
                {
                    if (currentEnvironmentId == currentEnvironmentAccess.EnvironmentId)
                    {
                        environmentExists = true;

                        environmentTable.Rows.Add(
                            currentEnvironmentAccess.EnvironmentId,
                            environmentDictionary[currentEnvironmentId],
                            currentEnvironmentAccess.IsGranted,
                            currentEnvironmentAccess.IsDenied
                            );

                        break;
                    }
                } // foreach

                if (!environmentExists)
                {
                    environmentTable.Rows.Add(
                        currentEnvironmentId,
                        environmentDictionary[currentEnvironmentId],
                        false,
                        false
                        );
                }
            } // foreach

            EnvironmentAccessGrid.DataSource = environmentTable;

            EnvironmentAccessGrid.Rebind();

            if (application.HasEnterprisePermission(Mercury.Server.EnterprisePermissions.EnvironmentManage))
            {
                foreach (Telerik.Web.UI.GridItem currentItem in EnvironmentAccessGrid.Items)
                {
                    currentItem.Edit = true;
                }
            }

            EnvironmentAccessGrid.MasterTableView.DataKeyNames = new String[] { "EnvironmentId", "EnvironmentName", "IsGranted", "IsDenied" };

            EnvironmentAccessGrid.Rebind();

            Session[SessionCachePrefix + "EnvironmentAccessGrid.DataSource" + SessionCacheSuffix] = EnvironmentAccessGrid.DataSource;
        }