Accessing the .NET SDK

Business Objects has been supporting Microsoft's .NET development platform since its inception when Crystal Reports for Visual Studio .NET was created. This has continued with Crystal Enterprise 10, which provides a full .NET SDK equivalent to the COM SDK. This SDK is intended for use within Microsoft Visual Studio .NET but can also work in other tools such as Borland C# Builder. This section covers content specific to the .NET SDK.

The .NET SDK consists of a set of .NET classes. Like Java, these classes are organized into namespaces. The Crystal Enterprise .NET SDK is contained in the CrystalDecisions.Enterprise namespace. The naming of all the objects is exactly the same as the COM SDK, for example, SessionMgr, EnterpriseSession. The .NET assemblies (.dll files) that make up the SDK can be found in the following folder:

Program FilesCommon FilesCrystal Decisions2.5managed

Unlike Java, there is no need to copy these files anywhere in order to be able to program with them. A developer simply needs to open the Project References dialog and select which assemblies they want to use. Although there is only a single namespace, there are multiple physical .dll files. The naming convention is CrystalDecisions.Enterprise.Module.dll where Module is one of a set of modules that compose the full Crystal Enterprise SDK. Some common assemblies a developer uses include the following:

  • CrystalDecisions.Enterprise.Framework.dll

  • CrystalDecisions.Enterprise.InfoStore.dll

  • CrystalDecisions.Web.dll

Notice that CrystalDecisions.Web.dll does not conform to the naming convention of the other assemblies. This is because it is a shared component across Crystal Reports and Crystal Enterprise.

→ For more information on the CrystalDecisions.Web.dll assembly and the CrystalReportViewer Web control, seeDelivering Reports with the Web Forms Viewer ,” p. 687


The C# code sample in Listing 34.16 is an ASPX page version of the report viewing page that has been used previously in this chapter.

Listing 34.16. Viewing a Report in HTML
<%@ Page Register TagPrefix="cr" Namespace="CrystalDecisions.Web" %>
<%@ Import Namespace="CrystalDecisions.Enterprise" %>
<html>
<head>
<script runat="server">

public void Page_Load()
{
        // Log on to CE
        SessionMgr sessMgr = new SessionMgr();
        EnterpriseSession sess = sessMgr.logon("Ryan", "123", "CMS1",
                                               "secEnterprise");

        // Get the name of the report from the query string
        String reportID = Request.QueryString["reportID"];

        // Retrieve the report source object given the ID
        InfoStore iStore = sess.GetService("InfoStore");
        InfoObject reportSource = iStore.Query("SELECT * FROM CI_INFOOBJECTS " +
                                               "WHERE SI_ID = 123")[1];

        // Create and set up the viewer object
        viewer.EnterpriseLogon = sess;
        viewer.ReportSource = reportSource;
}
</script>
</head>
<body>
<form runat="server" method=post action="ViewReportInASPX.aspx">
// Instruct the viewer to render the HTML output into the response stream
<cr:CrystalReportViewer id=viewer runat="server">
</form>
</body>
</html>

In addition, the .NET SDK has some components that the COM and Java SDKs do not: visual components for rapid Crystal Enterprise development. These components, found in the CrystalDecisions.Enterprise.WebControls namespace are visual components that can provide a drag-and-drop method of constructing a Crystal Enterprise application. Figure 34.3 shows the Crystal Enterprise .NET Web Controls in action.

Figure 34.3. The Crystal Enterprise .NET Web Controls in action.


The following list provides a brief explanation of some of the Web Controls:

  • Logon: Provides a visual control that automates the process of building a logon credential UI.

  • Identity: Abstracts the details of managing sessions across multiple pages away from the developer.

  • Items: Simplifies queries to the Crystal Enterprise InfoStore repository by hiding the actual SQL-like query and instead providing a programmatic interface.

NOTE

There are several more Crystal Enterprise Web Controls. For more information on these controls, consult the Crystal Enterprise .NET documentation, which is installed into the MSDN documentation framework.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.137.59