Skip to content

Instantly share code, notes, and snippets.

@Vintaurus
Created December 27, 2017 20:43
Show Gist options
  • Save Vintaurus/3810f020ce5398ebbd11d704afee775d to your computer and use it in GitHub Desktop.
Save Vintaurus/3810f020ce5398ebbd11d704afee775d to your computer and use it in GitHub Desktop.
string directoryReportFile = "D:\upload\Reports\DailyReport.rdl";
string reportFileName = Path.GetFileName(datasetFile);
string reportFullUrl = string.Concat("http://sharepoint/dashboard/Reports/", reportFileName)
SPList reportLibrary = <Reports>;
//First upload all report files
using(FileStream fileStream = File.OpenRead(directoryDatasetFile))
{
reportLibrary.Files.Add(datasetFileName, fileStream, true);
}
//Use this step, if all report files are uploaded. Some reports use subreports
ItemReferenceData[] itemDataList = reportingService.GetItemReferences(reportFullUrl, "DataSet");
ItemReference[] items = new ItemReference[itemDataList.Length];
if (itemDataList.Length > 0)
{
//get all dataset files from one report
for (int i = 0; i < itemDataList.Length; i++)
{
ItemReferenceData itemData = itemDataList[i];
ItemReference item = new ItemReference();
item.Name = itemData.Name; //Name of dataset
reportFile.DatasetFullUrl = <GetDatasetFullUrl(itemData.Name, datasetFiles)>;
item.Reference = reportFile.DatasetFullUrl;
items[i] = item;
}
reportingService.SetItemReferences(reportFile.FullUrl, items);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment