Using user context data(from HttpContext) in the custom functions
-
- Posts: 6
- Joined: Mon May 14, 2018 9:35 am
Using user context data(from HttpContext) in the custom functions
We are trying to transform data(decimal values, date, currency format) on the fly during the report generating from a template (ASP.NET core application).
It's needed to change the format of the date or amount depending on the user context (which is created by the request).
I know that this can be done(data transformation) with the help of custom functions. But it's using static methods to create the functions in which we cannot use the user context.
The question is: is there any way to use user context in the custom functions? Or is there some other mechanism for changing the settings of the date, currency formats etc. on the fly during the report generation?
It's needed to change the format of the date or amount depending on the user context (which is created by the request).
I know that this can be done(data transformation) with the help of custom functions. But it's using static methods to create the functions in which we cannot use the user context.
The question is: is there any way to use user context in the custom functions? Or is there some other mechanism for changing the settings of the date, currency formats etc. on the fly during the report generation?
Re: Using user context data(from HttpContext) in the custom functions
Hello.
The format of the dates and numbers depends on local settings.
If you need any other format you could change the Culture property of the report.
In this case, all currencies dates and numbers will be shown in the selected culture.
Also you could change the Text Format property of each text component separately or use the ToString() or other formatting methods.
Thank you.
The format of the dates and numbers depends on local settings.
If you need any other format you could change the Culture property of the report.
In this case, all currencies dates and numbers will be shown in the selected culture.
Also you could change the Text Format property of each text component separately or use the ToString() or other formatting methods.
Thank you.
-
- Posts: 6
- Joined: Mon May 14, 2018 9:35 am
Re: Using user context data(from HttpContext) in the custom functions
Hi, thank you for your answer. But how could I change the Culture property of the report on the fly during the report generation process? And could I change direct the specific culture settings (e.g. currency or decimal format) by the report engine in the code?
Re: Using user context data(from HttpContext) in the custom functions
Hello.
You could change the Culture propety of the report with next code:
Thank you.
You could change the Culture propety of the report with next code:
Code: Select all
report.Culture = "en-US";
Re: Using user context data(from HttpContext) in the custom functions
@HighAley,
Let me please generalize the question. The example mentioned by @Arysmyatov is only one use case.
What we really need is to be able to get a tenant context in a multi tenant environment to be able to execute different functions based on this context.
Thanks
Vitaly
Let me please generalize the question. The example mentioned by @Arysmyatov is only one use case.
What we really need is to be able to get a tenant context in a multi tenant environment to be able to execute different functions based on this context.
Thanks
Vitaly
Re: Using user context data(from HttpContext) in the custom functions
Hello,
What kind of functions do you want to execute?
There are different events of the report and each component of the report that you could use.
Maybe you could use other features of our product as Conditions or any other.
We need more information about your scenario.
Thank you.
What kind of functions do you want to execute?
There are different events of the report and each component of the report that you could use.
Maybe you could use other features of our product as Conditions or any other.
We need more information about your scenario.
Thank you.
Re: Using user context data(from HttpContext) in the custom functions
Hello, Vitaly.
Yes, you could use the AddFunction method to add custom functions.
Do you get any issue with it?
Thank you.
Yes, you could use the AddFunction method to add custom functions.
Do you get any issue with it?
Code: Select all
StiFunctions.AddFunction("Category", "LookupCode", "LookupCode", "..", typeof(int), typeof(object), "...", new Type[] { typeof(object) }, new string[] { "a" }, new string[] { "b" });
Re: Using user context data(from HttpContext) in the custom functions
Hi,
I know we can and we are doing it. But as I mentioned before....
Thanks
Vitaly
I know we can and we are doing it. But as I mentioned before....
So how can we do it within the code of this function?
Thanks
Vitaly
Re: Using user context data(from HttpContext) in the custom functions
Hello, Vitaly.
Our component is embedded in your web application.
You could get the HHTPContext in any available way.
Sorry, maybe we don't understand your question.
Could you elaborate on it?
Thank you.
Our component is embedded in your web application.
You could get the HHTPContext in any available way.
Sorry, maybe we don't understand your question.
Could you elaborate on it?
Thank you.