private void CreateAudit(int type, AuditFields af) { if (AdditionalAuditData != null) { string oldVal; string newVal; foreach (KeyValuePair<string, string[]> AuditEntry in AdditionalAuditData.UpdateList) { AuditFields.ExtractAuditValue(AuditEntry.Value, out oldVal, out newVal); af.Add((string)AuditEntry.Key, oldVal, newVal); } AdditionalAuditData = null; } string EventSrc = null; long EventID = 0; try { AuditLog al = new AuditLog((long)type, TableName + ":Audit", ID, EventSrc, EventID, af, AuditHistoryDatabase); //mLastAuditID is used for concurrency checking if (AuditHistoryDatabase == TDatabase.Unknown) mLastAuditID = al.Save(AuditLog.CompletionStatus.Success, Process.GetCurrentProcess().ProcessName, this.sqlUtil); else mLastAuditID = al.Save(AuditLog.CompletionStatus.Success, Process.GetCurrentProcess().ProcessName); } catch (Exception) { // don't crash the overall delete if the audit record failed to insert // TODO - log this error somewhere else } }
public static void AuditException(TDatabase db, Exception x, string msg, MethodBase ErrorOriginatingMethod) { try { if (bRecursiveCall) return; bRecursiveCall = true; AuditFields changelist = new AuditFields(); AddExceptionInfo(x, ErrorOriginatingMethod, changelist); string EventSrc = Environment.MachineName; long EventID = 0; AuditLog l = new AuditLog(0, "Exception", 0, EventSrc, EventID, changelist, db); l.Recover = true; l.Save(AuditLog.CompletionStatus.Exception, msg, true); } catch { } finally { bRecursiveCall = false; } }