feat: Blazor 增加程序异常页面

This commit is contained in:
Argo Zhang 2020-02-04 11:37:51 +08:00
parent 47c98c1466
commit 8d55776c70
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
4 changed files with 101 additions and 1 deletions

View File

@ -0,0 +1,32 @@
@inherits ExceptionsBase
<div class="card">
<div class="card-header">
<span>查询结果</span>
</div>
<div class="card-body">
<Table Id="exception" TItem="Bootstrap.DataAccess.Exceptions" ShowToolBar="true" ShowSearch="true" ShowRefresh="true" QueryModel="QueryModel" EditModel="DataContext" OnQuery="Query" OnResetSearch="ResetSearch">
<TableHeader>
<LgbTableHeader TItem="DateTime" @bind-Value="@context.LogTime" class="text-nowrap datetime"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.ErrorPage" class="text-nowrap"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.UserId" class="text-nowrap"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.UserIp" class="text-nowrap"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.ExceptionType"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Message"></LgbTableHeader>
</TableHeader>
<RowTemplate>
<td>@context.LogTime</td>
<td>@context.ErrorPage</td>
<td>@context.UserId</td>
<td>@context.UserIp</td>
<td>@context.ExceptionType</td>
<td>@context.Message</td>
</RowTemplate>
<TableToolbarTemplate>
<TableToolbarButton class="btn btn-danger" Icon="fa fa-file-text-o" Title="服务器日志" OnClick="ShowDetail" />
</TableToolbarTemplate>
<SearchTemplate>
</SearchTemplate>
</Table>
</div>
</div>

View File

@ -0,0 +1,61 @@
using Bootstrap.Admin.Pages.Components;
using Bootstrap.Admin.Pages.Extensions;
using Bootstrap.DataAccess;
using Microsoft.AspNetCore.Components;
using System;
namespace Bootstrap.Admin.Pages.Views.Admin.Components
{
/// <summary>
/// 部门维护组件
/// </summary>
public class ExceptionsBase : ComponentBase
{
/// <summary>
/// 获得/设置 编辑类型实例
/// </summary>
protected Bootstrap.DataAccess.Exceptions DataContext { get; set; } = new Bootstrap.DataAccess.Exceptions();
/// <summary>
/// 获得/设置 查询绑定类型实例
/// </summary>
protected Bootstrap.DataAccess.Exceptions QueryModel { get; set; } = new Bootstrap.DataAccess.Exceptions();
/// <summary>
/// 获得/设置 开始时间
/// </summary>
protected DateTime? StartTime { get; set; }
/// <summary>
/// 获得/设置 开始时间
/// </summary>
protected DateTime? EndTime { get; set; }
/// <summary>
/// 数据查询方法
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
protected QueryData<Bootstrap.DataAccess.Exceptions> Query(QueryPageOptions options)
{
var data = ExceptionsHelper.RetrievePages(options.ToPaginationOption(), StartTime, EndTime);
return data.ToQueryData();
}
/// <summary>
/// 重置搜索方法
/// </summary>
protected void ResetSearch()
{
}
/// <summary>
/// 显示异常明细方法
/// </summary>
protected void ShowDetail()
{
}
}
}

View File

@ -16,7 +16,7 @@
{ title: "记录时间", field: "LogTime", sortable: true },
{ title: "请求网址", field: "ErrorPage", sortable: true },
{ title: "用户名", field: "UserId", sortable: true },
{ title: "IP", field: "UserIp", sortable: true },
{ title: "登录主机", field: "UserIp", sortable: true },
{ title: "异常类型", field: "ExceptionType", sortable: false },
{ title: "异常描述", field: "Message", sortable: false }
],

View File

@ -1,6 +1,7 @@
using Longbow.Web.Mvc;
using PetaPoco;
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data.Common;
@ -26,26 +27,31 @@ namespace Bootstrap.DataAccess
/// <summary>
/// 获得/设置 用户请求页面地址
/// </summary>
[DisplayName("请求网址")]
public string ErrorPage { get; set; } = "";
/// <summary>
/// 获得/设置 用户 ID
/// </summary>
[DisplayName("用户名")]
public string? UserId { get; set; }
/// <summary>
/// 获得/设置 用户 IP
/// </summary>
[DisplayName("登录主机")]
public string? UserIp { get; set; }
/// <summary>
/// 获得/设置 异常类型
/// </summary>
[DisplayName("异常类型")]
public string? ExceptionType { get; set; }
/// <summary>
/// 获得/设置 异常错误描述信息
/// </summary>
[DisplayName("异常描述")]
public string Message { get; set; } = "";
/// <summary>
@ -56,6 +62,7 @@ namespace Bootstrap.DataAccess
/// <summary>
/// 获得/设置 日志时间戳
/// </summary>
[DisplayName("记录时间")]
public DateTime LogTime { get; set; }
/// <summary>