RAS ReportClientDocument Overview
Crystal Reports .NET references reports using the ReportDocument class. RAS references reports using the ReportClientDocument class. These two objects are designed to be used in conjunction with each other. A report can be referenced with either object model, or both simultaneously, and all changes are applied correctly. They are not mutually exclusive. The benefit of this is that you can write new code to call the RAS API without changing any existing code that used the ReportDocument class. Simply add the appropriate RAS code you need to take advantage of its report creation capabilities.
One word of caution when using both SDKs simultaneously: the ReportDocuemnt class and ReportClientDocument class use similar class names and collections. If you are importing the namespace (‘using’ in C#), the compiler will give error messages that it can’t resolve the class names since they appear in multiple namespaces. The best way to avoid this problem is to either only work with one SDK at a time, or use fully qualified class names which specify the entire namespace.
Before using the RAS SDK, you need to add the appropriate references to your application. Each one gives you different functionality and we’ll discuss which ones are necessary within the applicable sections. It can useful just to add all the references to your project and go back and delete the unused ones prior to putting your project into production. The references are as follows:
CrystalDecisions.ReportAppServer.ClientDoc
CrystalDecisions.ReportAppServer.DataDefModel
CrystalDecisions.ReportAppServer.Controllers
CrystalDecisions.ReportAppServer.ReportDefModel
It’s also important that you check the verion numbers for your existing CrystalDecisions.* references. Occaisionally, the references will refer to the older 10.x versions and these are not compatible with RAS. When this happens, delete all CrystalDecision.* libraries from the refernces list and add back the most recent versions.
There are numerous ways that you can work with the RAS SDK and it is impossible for me to predict what you need to do. So I created a library of common functions that will be beneficial to the most number of users. Each code listing is written so that you can copy and paste it into any application without any changes. Any required information is passed to it as a method argument. This allows you to pick and choose which methods you need to use for your application and get them working with a minimal amount of effort. Just remember that the first method, OpenReportClientDocument(), needs to be called first because it opens the report and gets a reference to the ReportClientDocument that is used by all the other methods.
I found that there are a few specific use cases that most programmers want to know about for using the RAS SDK. Of course, there are countless applications that the RAS can be with, but it’s not possible to cover everyting in this chapter. These use cases are as follows:
Opening a report
Logging on to a data source
Adding fields to a report (e.g. database fields, formulas, and parameters)
Modifying the record selection formula
Modifying parameters and formulas
Saving your changes to a report file
Each use case is covered throughout the remainder of this chapter.