This is a migrated thread and some comments may be shown as answers.

IReportResolver and print/save with Silverlight Viewer

1 Answer 137 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David Tosi
Top achievements
Rank 1
David Tosi asked on 21 Mar 2013, 05:08 PM
Hello-

I am using Telerik Reporting version Q1 2013 build 7.0.13.220 with the Silverlight viewer. I have implemented the IReportResolver interface to be able to pass custom parameters to reporting service. The primary reason for this is to support custom trdx reports and I need to know what report to create so I cannot pass this information to my custom report class. In the past I was able to do this with the report parameters but this was changed to be initialized after the report is created. So my solution was to use the custom IReportResolver which works great when viewing the report, but when I try to print the report, the path to the report appears to be falling back to the full class and assembly name, instead of my custom report path. Is there any way to get the printing and saving methods from the Silverlight control to pass the custom report path and not the fully qualified assembly/class path? I have verified that the custom report path is set correctly in the Report parameter of the ReportViewer control.

Thanks-
David Tosi

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 26 Mar 2013, 02:59 PM
Hello David,

As you have noticed the service makes subsequent request to the ReportResolver for export and refresh operations. Thus when you are deserializing the XML report definition to Telerik.Reporting.Report and returning an InstanceReportSource it's expected the subsequent calls to the resolver to be with this type. In order to avoid this unexpected behavior our recommendation is to return an UriReportSource and cache temporary trdx definitions for usage in the subsequent requests as shown in the following code snippet sample:

public ReportSource Resolve(string fullPath)
{
    try
    {
        new Uri(fullPath);
        return new UriReportSource
        {
            Uri = fullPath
        };
    }
    catch (UriFormatException) { }
   
    var settings = new System.Xml.XmlReaderSettings();
    settings.IgnoreWhitespace = true;
   
    using (var fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
    {
        var xmlSerializer = new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
   
        var report = (Report)xmlSerializer.Deserialize(fileStream);
   
        SetConnectionString(ConnectionString.ProviderName,
                ConnectionString.GetOracleConnectionString(), report);
   
        var reportFilePath = MapPath("report" + Guid.NewGuid() + ".xml");
        using (var tempFileStream = new FileStream(reportFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite))
        {
            using (var xmlWriter = System.Xml.XmlWriter.Create(tempFileStream))
            {
                xmlSerializer.Serialize(xmlWriter, report);
            }
        }
   
        return new UriReportSource
        {
            Uri = reportFilePath
        };
    }
}

Generally it's in our plans to enable the custom IReportResolver implementations to work directly with all of the available report sources.

Kind regards,
Peter
the Telerik team

Telerik Reporting Q1 2013 available for download with impressive new visualizations. Download today from your account.



Tags
General Discussions
Asked by
David Tosi
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or