1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.0 KiB
C#

using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository.service
{
public class SysErrorLogService
{
private static readonly Lazy<SysErrorLogService> lazy = new Lazy<SysErrorLogService>(() => new SysErrorLogService());
public static SysErrorLogService Instance
{
get
{
return lazy.Value;
}
}
private LogHelper log = LogHelper.Instance;
Repository<SysErrorLogEntity> _repository => new Repository<SysErrorLogEntity>("sqlserver");
/// <summary>
/// 查询所有报警日志信息
/// </summary>
/// <returns></returns>
public List<SysErrorLogEntity> GetErrorLogInfos(Expression<Func<SysErrorLogEntity, bool>> expression = null)
{
try
{
List<SysErrorLogEntity> entity;
if (expression != null)
{
entity = _repository.GetList(expression);
}
else
{
entity = _repository.GetList();
}
return entity;
}
catch (Exception ex)
{
log.Error("报警日志信息获取异常", ex);
return null;
}
}
/// <summary>
/// 添加报警日志
/// </summary>
/// <param name="sysUserEntity"></param>
/// <returns></returns>
public bool InsertErrorLogInfo(SysErrorLogEntity entity)
{
try
{
return _repository.Insert(entity);
}
catch (Exception ex)
{
log.Error("报警日志信息插入异常", ex);
return false;
}
}
}
}