2018-10-28 15:03:59 +08:00
|
|
|
|
using Longbow.Cache;
|
|
|
|
|
using Longbow.Data;
|
2019-01-11 23:20:28 +08:00
|
|
|
|
using Longbow.Web.Mvc;
|
|
|
|
|
using PetaPoco;
|
2018-10-19 23:09:52 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.DataAccess
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class ExceptionsHelper
|
|
|
|
|
{
|
2018-10-28 15:03:59 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string RetrieveExceptionsDataKey = "ExceptionHelper-RetrieveExceptions";
|
2018-10-19 23:09:52 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ex"></param>
|
|
|
|
|
/// <param name="additionalInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
2018-10-30 22:15:29 +08:00
|
|
|
|
public static void Log(Exception ex, NameValueCollection additionalInfo)
|
|
|
|
|
{
|
2019-01-11 23:20:28 +08:00
|
|
|
|
var ret = DbContextManager.Create<Exceptions>().Log(ex, additionalInfo);
|
2018-10-30 22:15:29 +08:00
|
|
|
|
if (ret) CacheManager.Clear(RetrieveExceptionsDataKey);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-19 23:09:52 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询一周内所有异常
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2019-01-11 23:20:28 +08:00
|
|
|
|
public static IEnumerable<Exceptions> Retrieves() => CacheManager.GetOrAdd(RetrieveExceptionsDataKey, key => DbContextManager.Create<Exceptions>().Retrieves());
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="po"></param>
|
|
|
|
|
/// <param name="startTime"></param>
|
|
|
|
|
/// <param name="endTime"></param>
|
|
|
|
|
/// <returns></returns>
|
2019-01-14 12:33:09 +08:00
|
|
|
|
public static Page<Exceptions> RetrievePages(PaginationOption po, DateTime? startTime, DateTime? endTime) => DbContextManager.Create<Exceptions>().RetrievePages(po, startTime, endTime);
|
2018-10-19 23:09:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|