/
ReportDesignerController.cs
61 lines (58 loc) · 2.56 KB
/
ReportDesignerController.cs
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using DevExpress.DataAccess.Sql;
using DevExpress.Web.Mvc.Controllers;
using DevExpress.XtraReports.Web.Localization;
using DevExpress.XtraReports.Web.ReportDesigner;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;
namespace AngularReportingLocalizationExample.Controllers
{
public class ReportDesignerController : ReportDesignerApiController
{
// GET: ReportDesigner
public ActionResult Index()
{
return View();
}
public override ActionResult Invoke()
{
var result = base.Invoke();
Response.AppendHeader("Access-Control-Allow-Origin", "*");
return result;
}
public ActionResult GetReportDesignerModel(string reportUrl)
{
Response.AppendHeader("Access-Control-Allow-Origin", "*");
string modelJsonScript =
new ReportDesignerClientSideModelGenerator()
.GetJsonModelScript(
reportUrl, // The URL of a report that is opened in the Report Designer when the application starts.
GetAvailableDataSources(), // Available data sources in the Report Designer that can be added to reports.
"ReportDesigner/Invoke", // The URI path of the controller action that processes requests from the Report Designer.
"WebDocumentViewer/Invoke",// The URI path of the controller action that processes requests from the Web Document Viewer.
"QueryBuilder/Invoke" // The URI path of the controller action that processes requests from the Query Builder.
);
return Content(modelJsonScript, "application/json");
}
override public ActionResult GetLocalization()
{
Response.AppendHeader("Access-Control-Allow-Origin", "*");
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("de-DE");
return base.GetLocalization();
}
Dictionary<string, object> GetAvailableDataSources()
{
var dataSources = new Dictionary<string, object>();
SqlDataSource ds = new SqlDataSource("NWindConnectionString");
var query = SelectQueryFluentBuilder.AddTable("Products").SelectAllColumns().Build("Products");
ds.Queries.Add(query);
ds.RebuildResultSchema();
dataSources.Add("SqlDataSource", ds);
return dataSources;
}
}
}