Interface IAuditService
Represents a service for handling audit.
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IAuditService : IService
Methods
View SourceAdd(AuditType, int, int, string?, string, string?)
Declaration
[Obsolete("Use AddAsync() instead. Scheduled for removal in Umbraco 19.")]
void Add(AuditType type, int userId, int objectId, string? entityType, string comment, string? parameters = null)
Parameters
| Type | Name | Description |
|---|---|---|
| AuditType | type | |
| int | userId | |
| int | objectId | |
| string | entityType | |
| string | comment | |
| string | parameters |
AddAsync(AuditType, Guid, int, string?, string?, string?)
Adds an audit entry.
Declaration
Task<Attempt<AuditLogOperationStatus>> AddAsync(AuditType type, Guid userKey, int objectId, string? entityType, string? comment = null, string? parameters = null)
Parameters
| Type | Name | Description |
|---|---|---|
| AuditType | type | The type of the audit. |
| Guid | userKey | The key of the user triggering the event. |
| int | objectId | The identifier of the affected object. |
| string | entityType | The entity type of the affected object. |
| string | comment | The comment associated with the audit entry. |
| string | parameters | The parameters associated with the audit entry. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<AuditLogOperationStatus>> | Result of the add audit log operation. |
CleanLogs(int)
Declaration
[Obsolete("Use CleanLogsAsync() instead. Scheduled for removal in Umbraco 19.")]
void CleanLogs(int maximumAgeOfLogsInMinutes)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maximumAgeOfLogsInMinutes |
CleanLogsAsync(int)
Cleans the audit logs older than the specified maximum age.
Declaration
Task CleanLogsAsync(int maximumAgeOfLogsInMinutes)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maximumAgeOfLogsInMinutes | The maximum age of logs in minutes. |
Returns
| Type | Description |
|---|---|
| Task | Task representing the asynchronous operation. |
GetItemsAsync(int, int, Direction, DateTimeOffset?, AuditType[]?)
Returns paged items in the audit trail.
Declaration
Task<PagedModel<IAuditItem>> GetItemsAsync(int skip, int take, Direction orderDirection = Direction.Descending, DateTimeOffset? sinceDate = null, AuditType[]? auditTypeFilter = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | skip | The number of audit trail entries to skip. |
| int | take | The number of audit trail entries to take. |
| Direction | orderDirection | By default, this will always be ordered descending (newest first). |
| DateTimeOffset? | sinceDate | If populated, will only return entries after this time. |
| AuditType[] | auditTypeFilter | Since we currently do not have enum support with our expression parser, we cannot query on AuditType in the query or the custom filter, so we need to do that here. |
Returns
| Type | Description |
|---|---|
| Task<PagedModel<IAuditItem>> | The paged audit logs. |
GetItemsByEntityAsync(int, int, int, Direction, AuditType[]?, IQuery<IAuditItem>?)
Returns paged items in the audit trail for a given entity.
Declaration
Task<PagedModel<IAuditItem>> GetItemsByEntityAsync(int entityId, int skip, int take, Direction orderDirection = Direction.Descending, AuditType[]? auditTypeFilter = null, IQuery<IAuditItem>? customFilter = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | entityId | The identifier of the entity. |
| int | skip | The number of audit trail entries to skip. |
| int | take | The number of audit trail entries to take. |
| Direction | orderDirection | By default, this will always be ordered descending (newest first). |
| AuditType[] | auditTypeFilter | Since we currently do not have enum support with our expression parser, we cannot query on AuditType in the query or the custom filter, so we need to do that here. |
| IQuery<IAuditItem> | customFilter | Optional filter to be applied. |
Returns
| Type | Description |
|---|---|
| Task<PagedModel<IAuditItem>> | The paged items in the audit trail for the specified entity. |
GetItemsByKeyAsync(Guid, UmbracoObjectTypes, int, int, Direction, DateTimeOffset?, AuditType[]?)
Returns paged items in the audit trail for a given entity.
Declaration
Task<PagedModel<IAuditItem>> GetItemsByKeyAsync(Guid entityKey, UmbracoObjectTypes entityType, int skip, int take, Direction orderDirection = Direction.Descending, DateTimeOffset? sinceDate = null, AuditType[]? auditTypeFilter = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | entityKey | The key of the entity. |
| UmbracoObjectTypes | entityType | The entity type. |
| int | skip | The number of audit trail entries to skip. |
| int | take | The number of audit trail entries to take. |
| Direction | orderDirection | By default, this will always be ordered descending (newest first). |
| DateTimeOffset? | sinceDate | If populated, will only return entries after this time. |
| AuditType[] | auditTypeFilter | Since we currently do not have enum support with our expression parser, we cannot query on AuditType in the query or the custom filter, so we need to do that here. |
Returns
| Type | Description |
|---|---|
| Task<PagedModel<IAuditItem>> | The paged items in the audit trail for the specified entity. |
GetLogs(int)
Declaration
[Obsolete("Use GetItemsByEntityAsync() instead. Scheduled for removal in Umbraco 19.")]
IEnumerable<IAuditItem> GetLogs(int objectId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | objectId |
Returns
| Type | Description |
|---|---|
| IEnumerable<IAuditItem> |
GetLogs(AuditType, DateTime?)
Declaration
[Obsolete("Use GetItemsAsync() instead. Scheduled for removal in Umbraco 19.")]
IEnumerable<IAuditItem> GetLogs(AuditType type, DateTime? sinceDate = null)
Parameters
| Type | Name | Description |
|---|---|---|
| AuditType | type | |
| DateTime? | sinceDate |
Returns
| Type | Description |
|---|---|
| IEnumerable<IAuditItem> |
GetPagedItemsByEntity(int, long, int, out long, Direction, AuditType[]?, IQuery<IAuditItem>?)
Returns paged items in the audit trail for a given entity.
Declaration
[Obsolete("Use GetItemsByEntityAsync() instead. Scheduled for removal in Umbraco 19.")]
IEnumerable<IAuditItem> GetPagedItemsByEntity(int entityId, long pageIndex, int pageSize, out long totalRecords, Direction orderDirection = Direction.Descending, AuditType[]? auditTypeFilter = null, IQuery<IAuditItem>? customFilter = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | entityId | The identifier of the entity. |
| long | pageIndex | The index of tha page (pagination). |
| int | pageSize | The number of results to return. |
| long | totalRecords | The total number of records. |
| Direction | orderDirection | By default, this will always be ordered descending (newest first). |
| AuditType[] | auditTypeFilter | Since we currently do not have enum support with our expression parser, we cannot query on AuditType in the query or the custom filter, so we need to do that here. |
| IQuery<IAuditItem> | customFilter | Optional filter to be applied. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IAuditItem> | The paged items in the audit trail for the specified entity. |
GetPagedItemsByUser(int, long, int, out long, Direction, AuditType[]?, IQuery<IAuditItem>?)
Returns paged items in the audit trail for a given user.
Declaration
[Obsolete("Use GetPagedItemsByUserAsync() instead. Scheduled for removal in Umbraco 19.")]
IEnumerable<IAuditItem> GetPagedItemsByUser(int userId, long pageIndex, int pageSize, out long totalRecords, Direction orderDirection = Direction.Descending, AuditType[]? auditTypeFilter = null, IQuery<IAuditItem>? customFilter = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | userId | |
| long | pageIndex | |
| int | pageSize | |
| long | totalRecords | |
| Direction | orderDirection | By default this will always be ordered descending (newest first). |
| AuditType[] | auditTypeFilter | Since we currently do not have enum support with our expression parser, we cannot query on AuditType in the query or the custom filter so we need to do that here. |
| IQuery<IAuditItem> | customFilter | Optional filter to be applied. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IAuditItem> |
GetPagedItemsByUserAsync(Guid, int, int, Direction, AuditType[]?, DateTime?)
Returns paged items in the audit trail for a given user.
Declaration
Task<PagedModel<IAuditItem>> GetPagedItemsByUserAsync(Guid userKey, int skip, int take, Direction orderDirection = Direction.Descending, AuditType[]? auditTypeFilter = null, DateTime? sinceDate = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | userKey | The key of the user. |
| int | skip | The number of audit trail entries to skip. |
| int | take | The number of audit trail entries to take. |
| Direction | orderDirection | By default, this will always be ordered descending (newest first). |
| AuditType[] | auditTypeFilter | Since we currently do not have enum support with our expression parser, we cannot query on AuditType in the query or the custom filter, so we need to do that here. |
| DateTime? | sinceDate | The date to filter the audit entries. |
Returns
| Type | Description |
|---|---|
| Task<PagedModel<IAuditItem>> | The paged items in the audit trail for the specified user. |
GetUserLogs(int, AuditType, DateTime?)
Declaration
[Obsolete("Use GetPagedItemsByUserAsync() instead. Scheduled for removal in Umbraco 19.")]
IEnumerable<IAuditItem> GetUserLogs(int userId, AuditType type, DateTime? sinceDate = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | userId | |
| AuditType | type | |
| DateTime? | sinceDate |
Returns
| Type | Description |
|---|---|
| IEnumerable<IAuditItem> |
Write(int, string, string, DateTime, int, string, string, string)
Writes an audit entry for an audited event.
Declaration
[Obsolete("Use IAuditEntryService.WriteAsync() instead. Scheduled for removal in Umbraco 19.")]
IAuditEntry Write(int performingUserId, string perfomingDetails, string performingIp, DateTime eventDateUtc, int affectedUserId, string affectedDetails, string eventType, string eventDetails)
Parameters
| Type | Name | Description |
|---|---|---|
| int | performingUserId | The identifier of the user triggering the audited event. |
| string | perfomingDetails | Free-form details about the user triggering the audited event. |
| string | performingIp | The IP address or the request triggering the audited event. |
| DateTime | eventDateUtc | The date and time of the audited event. |
| int | affectedUserId | The identifier of the user affected by the audited event. |
| string | affectedDetails | Free-form details about the entity affected by the audited event. |
| string | eventType | The type of the audited event - must contain only alphanumeric chars and hyphens with forward slashes separating
categories.
|
| string | eventDetails | Free-form details about the audited event. |
Returns
| Type | Description |
|---|---|
| IAuditEntry | The created audit entry. |