添加日志查询 时间区间条件

This commit is contained in:
Kimdiego2098
2023-08-27 16:58:45 +08:00
parent 6a70ef9f31
commit 58814f7f74
8 changed files with 94 additions and 1 deletions

View File

@@ -86,6 +86,8 @@ public class BackendLogService : DbRepository<BackendLog>, IBackendLogService
private ISugarQueryable<BackendLog> GetPage(BackendLogPageInput input)
{
var query = Context.Queryable<BackendLog>()
.WhereIF(input.StartTime != null, a => a.LogTime >= input.StartTime.Value.ToLocalTime())
.WhereIF(input.EndTime != null, a => a.LogTime <= input.EndTime.Value.ToLocalTime())
.WhereIF(!string.IsNullOrEmpty(input.Source), it => it.LogSource.Contains(input.Source))
.WhereIF(!string.IsNullOrEmpty(input.Level), it => it.LogLevel.ToString().Contains(input.Level));
for (int i = 0; i < input.SortField.Count; i++)

View File

@@ -19,6 +19,15 @@ namespace ThingsGateway.Application;
/// </summary>
public class BackendLogPageInput : BasePageInput
{
/// <summary>
/// 开始时间
/// </summary>
public DateTime? StartTime { get; set; } = DateTime.UtcNow.AddDays(-1);
/// <summary>
/// 结束时间
/// </summary>
public DateTime? EndTime { get; set; } = DateTime.UtcNow.AddDays(1);
/// <summary>
/// 日志源
/// </summary>
@@ -55,6 +64,14 @@ public class BackendLogInput
/// </summary>
public class RpcLogPageInput : BasePageInput
{
/// <summary>
/// 开始时间
/// </summary>
public DateTime? StartTime { get; set; } = DateTime.UtcNow.AddDays(-1);
/// <summary>
/// 结束时间
/// </summary>
public DateTime? EndTime { get; set; } = DateTime.UtcNow.AddDays(1);
/// <summary>
/// 操作源
/// </summary>

View File

@@ -44,6 +44,8 @@ public class RpcLogService : DbRepository<RpcLog>, IRpcLogService
private ISugarQueryable<RpcLog> GetPage(RpcLogPageInput input)
{
var query = Context.Queryable<RpcLog>()
.WhereIF(input.StartTime != null, a => a.LogTime >= input.StartTime.Value.ToLocalTime())
.WhereIF(input.EndTime != null, a => a.LogTime <= input.EndTime.Value.ToLocalTime())
.WhereIF(!string.IsNullOrEmpty(input.Source), it => it.OperateSource.Contains(input.Source))
.WhereIF(!string.IsNullOrEmpty(input.Object), it => it.OperateObject.Contains(input.Object))
.WhereIF(!string.IsNullOrEmpty(input.Method), it => it.OperateMethod.Contains(input.Method));

View File

@@ -2583,6 +2583,16 @@
运行日志分页DTO
</summary>
</member>
<member name="P:ThingsGateway.Application.BackendLogPageInput.StartTime">
<summary>
开始时间
</summary>
</member>
<member name="P:ThingsGateway.Application.BackendLogPageInput.EndTime">
<summary>
结束时间
</summary>
</member>
<member name="P:ThingsGateway.Application.BackendLogPageInput.Source">
<summary>
日志源
@@ -2613,6 +2623,16 @@
RPC日志分页DTO
</summary>
</member>
<member name="P:ThingsGateway.Application.RpcLogPageInput.StartTime">
<summary>
开始时间
</summary>
</member>
<member name="P:ThingsGateway.Application.RpcLogPageInput.EndTime">
<summary>
结束时间
</summary>
</member>
<member name="P:ThingsGateway.Application.RpcLogPageInput.Source">
<summary>
操作源

View File

@@ -32,6 +32,30 @@
IsShowDetailButton
IsShowQueryButton>
<SearchTemplate>
<MMenu CloseOnContentClick="false" OffsetY Context="menu">
<ActivatorContent>
<MTextField Dense Readonly Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 "
Value="context.StartTime.Value.ToDefaultDateTimeFormat(InitTimezone.TimezoneOffset)"
@attributes="menu.Attrs" Outlined Label=@context.Description(x => x.StartTime) />
</ActivatorContent>
<ChildContent>
<AppDateTimePicker @bind-Value="context.StartTime"></AppDateTimePicker>
</ChildContent>
</MMenu>
<MMenu CloseOnContentClick="false" OffsetY Context="menu">
<ActivatorContent>
<MTextField Dense Readonly Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 "
Value="context.EndTime.Value.ToDefaultDateTimeFormat(InitTimezone.TimezoneOffset)" Clearable
@attributes="menu.Attrs" Outlined Label=@context.Description(x => x.EndTime) />
</ActivatorContent>
<ChildContent>
<AppDateTimePicker @bind-Value="context.EndTime"></AppDateTimePicker>
</ChildContent>
</MMenu>
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " @bind-Value="context.Source"
Outlined Label=@context.Description(x => x.Source) />
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " @bind-Value="context.Level"

View File

@@ -30,6 +30,8 @@ public partial class BackendLogPage
[Inject]
AjaxService AjaxService { get; set; }
[Inject]
InitTimezone InitTimezone { get; set; }
private async Task ClearClickAsync()
{
var confirm = await PopupService.OpenConfirmDialogAsync("删除", "确定 ?");

View File

@@ -30,6 +30,31 @@
QueryCallAsync="QueryCallAsync"
IsShowDetailButton IsShowQueryButton>
<SearchTemplate>
<MMenu CloseOnContentClick="false" OffsetY Context="menu">
<ActivatorContent>
<MTextField Dense Readonly Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 "
Value="context.StartTime.Value.ToDefaultDateTimeFormat(InitTimezone.TimezoneOffset)"
@attributes="menu.Attrs" Outlined Label=@context.Description(x => x.StartTime) />
</ActivatorContent>
<ChildContent>
<AppDateTimePicker @bind-Value="context.StartTime"></AppDateTimePicker>
</ChildContent>
</MMenu>
<MMenu CloseOnContentClick="false" OffsetY Context="menu">
<ActivatorContent>
<MTextField Dense Readonly Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 "
Value="context.EndTime.Value.ToDefaultDateTimeFormat(InitTimezone.TimezoneOffset)" Clearable
@attributes="menu.Attrs" Outlined Label=@context.Description(x => x.EndTime) />
</ActivatorContent>
<ChildContent>
<AppDateTimePicker @bind-Value="context.EndTime"></AppDateTimePicker>
</ChildContent>
</MMenu>
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " @bind-Value="context.Source"
Outlined Label=@context.Description(x => x.Source) />
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " @bind-Value="context.Object"

View File

@@ -29,7 +29,8 @@ public partial class RpcLogPage
[Inject]
AjaxService AjaxService { get; set; }
[Inject]
InitTimezone InitTimezone { get; set; }
private async Task ClearClickAsync()
{
var confirm = await PopupService.OpenConfirmDialogAsync("删除", "确定 ?");