0
votes

I'm trying to implement a SSRS reporting feature in a Silverlight 5 application, which is operating in browser mode.

Attempt 1) The initial plan was to render the page using the URL technique on the Silverlight client

var path = item.Path; // Where item.Path is something like '/MyReportFolder/Report1'
var url= @"http://<MyServerAddress>/ReportServer/Pages/ReportViewer.aspx?{0}&rs:Command=Render";
var completeUrl = string.Format(url, path.Replace(@"/", "%2f").Replace(" ", "+"));
System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(completeUrl), "_newWindow", "toolbar=0,menubar=0,resizeable=1,scrollbars=1");

The issue here is that permission to call this URL would be difficult to manage, and is not related to the basic security under which the Silverlight application operates.

Attempt 2) Render the report on the IIS server (instead of on-the-client, on behalf of the user via a WCF call) via a similar Url call in a WebClient and download the byte[] output, then send the byte[] to the Silverlight client (as a response to the WCF call), and then render the content within the Silverlight app.

var path = itemPath;
var url = @"http://<MyServerAddress>/ReportServer/Pages/ReportViewer.aspx?{0}&rs:Command=Render";
var completeUrl = string.Format(url, path.Replace(@"/", "%2f").Replace(" ", "+"));

var tcs = new TaskCompletionSource<byte[]>();
var webClient = new WebClient();

webClient.DownloadDataCompleted += (sender, args) => tcs.TrySetResult(args.Error != null ? args.Result : new byte[0]);
webClient.DownloadDataAsync( new Uri(completeUrl));
return tcs.Task;

Works fine also to render the report to a byte[], and the security is easily handled via the WCF service operation call. However, once the byte[] is received on the client, I'm not aware of how to show the result on the screen. My preference would be to open a new browser window and render the content into it, however the System.Windows.Browser.HtmlPage.Window does not support this.

So my options are:

  1. Render the result on the IIS server to a temporary file and send the URL (instead of the byte[]) to the Silverlight client, so a browser client can open the result. This is a bad result, as the outcome is very similar to Attempt 1 as the Url is then available to third party receivers
  2. Render the report as a TIFF byte[], however I'm not sure this will handle multipage reports, and it may not support PDF and XLS report content, as a TIFF would need to be displayed in a Silverlight Image Control, instead of the browser.
  3. Some other fantastic alternative I've yet to consider...

Has anyone else attempted an enterprise SSRS feature in a Silverlight application and found solutions to similar issues?

1

1 Answers

0
votes

There is a component - PerpetuumSoft Viewers For SSRS (it's our component I need to confesss) which seamlessly integrates SSRS reports in Silverlight applications using a native XAML based viewer. So we obviously found the solution.