/// <summary> /// Saves the scope. /// </summary> public void SaveScope(IAuditDbContext context, AuditScope scope, EntityFrameworkEvent @event) { UpdateAuditEvent(@event, context); (scope.Event as AuditEventEntityFramework).EntityFrameworkEvent = @event; context.OnScopeSaving(scope); scope.Save(); }
/// <summary> /// Ends the event for asynchronous interceptions. /// </summary> private static void EndAsyncAuditInterceptEvent(Task task, IInvocation invocation, InterceptEvent intEvent, AuditScope scope, object result) { intEvent.AsyncStatus = task.Status.ToString(); if (task.Status == TaskStatus.Faulted) { intEvent.Exception = task.Exception?.GetExceptionInfo(); } else if (task.Status == TaskStatus.RanToCompletion) { SuccessAuditInterceptEvent(invocation, intEvent, result); } scope.Save(); }
public void Test_DataProviderFactory() { GetProviderCount = 0; var options = new AuditScopeOptions(_ => _.DataProvider(GetProvider).CreationPolicy(EventCreationPolicy.InsertOnStartReplaceOnEnd)); Assert.AreEqual(0, GetProviderCount); using (var scope = AuditScope.Create(options)) { Assert.AreEqual(1, GetProviderCount); scope.SetCustomField("custom", "value"); scope.Save(); } Assert.AreEqual(1, GetProviderCount); options = new AuditScopeOptions(_ => _.DataProvider(GetProvider).CreationPolicy(EventCreationPolicy.Manual)); using (var scope = new AuditScope(options)) { Assert.AreEqual(2, GetProviderCount); scope.Save(); scope.Save(); } Assert.AreEqual(2, GetProviderCount); Audit.Core.Configuration.DataProviderFactory = GetProvider; using (var scope = AuditScope.Create("Test", null, new { custom = "value" })) { Assert.AreEqual(3, GetProviderCount); scope.Discard(); } Assert.AreEqual(3, GetProviderCount); Audit.Core.Configuration.Setup().UseFactory(GetProvider); using (var scope = AuditScope.Create("Test", null, new { custom = "value" })) { Assert.AreEqual(4, GetProviderCount); scope.Save(); } Assert.AreEqual(4, GetProviderCount); }
private void SaveAuditScope(AuditScope auditScope, AuditWcfEvent auditWcfEvent) { auditScope.SetCustomField(AuditBehavior.CustomFieldName, auditWcfEvent); auditScope.Save(); }
/// <summary> /// Saves the scope. /// </summary> private void SaveScope(AuditScope scope, EntityFrameworkEvent @event) { scope.SetCustomField("EntityFrameworkEvent", @event); OnScopeSaving(scope); scope.Save(); }
/// <summary> /// Saves the scope. /// </summary> private void SaveScope(AuditScope scope, EntityFrameworkEvent @event) { (scope.Event as AuditEventEntityFramework).EntityFrameworkEvent = @event; OnScopeSaving(scope); scope.Save(); }
private void SaveAuditScope(AuditScope auditScope, WcfEvent auditWcfEvent) { (auditScope.Event as AuditEventWcfAction).WcfEvent = auditWcfEvent; auditScope.Save(); }