CreateFolder(folder,parent,properties())
Parameters:
Folder as string
The name of the new folder.
Parent as string
The full path name of the parent folder to which to add the new folder.
Properties
An array of Property[] objects that defines the property names and values to set for the folder.
Eg:
Public Sub Main()
Dim name As String = “ReportFolder”
Dim parent As String = “/”
Dim fullpath As String = parent + name
‘Common CatalogItem properties
Dim descprop As New [Property]
descprop.Name = “Description”
descprop.Value = “”
Dim hiddenprop As New [Property]
hiddenprop.Name = “Hidden”
hiddenprop.Value = “False”
Dim props(1) As [Property]
props(0) = descprop
props(1) = hiddenprop
Try
RS.CreateFolder(name, parent, props)
Console.WriteLine(“Folder created: {0}”, name)
Catch e As SoapException
If e.Detail.Item(“ErrorCode”).InnerText = “rsItemAlreadyExists” Then
Console.WriteLine(“Folder / Reports already exists and cannot be overwritten”)
Else
Console.WriteLine(“Error : ” + e.Detail.Item(“ErrorCode”).InnerText + ” (” + e.Detail.Item(“Message”).InnerText + “)”)
End If
End Try
End Sub
CreateReport(Report,parent,overwrite,definition,properties())
Parameters:
Report as String
The name of the new report.
Parent as String
The full path name of the parent folder to which to add the report.
Overwrite
A Boolean expression that indicates whether an existing report with the same name in the location specified should be overwritten.
Definition
The report definition to publish to the report server.
Properties
An array of Property[] objects that contains the property names and values to set for the report.
Return Value:
An array of Warning[] objects that describes any warnings that occurred when the report definition was validated.
Eg:
The following example demonstrates how to take backup of report, create/publish a report and set a datasource to it.
Public Sub Main()
Dim Reportname as String = “SampleReport”
Dim parent As String = “/ParentFolder/Subfolder”
Dim location As String = parent + “\” + Reportname
Dim overwrite As Boolean = True
Dim reportContents As Byte() = Nothing
Dim warnings As Warning() = Nothing
Dim fullpath As String = parent + “/” + name
‘Common CatalogItem properties
Dim descprop As New [Property]
descprop.Name = “Description”
descprop.Value = “”
Dim hiddenprop As New [Property]
hiddenprop.Name = “Hidden”
hiddenprop.Value = “False”
Dim props(1) As [Property]
props(0) = descprop
props(1) = hiddenprop
‘Read RDL definition from disk
Try
Dim stream As FileStream = File.OpenRead(location)
reportContents = New [Byte](stream.Length-1) {}
stream.Read(reportContents, 0, CInt(stream.Length))
stream.Close()
warnings = RS.CreateReport(name, parent, overwrite, reportContents, props)
If Not (warnings Is Nothing) Then
Dim warning As Warning
For Each warning In warnings
Console.WriteLine(Warning.Message)
Next warning
Else
Console.WriteLine(“Report: {0} published successfully with no warnings”, name)
End If
‘Set report DataSource references
Dim dataSources(0) As DataSource
Dim dsr0 As New DataSourceReference
dsr0.Reference = “/Data Sources/DatasourceName”
Dim ds0 As New DataSource
ds0.Item = CType(dsr0, DataSourceDefinitionOrReference)
ds0.Name=”SMS”
dataSources(0) = ds0
RS.SetItemDataSources(fullpath, dataSources)
Console.Writeline(“Report DataSources set successfully”)
Catch e As IOException
Console.WriteLine(e.Message)
Catch e As SoapException
Console.WriteLine(“Error : ” + e.Detail.Item(“ErrorCode”).InnerText + ” (” + e.Detail.Item(“Message”).InnerText + “)”)
End Try
End Sub
CreateDatasource(datasource,parent,overwrite,definition,properties())
Parameters:
DataSource
The name of the data source.
Parent as String
The full path name of the parent folder that contains the data source.
Overwrite
A Boolean expression that indicates whether an existing data source with the same name in the location specified should be overwritten.
Definition
A DataSourceDefinition object that describes the connection properties for the data source.
Properties
An array of Property[] objects that defines the property names and values to set for the data source.
Eg:
Public Sub Main()
Dim name As String = “Datasourcename”
Dim parent As String = “/Data Sources”
‘Common CatalogItem properties
Dim descprop As New [Property]
descprop.Name = “Description”
descprop.Value = “”
Dim hiddenprop As New [Property]
hiddenprop.Name = “Hidden”
hiddenprop.Value = “False”
Dim props(1) As [Property]
props(0) = descprop
props(1) = hiddenprop
Dim definition As New DataSourceDefinition
definition.CredentialRetrieval = CredentialRetrievalEnum.Store
definition.ConnectString = “Data Source=; Initial Catalog= “
definition.Enabled = True
definition.EnabledSpecified = True
definition.Extension = “SQL”
definition.ImpersonateUser = False
definition.ImpersonateUserSpecified = True
definition.UserName = “”
definition.Password = “”
definition.WindowsCredentials = False
definition.OriginalConnectStringExpressionBased = False
definition.UseOriginalConnectString = False
Try
RS.CreateDataSource(name, parent,True, definition, props)
Console.WriteLine(“DataSource created successfully”)
Console.WriteLine(“You must supply the password using Report Manager to use this DataSource”)
Catch e As SoapException
Console.WriteLine(“Error : ” + e.Detail.Item(“ErrorCode”).InnerText + ” (” + e.Detail.Item(“Message”).InnerText + “)”)
End Try
End Sub
CreateLinkedReport(Report,parent,link,properties())
Parameters:
Report as String
The name of the new linked report.
Parent as String
The full path name of the parent folder to which to add the new report.
Link as String
The full path name of the report that will be used for the report definition.
Properties
An array of Property[] objects that defines the property names and values to set for the linked report.
Eg:
Public Sub Main()
Dim overwrite As Boolean = True
Dim name As String = “OriginalReportName”
Dim parent As String = “/path”
Dim fullpath As String = parent + “/” + name
‘Common CatalogItem properties
Dim descprop As New [Property]
descprop.Name = “Description”
descprop.Value = “”
Dim hiddenprop As New [Property]
hiddenprop.Name = “Hidden”
hiddenprop.Value = “False”
Dim props(1) As [Property]
props(0) = descprop
props(1) = hiddenprop
Try
RS.CreateLinkedReport(name,parent, “/OrignalPath/Reportname”, props)
Console.WriteLine(“Linked Report published successfully”)
Catch e As SoapException
If e.Detail.Item(“ErrorCode”).InnerText = “rsItemAlreadyExists” Then
If overwrite Then
RS.DeleteItem(fullpath)
RS.CreateLinkedReport(name,parent, “/GoldenGate/Ascend_Claims_Not_In_Golden_Gate”, props)
Console.WriteLine(“Linked Report: published successfully”)
Else
End If
Else
Console.WriteLine(“Error : ” + e.Detail.Item(“ErrorCode”).InnerText + ” (” + e.Detail.Item(“Message”).InnerText + “)”)
End If
End Try
End Sub