using Ewide.Core; using Furion.DependencyInjection; using RoadFlow.Model.FlowRunModel; using RoadFlow.Utility; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RoadFlow.Data { public class FlowEntrust : RoadFlowRepository, IFlowEntrust, ITransient { /// /// 查询一页数据 /// /// public List GetPagerList(out int count, int size, int number, string userId, string date1, string date2, string order) { int total = 0; var list = this.db.Queryable() .WhereIF(userId.IsGuid(), x => x.UserId == userId) .WhereIF(date1.IsDateTime(), x => x.StartTime >= DateTime.Parse(date1)) .WhereIF(date2.IsDateTime(), x => x.EndTime <= DateTime.Parse(date2)) .OrderByIF(!order.IsNullOrEmpty(), order) .ToPageList(number, size,ref total); count = total; return list; } /// /// 得到一个人员一个流程的委托人员(如果没有则返回string.Empty) /// /// 流程ID /// 人员实体 /// 如果没有委托则返回string.Empty public string GetEntrustUserId(string flowId, SysUser user) { var all = GetAll(); DateTime now = Utility.DateExtensions.Now; var entrust = all.Find(p => p.UserId == user.Id && (!p.FlowId.IsNullOrWhiteSpace() || p.FlowId == flowId) && p.StartTime <= now && p.EndTime >= now); return null == entrust ? string.Empty : entrust.ToUserId; } } }