Ejemplo n.º 1
0
 /// <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();
 }
Ejemplo n.º 2
0
 /// <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();
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 private void SaveAuditScope(AuditScope auditScope, AuditWcfEvent auditWcfEvent)
 {
     auditScope.SetCustomField(AuditBehavior.CustomFieldName, auditWcfEvent);
     auditScope.Save();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Saves the scope.
 /// </summary>
 private void SaveScope(AuditScope scope, EntityFrameworkEvent @event)
 {
     scope.SetCustomField("EntityFrameworkEvent", @event);
     OnScopeSaving(scope);
     scope.Save();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Saves the scope.
 /// </summary>
 private void SaveScope(AuditScope scope, EntityFrameworkEvent @event)
 {
     (scope.Event as AuditEventEntityFramework).EntityFrameworkEvent = @event;
     OnScopeSaving(scope);
     scope.Save();
 }
Ejemplo n.º 7
0
 private void SaveAuditScope(AuditScope auditScope, WcfEvent auditWcfEvent)
 {
     (auditScope.Event as AuditEventWcfAction).WcfEvent = auditWcfEvent;
     auditScope.Save();
 }