diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs index d9f2a3a1..a8087414 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs @@ -1,4 +1,5 @@ using BootstrapAdmin.DataAccess.Models; +using BootstrapAdmin.DataAccess.PetaPoco.Extensions; using BootstrapAdmin.Web.Core; using PetaPoco; @@ -17,4 +18,31 @@ class ExceptionService : BaseDatabase, IException catch { } return true; } + + public (IEnumerable Items, int ItemsCount) GetAll(string? searchText, 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}%"); + } + + if (sortOrder == "Unset") + { + sortOrder = "desc"; + } + + if (string.IsNullOrEmpty(sortName)) + { + sql.OrderBy("Logtime desc", "ErrorPage", "UserId"); + } + else + { + sql.OrderBy($"{sortName} {sortOrder}"); + } + + var data = Database.Page(pageIndex, pageItems, sql); + return (data.Items, data.TotalItems.ToInt32()); + } } diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs index bfffe7ec..0e76fe35 100644 --- a/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs +++ b/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs @@ -5,4 +5,6 @@ namespace BootstrapAdmin.Web.Core; public interface IException { bool Log(Error exception); + + (IEnumerable Items, int ItemsCount) GetAll(string? searchText, int pageIndex, int pageItems, string?sortName, string sortOrder); } diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor new file mode 100644 index 00000000..913feb2d --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor @@ -0,0 +1,15 @@ +@page "/Admin/Exceptions" + + + + + + + + + + + diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor.cs new file mode 100644 index 00000000..cf958626 --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor.cs @@ -0,0 +1,29 @@ +using BootstrapAdmin.DataAccess.Models; +using BootstrapAdmin.Web.Core; + +namespace BootstrapAdmin.Web.Pages.Admin; + +public partial class Exceptions +{ + private List PageItemsSource { get; } = new List { 5, 20, 40, 80, 100, 200 }; + + [Inject] + [NotNull] + private IException? ExceptionService { get; set; } + + private Task> OnQueryAsync(QueryPageOptions options) + { + var ret = new QueryData() + { + IsSorted = true, + IsFiltered = true, + IsSearch = true + }; + + var items = ExceptionService.GetAll(options.SearchText, options.PageIndex, options.PageItems, options.SortName, options.SortOrder.ToString()); + + ret.TotalCount = items.ItemsCount; + ret.Items = items.Items; + return Task.FromResult(ret); + } +}