public async Task <IActionResult> Index(AuditLogSelectDto selectDto) { var logs = await _auditLogAppService.GetAuditLogs(selectDto); ViewBag.Page = selectDto.Page; ViewBag.PageSize = selectDto.PageSize; ViewBag.TotalCount = logs.TotalCount; return(View(logs)); }
/// <summary> /// 获取审计日期数据 /// </summary> /// <returns></returns> private async Task GetAuditLogs(GetAuditLogsFilter input) { await WebRequest.Execute(() => appService.GetAuditLogs(Map <GetAuditLogsInput>(input)), async result => { dataPager.SetList(result); await Task.CompletedTask; }); }
public async Task Should_Get_Audit_Logs() { //Arrange UsingDbContext( context => { context.AuditLogs.Add( new AuditLog { TenantId = AbpSession.TenantId, UserId = AbpSession.UserId, ServiceName = "ServiceName-Test-1", MethodName = "MethodName-Test-1", Parameters = "{}", ExecutionTime = Clock.Now.AddMinutes(-1), ExecutionDuration = 123 }); context.AuditLogs.Add( new AuditLog { TenantId = AbpSession.TenantId, ServiceName = "ServiceName-Test-2", MethodName = "MethodName-Test-2", Parameters = "{}", ExecutionTime = Clock.Now, ExecutionDuration = 456 }); }); //Act var output = await _auditLogAppService.GetAuditLogs(new GetAuditLogsInput { StartDate = Clock.Now.AddMinutes(-10), EndDate = Clock.Now.AddMinutes(10) }); output.TotalCount.ShouldBe(2); output.Items[0].ServiceName.ShouldBe("ServiceName-Test-2"); output.Items[0].UserName.ShouldBe(null); output.Items[1].ServiceName.ShouldBe("ServiceName-Test-1"); output.Items[1].UserName.ShouldBe(User.AdminUserName, StringCompareShould.IgnoreCase); }
public async Task <ActionResult> Index() { var output = await _auditLogAppService.GetAuditLogs(BuildPageListRequstDto()); return(View(output)); }