コード例 #1
0
        protected override void InsertAuditRecordToDatabase(EntityAuditRecord record)
        {
            // Bodge to prevent duplicate audit records being made.
            if (tempChanges.Contains(record.Entity))
            {
                tempChanges.Remove(record.Entity);
            }
            else
            {
                return;
            }

            AuditLog audit = new AuditLog()
            {
                ID = getNextIdentifier(typeof(AuditLog), this), EventDateUTC = DateTime.UtcNow
            };

            audit.EventDateUTC = DateTime.Now;

            switch (record.Action)
            {
            case AuditAction.Insert:
                audit.EventType = "INSERT";
                break;

            case AuditAction.Update:
                audit.EventType = "UPDATE";
                break;

            case AuditAction.Delete:
                audit.EventType = "DELETE";
                break;

            default:
                break;
            }

            audit.TableName = record.EntityTable;
            audit.RecordId  = record.EntityTableKey;

            foreach (ModifiedEntityProperty av in record.ModifiedProperties)
            {
                if (av.NewValue.StartsWith("System."))
                {
                    continue;
                }
                if (av.NewValue.StartsWith("ChampionshipSolutions.DM."))
                {
                    continue;
                }

                AuditLogDetails detail = new AuditLogDetails()
                {
                    ID = getNextIdentifier(typeof(AuditLogDetails), this)
                };

                detail.ColumnName    = av.MemberName;
                detail.OriginalValue = av.OldValue;
                detail.NewValue      = av.NewValue;

                audit.AddDetail(detail);
            }

            this.AuditLog.InsertOnSubmit(audit);
        }
コード例 #2
0
 public void AddDetail(AuditLogDetails Detail)
 {
     //Detail.AuditLogRecord = this;
     //_Details.Add(Detail);
 }