Change BO crystal password

Imports BusinessObjects.DSWS.BICatalog

Imports BusinessObjects.DSWS.BIPlatform

Imports BusinessObjects.DSWS.Publish

Imports BusinessObjects.DSWS.Session

Imports BusinessObjects.DSWS.QueryService

Imports BusinessObjects.DSWS

Imports BusinessObjects.DSWS.BIPlatform.Constants

Imports BusinessObjects.DSWS.BIPlatform.Dest

Imports BusinessObjects.DSWS.BIPlatform.Desktop

PartialClass Default2

Inherits System.Web.UI.Page

Dim Login AsString

Dim Password AsString

Dim Domain AsString

Dim AuthType AsString

Dim boSession As Session

Dim boCredential As EnterpriseCredential

Dim boConnection As BusinessObjects.DSWS.Connection

Dim biPlatform As BIPlatform

Dim bipConURL = “http://jeboxi31:8080/dswsbobje/services/BIPlatform”

ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load

‘logon info

Login = “Administrator”

Password = “Password123”

Domain = “jeboxi31”

AuthType = “secEnterprise”

‘logon to Enterprise info

boCredential = New EnterpriseCredential

boCredential.Login = Login

boCredential.Password = Password

boCredential.Domain = Domain

boCredential.AuthType = AuthType

‘create the connection and logon

boConnection = New BusinessObjects.DSWS.Connection(“http://jeboxi31:8080/dswsbobje/services/session”)

boSession = New Session(boConnection)

boSession.Login(boCredential)

boConnection.URL = bipConURL

‘create the biplatform service

biPlatform = New BIPlatform(boConnection, boSession.ConnectionState)

‘used to query for the administrators cuid for use later

Dim query AsString = “query://{Select SI_CUID from CI_SystemObjects where si_name = ‘Administrator’ and si_kind = ‘User’}”

Dim rh As ResponseHolder

Dim oGetOptions AsNew GetOptions

oGetOptions.IncludeSecurity = False

‘get the admins cuid and store it

rh = biPlatform.Get(query, oGetOptions)

Dim userId AsString = rh.InfoObjects.InfoObject(0).CUID

‘query for the publication and get it as an infoobject

‘rh = biPlatform.Get(“path://InfoObjects/Root Folder/MyPublications/testPublication”, oGetOptions)

rh = biPlatform.Get(“query://{Select * from ci_infoobjects where si_name = ‘testPublication’ and si_instance = 0}”, oGetOptions)

Dim pubObj As BusinessObjects.DSWS.BIPlatform.Desktop.InfoObjects

Dim pub As BusinessObjects.DSWS.BIPlatform.Desktop.Publication

pubObj = rh.InfoObjects

‘create the publication from the infoobject

pub = CType(pubObj.InfoObject(0), Publication)

‘get the number of reports in the publication

Dim numOfObj AsNewInteger

numOfObj = pub.Documents.Length

‘hold the cuid of a report

Dim docCUID AsString

Dim counter AsInteger = 0

‘loop through all the reports, query for each and set to pdf

For counter = 0 To numOfObj – 1

docCUID = pub.Documents(counter).ToString

‘used to query for the reports with that cuid

query = “query://{Select * from CI_InfoObjects where si_cuid ='” + docCUID + “‘}”

‘get the report rh = biPlatform.Get(query, oGetOptions)

Dim infoObj As BusinessObjects.DSWS.BIPlatform.Desktop.InfoObjects

infoObj = rh.InfoObjects

Dim crObj As BusinessObjects.DSWS.BIPlatform.Desktop.CrystalReport

crObj = infoObj.InfoObject(0)

‘set its format to pdf

Dim procinfo As ReportProcessingInfo = crObj.PluginProcessingInterface

Dim repFormat AsNew CrystalReportFormatOptions

repFormat.Format = ReportFormatEnum.PDF

Dim fmt AsNew PDFFormat

fmt.AllPageExported = True

fmt.CreateBookmarksFromGroupTree = True

fmt.AllPageExportedSpecified = True

repFormat.FormatInterface = fmt

procinfo.ReportFormatOptions = repFormat

crObj.PluginProcessingInterface = procinfo

Next

‘set the output format to pdf for merge

Dim pubProcInfo(numOfObj – 1) As PubDocProcessingInfo

Dim formatInfo(0) As FormatInfo

pubProcInfo = pub.PubDocumentProcessingInfos

formatInfo(0) = New FormatInfo

‘formatInfo(0).Format = FormatTypeEnum.PDF returns a string of 1 and fails

‘with an invalid format type. must hard code crxf_pdf:0 for pdf

‘this would be the same work around for other types

formatInfo(0).Format = “crxf_pdf:0”

formatInfo(0).DocumentKind = “CrystalReport”

pubProcInfo(0).FormatInfos = formatInfo

pubProcInfo(1).FormatInfos = formatInfo

pub.PubDocumentProcessingInfos = pubProcInfo

‘subscribe administrator to the publication

biPlatform.SubscribePub(pub.CUID, userId)

‘create and grab the schedulinginfo objects from the publication

Dim pubSchedulingInfo As BusinessObjects.DSWS.BIPlatform.Desktop.SchedulingInfo

pubSchedulingInfo = pub.SchedulingInfo

‘set up the schedule

pubSchedulingInfo.RightNow = True

pubSchedulingInfo.ScheduleType = Desktop.ScheduleTypeEnum.ONCE

‘create and grab the publicationeventhandlers from the publication

Dim myPublicationEventHandlers AsNew BusinessObjects.DSWS.BIPlatform.Desktop.PublicationEventHandlers

‘set up the Zip merge for the scheduled object

Dim PublicationEventHandlerArray(1) As BusinessObjects.DSWS.BIPlatform.Desktop.PostProcessingEventHandler

Dim zipPublicationEventHandler AsNew BusinessObjects.DSWS.BIPlatform.Desktop.PostProcessingEventHandler

zipPublicationEventHandler.Name = “ZipMergePlugin”

zipPublicationEventHandler.ClassName = “com.businessobjects.publisher.postprocessing.plugin.ZipMergePlugin”

PublicationEventHandlerArray(1) = zipPublicationEventHandler

‘set up the PDF merge for the scheduled object

‘it must be the first eventhandler in the collection if you are going to

‘zip it as well

Dim pdfPublicationEventHandler AsNew BusinessObjects.DSWS.BIPlatform.Desktop.PostProcessingEventHandler

pdfPublicationEventHandler.Name = “PdfMergePlugin”

pdfPublicationEventHandler.ClassName = “com.businessobjects.publisher.postprocessing.plugin.PdfMergePlugin”

PublicationEventHandlerArray(0) = pdfPublicationEventHandler

myPublicationEventHandlers.PostProcessingEventHandlers = PublicationEventHandlerArray

‘set the zip merge event handler back to the publication

pub.PublicationEventHandlers = myPublicationEventHandlers

‘use this for passing the user cuid to the inbox destination collection

Dim DestinationsCollection(0) AsString

‘Set up the administrator inbox as the destination of the scheduled publication

Dim dests(0) As Destination

dests(0) = New Destination

dests(0).Name = “CrystalEnterprise.Managed”

‘Copy the properties from the Destination Plugin object into the report’s scheduling

‘information.

Dim destPluginFormat(1) As DestinationPluginFormat

destPluginFormat(1) = New DestinationPluginFormat

destPluginFormat(1).DistributionMode = DistributionModeEnum.FILTER_EXCLUDE_SOURCE_DOCUMENTS

destPluginFormat(1).FormatName = “com.businessobjects.publisher.postprocessing.plugin.ZipMergePlugin”

destPluginFormat(1).DistributionModeSpecified = True

destPluginFormat(0) = New DestinationPluginFormat

destPluginFormat(0).DistributionMode = DistributionModeEnum.FILTER_EXCLUDE_SOURCE_DOCUMENTS

destPluginFormat(0).FormatName = “com.businessobjects.publisher.postprocessing.plugin.PdfMergePlugin”

destPluginFormat(0).DistributionModeSpecified = True

dests(0).DestinationPluginFormats = destPluginFormat

‘set up the Inbox options

Dim inboxOpts AsNew ManagedScheduleOptions

inboxOpts.SendToOption = SendToOptionEnum.COPY

inboxOpts.DestinationOption = DestinationOptionEnum.INBOX

‘Set the destination to the admin inbox

DestinationsCollection(0) = userId.ToString

inboxOpts.Destinations = DestinationsCollection

‘Pass the inbox options back to the destination and then to the scheduling info of the publication

dests(0).DestinationScheduleOptions = inboxOpts

pubSchedulingInfo.Destinations = dests

‘run the scheduled publication

biPlatform.Schedule(pubObj)

‘log off the user

boSession.Logout()

EndSub

EndClass

Leave a Reply

Your email address will not be published. Required fields are marked *