Hi support team,
Currently I have 3 reports called A, B, C with format *.trdp
I used CustomReportResolver to bind datasource for these reports. The problem is I have to use if else condition to know which report is A or B or C to get and bind correct data to the report. Imagine I have 100 reports it will be nightmare for me.
Do we have any way to resolve this or any way to get data source at run time for Standalone Report except the way I described above ?
NOTE: Before I used Visual Studio Report Designer and use NeedDataSource event in each report to get data for them now I have this issue when migrate to Standalone Report Designer.
Example Code:
public ReportSource Resolve(string reportId, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues) { var reportPath = Path.Combine(this.ReportsPath, reportId); var reportPackager = new ReportPackager(); Report report = null; using (var sourceStream = File.OpenRead(reportPath)) { report = (Report)reportPackager.Unpackage(sourceStream); } if (reportId == "A") { if (operationOrigin == OperationOrigin.GenerateReportDocument) { report.DataSource = GetDataForReportA(); } } else if (reportId == "B") { if (operationOrigin == OperationOrigin.GenerateReportDocument) { report.DataSource = GetDataForReportB(); } } else if (reportId == "C") { if (operationOrigin == OperationOrigin.GenerateReportDocument) { report.DataSource = GetDataForReportC(); } } return new InstanceReportSource { ReportDocument = report }; }
Thanks