using BaseService.Systems.AuditLoggingManagement.Dto; using BaseService.Permissions; using Microsoft.AspNetCore.Authorization; using System; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.AuditLogging; namespace BaseService.Systems.AuditLoggingManagement { [Authorize(BaseServicePermissions.AuditLogging.Default)] public class AuditLoggingAppService : ApplicationService, IAuditLoggingAppService { private readonly IAuditLogRepository _auditLogRepository; public AuditLoggingAppService( IAuditLogRepository auditLogRepository) { _auditLogRepository = auditLogRepository; } public async Task Get(Guid id) { var auditLog = await _auditLogRepository.GetAsync(id); return ObjectMapper.Map(auditLog); } public async Task> GetAll(GetAuditLogsInput input) { var count = await _auditLogRepository.GetCountAsync(httpMethod: input.HttpMethod, url: input.Url, userName: input.UserName, applicationName: input.ApplicationName, correlationId: input.CorrelationId, maxExecutionDuration: input.MaxExecutionDuration, minExecutionDuration: input.MinExecutionDuration, hasException: input.HasException, httpStatusCode: input.HttpStatusCode); var list = await _auditLogRepository.GetListAsync(sorting: input.Sorting,maxResultCount: input.MaxResultCount, skipCount: input.SkipCount, httpMethod: input.HttpMethod, url: input.Url, userName: input.UserName, applicationName: input.ApplicationName, correlationId: input.CorrelationId, maxExecutionDuration: input.MaxExecutionDuration, minExecutionDuration: input.MinExecutionDuration, hasException: input.HasException, httpStatusCode: input.HttpStatusCode); return new PagedResultDto( count, ObjectMapper.Map, List>(list) ); } public async Task GetAverageExecutionDurationPerDay(GetAverageExecutionDurationPerDayInput input) { var data = await _auditLogRepository.GetAverageExecutionDurationPerDayAsync(input.StartDate, input.EndDate); return new GetAverageExecutionDurationPerDayOutput() { Data = data }; } } }