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

Changing the SubReport.ReportSource in runtime

1 Answer 247 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fernando
Top achievements
Rank 1
Fernando asked on 18 Jun 2015, 12:44 PM

Hello guys. 

We are storing the TRDX files in the Windows Azure Cloud Storage in a Asp.Net MVC application. Given the *.trdx files are not on the disk, we need to verify at runtime (in a class that implements IReportResolver) if the report has a subreport. If it has, we try to get the trdx (xml content) an set the reportSource of a subReport as a XmlReportSource. Actually, we need to replace a UriReportSource to a XmlReportSource. It works when we do not have parameter, but does not work when we have parameters. Look at the code bellow:

// find a detail section and a subReport on it.
foreach (var section in reportInstance.Items.Where(i => i is DetailSection))
    foreach (var item in section.Items.Where(i => i is SubReport))
    {
        var subReport = (SubReport) item;
         
        // if the subReport is an UriReportSource
        if (subReport.ReportSource is UriReportSource)
        {
            // we try to convert the UriReportSource to XmlReportSource
            var subReportUriSource = (UriReportSource) subReport.ReportSource;
             
            // get an object that represents a report in our system
            var subReportViewModel = reportService.GetSubReportFileName(reportId, subReportUriSource.Uri);
 
            // create an instance of our helper to get the content from the windows azure cloud storage
            var storage = CloudStorageFactory.Create();
 
            // get the xml content
            var xmlContent = storage.GetContent(subReportViewModel.FileName);
 
            // create a XmlReportSource with the xmlContent
            var xmlReportSource = new XmlReportSource() {Xml = xmlContent};
             
            // set the parameters
            foreach (var parameter in subReportUriSource.Parameters)
                xmlReportSource.Parameters.Add(parameter);
             
            // set on the ReportSource
            subReport.ReportSource = xmlReportSource;
        }
    }
 

I am not sure if I can do it at runtime, or what I am doing wrong but it is giving an error like this:

 
Internal Server Error:
An error has occurred while processing the report. Processing canceled. Check the InnerException for more information.Invalid value of report parameter 'PersonID'.

 

Does anybody know what I can try? 

 

Internal Server Error:
An error has occurred while processing the report. Processing canceled. Check the InnerException for more information.Invalid value of report parameter 'PersonID'.
Internal Server Error:
An error has occurred while processing the report. Processing canceled. Check the InnerException for more information.Invalid value of report parameter 'PersonID'.
Internal Server Error:
An error has occurred while processing the report. Processing canceled. Check the InnerException for more information.Invalid value of report parameter 'PersonID'.

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 19 Jun 2015, 02:50 PM
Hello Fernando,

Beside reading the XML content you need to transfer the parameters from the original SubReport.ReportSource to the new report source object. For example check the code snippet in Changing the connection string dynamically according to runtime data (CreateInstanceReportSource method).


I hope the provided information is helpful.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Fernando
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or