Friday, February 10, 2012

Cant get my Reporting Services to work within DotNetNuke

I am trying to add a call to a Microsoft Report from my module. I have got the following code:

PrivateSub btnPrint_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles btnPrint.Click

Dim formatAsString = "PDF"

'This is the name/location where the report will be generated on the web server

'the best part is that you can name the actual file anything you want in this code

'give write permissions to this folder:

Dim fileNameAsString = "C:\Temp\Tester.PDF"

'name of report on the report server that you want to use

'its basically / project name / report name

Dim reportPathAsString = "/NDPReports/Report1"

Dim historyIDAsString =Nothing

Dim deviceInfoAsString =Nothing

Dim showHideAsString =Nothing

'results is the file stream that we will be using

Dim results()AsByte

Dim encodingAsString

Dim mimeTypeAsString

'hbs2 is the name of my web ref to the reportserver,

Dim warnings()As hbs2.Warning =Nothing

Dim reportHistoryParameters()As hbs2.ParameterValue =Nothing

Dim streamIDs()AsString =Nothing

'The actual reporting service

Dim rsAsNew hbs2.ReportingService

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

'report parameters, passed in by querystring

Dim Parameters(1)As hbs2.ParameterValue

Parameters(0) =New hbs2.ParameterValue

Parameters(0).Name = "Initials"

Parameters(0).Value = Request.QueryString("Initials")

Parameters(1) =New hbs2.ParameterValue

Parameters(1).Name = "WorkDate"

Parameters(1).Value = Request.QueryString("WorkDate")

'this is where the report is generated

results = rs.Render(reportPath, format, historyID, deviceInfo, Parameters, _

Nothing, showHide, encoding, mimeType, _

reportHistoryParameters, warnings, streamIDs)

'Write the file to the webserver, using what ever name you want!

Dim streamAs FileStream = File.OpenWrite(fileName)

stream.Write(results, 0, results.Length)

stream.Close()

DownloadFile(fileName,True)

Response.ClearContent()

Response.ClearHeaders()

Response.ContentType = "application/pdf"

EndSub

'--This is the Download file function that forces the download----

PrivateSub DownloadFile(ByVal fnameAsString,ByVal forceDownloadAsBoolean)

Dim pathAs Path

Dim fullpath = path.GetFullPath(fname)

Dim name = path.GetFileName(fullpath)

Dim ext = path.GetExtension(fullpath)

Dim typeAsString = ""

IfNot IsDBNull(ext)Then

ext = LCase(ext)

EndIf

SelectCase ext

Case ".pdf", ".html"

type = "Application/pdf"

Case ".txt"

type = "text/plain"

Case ".doc", ".rtf"

type = "Application/msword"

Case ".csv", ".xls"

type = "Application/x-msexcel"

CaseElse

type = "text/plain"

EndSelect

If (forceDownload)Then

Response.AppendHeader("content-disposition", "attachment; filename=" + name)

EndIf

If type <> ""Then

Response.ContentType = type

EndIf

Response.WriteFile(fullpath)

Response.End()

EndSub

I have added the web reference to the reportserver, but when I load up my dotnetnuke portal I am getting an assembly error? Any help?
Thanks,
Greg Duke

Dear Sir:

I use DotNetNuke as the "menu driver" for all Reporting Services reports -

I have noticed that you are doing a lot of work for the User and maybe you have found a solution - but

If Not -

Within DotNetNuke create a page and within the page indicate that a URL is used to call the application - (call the reporting services report and cust and paste the URL into the DotNetNuke URL for the Page definition) once the user calls the Reporting Services Report - then let the user export to whatever format they want (PDF, Excel, etc.)

Best Regards

No comments:

Post a Comment