Click here to Skip to main content
15,907,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

I'm trying to schedule a report from an ASP application to file in order to simultaniously print the report to printer. The code below results to the very same scheduled report as when I do this in the CMC. Only in the CMC application this works and when I try the code the report stays "Active" and does not write a file or print a copy to the printer. What could be the problem here?

This is my code:

string query = "Select SI_DEST_SCHEDULEOPTIONS, SI_PROGID From CI_SYSTEMOBJECTS "
    + "Where SI_PARENTID = 29 AND SI_NAME = 'CrystalEnterprise.DiskUnmanaged'";
InfoObjects fileInfoObjects = infoStore.Query(query);
InfoObject infoObject = fileInfoObjects[1];

DestinationPlugin destinationPlugin = (DestinationPlugin)infoObject;
DiskUnmanaged diskUnmanaged = (DiskUnmanaged)destinationPlugin;

DestinationOptions destinationOptions = diskUnmanaged.ScheduleOptions;
DiskUnmanagedOptions diskUnmanagedOptions = new DiskUnmanagedOptions(destinationOptions);

diskUnmanagedOptions.DestinationFiles.Add(@"c:/PrintedReports/test.rpt");

schedulingInfo.Destination.SetFromPlugin(diskUnmanaged);

query = "Select SI_ID, SI_NAME FROM CI_INFOOBJECTS " + "Where SI_ID=" + report.ID.ToString();
InfoObjects infoObjects = infoStore.Query(query);

infoObject = report;

ReportPrinterOptions reportPrinterOptions = report.ReportPrinterOptions;
reportPrinterOptions.Enabled = true;
reportPrinterOptions.AlwaysPrintToPDF = true;
reportPrinterOptions.Copies = 1;

reportPrinterOptions.PrinterName = printerDataTransfer.PrinterName;

infoObjects = report.ParentInfoObjects;
infoStore.Schedule(infoObjects);
Posted
Comments
thatraja 22-Jun-11 22:24pm    
Any error message? Need more details....

1 solution

Solved it like this:

C#
string query = "Select SI_DEST_SCHEDULEOPTIONS, SI_PROGID From CI_SYSTEMOBJECTS "
    + "Where SI_PARENTID = 29 AND SI_NAME = 'CrystalEnterprise.DiskUnmanaged'";
InfoObjects destinationInfoObjects = infoStore.Query(query);
InfoObject infoObject = destinationInfoObjects[1];


DestinationPlugin destinationPlugin = (DestinationPlugin)infoObject;
DiskUnmanaged diskUnmanaged = (DiskUnmanaged)destinationPlugin;

DestinationOptions destinationOptions = diskUnmanaged.ScheduleOptions;
DiskUnmanagedOptions diskUnmanagedOptions = new DiskUnmanagedOptions(destinationOptions);

diskUnmanagedOptions.DestinationFiles.Add(filename);

diskUnmanagedOptions.UserName = SMC_Reportserver_Classes.Properties.Settings.Default.printFileUser;
diskUnmanagedOptions.Password = SMC_Reportserver_Classes.Properties.Settings.Default.printFilePassword;

schedulingInfo.Destination.SetFromPlugin(diskUnmanaged);
InfoObjects infoObjects = report.ParentInfoObjects;
infoStore.Schedule(infoObjects);
 
Share this answer
 
Comments
thatraja 17-Oct-13 11:08am    
Are you kidding? I have asked you for error details 2 years ago
Anyway get a 5 for your solution. Keep doing this in future.
Mart Rijkers 17-Oct-13 11:12am    
txs thatraja. I'm sorry I didn't get back to you 2 years ago. I remember that project was a bit stressfull :-) and now I ran into the unsolved item again, I thought it would be nice to solve it myself since I got this running. Don't remember where I found the answer though...
thatraja 17-Oct-13 11:28am    
So that item was in ToDo list in for last 2 years? :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900