You
can create, read, update, and delete PPS objects through the SDK by
calling into a web service, named the BIMonitoringAuthoringService,
through a class available in the
Microsoft.PerformancePoint.Scorecards.Client.dll named
BIMonitoringAuthoringServiceProxy. This class contains static methods
that can locate and instantiate an IBIMonitoringAuthoring object that enable interaction with the web service.
Caution
Technically you can call the
web service directly without the help of the client-side assemblies, but
the Web Service Description Language (WSDL) document that ships with
PPS 2010 does not completely match the implementation. You need to
either modify the WSDL or acquire an updated one from an alternative
source.
To prepare your Visual
Studio project, first add a reference to
Microsoft.PerformancePoint.Scorecards.Client.dll. Then include the
following using statement at the top of any file:
using Microsoft.PerformancePoint.Scorecards;
The web service calls
are accomplished by creating an instance of a
BIMonitoringAuthoringServiceProxy object and calling methods from the
instance. In this code sample, we connect to the
BIMonitoringAuthoringService from the root site collection. We then
retrieve all the objects from a PPS Content list named PerformancePoint
Content and print out their name and their content type designation:
string WebServiceUrl = "http://servername/_vti_bin/PPSAuthoringService.asmx";
string ListRelativeUrl = "/Lists/PerformancePoint Content";
IBIMonitoringAuthoring cService =
BIMonitoringAuthoringServiceProxy.CreateInstance(WebServiceUrl);
FirstClassElementCollection allFCOs = cService.GetListItems(ListRelativeUrl);
foreach (FirstClassElement oneFCO in allFCOs)
Console.WriteLine (oneFCO.Name + " of type " + oneFCO.ContentType);
This technique is useful when
creating PPS objects, too. Often, it is not clear exactly what
properties need to be set for an object to be usable in a dashboard or
in Dashboard Designer. You can discover this information by creating
objects through Dashboard Designer and then querying the object for
properties in Visual Studio.
Creating Indicator Example
In the following
example, we create an indicator that extends the built-in Stoplight
indicator to change the default text color to purple:
A GUID will be automatically assigned to the object upon saving to the SharePoint content list.
Some
indicator functionality is contained in a different namespace, so it is
necessary to add this using a statement to the top of your coding file.
using Microsoft.PerformancePoint.Scorecards.Indicators;
There is a special NoDataIndicatorBand that must be defined for each indicator created.
In
this example, we just copy the existing bands from a built-in indicator
(the Stoplight pattern). You can create or customize your own indicator
bands. The number of bands for an indicator is dynamically set by the
number of bands added to the IndicatorBands collection of the Indicator object.
Indicator indicator = new Indicator();
indicator.Name.Text = "My Indicator";
indicator.IndicatorType = IndicatorType.Standard;
Indicator stoplightIndicator = Indicators.BuiltinIndicators.Indicators.
First(s => s.Name.Text == "Stoplight");
indicator.NoDataIndicatorBand = stoplightIndicator.NoDataIndicatorBand;
foreach( IndicatorBand oneBand in stoplightIndicator.IndicatorBands )
{
oneBand.Color = "#800080";
indicator.IndicatorBands.Add(oneBand);
}
indicator.Validate();
IBIMonitoringAuthoring cService = BIMonitoringAuthoringService
Proxy.CreateInstance(WebServiceUrl);
cService.CreateIndicator(ListRelativeUrl, indicator);
Updating Custom Properties on KPIs
In the following example, we
modify all KPIs in a specific content list to add a custom property that
can then display on a scorecard. This code adds a single hyperlink
property named Web Site Link to all KPIs and then saves the KPIs back to
the server one by one:
IBIMonitoringAuthoring cService = BIMonitoringAuthoringService
Proxy.CreateInstance(WebServiceUrl);
FirstClassElementCollection allFCOs = cService.GetListItems(ListRelativeUrl);
foreach (Kpi kpi in allFCOs.Where(fco => fco.ContentType == FCOContentType.PpsKpi) )
{
BpmPropertyHyperlink newHyperlinkProperty = new BpmPropertyHyperlink();
newHyperlinkProperty.Hyperlink = "http://www.bing.com";
newHyperlinkProperty.DisplayName = "Web site link";
newHyperlinkProperty.UniqueName = Guid.NewGuid().ToString();
kpi.Properties.Add(newHyperlinkProperty);
cService.UpdateKpi(kpi);
}