Share via


Binding to a Managed RAS Server Using ReportDocument.FileName Property

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 Visual Studio project, and in the Crystal Reports Server or BusinessObjects Enterprise repository that is exposed by the Report Application Server (RAS) within Crystal Reports Server or BusinessObjects Enterprise (BOE).

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

NET 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.

In this scenario you bind the embedded report at runtime to a managed RAS server, within Crystal Reports Server or BusinessObjects Enterprise, 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 CUID property of the duplicated report from Crystal Reports Server or BusinessObjects Enterprise.
  • Set the EnterpriseSession property of ReportDocument to the EnterpriseSession instance.
  • Set the FileName property of ReportDocument to the CUID string of the embedded report.

For a code sample, see the Implementation section below.

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 FileName property 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.

The underlying ReportClientDocument object model can be accessed directly through the ReportDocument.ReportClientDocument property, allowing you to modify the report using 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.

Cons

  • Minor added coding: 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 using ReportDocument, the CUID must be retrieved and set in the FileName property of ReportDocument.
  • 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 Visual Studio 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 report's CUID with the FileName property 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 install.

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.

  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 dialog 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>


For information about sample reports, see [Sample Reports' Directory](ms225622\(v=vs.90\).md).
  1. Within the ConfigureCrystalReports() method (that you have created in Project Setup), you have the below 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 must add several new lines of code (see steps 3 to 14) 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 CUID that identifies the report stored in Crystal Reports Server or BusinessObjects Enterprise.
  - Call the report by its CUID.
  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.
``` vb
Imports CrystalDecisions.Enterprise
```

``` csharp
using CrystalDecisions.Enterprise;
```

You are now ready to add code that redirects the embedded report to Crystal Reports Server or BusinessObjects Enterprise.
  1. Following the line of code in which hierarchicalGroupingReport is instantiated, 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.
``` vb
Dim mySessionMgr As SessionMgr = New SessionMgr()
```

``` csharp
SessionMgr sessionMgr = new SessionMgr();
```
  1. 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 using 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 CUID of 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 CUID of 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. Retrieve the report's CUID string from the SI_CUID property of the InfoObject into a reportCUID string variable.
``` vb
Dim reportCUID As String = myInfoObject.CUID
```

``` csharp
string reportCUID = infoObject.CUID;
```
  1. Set the EnterpriseSession property of the embedded report to the EnterpriseSession instance.
``` vb
hierarchicalGroupingReport.EnterpriseSession = myEnterpriseSession
```

``` csharp
hierarchicalGroupingReport.EnterpriseSession = enterpriseSession;
```
  1. Set the FileName property of the embedded report to the reportCUID variable, prefixed with the cecuid:/// protocol.
> [!NOTE]
> <P>Use a triple-slash rather than a double-slash. This implies that the hostname is null.</P>


``` vb
hierarchicalGroupingReport.FileName = "cecuid:///" & reportCUID
```

``` csharp
hierarchicalGroupingReport.FileName = "cecuid:///" + reportCUID;
```
  1. To view the report, build and run your project.
The report is now loaded from Crystal Reports Server or BusinessObjects Enterprise and served from the managed RAS server.

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