Files
number_zj/20220330_Vote/Ewide.RoadFlow/Data/FlowEntrust/FlowEntrust.cs
2022-03-30 17:54:33 +08:00

53 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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<RoadFlow.Model.rf_flowentrust>, IFlowEntrust, ITransient
{
/// <summary>
/// 查询一页数据
/// </summary>
/// <returns></returns>
public List<RoadFlow.Model.rf_flowentrust> GetPagerList(out int count, int size, int number, string userId, string date1, string date2, string order)
{
int total = 0;
var list = this.db.Queryable<RoadFlow.Model.rf_flowentrust>()
.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;
}
/// <summary>
/// 得到一个人员一个流程的委托人员如果没有则返回string.Empty
/// </summary>
/// <param name="flowId">流程ID</param>
/// <param name="user">人员实体</param>
/// <returns>如果没有委托则返回string.Empty</returns>
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;
}
}
}