Search results

IReportController

The IReportController interface has the declaration of action methods that is defined in the Web API Controller for processing the RDL, RDLC, and SSRS report and handling the request from the Report Viewer control. The IReportController has the following action methods declaration.

Methods Description
GetResource Action (HttpGet) method to get a resource for the report.
PostReportAction Action (HttpPost) method to post the request for report process.
OnInitReportOptions Report initialization method that is triggered when the report begins to be processed.
OnReportLoaded Report loaded method is triggered when the report and sub report starts loading.

ReportHelper

The ReportHelper class contains helper methods that help you process a Post or Get request from the Report Viewer control and return the response to the Report Viewer control. It has the following methods.

Methods Description
GetResource Returns the report resource to the requested key.
ProcessReport Processes the report request and returns the result.
public class ReportsController: ApiController,IReportController
{
    /// <summary>
    /// Action (HttpGet) method for getting resource for report.
    /// </summary>
    /// <param name="key">The unique key to get the required resource.</param>
    /// <param name="resourceType">The type of the requested resource.</param>
    /// <param name="isPrinting">If set to <see langword="true"/>, then the resource is generated for printing.</param>
    /// <returns>The object data.</returns>
    public object GetResource(string key, string resourceType, bool isPrinting)
    {
        //Returns the report resource for the requested key.
        return ReportHelper.GetResource(key, resourceType, isPrinting);
    }

    /// <summary>
    /// Report Initialization method that is triggered when report begin processed.
    /// </summary>
    /// <param name="reportOptions">The ReportViewer options.</param>
    public void OnInitReportOptions(ReportViewerOptions reportOptions)
    {
        //You can update report options here
    }

    /// <summary>
    /// Report loaded method that is triggered when report and sub report begins to be loaded.
    /// </summary>
    /// <param name="reportOptions">The ReportViewer options.</param>
    public void OnReportLoaded(ReportViewerOptions reportOptions)
    {
        //You can update report options here
    }

    /// <summary>
    /// Action (HttpPost) method for posting the request for report process.
    /// </summary>
    /// <param name="jsonData">The JSON data posted for processing report.</param>
    /// <returns>The object data.</returns>
    public object PostReportAction(Dictionary < string, object > jsonData)
    {
        //Processes the report request and returns the result.
        return ReportHelper.ProcessReport(jsonData, this);
    }
}