Share via


Creating and Deploying Dashboards Remotely

You can create and deploy PerformancePoint dashboards remotely by using several assemblies that are installed with Dashboard Designer. The code example in this article shows how to create a report object and a dashboard object, deploy (publish) a dashboard to SharePoint Server, and retrieve an existing dashboard object by name.

Note: Creating and deploying dashboards remotely is not an officially supported scenario for PerformancePoint Services development, therefore the API is not exposed in the SDK.

Using the code example
1. In Visual Studio, create a C# console application project that uses the .NET Framework 3.5.
2. Add the following PerformancePoint and SharePoint assemblies as references to your project. To find the path to these assemblies, run Dashboard Designer and open Task Manager to the Process tab. Right-click DashboardDesigner.exe and select Open File Location.

· Microsoft.PerformancePoint.Scorecards.Client

· Microsoft.PerformancePoint.Scorecards.DesignerPlugins

· Microsoft.PerformancePoint.Scorecards.DesignerWorkspace

These assemblies enable you to use the BIMonitoringAuthoringServiceProxy object to create and retrieve PerformancePoint objects from the repository and the ScorecardModel, SharePointDeploy, and SharePointProxy objects to deploy a dashboard.
Note: You must also add references to System.Web.Services and System.Windows.Forms.
3. Replace the placeholder code in Program.cs with the code example below.
4. Edit the strings in the "Configuration variables" region as needed to match your configuration.
5. Run the application. You must be logged on as a user that has sufficient permissions to create content on the target SharePoint Server site.

Important This example is for demonstration purposes only and is not supported by Microsoft. When developing your own implementation, be sure to follow coding best practices for security and performance.

 using System;
  
 using System.Globalization;
  
 using Microsoft.PerformancePoint.Scorecards;
  
 using Microsoft.PerformancePoint.Scorecards.DesignerPlugins.Deploy;
  
 using Microsoft.PerformancePoint.Scorecards.DesignerPlugins.Deploy.SharePoint;
  
 using Microsoft.PerformancePoint.Scorecards.DesignerWorkspace;
  
 namespace Microsoft.PerformancePoint.Scorecards.SDK
  
 {
  
 // TODO: Handle exceptions from all calls.
  
 class DeployDashboardApp
  
 {
  
 // Define the variables used to create the report 
  
 // and dashboard, and to deploy the dashboard.
  
 #region Define variable for your configuration
  
 // Change these default values to match your configuration. 
  
 // For example, if your configuration does not contain a site
  
 // collection, remove "/bicenter" from the following paths.
  
 static string serverName = "serverName";
  
 static string sitePath = "/bicenter";
  
 static string deploymentPath = "Dashboards";
  
 static string masterPagePath = "/bicenter/_catalogs/masterpage/v4.master";
  
 static string masterPageName = "v4";
  
 // Define the path to the SharePoint list that stores
  
 // PerformancePoint content.
  
 static string listUrl = "/bicenter/Lists/PerformancePoint Content/";
  
 #endregion
  
 // Create an instance of the web service proxy.
  
 static IBIMonitoringAuthoring authoringService = BIMonitoringAuthoringServiceProxy.CreateInstance("https://" + serverName + "/_vti_bin/PPS/PPSAuthoringService.asmx");
  
 static void Main(string[] args)
  
 {
  
 string dashboardName = "Remotely Deployed Dashboard";
  
 ReportView report = CreateReport();
  
 Dashboard dashboard = CreateDashboard(dashboardName, listUrl, report);
  
 DeployDashboard(dashboard);
  
 // Instead of creating a new dashboard, you can retrieve 
  
 // an existing dashboard.
  
 // This method shows how to retrieve a dashboard by name.
  
 GetDashboardByName(dashboardName);
  
 }
  
 // Create and save the report that will be added to the dashboard.
  
 static ReportView CreateReport()
  
 {
  
 string reportName = "Autogenerated Web Page Report";
  
 ReportView tempReport = ReportView.CreateNew();
  
 tempReport.Name.Text = reportName;
  
 tempReport.SubTypeId = ReportViewNames.Url;
  
 tempReport.CustomData = "https://msn.com";
  
 // Save the report to the repository.
  
 return authoringService.CreateReportView(listUrl, tempReport);
  
 }
  
 // Create a dashboard that contains a report, based on the 
  
 // following parameters:
  
 // - dashboardName is the name for the dashboard.
  
 // - listUrl is the server-relative URL of the list to
  
 // save the dashboard to.
  
 // - report is a report to add to the dashboard.
  
 static Dashboard CreateDashboard(string dashboardName, string listUrl, ReportView report)
  
 {
  
 if (String.IsNullOrEmpty(dashboardName))
  
 throw new ArgumentException("The name must not be null or empty.");
  
 if (String.IsNullOrEmpty(listUrl))
  
 throw new ArgumentException("The list URL must not be null or empty.");
  
 if (null == report)
  
 throw new ArgumentNullException("report");
  
 Dashboard dashboard = Dashboard.CreateNew();
  
 dashboard.Name.Text = dashboardName;
  
 dashboard.Description.Text = "Created with BIMonitoringAuthoringServiceProxy.";
  
 // Define the page. The dashboard has one page with one zone.
  
 DashboardElementContainer page = new DashboardElementContainer();
  
 page.Guid = Guid.NewGuid();
  
 page.Name.Text = "Dashboard Page 1";
  
 page.Orientation = LayoutOrientation.VerticalTopJustified;
  
 dashboard.TemplateType = DashboardTemplateId.Zone1;
  
 // Define the zone. 
  
 DashboardElementContainer zone = new DashboardElementContainer();
  
 zone.Guid = Guid.NewGuid();
  
 zone.Name.Text = "Zone 1";
  
 zone.Height = new DashboardElementSize();
  
 zone.Height.Units = System.Windows.Forms.SizeType.Percent;
  
 // The dashboard has one zone, so set the zone to 100 percent.
  
 zone.Height.Measurement = 100;
  
 zone.Orientation = LayoutOrientation.HorizontalLeftJustified;
  
 // Define the FCO that the zone contains.
  
 DashboardItem item = new DashboardItem();
  
 item.Guid = Guid.NewGuid();
  
 item.Height.Measurement = 100;
  
 item.Height.Units = System.Windows.Forms.SizeType.Percent;
  
 FirstClassElement currentElement;
  
 currentElement = report;
  
 item.AutoSizeHeight = false;
  
 item.AutoSizeWidth = false;
  
 item.UnderlyingElementType = currentElement.GetType();
  
 item.UnderlyingElementLocation = currentElement.Location;
  
 zone.DashboardElements.Add(item);
  
 page.DashboardElements.Add(zone);
  
 dashboard.Pages.Add(page);
  
 // Save the dashboard to the repository.
  
 return authoringService.CreateDashboard(listUrl, dashboard);
  
 }
  
 static void DeployDashboard(Dashboard dashboard)
  
 {
  
 // Set the dashboard properties. 
  
 dashboard.SitePath = sitePath;
  
 dashboard.DeploymentPath = deploymentPath;
  
 dashboard.MasterPagePath = masterPagePath;
  
 dashboard.MasterPageDisplayName = masterPageName;
  
 bool createPageList = string.IsNullOrEmpty(dashboard.PageList) ? (0 < dashboard.Pages.Count) : Convert.ToBoolean(dashboard.PageList, CultureInfo.CurrentUICulture);
  
 FirstClassElementCollection fcoColl = authoringService.GetListItems(listUrl);
  
 // Get an instance of ScorecardModel and populate
  
 // it with the repository items.
  
 // ScorecardModel throws a NullReferenceException
  
 // if it does not have all the items it needs to
  
 // generate the dashboard mark-up.
  
 foreach (FirstClassElement element in fcoColl)
  
 {
  
 ScorecardModel.GetInstance().ElementsOnServer.AddElement(element);
  
 }
  
 // Build the URL and deploy the dashboard.
  
 string sharePointSiteUrl = "https://" + serverName + dashboard.SitePath;
  
 Uri siteUrl = new Uri(sharePointSiteUrl);
  
 if (null != dashboard)
  
 {
  
 SharePointDeploy sharePointDeploy =
  
 new SharePointDeploy(
  
 SharePointProxy.CreateSharePointProxy(siteUrl),
  
 dashboard,
  
 createPageList);
  
 Uri dashboardUrl = sharePointDeploy.DeployDashboard(dashboard.DeploymentPath, dashboard.MasterPagePath);
  
 }
  
 }
  
 // Retrieve an existing dashboard object by name.
  
 static Dashboard GetDashboardByName(string dashName)
  
 {
  
 foreach (FirstClassElement item in authoringService.GetListItems(listUrl))
  
 {
  
 if (item.ContentType == FCOContentType.PpsDashboard)
  
 {
  
 if (item.Name.Text == dashName)
  
 {
  
 return (Dashboard)item;
  
 }
  
 }
  
 }
  
 return null;
  
 }
  
 }
  
 }
  

Josh Unger, Marko Lah, Diane Diaz

Related information

SPDataStore Class (contains code examples for FCO CRUD methods)

[MS-PPSAS]: PerformancePoint Services Authoring Service Protocol Specification

Comments

  • Anonymous
    October 29, 2010
    Nice article! :) Where can I read documentation about it? I want more... I want to get analytics chart and change their config/queries programmatically... but I dont know if this is possible... :S Regards, Thiago.

  • Anonymous
    October 09, 2011
    Is it possible to hide scorecard elements programmatically ?  I have a report with a calendar filter and I want to show the kpi actual value for all months selected, but the kpi target and the kpi trend only for the last month selected in the filter

  • Anonymous
    November 09, 2011
    Good Article, Thanks. I have a question, how to create performancepoint 2010 dashboard reports using oracle data.Scot

  • Anonymous
    October 01, 2012
    Is this post still relevant for SharePoint 2013, or is there a new way to create and package performancepoint content (including dashboards) as a feature via Visual Studio? I understand that SharePoint 2013 has new dashboard migration features.  Would this now be the preferred way to do this?

  • Anonymous
    October 24, 2012
    Paul, this should still be relevant for 2013.

  • Anonymous
    May 05, 2014
    Hi, This code is working in my vm but it fails in the https connection error is as: Unable to connect to the remote server Do you have any solution for that? Thanks

  • Anonymous
    June 01, 2014
    Hi, I need to run same code through wcf service since I need to call it from CLR. Same code is working under share point project but I can't open deployed page if I run it through WCF. I found the error: Unexpected System.Web.HttpException: 'redef.dev/.../v4.master& is not a valid virtual path.