ReportingServices服务部署配置及开发doc39 - 图文(8)

2019-08-29 18:52

If items(i).Name.ToUpper = strAimReportsFolder.ToUpper And items(i).Type = ItemTypeEnum.Folder Then

oAimReportsFolderExists = True End If

'是数据源类型

If items(i).Name.ToUpper = strAimFolder.ToUpper And items(i).Type = ItemTypeEnum.DataSource Then

oDataSourceExists = True End If Next

Catch ex As Exception

Console.WriteLine(ex.Message.ToString) End Try

'创建数据源目标目录 If oAimFolderExists Then

Console.WriteLine(\目录\已经存在!\ Else Try

rs.CreateFolder(strAimFolder, \ Catch ex As Exception

Console.WriteLine(ex.Message.ToString) End Try End If

'创建报表目标目录

If oAimReportsFolderExists Then

Console.WriteLine(\目录\已经存在!\ Else Try

rs.CreateFolder(strAimReportsFolder, \ Catch ex As Exception

Console.WriteLine(ex.Message.ToString) End Try End If

'创建数据源

If oAimFolderExists And oDataSourceExists And oOverWriteDataSource = False Then Console.WriteLine(\数据源已经存在!\ Else

CreateDataSource()

End If

'发布报表 Try

Dim oDirectoryInfo As DirectoryInfo

If strReportsFilePath = \

oDirectoryInfo = New DirectoryInfo(\ Else

oDirectoryInfo = New DirectoryInfo(strReportsFilePath) End If

Dim files As FileInfo() = oDirectoryInfo.GetFiles(\

Console.WriteLine(\总共报表数量: {0}\

Dim fiNext As FileInfo

'循环发布报表

For Each fiNext In files

DeployReport(Microsoft.VisualBasic.Left(fiNext.Name, fiNext.Name.Length - 4))

Next

'将报表引用已创建的数据源

Dim reference As New DataSourceReference

reference.Reference = strParentPath & \

Dim subItems As CatalogItem() = rs.ListChildren(strParentReportsPath, False) For Each item As CatalogItem In subItems If item.Type = ItemTypeEnum.Report Then

Dim dataSources As DataSource() = rs.GetItemDataSources(item.Path) For Each datasource As DataSource In dataSources datasource.Item = reference Next

rs.SetItemDataSources(item.Path, dataSources) End If Next

Catch ex As Exception

Console.WriteLine(ex.Message.ToString) End Try

End Sub

Public Sub CreateDataSource()

'Dim folderPath As String = \

Dim csrdb As New DataSourceDefinition

csrdb.ConnectString = \strServerName

csrdb.Extension = \

csrdb.CredentialRetrieval = CredentialRetrievalEnum.Store csrdb.Enabled = True

csrdb.EnabledSpecified = True

csrdb.ImpersonateUserSpecified = False csrdb.UserName = strDataSourceUserName csrdb.Password = strDataSourcePassword

'csrdb.CredentialRetrieval = CredentialRetrievalEnum.Integrated Try

rs.CreateDataSource(strDataSourceName, strParentPath, True, csrdb, Nothing) Catch ex As Exception

Console.WriteLine(ex.Message.ToString) End Try End Sub

Public Sub DeployReport(ByVal strReportName As String) Try

Dim stream As FileStream = File.OpenRead(strReportsFilePath & \& strReportName & \

mDefinition = New [Byte](stream.Length) {} stream.Read(mDefinition, 0, CInt(stream.Length)) stream.Close() Catch ex As IOException

Console.WriteLine(ex.Message.ToString) End Try

Try

mWarnings = rs.CreateReport(strReportName, strParentReportsPath, True, mDefinition, Nothing)

If Not (mWarnings Is Nothing) Then Dim warning As Warning For Each warning In mWarnings

Console.WriteLine(warning.Message) Next warning Else


ReportingServices服务部署配置及开发doc39 - 图文(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:北师大二年级数学新版全册教案和反思

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: