-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCustomReportProvider.cs
More file actions
46 lines (38 loc) · 1.74 KB
/
CustomReportProvider.cs
File metadata and controls
46 lines (38 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using DevExpress.XtraReports.Services;
using DevExpress.XtraReports.UI;
using ReportingWebApp.PredefinedReports;
using System;
using System.Web;
namespace ReportingWebApp.Server.Services {
public class CustomReportProvider : IReportProvider {
public XtraReport GetReport(string id, ReportProviderContext context) {
// Parse the string with the report name and parameter values.
string[] parts = id.Split('?');
string reportName = parts[0];
string parametersQueryString = parts.Length > 1 ? parts[1] : String.Empty;
// Create a report instance.
XtraReport report;
if (reportName == "XtraReport1") {
report = new XtraReport1();
} else {
throw new DevExpress.XtraReports.Web.ClientControls.FaultException(
string.Format("Could not find report '{0}'.", reportName)
);
}
// Apply the parameter values to the report.
var parameters = HttpUtility.ParseQueryString(parametersQueryString);
foreach (string parameterName in parameters.AllKeys) {
report.Parameters[parameterName].Value = Convert.ChangeType(
parameters.Get(parameterName), report.Parameters[parameterName].Type);
}
// Disable the Visible property for all report parameters
// to hide the Parameters Panel in the viewer.
foreach (var parameter in report.Parameters) {
parameter.Visible = false;
}
// If you do not hide the panel, disable the report's RequestParameters property.
// report.RequestParameters = false;
return report;
}
}
}