Thursday, April 15, 2010

Programming Performance Point Services 2010 – Part 2 (Create a new DataSource In Performance Point Programmatically)

Check the First Post (Click Here)

The Below function will allow you to create a new DataSource inside Performance Point

public IDataSource CreateNewAnalysisServicesDataSource(string dataSourceName,string serverName,string databaseName,string cubeDisplayName,DSConnectionContext connectionContext)
{
// Get a New Instance from the Service
PPSWebService service = PPSWebService.GetInstance();
// Create a new Data Source Instance
DataSource newDS = DataSource.CreateNew();
newDS.Name.Text = dataSourceName;
newDS.Description.Text = "Created By System";

newDS.ServerName = serverName;
// Set the Data Source Type to Analysis Services Type
newDS.SourceName = "ADOMD.NET";
newDS.CubeName = cubeDisplayName;
newDS.MinutesToCache = 10;
newDS.ContentType = FCOContentType.PpsDataSource;

// Set the Connection Type Based on Enumerator
if(connectionContext == DSConnectionContext.PerIdentity)
{
newDS.ConnectionContext = ConnectionContext.ConnectAsUser;
}else if(connectionContext == DSConnectionContext.SharedUser)
{
newDS.ConnectionContext = ConnectionContext.ConnectAsSharedUser;
}

newDS.DatabaseName = databaseName;

// Request the Service Instance to Create the DataSource
PPSWebService.GetInstance().WebService.CreateDataSource(Configurations.PerformancePointDefaultDataConnectionsList, newDS);
return new Datasource(newDS);

}





Note:



To be Able to restore the DataSource Again Always Store the List URL (Relative Path and the Item Index in your Data Store)



The Default List Should be store in a Relative Path like the below sample:



"Data%20Connections%20for%20PerformancePoint/"




Feel free to Contact me for more info mahmoud.m.moussa@gmail.com

No comments: