I'm working with the new SDK to schedule a report and export its result on my local c:\ hard disk drive. My code give no errors at run but I do not find the file on my root.
The Instance counter of the report increase each time, so there is a refresh.
Is something wrong in the following lines? I just follow the examples give in the documentation for scheduling.
Thanks in advance !
Here is my code :
//--------------------
Destinations oDestinations = Destinations.Factory.newInstance();
Destination[] oDestination = new Destination[1];
oDestination[0] = Destination.Factory.newInstance();
oDestination[0].setName("CrystalEnterprise.DiskUnmanaged");
DiskUnmanagedScheduleOptions diskOptions = DiskUnmanagedScheduleOptions.Factory.newInstance();
String[] destinationFile = new String[1];
destinationFile[0] = "c:\\" + report_name + ".pdf";
DestinationFiles destinationFiles = DestinationFiles.Factory.newInstance();
destinationFiles.setDestinationFileArray(destinationFile);
diskOptions.setDestinationFiles(destinationFiles);
oDestination[0].setDestinationScheduleOptions(diskOptions);
oDestinations.setDestinationArray(oDestination);
//---------------------
System.out.println("Getting report...");
ResponseHolder respons = this.platform.get("path://InfoObjects/<path to report>/" + report_name, null);
InfoObjects reports = respons.getInfoObjects();
if (reports == null)
{
return;
}
Webi myReport = (Webi)reports.getInfoObjectArray()[0];
System.out.println("Getting scheduling info...");
SchedulingInfo schedulingInfo = myReport.getSchedulingInfo();
boolean newSchedulingInfo = false;
if (schedulingInfo == null)
{
schedulingInfo = SchedulingInfo.Factory.newInstance();
newSchedulingInfo = true;
}
System.out.println("Setting scheduling info...");
schedulingInfo.setRightNow(Boolean.TRUE);
schedulingInfo.setScheduleType(ScheduleTypeEnum.ONCE);
schedulingInfo.setDestinations(oDestinations);
WebiProcessingInfo webiProcessingInfo = myReport.getWebiProcessingInfo();
if(webiProcessingInfo == null) {
webiProcessingInfo = WebiProcessingInfo.Factory.newInstance();
}
WebiFormatOptions webiReportFormatOptions = webiProcessingInfo.getWebiFormatOptions();
if(webiReportFormatOptions == null)
{
webiReportFormatOptions = WebiFormatOptions.Factory.newInstance();
}
System.out.println("Setting Format...");
webiReportFormatOptions.setFormat(WebiFormatEnum.PDF);
webiProcessingInfo.setWebiFormatOptions(webiReportFormatOptions);
myReport.setWebiProcessingInfo(webiProcessingInfo);
if (newSchedulingInfo)
{
myReport.setSchedulingInfo(schedulingInfo);
}
System.out.println("Schedule...");
this.platform.schedule(reports);
System.out.println("Schedule done...");