Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
string dataConnectionsLibraryUrl = "http://sharepoint/dashboard/Data Connections/DataSources"
string directorySourceFile = "D:\upload\Reporting.SSAS.Tabular.rds";
//Need to change file extension for SharePoint
string sourceFileName = Path.GetFileName(directorySourceFile).Replace("rds", "rsds");
//Relevant for dataset property
string dataSourcesFileFullUrl = string.Concat(dataConnectionsLibraryUrl, sourceFileName);
XmlNode extensionNode = null;
XmlDocument xDocument = new XmlDocument();
using(FileStream stream = File.OpenRead(directorySourceFile))
{
xDocument.Load(stream);
}
//Get connection data
XmlNodeList connectionPropertiesNodes = xDocument.SelectNodes("RptDataSource/ConnectionProperties");
foreach(XmlNode node in connectionPropertiesNodes)
{
extensionNode = node.SelectSingleNode("Extension");
}
//Set Data Source Definition
DataSourceDefinition dsDefinition = new DataSourceDefintion();
dsDefinition.Extension = extensionNode.InnerText;
dsDefinition.Prompt = null;
dsDefinition.ConnectString = "Data Source=....;Initial Catalog=....";
dsDefinition.ImpersonateUserSpecified = true;
dsDefinition.WindowsCredentials = true;
dsDefinition.CredentialRetrieval = CredentialRetrievalEnum.Store;
dsDefinition.UserName="ReportAccount";
dsDefinition.Password="ReportPassword";
//Upload it to reporting service
reportingService.CreateDataSourcde(sourceFileName, dataConnectionsLibraryUrl, true, null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.