-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGlobal.asax.vb
66 lines (60 loc) · 2.95 KB
/
Global.asax.vb
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
62
63
64
65
66
Imports System
Imports System.Web.Hosting
Imports System.Web.Mvc
Imports System.Web.Routing
Imports DevExpress.DashboardWeb
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.Web
Imports MvcDashboard_ServerSideApi.Controllers
Namespace MvcDashboard_ServerSideApi
Public Class MvcApplication
Inherits System.Web.HttpApplication
Protected Sub Application_Start()
DashboardConfig.RegisterService(RouteTable.Routes)
RouteConfig.RegisterRoutes(RouteTable.Routes)
AddHandler ASPxWebControl.CallbackError, AddressOf Application_Error
ControllerBuilder.Current.SetControllerFactory(GetType(CustomControllerFactory))
End Sub
Protected Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim exception As Exception = System.Web.HttpContext.Current.Server.GetLastError()
End Sub
End Class
Public Class CustomControllerFactory
Inherits DefaultControllerFactory
Public Overrides Function CreateController(ByVal requestContext As RequestContext, ByVal controllerName As String) As IController
If controllerName = "SalesDashboard" Then
Dim salesConfigurator As New DashboardConfigurator()
salesConfigurator.SetDashboardStorage(New DashboardFileStorage("~/App_Data/Sales"))
AddHandler salesConfigurator.ConfigureDataConnection, Sub(s, e)
Dim databasePath As String = HostingEnvironment.MapPath("~/App_Data/nwind.mdb")
If e.ConnectionName = "Northwind connection" Then
e.ConnectionParameters = New Access97ConnectionParameters(databasePath, "", "")
End If
End Sub
Return New DefaultDashboardController(salesConfigurator)
ElseIf controllerName = "MarketingDashboard" Then
Dim marketingConfigurator As New DashboardConfigurator()
marketingConfigurator.SetDashboardStorage(New DashboardFileStorage("~/App_Data/Marketing"))
AddHandler marketingConfigurator.ConfigureDataConnection, Sub(s, e)
Dim connectionString As String = "provider=MSOLAP;" & ControlChars.CrLf & _
" data source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;" & ControlChars.CrLf & _
" initial catalog=Adventure Works DW Standard Edition;" & ControlChars.CrLf & _
" cube name=Adventure Works;"
If e.ConnectionName = "Adventure Works connection" Then
e.ConnectionParameters = New OlapConnectionParameters(connectionString)
End If
End Sub
Return New DefaultDashboardController(marketingConfigurator)
Else
Return MyBase.CreateController(requestContext, controllerName)
End If
End Function
Public Overrides Sub ReleaseController(ByVal controller As IController)
'INSTANT VB NOTE: The variable dispose was renamed since Visual Basic does not handle local variables named the same as class members well:
Dim dispose_Renamed As IDisposable = TryCast(controller, IDisposable)
If dispose_Renamed IsNot Nothing Then
dispose_Renamed.Dispose()
End If
End Sub
End Class
End Namespace