CustomStore method called multiple times

Posted by: mike.killey on 16 December 2020, 2:23 am EST

    • Post Options:
    • Link

    Posted 16 December 2020, 2:23 am EST

    Hi,

    I am using the CustomStore option so that I can load reports dynamically and interject parameters etc.

    I’ve noticed that the custom store implementation method I’ve defined is called three times from the JSViewer - firstly /info, then /render and finally there is /values.

    Could you please tell me what is expected from each of these URL calls? I’m hoping to pre-populate a number of dynamic parameters within the report (the ‘from query’ of report parameters does not seem to work as expected), but don’t want to be fetching data and injecting it into the report on all three URL calls made to the custom store GetReport method. I’d prefer to be returning the bare minimum each time that method is called. Currently I am loading the report file into a PageReport, adding dynamic parameters, then returning the PageReport.Report property. This all works fine, but I’d like to streamline and reduce database calls.

    Thanks.

  • Posted 16 December 2020, 9:34 pm EST

    Hello,

    Currently, the ReportsService.GetReport() method is called during the processing of the following requests:

    "/reports/

    {reportId}/info" (get the report descriptor)

    “/reports/{reportId}

    /values” (get the report parameters values)

    "/reports/

    {reportId}/render" (start render report)

    "/reports/{reportId}

    /export/

    {exportType}

    " (export report)

    All these requests are processed independently and report data is not cached.

    To overcome this, you can cache the report at your end by using the following of code:

    app.UseReporting(settings =>
           {
               var cache = new MemoryCache(new MemoryCacheOptions { SizeLimit = 10000 });
               settings.UseCustomStore(reportId =>
               {
                   return cache.GetOrCreate(reportId, entry =>
                   {
                       var reportFile = new FileInfo(Path.Combine(FileStoreReportsPath, reportId));   
               
                       entry.SetSlidingExpiration(TimeSpan.FromSeconds(30));
                       entry.SetSize(1000);
               
                       return new PageReport(reportFile);
                   });
               });
    
               settings.UseCompression = true;
           });
    

    Hope it helps.

    Thanks,

    Mohit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels