-
Notifications
You must be signed in to change notification settings - Fork 1
/
Default.aspx.vb
52 lines (44 loc) · 2.49 KB
/
Default.aspx.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
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWeb
Imports System
Imports System.Collections.Generic
Imports System.IO
Namespace ASPxDashboard_ServerExport
Public Partial Class [Default]
Inherits Web.UI.Page
Private fileStorage As DashboardFileStorage = New DashboardFileStorage("App_Data/Dashboards")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
ASPxDashboard1.AllowExportDashboard = False
ASPxDashboard1.SetDashboardStorage(fileStorage)
End Sub
Protected Sub ASPxDashboard1_CustomJSProperties(ByVal sender As Object, ByVal e As DevExpress.Web.CustomJSPropertiesEventArgs)
Dim dashboardIDs As List(Of String) = New List(Of String)()
For Each dashboardInfo As DashboardInfo In CType(fileStorage, IDashboardStorage).GetAvailableDashboardsInfo()
dashboardIDs.Add(dashboardInfo.ID)
Next
e.Properties.Add("cpGetDashboardIDs", dashboardIDs)
End Sub
Protected Sub ASPxDashboard1_CustomDataCallback(ByVal sender As Object, ByVal e As DevExpress.Web.CustomDataCallbackEventArgs)
Using stream As MemoryStream = New MemoryStream()
Dim selectedDashboardID As String = e.Parameter.Split("|"c)(0)
Dim dashboardStateJson As String = e.Parameter.Split("|"c)(1)
Dim dashboardState As DashboardState = New DashboardState()
dashboardState.LoadFromJson(dashboardStateJson)
Dim pdfOptions As DashboardPdfExportOptions = New DashboardPdfExportOptions()
pdfOptions.ExportFilters = True
pdfOptions.DashboardStatePosition = DashboardStateExportPosition.Below
Dim dateTimeNow As String = Date.Now.ToString("yyyyMMddHHmmss")
Dim filePath As String = "~/App_Data/Export/" & selectedDashboardID & "_" & dateTimeNow & ".pdf"
Dim exporter As ASPxDashboardExporter = New ASPxDashboardExporter(ASPxDashboard1)
exporter.ExportToPdf(selectedDashboardID, stream, New System.Drawing.Size(1920, 1080), dashboardState, pdfOptions)
SaveFile(stream, filePath)
e.Result = filePath
End Using
End Sub
Private Sub SaveFile(ByVal stream As MemoryStream, ByVal path As String)
Dim fileStream = File.Create(Server.MapPath(path))
stream.WriteTo(fileStream)
fileStream.Close()
End Sub
End Class
End Namespace