如何实现你的对象(编程)审计线索? [英] How do you implement audit trail for your objects (Programming)?

查看:252
本文介绍了如何实现你的对象(编程)审计线索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现审计跟踪的添加/编辑/删除我的目标,我使用的定义我的对象等的ORM(XPO)我实现了被触发的审计跟踪对象

I need to implement an audit trail for Add/Edit/Delete on my objects,I'm using an ORM (XPO) for defining my objects etc. I implemented an audit trail object that is triggered on


  1. OnSaving

  2. OnDeleting

基本对象,我存储在审计,审计跟踪(MAST-DET)表的变化,现场的变化。等使用一些调用方法的服务。

Of the base object, and I store the changes in Audit-AuditTrail (Mast-Det) table, for field changes. etc. using some method services called.

如何实现你的OOP代码审计线索?请分享您的见解?任何模式等?最佳实践等?另一件事是,运行单元测试时,如何禁用审计,因为我并不需要进行审计,但由于基础对象的代码。

How do you implement audit trail in you OOP code? Please share your insights? Any patterns etc? Best practices etc? Another thing is that how to disable audit when running unit test,since I don't need to audit them but since base object has the code.

更改对象(编辑/添加需要/ DEL),什么领域的变化要审核

Changes to object (edit/add/del) and what field changes need to be audited

推荐答案

数据库触发器,去这里如果你的首选方式可以。

Database triggers are the preferred way to go here, if you can.

不过,最近我不得不这样做在客户端的代码,我最后写创建该对象的深(值)复制时,它的类。在保存时(使用的ToString()只)被打开进行编辑,比较的两个对象,并写信给审核表进行任何更改。

However, recently I had to do this in client-side code and I ended up writing a class that created a deep (value) copy of the object when it was opened for editing, compared the two objects at save time (using ToString() only) and wrote any changes to an audit table.

编辑:我有一个[审计]属性上,我想考虑的审核和使用反射来找到他们每个属性,使特定的非对被审计对象的方法。

I had an [Audit] attribute on each property I wanted to consider auditable and used reflection to find them, making the method non-specific to the objects being audited.

这篇关于如何实现你的对象(编程)审计线索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆