懶人快速更新多個 rdl

摘要:懶人快速更新多個 rdl


    Private Sub DoUpdate(ByVal sFolder As String)
        For Each FileName As String In lstFilePathName
            With ProgressBar
                .Value = .Value + 1
            End With

            'load rdl
            Dim RDLData As Byte() = Nothing
            Dim fs As FileStream = File.OpenRead(FileName)
            RDLData = New Byte(fs.Length - 1) {}
            fs.Read(RDLData, 0, CInt(fs.Length))
            fs.Close()

            Dim ws As ReportingService = New ReportingService()
            ' Set URL and Credentials
            ws.Url = txtSrvURL.Text
            ws.Credentials = New System.Net.NetworkCredential(RSADMINID, RSADMINPW, RSNETWORKNAME)

            ' Set folder properties
            Dim folderProperty As New [Property]()
            folderProperty.Name = "Description"
            folderProperty.Value = sFolder
            ' May want to prompt for this
            Dim folderProperties As [Property]() = New [Property](0) {}
            folderProperties(0) = folderProperty

            ' Set report properties
            Dim reportProperty As New [Property]()
            reportProperty.Name = "Description"
            reportProperty.Value = "" 'Path.GetFileName(FileName)
            'ignore this value, the screen will be clear
            ' May want to prompt for this
            Dim reportProperties As [Property]() = New [Property](0) {}
            reportProperties(0) = reportProperty
            Dim reportName As String = System.IO.Path.GetFileNameWithoutExtension(FileName)
            ' Upload report
            Try
                Dim warnings As Warning() = Nothing
                warnings = ws.CreateReport(reportName, "/" + sFolder, True, RDLData, reportProperties)
                txtResult.Text = reportName + " uploaded" + vbCrLf + txtResult.Text
            Catch ex As Exception
                txtResult.Text = reportName + " failed (" + ex.Message & ")" + vbCrLf + txtResult.Text
            End Try
            Application.DoEvents()
        Next
    End Sub

 


lstFilePathName : string list for rdl files
RSADMINID : ID 
RSADMINPW : Password
RSNETWORKNAME : Network Name