DataWeb
Search Results for

    Show / Hide Table of Contents

    Interface IAuditService

    Provides audit events services.

    Namespace: DataWeb.Audit
    Assembly: DataWeb.Core.dll
    Syntax
    public interface IAuditService

    Methods

    DeleteExpiredEntriesAsync(DateTimeOffset, CancellationToken)

    Asynchronously deletes all audit event entries that have expired.

    Declaration
    Task DeleteExpiredEntriesAsync(DateTimeOffset expirationDate, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DateTimeOffset expirationDate

    The expiration date threshold. Entries with an expiration date on or before this date will be deleted.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    Remarks

    This method performs cleanup of old audit entries for maintenance purposes. To prevent accidental deletion of recent events, the expiration date must be at least 1 year in the past.

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the expiration date is too recent (less than 1 year in the past).

    GetAuditEventsAsync(AuditEventFilter, CancellationToken)

    Asynchronously retrieves audit events that match the specified filter.

    Declaration
    Task<IEnumerable<AuditEvent>> GetAuditEventsAsync(AuditEventFilter filter, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    AuditEventFilter filter

    The AuditEventFilter used to retrieve the audit events.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IEnumerable<AuditEvent>>

    A task that represents the asynchronous operation. The task result contains the audit events matching the filter, or an empty collection if none are found.

    SetAuditEventAsync(AuditEvent, CancellationToken)

    Asynchronously adds an audit event to the store.

    Declaration
    Task SetAuditEventAsync(AuditEvent auditEvent, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    AuditEvent auditEvent

    The AuditEvent to add to the store.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    Remarks

    This method performs automatic validation, sanitization, and enrichment of the audit event before storing:

    • Validates that ReferenceType is not empty.
    • Truncates Description to a maximum of 256 characters.
    • Truncates EventUrl to a maximum of 1000 characters.
    • Populates missing values from the HTTP context and application settings.
    • Sets expiration date to 2 years from the event date if not specified.
    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when auditEvent is null.

    ArgumentException

    Thrown when ReferenceType is null or empty.

    In this article
    Back to top Generated by DocFX