protected string CategorizeSelectedItems(string listUrl, string[] selectedItemIds)
        {
            // Get the item identifiers into the ItemUrl format.
            StringCollection itemUrls = new StringCollection();

            for (var i = 0; i < selectedItemIds.Length; i++)
            {
                if (!string.IsNullOrEmpty(selectedItemIds[i]))
                {
                    string itemUrl = listUrl + "/" + selectedItemIds[i] + "_.000";
                    itemUrls.Add(itemUrl);
                }
            }

            // Get the all items in the list and filter for analytic reports.
            // Getting the entire collection because we do not know in advance whether all selected items are analytic reports,
            // and we want to inform users which items are not and therefore will not be changed.
            FirstClassElementCollection fcos = SPDataStore.GlobalDataStore.GetListItems(listUrl);

            string notAnalyticReports = "";

            // Find each selected item in the returned collection.
            foreach (var itemUrl in itemUrls)
            {
                foreach (var fco in fcos)
                {
                    if (fco.Location.ItemUrl == itemUrl)
                    {
                        if (fco.ContentType == FCOContentType.PpsReportView)
                        {
                            ReportView report = (ReportView)fco.Clone();

                            // Add the selected analytic reports to the selectedAnalyticReports collection.
                            if (report.SubTypeId == ReportViewNames.AnalyticChart || report.SubTypeId == ReportViewNames.OLAPGrid)
                            {
                                selectedAnalyticReports.Add(report);
                                break;
                            }

                            // Add the names of non-analytic reports to the notAnalyticReports string.
                            else
                            {
                                notAnalyticReports += fco.Name.Text + "\n";
                                break;
                            }
                        }

                        // Add the names of selected items that are not reports to the notAnalyticReports string.
                        else
                        {
                            notAnalyticReports += fco.Name.Text + "\n";
                        }
                    }
                }
            }
            return(notAnalyticReports);
        }
        // Populate the data source dropdown with OLAP data sources from PerformancePoint Data Connections Libraries within the site.
        protected void PopulateDataSourceDropDownList()
        {
            Microsoft.PerformancePoint.Scorecards.DataSourceCollection avaliableDataSources = new Microsoft.PerformancePoint.Scorecards.DataSourceCollection();
            using (SPWeb site = SPContext.Current.Site.OpenWeb(siteUrl))
            {
                // Get available OLAP data sources in the site.
                foreach (SPList list in site.Lists)
                {
                    if (list.BaseType == SPBaseType.DocumentLibrary)
                    {
                        int baseTemplateValue = (int)list.BaseTemplate;
                        if ((baseTemplateValue == 470) && list.DoesUserHavePermissions(site.CurrentUser, SPBasePermissions.AddListItems))
                        {
                            FirstClassElementCollection dataSourceFcos = SPDataStore.GlobalDataStore.GetListItems(list.RootFolder.ServerRelativeUrl);
                            foreach (var ds in dataSourceFcos)
                            {
                                DataSource dataSource = (DataSource)ds;
                                if ((dataSource.SubTypeId == DataSourceNames.Adomd) || (dataSource.IsGemini))
                                {
                                    avaliableDataSources.Add(dataSource);
                                }
                            }
                        }
                    }
                }
            }

            Dictionary <string, string> dataSourcesForDropDown = new Dictionary <string, string>();

            foreach (var dataSource in avaliableDataSources)
            {
                string dataSourceDisplayString = dataSource.Location.GetListUrl() + "/" + dataSource.Name.Text + " (" + dataSource.ServerName + ")";
                dataSourcesForDropDown.Add(dataSourceDisplayString, dataSource.Location.ItemUrl);
            }

            ddlDataSources.DataSource     = dataSourcesForDropDown;
            ddlDataSources.DataTextField  = "Key";
            ddlDataSources.DataValueField = "Value";
            ddlDataSources.DataBind();
        }