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

Custom resolver not loading subreport

2 Answers 234 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
cody
Top achievements
Rank 1
cody asked on 14 Mar 2018, 04:55 PM

I am currently working towards moving our report files into database storage. I have setup a custom resolver that is able to get the report from the id properly; however, when the subreport is loaded, it does not appear to be using the /api/reports serviceUrl. instead, it is looking in the root directory of the project in visual studio and not being routed through the Reports controller. Of course, the report is not there. What do I need to do to make the reports to evaluate on the serviceUrl to get it like the other reports? 

Here's my resolver:

public class DatabaseReportResolver : Telerik.Reporting.Services.Engine.IReportResolver
    {
        public ReportSource Resolve(string message)
        {
            using (var _context = new CommonDataContext())
            {
                var report = _context.ReportRecord.FirstOrDefault(x => x.UniqueName == message);
                if(report == null)
                {
                    return null;
                }
                var fileContent = report.ReportFiles.OrderByDescending(x => x.DateActive).FirstOrDefault();

                if (fileContent != null)
                {
                    var file = fileContent.File;
                    XmlReportSource source = new XmlReportSource();
                    source.Xml = System.Text.Encoding.Default.GetString(file);
                    return source;
                }
            }
            return null;
        }

       
    }

2 Answers, 1 is accepted

Sort by
0
cody
Top achievements
Rank 1
answered on 14 Mar 2018, 05:02 PM
Also, I'm presented with a 'could not find file message.' It seems to be trying to go directly through the file system. 
0
Katia
Telerik team
answered on 19 Mar 2018, 12:43 PM
Hi cody,

Based on the provided information, it seems that the sub reports are specified via path, and the error occurs on resolving the SubReport item's ReportSource property as the target file is not mapped correctly on the server where the generation of the report happens.
Therefore, you might need to add the logic for mapping the sub report file on the server at the moment when the SubReport.ReportSource is handled.

In general, when using a TRDP/TRDX file with a UriReportSource the relative path to the sub reports will be based on the location of the file. If you resolve the report as an InstanceReportSource in custom resolver, the path to the sub reports will be relative to the application root directoryIn this scenario, you will need to change the ReportSource property of SubReport items (map the file on the server).


Regards,
Katia
Progress 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
cody
Top achievements
Rank 1
Answers by
cody
Top achievements
Rank 1
Katia
Telerik team
Share this question
or