src/blazor/admin/BootstrapAdmin.DataAccess.EFCore/Services/ExceptionService.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone

using BootstrapAdmin.DataAccess.Models;
using BootstrapAdmin.Web.Core;
using Microsoft.EntityFrameworkCore;

namespace BootstrapAdmin.DataAccess.EFCore.Services;

/// <summary>
/// 
/// </summary>
public class ExceptionService : IException
{
    private IDbContextFactory<BootstrapAdminContext> DbFactory { get; }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="dbFactory"></param>
    public ExceptionService(IDbContextFactory<BootstrapAdminContext> dbFactory) => DbFactory = dbFactory;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="searchText"></param>
    /// <param name="filter"></param>
    /// <param name="pageIndex"></param>
    /// <param name="pageItems"></param>
    /// <param name="sortList"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    public (IEnumerable<Error> Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, List<string> sortList)
    {
        using var dbcontext = DbFactory.CreateDbContext();

        var items = dbcontext.Set<Error>();

        if (!string.IsNullOrEmpty(searchText))
        {
            items.Where(s => s.Message!.Contains(searchText) || s.StackTrace!.Contains(searchText) || s.ErrorPage!.Contains(searchText));
        }

        if (!string.IsNullOrEmpty(filter.Category))
        {
            items.Where(s => s.Category!.Contains(filter.Category));
        }

        if (!string.IsNullOrEmpty(filter.UserId))
        {
            items.Where(s => s.UserId!.Contains(filter.UserId));
        }

        if (!string.IsNullOrEmpty(filter.ErrorPage))
        {
            items.Where(s => s.ErrorPage!.Contains(filter.ErrorPage));
        }

        items.Where(s => s.LogTime >= filter.Star && s.LogTime <= filter.End);
后面还有 27 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。