Class ActivityAudit<TRequest, TResponse>
Represents an audited activity, including details about the request, response, and context.
[MessageName("Excalibur.A3.ActivityAudit")]
public class ActivityAudit<TRequest, TResponse> : IActivityAudited, IDomainEvent, IDispatchEvent, IDispatchMessage, IAuditIdentity, IAuditContext, IAuditResult
Type Parameters
TRequestThe type of the request.
TResponseThe type of the response.
- Inheritance
-
ActivityAudit<TRequest, TResponse>
- Implements
- Inherited Members
Constructors
ActivityAudit(IActivityContext, TRequest)
Initializes a new instance of the ActivityAudit<TRequest, TResponse> class.
public ActivityAudit(IActivityContext context, TRequest request)
Parameters
contextIActivityContextThe activity context providing contextual information.
requestTRequestThe request object associated with the activity.
Properties
ActivityName
Gets the name of the activity.
public string ActivityName { get; init; }
Property Value
- string
The name of the activity.
ApplicationName
Gets the name of the application.
public string ApplicationName { get; init; }
Property Value
- string
The name of the application.
Body
public object Body { get; }
Property Value
ClientAddress
Gets the client address from which the activity originated.
public string? ClientAddress { get; init; }
Property Value
CorrelationId
Gets the correlation ID associated with the activity.
public Guid CorrelationId { get; init; }
Property Value
- Guid
The correlation ID associated with the activity.
EventId
Gets the unique identifier for this event instance.
public string EventId { get; }
Property Value
- string
The unique identifier for this event instance.
EventType
public string EventType { get; }
Property Value
Exception
Gets or sets the exception encountered during the activity, if any.
public Exception? Exception { get; set; }
Property Value
Features
public IMessageFeatures Features { get; }
Property Value
Headers
Gets the message headers.
public IReadOnlyDictionary<string, object> Headers { get; }
Property Value
- IReadOnlyDictionary<string, object>
A read-only dictionary containing the audit's metadata headers.
Id
Gets the unique identifier for this audit record as a GUID.
public Guid Id { get; init; }
Property Value
- Guid
A unique identifier for this audit instance.
Login
Gets the login of the user performing the activity.
public string? Login { get; init; }
Property Value
MessageId
Gets the unique identifier for this audit record as a string.
public string MessageId { get; }
Property Value
- string
The string representation of the audit's unique identifier.
MessageType
Gets the type identifier for this audit record.
public string MessageType { get; }
Property Value
- string
The fully qualified type name of the audit.
Metadata
Gets optional metadata for cross-cutting concerns. Examples: UserId, TenantId, custom tags.
public IDictionary<string, object>? Metadata { get; }
Property Value
- IDictionary<string, object>
Optional metadata for cross-cutting concerns.
OccurredAt
Gets the UTC timestamp when this event occurred.
public DateTimeOffset OccurredAt { get; }
Property Value
- DateTimeOffset
The UTC timestamp when this event occurred.
Request
Gets or sets the request object associated with the activity.
public TRequest Request { get; protected set; }
Property Value
- TRequest
The request object associated with the activity.
Response
Gets or sets the response object associated with the activity.
public TResponse? Response { get; set; }
Property Value
- TResponse
The response object, or null if not available.
StatusCode
Gets or sets the status code of the activity result.
public int StatusCode { get; set; }
Property Value
- int
The status code of the activity result.
TenantId
Gets the tenant ID associated with the activity.
public string? TenantId { get; init; }
Property Value
Timestamp
Gets or sets the timestamp of when the activity occurred.
public DateTimeOffset Timestamp { get; set; }
Property Value
- DateTimeOffset
The timestamp of when the activity occurred.
UserId
Gets the user ID of the person performing the activity.
public string UserId { get; init; }
Property Value
- string
The user ID of the person performing the activity.
UserName
Gets the username of the person performing the activity.
public string UserName { get; init; }
Property Value
- string
The username of the person performing the activity.
Methods
DecorateAsync(Func<Task<TResponse>>)
Executes the specified activity and captures its result, audit information, and exceptions.
public Task<TResponse?> DecorateAsync(Func<Task<TResponse>> activity)
Parameters
Returns
- Task<TResponse>
The response produced by the activity.