using Chloe; using DB.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Tool; namespace DB.Service { public class ReadBufLogService { public PagedList GetPagedList(int pageIndex, int pageSize, string category,DateTime beDateTime,DateTime endTime) { PagingResult pagePagingResult; using (var dbContext = DbFactory.GetContext) { pagePagingResult = dbContext.Query() //.Where(x=>x.CreateTime>=beDateTime) //.Where(x=>x.CreateTime<=endTime) .Where(x=>x.Category==category) .OrderByDesc(x => x.ID) .Paging(pageIndex, pageSize); } PagedList paged = new PagedList(pagePagingResult.DataList, pagePagingResult.Totals.ToInt(), pageIndex, pageSize); return paged; } public void Insert(string category, string barCode) { using (var dbContext = DbFactory.GetContext) { var entity= dbContext.Query() .Where(x => x.Category == category) .Where(x => x.BarCode == barCode) .OrderBy(x => x.ID) .Select(x => x.BarCode).FirstOrDefault(); if (string.IsNullOrEmpty(entity)) { ReadBufLog log = new ReadBufLog(); log.CreateTime=DateTime.Now; log.ID = SnowflakeFactory.NewId; log.Category = category; log.BarCode = barCode; dbContext.Insert(log); } } } } }