How to: Execute Custom Code when a Report is Persisted 如何:在报表持久化时执行自定义代码
This topic describes how you can customize the ReportsStorage class. Assume you have a customized the ReportDataV2 class and added the ModifiedBy property that should return the name of the user who last edited the report layout. You need to update this property value each time a report layout is saved. For this purpose, customize the ReportsStorage and register your custom implementation. The steps below demonstrate how to do it.
本主题介绍如何自定义报表存储类。假设您已自定义了 ReportDataV2 类,并添加了"修改者"属性,该属性应返回上次编辑报表布局的用户的名称。每次保存报表布局时,都需要更新此属性值。为此,请自定义报表存储并注册自定义实现。以下步骤演示如何执行此操作。
Note 注意
The approach described in this topic is not supported by the Mobile platform.
移动平台不支持本主题中描述的方法。
-
Inherit the ReportsStorage class and override its ReportsStorage.SaveReport method.
-
继承报表存储类并重写其报表存储.保存报表方法。
using DevExpress.XtraReports.UI; using DevExpress.ExpressApp; using DevExpress.ExpressApp.ReportsV2; using DevExpress.ExpressApp.Security; // ... public class CustomReportsStorage : ReportsStorage { public override void SaveReport(IReportDataV2Writable reportData, XtraReport report) { if (reportData is MyReportDataV2) { ISecurityUser currentUser = SecuritySystem.CurrentUser as ISecurityUser; if (currentUser != null) { ((MyReportDataV2)reportData).ModifiedBy = currentUser.UserName; } } base.SaveReport(reportData, report); } }
-
Edit the Module.cs (Module.vb) file and override the ModuleBase.Setup method. In this method, assign an instance of the CustomReportsStorage to the static ReportDataProvider.ReportsStorage property.
-
编辑Module.cs(模块.vb)文件并重写模块Base.安装程序方法。在此方法中,将自定义报表存储的实例分配给静态报表数据提供程序。报告存储属性。
using DevExpress.ExpressApp.ReportsV2; // ... public override void Setup(XafApplication application) { ReportDataProvider.ReportsStorage = new CustomReportsStorage(); base.Setup(application); }
XAF开发成品案例参考
如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。
作者博客: http://www.cnblogs.com/foreachlife
欢迎加入CIIP框架\XAF技术应用交流群: 336090194 群文件中有更多相关工具及文档资料
转载请注明出处。多谢!
欢迎加我微信: admiralcn 或扫码:

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!