Почему Dev Express ReportService Сохраняет классы, но загружает байтовый массив? - PullRequest
0 голосов
/ 21 мая 2019

При создании дизайнера отчетов, если создается ReportStorageWebExtension, у него есть 2 метода набора данных и 1 метод для получения данных.

Public Overrides Function GetData(ByVal url As String) As Byte()
    ' Returns report layout data stored in a Report Storage using the specified URL. 
    ' This method is called only for valid URLs after the IsValidUrl method is called.

    Return MyBase.GetData(url)
End Function

  Public Overrides Sub SetData(ByVal report As XtraReport, ByVal url As String)
    ' Stores the specified report to a Report Storage using the specified URL. 
    ' This method is called only after the IsValidUrl and CanSetData methods are called.

    MyBase.SetData(report, url)
End Sub

Public Overrides Function SetNewData(ByVal report As XtraReport, ByVal defaultUrl As String) As String
    ' Stores the specified report using a new URL. 
    ' The IsValidUrl and CanSetData methods are never called before this method. 
    ' You can validate and correct the specified URL directly in the SetNewData method implementation 
    ' and return the resulting URL used to save a report in your storage.

    Return MyBase.SetNewData(report, defaultUrl)
End Function

Почему набор данных получает XtraReport, но получает данные какbyte()

1 Ответ

0 голосов
/ 22 мая 2019

Как поясняется командой Devexpress в этом билете , все сделано так, что вы можете получить доступ к свойствам отчета, прежде чем сохранить его.и правильный способ сохранить их в виде байтового массива, подобного этому (показано здесь ):

Public Overrides Sub SetData(ByVal report As XtraReport, ByVal url As String)
        ' Write a report to the storage under the specified URL.
        Dim row As DataRow = reportsTable.Rows.Find(Integer.Parse(url))
        If row IsNot Nothing Then
            Using ms As New MemoryStream()
                report.SaveLayoutToXml(ms)
                row("LayoutData") = ms.GetBuffer()
            End Using
            reportsTableAdapter.Update(catalogDataSet)
            catalogDataSet.AcceptChanges()
        End If
    End Sub
...