Saturday, August 28, 2010

Crystal Reports Material

Advantages of Crystal Reports
Some of the major advantages of using Crystal Reports are:

1. Rapid report development since the designer interface would ease the coding work for the programmer.

2. Can extend it to complicated reports with interactive charts and enhance the understanding of the business model

3. Exposes a report object model, can interact with other controls on the ASP.NET Web form

4. Can programmatically export the reports into widely used formats like .pdf, .doc, .xls, .html and .rtf

Implementation Models
Crystal Reports need database drivers to connect to the data source for accessing data. Crystal Reports in .net support two methods to access data from a data source:

The Pull Method
When this model is used to access data from the data source, the database driver directly retrieves the data from the data source. This model does not require the developer to write code for creating a connection and retrieving data from the data source. It is the Crystal report that manages the SQL commands for connecting by using the specified driver.

The Push Method
When this model is used to access data from data source, the developer writes the code to connect to the data source and retrieve data. The data from the data source is cached in dataset and multiple crystal reports accesses data from the dataset. The performance can be optimized in this manner by using connection sharing and manually limiting the number of records that are passed on to the report.

Crystal Reports Types
Crystal Report Designer can load reports that are included into the project as well as those that are independent of the project.

Strongly-typed Report
When you add a report file into the project, it becomes a "strongly-typed" report. In this case, you will have the advantage of directly creating an instance of the report object, which could reduce a few lines of code, and cache it to improve performance. The related .vb file, which is hidden, can be viewed using the editor's "show all files" icon in the Solution Explorer.

Un-Typed Report
Those reports that are not included into the project are "un-typed" reports. In this case, you will have to create an instance of the Crystal Report Engine's "ReportDocument" object and manually load the report into it.


Http Handler

Http Modules

1.      Where will you use HttpHandlers ?
*Suppose I want
to create RSS feeds for my web site. I will create a handler which will emit
RSS formatted XML, rather than HTML
*Image Server : For serving images of different sizes.

Where will you use HttpModules?
*I want to add custom security handling to my web pages.   (In fact, ASP.NET itself implements Forms
auth using  a module.
*Logging request, logging page visits.
* Adding same header or footer to web pages.

HttpHandlers used by  ASP.NET :
.aspx (asp. Net page)
.ashx (generic handler for all web handlers
that do not have ui and include a @WebHandler directive)

HttpModules used by ASP.NET
*forms authentication

*caching *

session state

*client script services

HttpHandlers are invoked  only when  particular resource  is requested, which is assigned to the

Modules are invoked for each request

In a module's Init method, you can subscribe to various application events such as BeginRequest or EndRequestby binding the events to methods in the module

should use a module whenever you must create code that depends on application
events, and when the following conditions are true:

·        You want to re-use the module in other applications.

·        You want to avoid putting complex code in the Global.asax

·        The module applies to all requests in the pipeline (IIS
7.0 Integrated mode only).

You should add code in the Global.asax
file whenever you must create code that depends on application events and you
do not have to reuse it across applications. You can also use the Global.asax file when you have to subscribe to events that
are not available to modules, such as
Session_Start and Session_End

The advantage of using the Global.asax file is that you can handle other registered
events such as Session_Start
and Session_End. In
addition, the Global.asax file enables you to
instantiate global objects that are available throughout the application.

Page_PreInit method cannot be bound using Global.asax,
it doesn’t work.

In IIS 7.0, the integrated
pipeline enables managed modules to subscribe to pipeline notifications for all
requests, not just requests for ASP.NET resources. Event handlers in the Global.asax file are invoked only for notifications during
requests for resources in the application. Custom modules in Integrated
mode can be explicitly scoped to receive event notifications only for
requests to the application. Otherwise, custom modules receive event
notification for all requests to the application. If the
precondition attribute of the add element of the modules section
is set to "managedHandler", the module is
scoped to the application.

Friday, August 27, 2010

Implementing Two Interfaces with same method signatures.

Yes, this is absolutely possible.

Public Interface IMyInterface

    Sub MySub()
    Function MyFunc() As Integer
End Interface

Public Interface IMyInterface1
Sub MySub()
Function MyFunc() As Integer
End Interface

Public Class MyClass1
Implements IMyInterface1, IMyInterface
Public Function MyFunc() As Integer Implements IMyInterface.MyFunc
Return 14
End Function

Public Sub MySub() Implements IMyInterface.MySub
End Sub

Public Sub MySub1() Implements IMyInterface1.MySub
End Sub

Public Function MyFunc1() As Integer Implements IMyInterface1.MyFunc
Return 15
End Function

1. Which  method will be called if the method MyFunc is called on  MyClass1 ?

this will depend upon how the class is being instantiated.
if an interface is explicitely called, then the call is unambiguos :

case 1 : dim x as IMyInterface = new MyClass1()
dim i as integer = x.MyFunc()

case 2 : dim x as IMyInterface1 = new MyClass1()

dim i as integer = x.MyFunc()

in the above cases the interface is clearly specified so the relevant
method will be called.

Now consider the following :
Dim x as new MyClass1()
dim i as integer = x.MyFunc

In this case, the interface which is LAST DECLARED in the "Implements" list will be refered.
Public Class MyClass1

       Implements IMyInterface1, IMyInterface

Since IMyInterface appears last in the list, it will be refered.

Can I remove any of the methods implementation ?
No (at least in VB) implementation of both methods is required, other wise the program will not compile.

Public Sub MySub2() Implements IMyInterface1.MySub
End Sub

End Class