VB to C#, xml

0

Chciałem skorzystać z tego skryptu ale występuje gdzieś null pointer exception (odopwiednik). Debugowanie tego jest awykonalne, zwlaszcza na serwerze. Ostatni raz z vb mialem stycznosc jak mialem 12 lat. Potrzebuje wskazówek do przepisania tego na C#, finalnie zamiast w SSRS (rs.exe) bede to uruchamial lokalnie w katalogu, skrypt ma zaorac wszystkie headery i footery raportow zapisanych w xml na takie jak są w pliku Custom.rld

intryguje mnie zwlaszcza
Dim reportDefinition As Byte() = Nothing
reportDefinition = rs.GetItemDefinition(item.Path)
i streamy.
Czy tutaj sie dzieje jakas vb owa magia i to przelatuje czy to moze byc miejsce tego bledu? (I tak chce przepisac)
W szczegolnosci interesuje mnie jak autor chce wpisac caly string path pliku do byte?

'Script to apply custom header and footer from Custom.rdl file saved to ReportServer to all report files on ReportServer
' uses Mgmt2010 endpoint / executable against stand alone or SharePoint integrated instance
' Save file as .rss extension and run using rs.exe from command line.
'Authored by Jared Zagelbaum 11/2014    jaredzagelbaum.wordpress.com
Sub Main()
**pogrubienie**Dim reportDefinition As Byte() = Nothing
Dim doc As New System.Xml.XmlDocument
Dim nsmanager As New XmlNamespaceManager(doc.NameTable)
Dim templateHeader As System.Xml.XmlElement
Dim templateFooter As System.Xml.XmlElement
Dim reportHeader As System.Xml.XmlElement
Dim reportFooter As System.Xml.XmlElement
nsmanager.AddNamespace("rd", "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition")
Dim items As CatalogItem() = rs.ListChildren("/", True)

'find template file
For Each item As CatalogItem In items
If item.TypeName = "Report" And item.Name = "Custom" Then
**reportDefinition = rs.GetItemDefinition(item.Path)
Dim stream As New MemoryStream(reportDefinition)
doc.Load(stream)**
Exit For
End If
Next

'load template header / footer into var
templateFooter = doc.SelectSingleNode("/rd:Report/rd:ReportSections/rd:ReportSection/rd:Page/rd:PageFooter", nsmanager)
templateHeader = doc.SelectSingleNode("/rd:Report/rd:ReportSections/rd:ReportSection/rd:Page/rd:PageHeader", nsmanager)

'iterate through catalog items and replace report headers with template
For Each item As CatalogItem In items
If item.TypeName = "Report" And item.Name <> "Custom" Then
**reportDefinition = rs.GetItemDefinition(item.Path)
Dim stream As New MemoryStream(reportDefinition)
Dim outstream As New MemoryStream()**
doc.Load(stream)
reportHeader = doc.SelectSingleNode("/rd:Report/rd:ReportSections/rd:ReportSection/rd:Page/rd:PageHeader", nsmanager)
reportFooter = doc.SelectSingleNode("/rd:Report/rd:ReportSections/rd:ReportSection/rd:Page/rd:PageFooter", nsmanager)
reportHeader.InnerXml = templateHeader.InnerXml
reportFooter.InnerXml = templateFooter.InnerXml
doc.Save(outstream)
reportDefinition = outstream.ToArray()
rs.SetItemDefinition(item.Path, reportDefinition, Nothing)
stream.Dispose()
outstream.Dispose()

End If
Next

End Sub
0

Pomoc raczej słaba, ale po przekonwertowaniu na szybko wychodzi coś takiego

1 użytkowników online, w tym zalogowanych: 0, gości: 1