UserIdentity in ReportProcessor.RenderReport

0 Answers 237 Views
Report Viewer - HTML5 Rest Service Upgrade
Chana
Top achievements
Rank 1
Chana asked on 23 Jan 2022, 08:18 AM

Hllow,

We using with Rest API

In our project we use with 2 different ways with the reports:

sometimes with html5 report viewer. and other time we render the reports in the code with ReportProcessor, RenderReport.

Until now we use wit previous version of telerik reporting (from 2015)  and now we upgrade our solution to newer version,

We need to use in the reports with http.context data.

From 2018 this data is not available in report possessing, I override the GetUserIdentity function in the reportscontroller. In the reports I success to get the user data.

But when I Render the reports at code I do not now how to send to report this data(UserIdentity). Additionally,  when I try to get data from UserIdentity.Current in the report (after call render report function) I get older data of another report with proccessing from HTML5 viewer.

My questions:

1. Is there a way to use UserIdentity in ReportProcessor.RenderReport? (find attached option2-render report.PNG)

2. Why I sometimes get old value in reports which call from RenderReport function?

Thanks,Chani

Neli
Telerik team
commented on 27 Jan 2022, 10:30 AM

Hi Chana,

We have such a feature request - Provide "Telerik.Reporting.Processing.UserIdentity.Current.Context" to "ReportProcessor" object in our Feedback portal. I would recommend voting for it to increase its priority. 

The Telerik.Reporting.Processing.UserIdentity.Current.Context is an IDictionary<string, object> that may be used to pass custom objects to the Report. By design, the UserIdentity object gets populated with the current user in web applications utilizing the Telerik Reporting REST Service. You may change its value from the ReportsController > GetUserIdentity method.

For renderings with the ReportProcessor, we haven't exposed a property or method you may use to set a value for the UserIdentity and its inner properties. The identity is Null. The reason is that you may use other approaches to pass information to the report.

For example, if you need to provide some custom values that don't comply with the Report Parameter Types to the Report, you may utilize a custom User Function instead.

You also may test the following piece of code. In order to make the thread safe, you can:

  • Execute the code in the static constructor of the controller, as it is thread-safe.
  • Use it in a lock statement to assure it is thread-safe.
Telerik.Reporting.Processing.UserIdentity.Current = new Telerik.Reporting.Processing.UserIdentity();
Telerik.Reporting.Processing.UserIdentity.Current.Context = TelerikReportContext;

When it comes to the second issue, indeed, it is strange. You may test to debug and check what values are passed.

No answers yet. Maybe you can help?

Tags
Report Viewer - HTML5 Rest Service Upgrade
Asked by
Chana
Top achievements
Rank 1
Share this question
or