Share via


Binding to a Managed RAS Server Using ReportDocument.Load() Method

Note

This page describes functionality that is not available in Crystal Reports for Visual Studio, but is available in one of the upgraded versions. For more information about Crystal Reports for Visual Studio, see What is Crystal Reports for Visual Studio? For more information about upgraded versions, see Upgrade Options.

Object Model

This report binding scenario uses ReportClientDocument (see Report Binding with ReportClientDocument Object Model (RAS)).

Location of Reports

One of the few scenarios where the report is copied and exists in two locations: from an embedded report within the Web project, and in the Crystal Reports Server or BusinessObjects Enterprise repository that is exposed by the managed RAS server (see Report Application Server (RAS)).

Note

Because the report is ultimately displayed from the remote server, this report binding scenario also works successfully with non-embedded reports (as implemented in Binding to a Non-embedded Report Loaded into the ReportDocument Class).

Description

Web projects that were originally created with embedded reports and the ReportDocument object model in Crystal Reports for Visual Studio can now be easily ported to the managed RAS server within Crystal Reports Server or BusinessObjects Enterprise

In this scenario, you bind the embedded report at runtime to a managed RAS server, by placing a copy of the report in Crystal Reports Server or BusinessObjects Enterprise with the Publishing Wizard. The existing code for the embedded report continues to work, but you redirect the source of that report to a managed RAS server by doing the following:

  • Add Crystal Reports Server or BusinessObjects Enterprise logon functionality to the project and retrieve the EnterpriseSession instance.
  • Retrieve the duplicated report from Crystal Reports Server or BusinessObjects Enterprise as an instance of InfoObject.
  • Pass the EnterpriseSession instance and the InfoObject instance to the ReportDocument.Load() method of the embedded report.

You can also bind a non-embedded report to a managed RAS server. You achieve this by deleting the call to the ReportDocument.Load(String filename) method described in Binding to a Non-embedded Report Loaded into the ReportDocument Class, and replacing it with the code described in the steps described above.

This scenario demonstrates that in Crystal Reports Developer you can bind embedded or non-embedded reports that use the ReportDocument object model directly to a RAS server, which uses the ReportClientDocument object model. How is that possible? In Crystal Reports 10 the ReportDocument object model was rewritten as a proxy layer that addresses the ReportClientDocument object model. For more information, see ReportClientDocument Object Model (RAS) in Architecture.

Note

The InfoObject instance references the report from the managed RAS server. The report on the managed RAS server is always displayed, even if this report is a different version or has a different name than the embedded report.

You can access the underlying ReportClientDocument object model directly through the ReportDocument.ReportClientDocument property, which allows you to modify the report with the ReportClientDocument object model at runtime.

Pros

  • Ease of portability: maintains all original code that interacted with reports with the ReportDocument object model, while still providing full access to the underlying ReportClientDocument object model through the ReportDocument.ReportClientDocument property.

    Note

    The ReportClientDocument object model allows you to programmatically create, modify and save changes to the report definition file. For further information, see ReportClientDocument Object Model (RAS) in Architecture.

  • Optimized performance: significant performance gains, due to superior performance of the report engine in the Report Application Server (RAS). See Comparing Architectures Across Business Objects Reporting Solutions for more information.

Cons

  • Minor added coding: the project must log in and retrieve an EnterpriseSession object and store it in the ASP.NET Session. For each time that a report is bound to the CrystalReportViewer control with ReportDocument, you must retrieve InfoObject and call the Load() method.
  • Increased maintenance: to make a copy of the embedded report to Crystal Reports Server or BusinessObjects Enterprise increases maintenance requirements. If a report requires modification or deletion, those changes must be propagated into both the embedded report in the Web project as well as the report copy in Crystal Reports Server or BusinessObjects Enterprise.

To display the duplicate copy of the embedded report stored in Crystal Reports Server or BusinessObjects Enterprise using the InfoObject of the report with the Load method of ReportDocument

  • Crystal Reports Server or BusinessObjects Enterprise is installed and verified to be working.

  • Crystal Reports Server or BusinessObjects Enterprise SDK (including the .NET assemblies) is installed and verified to be working.

    Note

    If you have installed Crystal Reports Server or BusinessObjects Enterprise on your development machine, the SDK is included with that installation.

This procedure works only with a project that has been created from Project Setup. Project Setup contains specific namespace references and code configuration that is required for this procedure, and you will be unable to complete the procedure without that configuration. Therefore, before you begin this procedure, you must first follow the steps in Project Setup.

Note

A RAS server only works with Web projects.

  1. Locate and write down the name of a Crystal Reports Server or BusinessObjects Enterprise server. For purposes of this example, the server name is "BOE01."
1.   To find the server name, right-click the My Computer icon, and then select Properties.
2.   On the System Properties dimalog box, click the Network Identification tab.
3.   The computer name is in the Full computer name field.
  1. Use the Publishing Wizard to publish the Hierarchical Grouping.rpt to the Crystal Reports Server or BusinessObjects Enterprise server.
> [!NOTE]
> <P>To learn how to use the Publishing Wizard, see the Crystal Reports Server or BusinessObjects Enterprise User documentation.</P>
  1. Within the ConfigureCrystalReports() method (that you have created in Project Setup), you have the following report binding code:
``` vb
Dim hierarchicalGroupingReport As Hierarchical_Grouping = New
Hierarchical_Grouping()
myCrystalReportViewer.ReportSource = hierarchicalGroupingReport
```

``` csharp
Hierarchical_Grouping hierarchicalGroupingReport = new
Hierarchical_Grouping();
crystalReportViewer.ReportSource = hierarchicalGroupingReport;
```

Between those two lines of code, you add several new lines of code (see steps 5 to 16) that do the following before binding the report to the CrystalReportViewer control:

  - Log into a Crystal Reports Server or BusinessObjects Enterprise server on the network.
  - Retrieve the report as an InfoObject instance.
  1. Add the following assembly references to your project:
1.  CrystalDecisions.Enterprise.Framework
2.  CrystalDecisions.Enterprise.InfoStore
  1. At the top of the code-behind page, add a "Imports" [Visual Basic] or "using" [C#] statement for the CrystalDecisions.Enterprise namespace.
You are now ready to begin adding code that redirects the embedded report to Crystal Reports Server or BusinessObjects Enterprise.

``` vb
Imports CrystalDecisions.Enterprise
```

``` csharp
using CrystalDecisions.Enterprise;
```
  1. Following the line of code that instantiates hierarchicalGroupingReport, declare a serverName string and set it to the name of the Crystal Reports Server or BusinessObjects Enterprise server.
``` vb
Dim serverName As String = "BOE01"
```

``` csharp
string serverName = "BOE01";
```
  1. Declare and instantiate the SessionMgr class.

    Dim mySessionMgr As SessionMgr = New SessionMgr()
    
    SessionMgr sessionMgr = new SessionMgr();
    
  2. Pass the user name (Administrator), the password (blank), the serverName variable, and the logon type (secEnterprise) to the Logon method of the SessionMgr instance and retrieve it as an instance of EnterpriseSession.

``` vb
Dim myEnterpriseSession As EnterpriseSession = mySessionMgr.Logon(
_
        "Administrator", "", serverName, "secEnterprise")
```

``` csharp
EnterpriseSession enterpriseSession = sessionMgr.Logon(
      "Administrator", "", serverName, "secEnterprise");
```
  1. Retrieve the InfoStore service (as EnterpriseService) from the GetService() method of EnterpriseSession.
``` vb
Dim myEnterpriseService As EnterpriseService = _
        myEnterpriseSession.GetService("InfoStore")
```

``` csharp
EnterpriseService enterpriseService =
enterpriseSession.GetService("InfoStore");
```
  1. Declare and instantiate InfoStore with the retrieved InfoStore service.
``` vb
Dim myInfoStore As InfoStore = New InfoStore(myEnterpriseService)
```

``` csharp
InfoStore infoStore = new InfoStore(enterpriseService);
```

You are now ready to retrieve the Hierarchical Grouping report from Crystal Reports Server or BusinessObjects Enterprise.
  1. Enter the query string below to query Crystal Reports Server or BusinessObjects Enterprise for the report.
``` vb
Dim queryString As String = "Select SI_CUID From CI_INFOOBJECTS " _
                & "Where SI_PROGID='CrystalEnterprise.Report' "
_
                & "And SI_NAME Like 'Hierarchical Grouping'"
```

``` csharp
string queryString = "Select SI_CUID From CI_INFOOBJECTS "
   + "Where SI_PROGID='CrystalEnterprise.Report' "
   + "And SI_NAME Like 'Hierarchical Grouping'";
```
  1. Retrieve the InfoObjects indexed class that contains the query result, by passing the query string to the Query method of InfoStore.
``` vb
Dim myInfoObjects As InfoObjects = myInfoStore.Query(queryString)
```

``` csharp
InfoObjects infoObjects = infoStore.Query(queryString);
```
  1. Retrieve the InfoObject from the first column of the InfoObjects indexed class.
> [!NOTE]
> <P>The InfoObjects indexed class is 1-based, not 0-based.</P>


``` vb
Dim myInfoObject As InfoObject = myInfoObjects(1)
```

``` csharp
InfoObject infoObject = infoObjects[1];
```

You are now ready to load the duplicate copy of the embedded report from Crystal Reports Server or BusinessObjects Enterprise.
  1. Call the Load() method of the embedded report, and then pass the current instances of InfoObject and EnterpriseSession to the Load() method.
``` vb
hierarchicalGroupingReport.Load(myInfoObject, myEnterpriseSession)
```

``` csharp
hierarchicalGroupingReport.Load(infoObject, enterpriseSession);
```
  1. To view the report, build and run your project.

    The report is loaded from Crystal Reports Server or BusinessObjects Enterprise and served from the Report Application Server (RAS) within Crystal Reports Server or BusinessObjects Enterprise.

To access the ReportClientDocument object model from within the ReportDocument object model, see the Implementation section in Binding to Unmanaged RAS Using ReportDocument.Load() Method.

See Also