Programming the Report Application Server

book list add book to my bookshelf create a bookmark purchase this book online

mastering crystal reports 9
Chapter 24 - Report Application Server
Mastering Crystal Reports 9
by Cate McCoy and Gord Maric
Sybex 2003

Programming the Report Application Server involves using a web-development tool like Microsoft’s Visual Studio 6.0 or Visual Studio .NET and creating Active Server Pages (or in the case of ASP .NET, webforms) that use programming code to work with the RAS SDK and web-reporting viewers. Perhaps the easiest way to learn how to program with the Report Application Server is to use the sample web-reporting application, ePortfolio Lite.

Creating an ASP Project with ePortfolio Lite

The first step in customizing the ePortfolio Lite sample application is to create a new ASP web project and then import all of the ePortfolio project files into the new project. The following step-by-step procedure uses Microsoft Visual InterDev 6.0, which is a component of Visual Studio 6.0, to create a new ASP web project.

  1. Open Visual InterDev, and in the New Project dialog, shown in Figure 24.17, choose New Web Project, name the project WebReporter, enter a location for the project files, and then click Open to launch the Web Project Wizard.

  2. In step 1 of the Web Project Wizard, select the server that is hosting the Report Application Server and then click Next. (In most cases, this is probably your local machine if that is where you installed the Report Application Server.)

  3. In step 2 of the Web Project Wizard, make sure that the Create A New Web Application option is selected and that the name of the project is WebReporter and then click Next. (You can also uncheck the Create Search.htm To Enable Full Text Search check box to cut down on the number of files that Visual InterDev generates.)

  4. In step 3 of the Web Project Wizard, click Finish.

    click to expand
    Figure 24.17. New Project dialog

  5. Copy the ePortfolio Lite source files into the directory that you specified as the project location in step 1. The ePortfolio Lite source files can be found at C:\Program Files\Crystal Decisions\ Report Application Server 9\Samples\En\ASP\rPortfolio. The following is the list of files and folders to copy.

    • rPortfolio: Copy the files from this folder to the root project folder.

    • HTMLViewers: Copy this folder and the files that it contains to the project folder.

    • Include: Copy this folder and the files that it contains to the project folder.

  6. Add the files and folders that you just copied to the project using the Project Explorer. In the Project Explorer, right-click the project name and then select Add > Add Item from the context menu. This will open the Add Item dialog, as shown in Figure 24.18.

    click to expand
    Figure 24.18. Add Item dialog

  7. Click the Existing tab, select All Files (*.*) in the Files Of Type drop-down list, select all of the ePortfolio Lite files and folders listed, and then click Add Folder. Once the files and folders have been imported into the WebReporter project, your Project Explorer window should look similar to Figure 24.19.


    Figure 24.19. Project Explorer with ePortfolio Lite files imported

  8. Right-click the default.htm file in the Project Explorer, and on the context menu, select Set As Start Page.

  9. Save your project.

  10. Right-click the default.htm file and choose View In Browser to run the WebReporter project.

After running your project, you should see ePortfolio Lite open in the web browser and it should appear as it did in Figure 24.5 in the previous section except that this time, the path shown in the Address field of the web browser reads http://localhost/WebReporter/reportListing.asp.

Notice that the default page is not named default.htm but is instead named reportListing.asp. This is because the code in the default.htm file makes a call to the location.replace method to redirect processing to the reportListing.asp file. The code for the default.htm file is shown in Listing 24.1.

Listing 24.1: The default.htm Code

start example
<HTML> <HEAD> <SCRIPT language="javascript"> location.replace ( "reportListing.asp" ); </SCRIPT> </HEAD> </HTML>
end example

Modifying the User Interface

One of the first things that you may want to customize in the ePortfolio Lite application is the user interface. This could include removing the Crystal graphics and replacing them with your own, changing the color scheme, or modifying the buttons in the toolbar.

One of the easiest changes to make is to remove the Powered By Crystal logo that appears in the lower-left portion of the ePortfolio Lite interface. To remove this logo, all you need to do is comment out a portion of the code found in the reportListing.asp file using the <!-- and --> comment tags. The code snippet that can be commented out to accomplish this is shown here:

<!-- </DIV> <DIV align=left> <a href="http://www.crystaldecisions.com/"> <img alt="<%= L_POWEREDBYCRYSTAL %>" src="/books/2/825/1/html/2/include/pb_blue_sml.gif" border="0" WIDTH="108" HEIGHT="30"> </a> </DIV> -->

Modifying the Default Preferences

When users first open ePortfolio Lite, they will immediately notice all of the reporting features that are disabled. While they can click the Preferences button to open the Preferences window and choose to remove these disabled features from the interface, it would be better if they never saw them in the first place.

Changing the default view in the interface is another easy modification to make. Open the default .inc file and replace the value of the mainDefaultView variable with MinimalView. Listing 24.2 shows the code for the default.inc file with the change already made.

Listing 24.2: Default View Code

start example
<% ' Set the Defaults for a new user const CEView = "0" const MinimalView = "1" const ActiveXViewer = "0" const HTMLPageViewer = "1" const interactiveViewer = "2" const javaViewer = "3" const HTMLPartsViewer = "4" Dim mainViewDefault, viewerDefault mainViewDefault = MinimalView viewerDefault = interactiveViewer %>
end example

Programming the Web-Reporting Viewers

The ePortfolio Lite web-reporting application contains code for displaying reports in the three COM-based report viewers. Table 24.5 lists the ASP files that are used for each of the report viewers.

Table 24.5: Report Viewer ASP Files

ASP File

Report Viewer

interactiveViewer.asp

Contains code for using the Interactive Report Viewer.

pageViewer.asp

Contains code for using the Report Page Viewer.

partViewer.asp

Contains code for using the Report Parts Viewer.

The complete code for the interactiveViewer.asp file is shown in Listing 24.3.

Listing 24.3: Interactive Viewer Code

start example
<%@ Language=VBScript CodePage=65001  ENABLESESSIONSTATE = False %> <% Option Explicit ' Note - the CodePage=65001 is needed to display Unicode  ' text correctly in the viewer '  if Session is null for ProcessHttpRequest Dim objectFactory Set objectFactory =  CreateObject("CrystalReports.ObjectFactory.2") Response.ExpiresAbsolute = Now() - 1   Dim viewer Set viewer =  objectFactory.CreateObject("CrystalReports.CrystalReportInteractiveViewer")   viewer.Name = "page" viewer.IsOwnForm = true viewer.IsOwnPage = true Dim theReportName theReportName = Request.Form("ReportName") if theReportName = "" then  theReportName = Request.QueryString("ReportName") viewer.URI = "interactiveViewer.asp?ReportName=" +  Server.URLEncode(theReportName) Dim clientDoc Set clientDoc =  objectFactory.CreateObject("CrystalClientDoc.ReportClientDocument") clientDoc.Open theReportName viewer.ReportSource = clientDoc.ReportSource Dim BooleanSearchControl Set BooleanSearchControl =  objectFactory.CreateObject("CrystalReports.BooleanSearchControl") BooleanSearchControl.ReportDocument = clientDoc viewer.BooleanSearchControl = BooleanSearchControl viewer.ProcessHttpRequest Request, Response, Null ' ReportClientDocument will be automatically closed when  ' clientDoc is released %>
end example

As you can see from Listing 24.3, the ASP code uses three primary Crystal objects for displaying a report using the Interactive Report Viewer: ObjectFactory, CrystalReportInteractiveViewer, and CrystalClientDoc. Each of these objects, along with their properties, methods, and events, is documented in the Report Application Server Software Development Kit help file.

Use of content on this site is expressly subject to the restrictions set forth in the Membership Agreement
 
Conello © 2000-2003     Feedback


Mastering Crystal Reports 9
Mastering Crystal Reports 9
ISBN: 0782141730
EAN: 2147483647
Year: 2005
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net