By default when a report is scheduled inside Crystal Enterprise, the resulting file is stored inside the Crystal Enterprise repository. In addition to this, scheduler has the capability to write the report to an arbitrary folder on the machine, e-mail the report to an individual or group, and upload the file to another machine via ftp. The destination is set as part of the scheduled job. From the ISchedulingInfo interface, there is a getDestination method that is used to get access to the IDestination interface. The setFromPlugin method accepts a handle to a destination type object called an IDestinationPlugin. Don worry about the code required to create the plug-in object, which is covered in the next chapter. The types of destination plug-ins are
For more information on the code required to create the plug-in, see Chapter 36, "Creating Enterprise Reporting Applications with Crystal Enterprise Part II."
The following code shows a report being scheduled once to the Temp folder of the machine:
ISchedulingInfo sched = report.getSchedulingInfo(); sched.setRightNow(true); IDestination dest = sched.getDestination(); IDestinationPlugin disk = getDestinationPlugin(iStore, "CrystalEnterprise.DiskUnmanaged"); IDiskUnmanagedOptions options = (IDiskUnmanagedOptions) disk.getScheduleOptions(); options.getDestinationFiles().add("C:/Temp/"); dest.setFromPlugin(disk); iStore.schedule(results);
Each type of destination has its own corresponding set of options. In the case of the DiskUnmanaged destination, it has an object called IDiskUnmanagedOptions that accepts a folder location as well as optional credentials used to access that folder. The Smtp destination has an ISMTPOptions object that specifies mail routing information. Finally, the Ftp destination has an IFTPOptions object that specifies server, port, credentials, and the target folder:
ISchedulingInfo sched = report.getSchedulingInfo(); sched.setRightNow(true); IDestination dest = sched.getDestination(); IDestinationPlugin smtp = getDestinationPlugin(iStore, "CrystalEnterprise.Smtp"); ISMTPOptions options = (ISMTPOptions) smtp.getScheduleOptions(); options.setDomainName("domain_name"); options.setServerName("smtp_server_name"); options.setPort(25); options.setSMTPAuthenticationType(ISMTPOptions.CeSMTPAuthentication.NONE); options.setSMTPUserName("domainusername"); options.setSMTPPassword("password"); options.setSenderAddress("email@address.com"); options.setSubject("The report \%SI_NAME% ran successfuly"); dest.setFromPlugin(smtp); iStore.schedule(results);
Note that in the call to the setSubject method, the string uses the %SI_NAME% variable. Crystal Enterprise replaces this placeholder with the name of the report. This means that the code can be written fairly generically.
Part I. Crystal Reports Design
Creating and Designing Basic Reports
Selecting and Grouping Data
Filtering, Sorting, and Summarizing Data
Understanding and Implementing Formulas
Implementing Parameters for Dynamic Reporting
Part II. Formatting Crystal Reports
Fundamentals of Report Formatting
Working with Report Sections
Visualizing Your Data with Charts and Maps
Custom Formatting Techniques
Part III. Advanced Crystal Reports Design
Using Cross-Tabs for Summarized Reporting
Using Record Selections and Alerts for Interactive Reporting
Using Subreports and Multi-Pass Reporting
Using Formulas and Custom Functions
Designing Effective Report Templates
Additional Data Sources for Crystal Reports
Multidimensional Reporting Against OLAP Data with Crystal Reports
Part IV. Enterprise Report Design Analytic, Web-based, and Excel Report Design
Introduction to Crystal Repository
Crystal Reports Semantic Layer Business Views
Creating Crystal Analysis Reports
Advanced Crystal Analysis Report Design
Ad-Hoc Application and Excel Plug-in for Ad-Hoc and Analytic Reporting
Part V. Web Report Distribution Using Crystal Enterprise
Introduction to Crystal Enterprise
Using Crystal Enterprise with Web Desktop
Crystal Enterprise Architecture
Planning Considerations When Deploying Crystal Enterprise
Deploying Crystal Enterprise in a Complex Network Environment
Administering and Configuring Crystal Enterprise
Part VI. Customized Report Distribution Using Crystal Reports Components
Java Reporting Components
Crystal Reports .NET Components
COM Reporting Components
Part VII. Customized Report Distribution Using Crystal Enterprise Embedded Edition
Introduction to Crystal Enterprise Embedded Edition
Crystal Enterprise Viewing Reports
Crystal Enterprise Embedded Report Modification and Creation
Part VIII. Customized Report Distribution Using Crystal Enterprise Professional
Introduction to the Crystal Enterprise Professional Object Model
Creating Enterprise Reports Applications with Crystal Enterprise Part I
Creating Enterprise Reporting Applications with Crystal Enterprise Part II
Appendix A. Using Sql Queries In Crystal Reports
Creating Enterprise Reporting Applications with Crystal Enterprise Part II