Showing posts with label custom. Show all posts
Showing posts with label custom. Show all posts

Friday, March 9, 2012

How to set ReportViewer DataSource to a Custom Collection in Another Project

I have a web site that uses a business logic layer (BLL) and a data access layer (DAL). The BLL is in a separate project. The DAL is in a separate project. The web site has a reference to the BLL project and the BLLproject has a reference to the DAL project. Just to learn how to use the reportviewer control I used the server explorer to create a web datasource based directly on a stored procedure and everything works just fine. However, now I want to reportviewer to be based on a method in my BLL project. My problem is that the web data source window only shows those methods that have not paramenters. I want it to show CovAdm.BLL.InitialInspectionMgr.LoadDataTableForParcelID which has one parameter for ParcelID and returns a datatable. How do I get this method to show up under the CovAdm.BLL item in the web data sources window?

I found what I think is a simpler and better solution, especially because the reportviewer control seems be a long way from WYSIWYG. My solution doesn't use a report viewer control at all. Here's what I did.

My web page has a formview control with a "Report" button. The formview control itemcommand event checks for which button has been clicked and executes the following code behind for the Report button:
' get the data
Dim bll As New CovAdm.BLL.InitialInspectionMgr
Dim col As CovAdm.BLL.InitialInspectionCollection
Dim lngParcelID As Long = MySession.ParcelSearchResultDetailParcelID(Session)
col = bll.LoadForParcelID(lngParcelID, "ParcelID", "ASC")
' use the default file name for cases that have no file name
' use a physical path because local reports don't work with virtual paths
For Each ii As CovAdm.BLL.InitialInspection In col
If String.IsNullOrEmpty(ii.FQPhotoFileName) Then
Dim str As String = AppConfigurationMgr.PhotoNotAvailableRelativeFile()
str = Server.MapPath(str)
ii.FQPhotoFileName = str
End If
Next
' set up the report
Dim lr As New Microsoft.Reporting.WebForms.LocalReport
lr.ReportPath = Server.MapPath("~/Home/Report/rptInitialInspection.rdlc")
lr.EnableExternalImages = True
lr.DataSources.Clear()
' make sure we use the correct data source name
Dim rds As New Microsoft.Reporting.WebForms.ReportDataSource("dsrptInitialInspection_dtrptInitialInspection", col)
lr.DataSources.Add(rds)
' show the file dialog for opening or saving the pdf verion of the report
Utility.ShowLocalReport(Response, lr)

The code from my Utility class is shown below:
Public Shared Sub ShowLocalReport _
( _
ByVal vResponse As System.Web.HttpResponse, _
ByVal vlr As Microsoft.Reporting.WebForms.LocalReport _
)
'
' Aruments
' ========
' vResponse - HttpResponse object from calling page
' vlr - LocalReport object from calling page
'
' the procedure is currently limited to PDF format
Dim strFormat As String = "PDF"
Dim strMimeType As String = Nothing
Dim strEncoding As String = Nothing
Dim strFileExt As String = Nothing
' the default filename for saving will be the name if the rdlc file
Dim strFileName As String = System.IO.Path.GetFileNameWithoutExtension(vlr.ReportPath)
Dim astrStream() As String
Dim aWarning() As Microsoft.Reporting.WebForms.Warning
Dim aBytes As Byte()
' render the report
aBytes = vlr.Render(strFormat, Nothing, strMimeType, strEncoding, strFileExt, astrStream, aWarning)
' show the open / save dialog
vResponse.Clear()
vResponse.ContentType = "application/" & strFormat
vResponse.AddHeader("content-disposition", "attachment; filename=" & strFileName & "." & strFileExt)
vResponse.BinaryWrite(aBytes)
vResponse.End()
End Sub

Sunday, February 19, 2012

How to send Notifications to WinForm?

How to send Notifications to WinForm?

How to define the user devices and the custom delivery protocol and delivery channel?

Can you give me some examples? Source Codes?

Thank you very much!

no replies!

|||There are a number of ways you could do this, but it really depends on what you're trying to accomplish. You could deliver through MSMQ and poll the queue with your WinForms app, or you could probably even create a remoting delivery protocol. It'd probably help if you explained what you're really trying to accomplish.|||

How to create a remoting delivery protocol? The WinForm and the NS are on two different matchines.

Thank you very much!

|||

It's not something I've done, so I can't cut and paste code for you. I imagine a good start would be:

Developing a Custom Delivery Protocol

and a good tutorial on remoting. If you have access to it, or are willing to buy it, Ingo Rammer's Advanced .NET Remoting is probably the book to get.

-Francis

How to send notification to .aspx page...

... as far as I understand, I need to create a custom HTTP protocol. Where do get an example of this? Shyam's book has an example of creating custom protocol that is not HTTP based. There are few remarks on HTTP custom protocol in Chapter 10, but those are not very helpful.

The scenario it is used for is as follows: ASP.NET messenger (an .aspx page) writes messages into SQL server table. The page needs to get notified as soon as new entry appears in the table (from another instance of messenger), so that the first instance of messenger would be able to get new message from the table. Is this appropriate usage of notification services? If not, can you suggest alternative ways to write ASP.NET messenger?

Thank you in advance.

Is this a kinda IM application ? If so NS is not a right choice for Real Time Communication I would prefer to explore RTC (Real Time CommunicationI API with MS Live Communication Server. These two works well for any IM/Messaging related application.

If you mention ur requirements in detail (what do u mean by message etc) i will be more clear... thanks

--Satyen

|||

Query Notifications may be a better technology choice for you in this application.

HTH...

Joe

How to send notification to .aspx page...

... as far as I understand, I need to create a custom HTTP protocol. Where do get an example of this? Shyam's book has an example of creating custom protocol that is not HTTP based. There are few remarks on HTTP custom protocol in Chapter 10, but those are not very helpful.

The scenario it is used for is as follows: ASP.NET messenger (an .aspx page) writes messages into SQL server table. The page needs to get notified as soon as new entry appears in the table (from another instance of messenger), so that the first instance of messenger would be able to get new message from the table. Is this appropriate usage of notification services? If not, can you suggest alternative ways to write ASP.NET messenger?

Thank you in advance.

Is this a kinda IM application ? If so NS is not a right choice for Real Time Communication I would prefer to explore RTC (Real Time CommunicationI API with MS Live Communication Server. These two works well for any IM/Messaging related application.

If you mention ur requirements in detail (what do u mean by message etc) i will be more clear... thanks

--Satyen

|||

Query Notifications may be a better technology choice for you in this application.

HTH...

Joe

How to send notification to .aspx page...

... as far as I understand, I need to create a custom HTTP protocol. Where do get an example of this? Shyam's book has an example of creating custom protocol that is not HTTP based. There are few remarks on HTTP custom protocol in Chapter 10, but those are not very helpful.

The scenario it is used for is as follows: ASP.NET messenger (an .aspx page) writes messages into SQL server table. The page needs to get notified as soon as new entry appears in the table (from another instance of messenger), so that the first instance of messenger would be able to get new message from the table. Is this appropriate usage of notification services? If not, can you suggest alternative ways to write ASP.NET messenger?

Thank you in advance.

Is this a kinda IM application ? If so NS is not a right choice for Real Time Communication I would prefer to explore RTC (Real Time CommunicationI API with MS Live Communication Server. These two works well for any IM/Messaging related application.

If you mention ur requirements in detail (what do u mean by message etc) i will be more clear... thanks

--Satyen

|||

Query Notifications may be a better technology choice for you in this application.

HTH...

Joe