Custom resolver not loading subreport

3 posts, 0 answers
  1. cody
    cody avatar
    3 posts
    Member since:
    Aug 2016

    Posted 14 Mar 2018 Link to this post

    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. cody
    cody avatar
    3 posts
    Member since:
    Aug 2016

    Posted 14 Mar 2018 in reply to cody Link to this post

    Also, I'm presented with a 'could not find file message.' It seems to be trying to go directly through the file system. 
  3. Katia
    Admin
    Katia avatar
    760 posts

    Posted 19 Mar 2018 Link to this post

    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
Back to Top