-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGlobal.asax.cs
39 lines (33 loc) · 1.73 KB
/
Global.asax.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
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using System.Web.Mvc;
using System.Web.Routing;
namespace MvcCustomTextForInternalDashboardErrors {
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
DashboardConfig.RegisterService(RouteTable.Routes);
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
ControllerBuilder.Current.SetControllerFactory(typeof(RestrictedControllerFactory));
DataSourceInMemoryStorage dataSourceStrorage = new DataSourceInMemoryStorage();
DashboardSqlDataSource sql = new DashboardSqlDataSource("sql", "sqlConn");
sql.Queries.Add(SelectQueryFluentBuilder.AddTable("Products").SelectAllColumns().Build("query"));
dataSourceStrorage.RegisterDataSource(sql.SaveToXml());
DashboardConfigurator.Default.SetDashboardStorage(new DashboardFileStorage(Server.MapPath("~/App_Data/Dashboards")));
DashboardConfigurator.Default.SetDataSourceStorage(dataSourceStrorage);
DashboardConfigurator.Default.ConfigureDataConnection += ASPxDashboard1_ConfigureDataConnection;
}
void ASPxDashboard1_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
// Invalid connection parameters:
switch (e.ConnectionName) {
case "sqlConn":
e.ConnectionParameters = new MsSqlConnectionParameters(@"localhost", "Northwind123", null, null, MsSqlAuthorizationType.Windows);
break;
}
}
}
}