Beispiel #1
0
        private void BindSites()
        {
            // Create new datatable
            DataTable sitesTable = new DataTable();

            // Create columns
            DataColumn selectedCol = new DataColumn(COLUMN_SELECTED, typeof(Boolean));
            DataColumn siteNameCol = new DataColumn(COLUMN_SITENAME, typeof(String));
            DataColumn codeNameCol = new DataColumn(COLUMN_CODENAME, typeof(String));

            // Add columns to datatable
            sitesTable.Columns.Add(selectedCol);
            sitesTable.Columns.Add(siteNameCol);
            sitesTable.Columns.Add(codeNameCol);

            // Bind DataGridView to CMS sites
            DataSet sites = SiteInfo.Provider.Get()
                            .OrderBy("SiteDisplayName")
                            .Columns("SiteDisplayName, SiteName");

            bool sitesAvailable = !DataHelper.DataSourceIsEmpty(sites);

            pnlImportGroups.Enabled = sitesAvailable;
            if (sitesAvailable)
            {
                // Remove non-existing sites
                IEnumerator   sitesEnumerator = ImportProfile.Sites.GetEnumerator();
                List <string> removeSites     = new List <string>();
                while (sitesEnumerator.MoveNext())
                {
                    // Get site
                    if (sitesEnumerator.Current != null)
                    {
                        KeyValuePair <string, List <Guid> > importedSite = (KeyValuePair <string, List <Guid> >)sitesEnumerator.Current;

                        // Clear hash tables
                        ProviderHelper.ClearHashtables(SiteInfo.OBJECT_TYPE, true);

                        // Get info object
                        SiteInfo site = SiteInfo.Provider.Get(importedSite.Key);

                        // If site is not present
                        if (site == null)
                        {
                            // Add to removal list
                            removeSites.Add(importedSite.Key);
                        }
                    }
                }
                foreach (string siteToRemove in removeSites)
                {
                    ImportProfile.Sites.Remove(siteToRemove.ToLowerCSafe());
                }
                foreach (DataRow site in sites.Tables[0].Rows)
                {
                    // Create new row with the table schema
                    DataRow dr = sitesTable.NewRow();

                    // Preselect sites
                    bool checkSite = (ImportProfile.Sites.ContainsKey(site["SiteName"].ToString().ToLowerCSafe()));

                    // Localize display name
                    string siteDisplayName = CMS.Helpers.ResHelper.LocalizeString(site["SiteDisplayName"].ToString());

                    // Add data to row
                    object[] dataRow = { checkSite, siteDisplayName, site["SiteName"] };
                    dr.ItemArray = dataRow;

                    // Add row to table
                    sitesTable.Rows.Add(dr);
                }
                // Bind table as a grid's datasource
                grdSites.DataSource = sitesTable;

                // Adjust columns
                DataGridViewColumn columnSelected = grdSites.Columns[COLUMN_SELECTED];
                if (columnSelected != null)
                {
                    columnSelected.HeaderText   = ResHelper.GetString("General_Import");
                    columnSelected.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                }
                DataGridViewColumn columnSiteName = grdSites.Columns[COLUMN_SITENAME];
                if (columnSiteName != null)
                {
                    columnSiteName.HeaderText   = ResHelper.GetString("General_Sitename");
                    columnSiteName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    columnSiteName.ReadOnly     = true;
                }
                DataGridViewColumn columnCodeName = grdSites.Columns[COLUMN_CODENAME];
                if (columnCodeName != null)
                {
                    columnCodeName.Visible = false;
                }
            }
            else
            {
                // No sites to import
                ImportProfile.Sites.Clear();
            }
        }
Beispiel #2
0
 private void Step4_Load(object sender, EventArgs e)
 {
     // Localize step
     toolTipOnlySelectedAndNew.SetToolTip(radOnlySelectedAndNewGroups, ResHelper.GetString("Step4_UpdateSelectedImportNew"));
     toolTipOnlySelectedAndNew.SetToolTip(radOnlySelectedAndNewUsers, ResHelper.GetString("Step4_UpdateSelectedImportNew"));
     toolTipImportOnlyUsersFromSelectedRoles.SetToolTip(chkImportNewUsersOnlyFromSelectedRoles, ResHelper.GetString("Step4_ToolTipImportNewUsersOnlyFromSelectedRoles"));
 }
Beispiel #3
0
        private void BindRoles()
        {
            // Create new datatable
            DataTable rolesTable = new DataTable();

            // Create columns in the datatable
            rolesTable.Columns.Add(new DataColumn(COLUMN_SELECTED, typeof(Boolean)));
            rolesTable.Columns.Add(new DataColumn(COLUMN_ROLENAME, typeof(String)));
            rolesTable.Columns.Add(new DataColumn(COLUMN_ROLEGUID, typeof(Guid)));

            if (cmbSites.SelectedValue != null)
            {
                SiteInfo si = SiteInfoProvider.GetSiteInfo(cmbSites.SelectedValue.ToString());
                if (si != null)
                {
                    DataSet roles = RoleInfoProvider.GetAllRoles(si.SiteID, false, false);
                    if (!DataHelper.DataSourceIsEmpty(roles))
                    {
                        foreach (DataRow role in roles.Tables[0].Rows)
                        {
                            // Determine preselection state
                            string siteName  = si.SiteName.ToLowerCSafe();
                            Guid   roleGuid  = ValidationHelper.GetGuid(role["RoleGuid"], Guid.Empty);
                            bool   checkRole = ImportProfile.Sites.ContainsKey(siteName) && ImportProfile.Sites[siteName].Contains(roleGuid);

                            // Create data for the row
                            object[] dataRow = { checkRole, role["RoleDisplayName"], roleGuid };

                            // Create new row with the table schema
                            DataRow dr = rolesTable.NewRow();
                            dr.ItemArray = dataRow;

                            // Add row to table
                            rolesTable.Rows.Add(dr);
                        }
                    }

                    // Apply sorting
                    rolesTable.DefaultView.Sort = COLUMN_ROLENAME;

                    // Bind table as a grid's datasource
                    grdRoles.DataSource = rolesTable;

                    if (!DataHelper.DataSourceIsEmpty(grdRoles.DataSource))
                    {
                        // Adjust columns
                        DataGridViewColumn columnSelected = grdRoles.Columns[COLUMN_SELECTED];
                        if (columnSelected != null)
                        {
                            columnSelected.HeaderText   = ResHelper.GetString("General_Assign");
                            columnSelected.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                        }

                        DataGridViewColumn columnRoleName = grdRoles.Columns[COLUMN_ROLENAME];
                        if (columnRoleName != null)
                        {
                            columnRoleName.HeaderText   = ResHelper.GetString("General_Role");
                            columnRoleName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                            columnRoleName.ReadOnly     = true;
                        }

                        DataGridViewColumn columnRoleGuid = grdRoles.Columns[COLUMN_ROLEGUID];
                        if (columnRoleGuid != null)
                        {
                            columnRoleGuid.Visible = false;
                        }
                    }
                }
            }
        }