How to get the environment at execution for FastReport
We are using FastReport with our on-premise ERP software.
Reports are designed with the FastReport Desktop (version 2021.4.15).
The reports are executed from within the ERP client which runs in the browser.
As we have multiple instances of the ERP (Dev, Test, Training, Production, ...) we need to include the environment in which a report is being executed.
I have looked at using the Report or Engine classes but I can't find any property or method that could give me a hint: I would be happy if I could retrieve the URL or server name or just anything that could help in distinguishing the environment.
Comments
I think you can make use of the parameters available in the reports.
And the .NET code for set parameter value.
Report reportFRX;
reportFRX.Load("XXXXXX.report.frx");
reportFRX.SetParameterValue("environment", "The value environment by appsetting.json, web.config, other");
reportFRX.SetParameterValue("executionGuid", Guid.NewGuid().ToString());
reportFRX.RegisterData(ds); //load data set
.... other code
reportFRX.Prepare();
--------------------------------------------------
The answer is a little late, but I hope it helps someone else.
😉
Thanks, any input welcome.
If I'm correct SetParameterValue assigns a value to a parameter? I am wondering where/how I could retrieve a value from a config file? Just note that we are running the report from an ERP application, we don't have own code that launches the report. We can pass a value to a parameter but would need to do that for every report separately.