This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
/
ReportViewerService.vb
37 lines (34 loc) · 1.69 KB
/
ReportViewerService.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
Imports System.Windows
Imports DevExpress.Mvvm.UI
Imports DevExpress.ReportServer.Printing
Imports DevExpress.ReportServer.ServiceModel.ConnectionProviders
Imports DevExpress.ReportServer.ServiceModel.DataContracts
Imports DevExpress.Utils
Imports DevExpress.Xpf.Printing
Imports T258870.View
Namespace T258870.Service
Public Class ReportViewerService
Inherits ServiceBase
Implements IReportViewerService
Public Property connectionProvider() As ConnectionProvider Implements IReportViewerService.connectionProvider
Private Property reportViewerView() As ReportViewerView
Public Sub Show(ByVal reportId As Integer) Implements IReportViewerService.Show
Guard.ArgumentNotNull(connectionProvider, "connectionProvider")
Dim remoteDocumentSource As RemoteDocumentSource = New DevExpress.ReportServer.Printing.RemoteDocumentSource()
remoteDocumentSource.ReportIdentity = New ReportIdentity(reportId)
AddHandler remoteDocumentSource.ReportServiceClientDemanded, AddressOf remoteDocumentSource_ReportServiceClientDemanded
reportViewerView = New ReportViewerView()
reportViewerView.DocumentPreviewControl.DocumentSource = remoteDocumentSource
remoteDocumentSource.CreateDocument()
Try
reportViewerView.ShowDialog()
Catch
reportViewerView.Close()
Throw
End Try
End Sub
Private Sub remoteDocumentSource_ReportServiceClientDemanded(ByVal sender As Object, ByVal e As ReportServiceClientDemandedEventArgs)
e.Client = connectionProvider.CreateClient()
End Sub
End Class
End Namespace