我需要进行某种审计。我们希望存储插入、更新、删除或打开记录的时间。
现在我已经在 Singleton 类上创建了一个简单的方法:
public void Audit(string audit, AuditTypes type)
{
AuditEntry = new AuditEntry(){ Audit = audit, TypeId = (int)type };
// some logic to commit the audit entry to the database
}
public enum AuditTypes
{
Insert = 1,
Update = 2,
Delete = 3
Open = 4
}
在表格中的某处我称之为这种方法:
MyForm.cs:
private void RemoveSomeObject(SomeObject myObject)
{
/* Do some stuff that removes the object*/
MySingleton.GetInstance().Audit(myObject.Title, AuditTypes.Delete)
}
出于某种原因,我不认为这是要走的路,因为在代码中的任何地方都使用这种方法我有这种行。
我认为以更面向对象的方式来做更聪明,你觉得呢?编辑:
我确实记录了用户 ID 和日期,但我发现它与通知无关。