diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs index a8087414..7327b95e 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs @@ -19,15 +19,32 @@ class ExceptionService : BaseDatabase, IException return true; } - public (IEnumerable Items, int ItemsCount) GetAll(string? searchText, int pageIndex, int pageItems, string? sortName, string sortOrder) + public (IEnumerable Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, string? sortName, string sortOrder) { var sql = new Sql(); if (!string.IsNullOrEmpty(searchText)) { - sql.Append("WHERE ErrorPage Like @0 or Message Like @0 or StackTrace Like @0", $"%{searchText}%"); + sql.Where("ErrorPage Like @0 or Message Like @0 or StackTrace Like @0", $"%{searchText}%"); } + if (!string.IsNullOrEmpty(filter.Category)) + { + sql.Where("Category = @0", filter.Category); + } + + if (!string.IsNullOrEmpty(filter.UserId)) + { + sql.Where("UserId Like @0", $"%{filter.UserId}%"); + } + + if (!string.IsNullOrEmpty(filter.ErrorPage)) + { + sql.Where("ErrorPage Like @0", $"%{filter.ErrorPage}%"); + } + + sql.Where("LogTime >= @0 and LogTime <= @1", filter.Star, filter.End); + if (sortOrder == "Unset") { sortOrder = "desc"; diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/ExceptionFilter.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/ExceptionFilter.cs new file mode 100644 index 00000000..840129b4 --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web.Core/ExceptionFilter.cs @@ -0,0 +1,14 @@ +namespace BootstrapAdmin.Web.Core; + +public class ExceptionFilter +{ + public DateTime Star { get; set; } + + public DateTime End { get; set; } + + public string? UserId { get; set; } + + public string? ErrorPage { get; set; } + + public string? Category { get; set; } +} diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs index 0e76fe35..1d19f244 100644 --- a/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs +++ b/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs @@ -6,5 +6,5 @@ public interface IException { bool Log(Error exception); - (IEnumerable Items, int ItemsCount) GetAll(string? searchText, int pageIndex, int pageItems, string?sortName, string sortOrder); + (IEnumerable Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, string? sortName, string sortOrder); } diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/ErrorSearch.razor b/src/blazor/admin/BootstrapAdmin.Web/Components/ErrorSearch.razor new file mode 100644 index 00000000..125710af --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/ErrorSearch.razor @@ -0,0 +1,14 @@ +
+
+ +
+
+ +
+
+ +
+
+