on 03-05-2009 5:42 AM
Hi,
I am using BO XI R2 SDK to schedule reports.
I want to set all my reports destinations to Unmanaged disk to a particular folder. I have set these in reportjobserver's destination configuration too.
Now i want create schedules through code for all my reports. I want these reports to use the job server defaults. I am unable to find a solution for this. The code i am currently using is as follows:
Code:
InfoObject diskObj = tempStoreForDisk.Query("SELECT * FROM ci_systemobjects where si_name='CrystalEnterprise.DiskUnmanaged'")[1];
DestinationPlugin destDiskPlugin = (DestinationPlugin)diskObj;
DiskUnmanaged diskUnmanaged = (DiskUnmanaged)destDiskPlugin;
DestinationOptions destinationOptions = (DestinationOptions)diskUnmanaged.ScheduleOptions;
DiskUnmanagedOptions diskUnmanagedOptions = new DiskUnmanagedOptions(destinationOptions);
diskUnmanagedOptions.DestinationFiles.Add(path);
schedulingInfo.Destinations.Add("CrystalEnterprise.DiskUnmanaged");
schedulingInfo.Destinations[1].SetFromPlugin(destDiskPlugin);
I want the italics line of code to be replaced with some code that enables the instance to use job server defaults.
If a solution for the above query is not available, is it possible to set 'specific filename with extension' in the unmanaged destination through code?
Could anyone please help me with any pointers?
Thanks.
Hello, Gayathri;
I am not aware of a method to get defaults from the Job Server.
You can use Visual Studio .NET to schedule to a disk file. We do have samples associated with our Developers Library on line.
http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/devsuite.htm
The sample I am thinking of is "Schedule Report".
http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/BOE_SDK/sampleList.htm
Here is a simple sample that schedules to disk:
Imports CrystalDecisions.Enterprise
Imports CrystalDecisions.Enterprise.Desktop
Imports CrystalDecisions.Enterprise.Dest
Public Class ScheduleDisk
Inherits System.Web.UI.Page
Dim ceSession As EnterpriseSession
Dim ceEnterpriseService As EnterpriseService
Dim ceInfoStore As InfoStore
Dim ceReportObjects As InfoObjects
Dim ceReportObject As InfoObject
Dim ceReport As Report
Dim sQuery As String
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Try
'grab the Enterprise session
If TypeOf Session.Item("ceSession") Is Object Then
ceSession = Session.Item("ceSession")
'Create the infostore object
ceEnterpriseService = ceSession.GetService("", "InfoStore")
ceInfoStore = New InfoStore(ceEnterpriseService)
'Create query to grab the desired report
sQuery = "Select SI_ID From CI_INFOOBJECTS Where SI_PROGID = 'CrystalEnterprise.Report' AND SI_Name='Consolidated Balance Sheet' AND SI_INSTANCE=0"
ceReportObjects = ceInfoStore.Query(sQuery)
'check for returned reports
If ceReportObjects.Count > 0 Then
ceReportObject = ceReportObjects.Item(1)
ceReport = CType(ceReportObject, Report)
'Create an interface to the scheduling options for the report.
Dim ceSchedulingInfo As SchedulingInfo
ceSchedulingInfo = ceReport.SchedulingInfo
'run the report right now
ceSchedulingInfo.RightNow = True
'run the report once only
ceSchedulingInfo.Type = CeScheduleType.ceScheduleTypeOnce
'When scheduling to all destinations except the printer, you must first retrieve
'the appropriate destination object. Each destination InfoObject is stored in the
'CMS system table (CI_SYSTEMOBJECTS) under the Destination Plugins folder
'Retrieve the DiskUnmanaged Plugin from CI_SYSTEMOBJECTS
Dim ceDestinationObjects As InfoObjects
Dim ceDestinationObject As InfoObject
ceDestinationObjects = ceInfoStore.Query("Select * from CI_SYSTEMOBJECTS Where SI_NAME = 'CrystalEnterprise.DiskUnmanaged'")
ceDestinationObject = ceDestinationObjects.Item(1)
'Create the DestinationPlugin object
Dim ceDisk As New DestinationPlugin(ceDestinationObject.PluginInterface)
'Create a diskUnmanagedOptions object and its ScheduleOptions from the Destination plugin
Dim ceDiskOpts As New DiskUnmanagedOptions(ceDisk.ScheduleOptions)
ceDiskOpts.DestinationFiles.Add("c:\ScheduledReports\ScheduledToDisk.rpt")
'Copy the properties from the Destination Plugin object into the report's scheduling
'information. This will cause the file to be transfered to Disk after it has been run.
Dim ceDestination As Destination
ceDestination = ceSchedulingInfo.Destination
ceDestination.SetFromPlugin(ceDisk)
'schedule report
ceInfoStore.Schedule(ceReportObjects)
Response.Write("Report Scheduled Successfully with an Object ID of : " + ceReportObject.Properties("SI_NEW_JOB_ID").ToString)
Response.Write("<br>Report Scheduled to the following location: " + ceDiskOpts.DestinationFiles(1).ToString)
Else
'no objects returned by query
Response.Write("No report objects found by query <br>")
Response.Write("Please click <a href='Index.aspx'>here</a> to return to the logon page.<br>")
End If
Else
'no Enterprise session available
Response.Write("No Valid Enterprise Session Found!<br>")
Response.Write("Please click <a href='Index.aspx'>here</a> to return to the logon page.<br>")
End If
Catch err As Exception
Response.Write("There was an error scheduling the report: <br>")
Response.Write(err.Message.ToString + "<br>")
Response.Write("Please click <a href='Index.aspx'>here</a> to return to the logon page.<br>")
End Try
End Sub
End Class
Elaine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.