Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
http://yourserver/reportserver/reportservice.asmx?wsdl
Imports System.Web
Imports System.Web.Services
Imports System.Xml
Imports System
Imports System.IO
Imports System.Xml.Serialization
Public Class MISReportingService
Enum Format
PDF
Excel
HTML
XML
CSV
Image
End Enum
Public Function SimpleRendering(ByVal NewFileName As String, ByVal NewFilePath As String, ByVal ReportPathAndName As String, ByVal RenderingFormat As String) As String
'dimming the return value
Dim Outcome As String
Dim Extension As String
Try
'selecting which format is wanted, then assigning the extension
Select Case RenderingFormat
Case "PDF"
Extension = ".pdf"
Case "Excel"
Extension = ".xls"
Case "HTML"
'does not work for some reason.
Extension = ".html"
Case "XML"
Extension = ".xml"
Case "Image"
Extension = ".tiff"
Case "CSV"
Extension = ".csv"
End Select
Dim rs As New ReportingService.ReportingService
'setting the credentials to the machine that this application is running on
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
'Dimming all of the needed parameters
Dim ResultStream() As Byte
Dim StreamIdentifiers() As String
Dim OptionalParam As String = Nothing
Dim optionalParams As ReportingService.ParameterValue() = Nothing
Dim optionalWarnings As ReportingService.Warning() = Nothing
'rendering the report in the specific format
ResultStream = rs.Render(ReportPathAndName, RenderingFormat, Nothing, "<DeviceInfo><StreamRoot>/RSWebServiceXS/</StreamRoot></DeviceInfo>", Nothing, Nothing, Nothing, OptionalParam, OptionalParam, optionalParams, optionalWarnings, StreamIdentifiers)
'creating a file to hold the stream with the correct extension from above
Dim stream As FileStream = File.Create(NewFilePath + NewFileName + Extension)
'writing the stream to the file
stream.Write(ResultStream, 0, ResultStream.Length)
stream.Close()
'setting the return value
Outcome = "Successful"
Return Outcome
Catch ex As Exception
'setting the return value
Outcome = ex.ToString
Return Outcome
End Try
End Function
Public Function ListAvailableReports() As DataTable
Dim dtReports As New DataTable("Reports")
Dim datarow As DataRow
Try
'creating an new instance of the web service
Dim rs As New reportingservice.ReportingService
'setting the credentials to the machine that this application is running on
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
'getting the available reports
Dim items() As reportingservice.CatalogItem = rs.ListChildren("/", True)
'defining a datacolumn
Dim dcReportName As DataColumn = dtReports.Columns.Add("Report", GetType(System.String))
'looping through all of the returned reports
Dim cnt As Integer
For cnt = 0 To items.Length - 1
'creating a new row
datarow = dtReports.NewRow
'adding text to the row and column
datarow("Report") = items(cnt).Name.ToString()
'adding the row the the datatable
dtReports.Rows.Add(datarow)
Next cnt
'returning the datatable
Return dtReports
Catch ex As Exception
'returning the datatable with no rows(shows that you have an exception)
dtReports = Nothing
Return dtReports
End Try
End Function
End Class
Dim location As String = "\\whateverserver\pub\_deletedeveryfriday\Jeremy\"
Dim NewFileName As String = "Testing"
Dim reportName As String = "/PAWS/rptAnimalsInShelterCount"
'create the file using the .dll
Dim outcome = SQL.SimpleRendering(NewFileName, location, reportName, SQL.Format.Image.ToString)
Label1.Text = outcome & " " & [b]SQL.Format.Image.ToString[/b]
'lists available reports
Dim outcome As DataTable
outcome = SQL.ListAvailableReports
cmbReports.DataSource = outcome
cmbReports.DisplayMember = "Report"
Dim SQL As New MISReportingService.MISReportingService