Created
December 27, 2017 20:41
-
-
Save Vintaurus/fbc96a2b58b92879dc22708db962d423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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