using Microsoft.Extensions.Logging; using SlnMesnac.Model.domain; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SlnMesnac.Repository.service.Impl { public class LogoIdentifyImpl : ILogoIdentifyService { private readonly ILogger _logger; private readonly Repository _rep; public LogoIdentifyImpl(ILogger logger, Repository rep) { _logger = logger; _rep = rep; } public async Task> GetAllRecordAsync() { List list = null; list = await _rep.GetListAsync(); return list; } /// /// 时间段条件查询 /// /// public async Task> QueryAllByTime(string time1, string time2) { try { List list = null; if(time1 == null && time2 == null){ list = _rep.GetList(); }else if (time1 == null) { list = _rep.GetList().Where(x => x.RecordTime <= DateTime.Parse(time2)).ToList(); }else if (time2 == null) { list = _rep.GetList().Where(x => x.RecordTime >= DateTime.Parse(time1)).ToList(); } else { list = _rep.GetList().Where(x=>x.RecordTime >= DateTime.Parse(time1) && x.RecordTime <= DateTime.Parse(time2)).ToList(); } return list; } catch (Exception ex) { _logger.LogError("时间段条件查询QueryAllByTime()出现异常:" + ex); return null; } } public bool InsertRecord(LogoIdentify ocrRecord) { return _rep.Insert(ocrRecord); } } }