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 SysLogService { private static readonly Lazy lazy = new Lazy(() => new SysLogService()); public static SysLogService Instance { get { return lazy.Value; } } private LogHelper log = LogHelper.Instance; Repository _repository => new Repository("sqlserver"); /// /// 查询所有日志信息 /// /// public List GetLogInfos(Expression> expression = null) { try { List entity; if (expression != null) { entity = _repository.GetList(expression); } else { entity = _repository.GetList(); } return entity; } catch (Exception ex) { log.Error("日志信息获取异常", ex); return null; } } /// /// 添加日志 /// /// /// public bool InsertLogInfo(SysLogEntity entity) { try { return _repository.Insert(entity); } catch (Exception ex) { log.Error("日志信息插入异常", ex); return false; } } } }