Download custom IReportResolver example (C#)
The Telerik Reporting Service is a WCF service that enables the remote access to the Telerik Reporting Engine (aka ReportProcessor). The Reporting Service acts as a communication interface between the client programs and the ReportProcessor.
The client programs invoke the report rendering from the service using a string report description. Based on the report description the service’s report resolvers try to create an IReportDocument instance needed by the ReportProcessor.
The IReportDocument interface represents a report document. This includes a single Report or ReportBook. The IReportDocument returned by the report resolver will be further handled by the ReportProcessor.
The service includes default report resolvers that are capable to resolve IReportDocument from relative and physical path that points to trdx file (report definition serialized in XML) or from assembly qualified name. This way we cover most of the scenarios. However if you have requirements that are not covered by the default report resolvers, such as retrieving report definitions stored in database or building a report book based on the report description, you can plug into the Telerik Reporting Service report resolving workflow.
The report resolvers implement the IReportResolver interface. This interface has only one method Resolve with a string argument - the report description. In custom resolver implementations you should use that description as you like in order to map it to IReportDocument instance.
If you use the Silverlight report viewer the report description is provided by the ReportViewer.Report property.
Prerequisites:
Even if you use your own IReportResolver implementation you can still fallback to the default IReportResolver implementations as shown in the following walkthrough.
class CustomReportResolverWithFallBack : IReportResolver{ readonly IReportResolver parentResolver; public CustomReportResolverWithFallBack(IReportResolver parentResolver) { this.parentResolver = parentResolver; } public ReportSource Resolve(string report) { ReportSource reportDocument = this.CustomReportResolver(report); if (null == reportDocument && null != this.parentResolver) { reportDocument = this.parentResolver.Resolve(report); } return reportDocument; } public ReportSource CustomReportResolver(string report) { //TODO implement custom report resolving mechanism return null; }}namespace CSharp.SilverlightDemo.Web { using Telerik.Reporting.Service; using Telerik.Reporting; public class CustomReportService : ReportService { // static readonly IReportResolver resolvers = new CustomReportResolverWithFallBack( new ReportTypeResolver( new ReportFileResolver( new ReportFileResolverWeb(null)))); public CustomReportService() { this.ReportResolver = resolvers; } } }<%@ServiceHost Service="CSharp.SilverlightDemo.Web.CustomReportService, CSharp.SilverlightDemo.Web" %><?xml version="1.0" encoding="utf-8" ?><configuration> <system.serviceModel> <services> <service name="CSharp.SilverlightDemo.Web.CustomReportService" behaviorConfiguration="ReportServiceBehavior"> <endpoint address="" binding="basicHttpBinding" contract="Telerik.Reporting.Service.IReportService"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="resources" binding="webHttpBinding" behaviorConfiguration="WebBehavior" contract="Telerik.Reporting.Service.IResourceService"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="ReportServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="WebBehavior"> <webHttp /> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel></configuration>
Stefan’s main interests outside the .NET domain include rock music, playing the guitar and swimming.