Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
string directoryDatasetFile = "D:\upload\Report_Dataset.rsd";
string datasetFileName = Path.GetFileName(datasetFile);
string datasetFullUrl = string.Concat("http://sharepoint/dashboard/Data Connections/Datasets/", datasetFileName)
SPFolder folder = ....; //get folder "Datasets" from library "Data Connections"
using(FileStream fileStream = File.OpenRead(directoryDatasetFile))
{
folder.Files.Add(datasetFileName, fileStream, true);
}
//Add DataSource
DataSourceReference reference = new DataSourceReference();
reference.Reference = dataSourcesFileFullUrl;
//if you have different datasource files for some reports, so you can get
//information directly from dataset file
/**
XmlDocument xDocument = new XmlDocment();
using(FileStream stream = File.OpenRead(directorySourceFile))
{
xDocument.Load(stream)
}
XmlNamespaceManager namespaces = new XmlNamespaceManager(xDocument.NameTable);
namespaces.AddNamespace("sdsd", "http://schemas.microsoft.com/sqlserver/reporting/2010/01/shareddatasetdefinition");
XmlElement root = xDocument.DocumentElement;
XmlNode dataSourceReferenceNode = root.SelectSingleNode("sdsd:DataSet/sdsd:Query/sdsd:DataSourceReference", namespaces);
string dataSourceFileName = dataSourceReferenceNode.InnerText;
**/
DataSource[] itemDataSources = reportingService.GetItemDataSources(datasetFullUrl);
DataSource dataSource = new DataSource();
dataSource = itemDataSource[0];
dataSource.Item = reference;
reportingService.SetItemDataSources(datasetFullUrl, itemDataSources);
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.