You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
2.5 KiB

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<AuditLogDto> Get(Guid id)
{
var auditLog = await _auditLogRepository.GetAsync(id);
return ObjectMapper.Map<AuditLog, AuditLogDto>(auditLog);
}
public async Task<PagedResultDto<AuditLogDto>> 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<AuditLogDto>(
count,
ObjectMapper.Map<List<AuditLog>, List<AuditLogDto>>(list)
);
}
public async Task<GetAverageExecutionDurationPerDayOutput> GetAverageExecutionDurationPerDay(GetAverageExecutionDurationPerDayInput input)
{
var data = await _auditLogRepository.GetAverageExecutionDurationPerDayAsync(input.StartDate, input.EndDate);
return new GetAverageExecutionDurationPerDayOutput()
{
Data = data
};
}
}
}