devexpress - 为什么 Dev express ReportService 保存类但加载字节数组?
问题描述
创建报表设计器时,如果创建了 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
为什么 set data 得到 aXtraReport
但得到的数据为byte()
解决方案
正如 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
推荐阅读
- javascript - 在 django 博客站点中集成文本编辑器
- python - Python:将函数打印为另一个打印字符串中的字符串?
- javascript - 用于合并排序可视化的异步等待 javascript
- csv - 导入到 BigQuery 的大 CSV 中的一行错误
- pyspark - 使用 PySpark 根据另一个表的值从一个表中获取最大值
- python - 我需要一个逗号分隔 2 个输出,它们之间没有空格
- database - wordpress ACF 库字段使用中的问题
- retrofit - OkHttp 调用超时,包括或不包括拦截器重试次数
- node.js - 如何使用 Express 中间件限定 MongoDB 访问范围
- java - 无法识别的 VM 选项“ShowCodeDetailsInExceptionMessages”