예제 #1
0
        public override bool RecordWillBePersisted(AuditRecord auditRecord)
        {
            var packageAuditRecord = auditRecord as PackageAuditRecord;

            return(packageAuditRecord != null &&
                   (packageAuditRecord.Action == AuditedPackageAction.Delete || packageAuditRecord.Action == AuditedPackageAction.SoftDelete));
        }
예제 #2
0
        public void OnlyPackageAuditRecordsWillBeSaved(AuditRecord record, bool expectedResult)
        {
            // Arrange
            CloudBlobContainer nullBlobContainer = null;
            var service = new CloudAuditingService(nullBlobContainer, AuditActor.GetCurrentMachineActorAsync);

            // Act + Assert
            Assert.Equal<bool>(expectedResult, service.RecordWillBePersisted(record));
        }
예제 #3
0
        public virtual async Task<Uri> SaveAuditRecord(AuditRecord record)
        {
            // Build an audit entry
            var entry = new AuditEntry(record, await GetActor());

            // Serialize to json
            string rendered = RenderAuditEntry(entry);

            // Save the record
            return await SaveAuditRecord(rendered, record.GetResourceType(), record.GetPath(), record.GetAction(), entry.Actor.TimestampUtc);
        }
예제 #4
0
        public virtual async Task <Uri> SaveAuditRecord(AuditRecord record)
        {
            // Build an audit entry
            var entry = new AuditEntry(record, await GetActor());

            // Serialize to json
            string rendered = RenderAuditEntry(entry);

            // Save the record
            return(await SaveAuditRecord(rendered, record.GetResourceType(), record.GetPath(), record.GetAction(), entry.Actor.TimestampUtc));
        }
        /// <summary>
        /// Persists the audit record to storage.
        /// </summary>
        /// <param name="record">An audit record.</param>
        /// <returns>A <see cref="Task"/> that represents the asynchronous save operation.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="record" /> is <c>null</c>.</exception>
        public async Task SaveAuditRecordAsync(AuditRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            var tasks = _services.Select(service => service.SaveAuditRecordAsync(record))
                        .ToArray();

            await Task.WhenAll(tasks);
        }
        /// <summary>
        /// Persists the audit record to storage.
        /// </summary>
        /// <param name="record">An audit record.</param>
        /// <returns>A <see cref="Task"/> that represents the asynchronous save operation.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="record" /> is <c>null</c>.</exception>
        public async Task SaveAuditRecordAsync(AuditRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            var entry    = new AuditEntry(record, await GetActorAsync());
            var rendered = RenderAuditEntry(entry);

            await SaveAuditRecordAsync(rendered, record.GetResourceType(), record.GetPath(), record.GetAction(), entry.Actor.TimestampUtc);
        }
 /// <summary>
 /// The Auditing services can use it to stop the saving of the record before rendering.
 /// </summary>
 public virtual bool RecordWillBePersisted(AuditRecord auditRecord)
 {
     return(true);
 }
예제 #8
0
 public AuditEntry(AuditRecord record, AuditActor actor)
 {
     Record = record;
     Actor  = actor;
 }
예제 #9
0
 public AuditEntry(AuditRecord record, AuditActor actor)
 {
     Record = record;
     Actor = actor;
 }
예제 #10
0
 public override bool RecordWillBePersisted(AuditRecord auditRecord)
 {
     return(auditRecord.GetType() == typeof(PackageAuditRecord));
 }