using Learun.DataBase.Repository; using Learun.Util; using System; using System.Collections.Generic; namespace Learun.Application.WorkFlow { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创建人:陈彬彬 /// 日 期:2017.04.17 /// 描 述:工作流实例 /// public class WfProcessInstanceService : RepositoryFactory { #region 获取数据 /// /// 获取流程实例 /// /// 主键 /// public WfProcessInstanceEntity GetEntity(string keyValue) { try { return this.BaseRepository().FindEntity(keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取流程信息列表 /// /// 分页参数 /// 查询条件 /// public IEnumerable GetPageList(Pagination pagination, string queryJson) { try { var expression = LinqExtensions.True(); var queryParam = queryJson.ToJObject(); // 分类 if (!queryParam["categoryId"].IsEmpty()) // 1:未完成 2:已完成 { if (queryParam["categoryId"].ToString() == "1") { expression = expression.And(t => t.F_IsFinished == 0); } else { expression = expression.And(t => t.F_IsFinished == 1); } } // 操作时间 if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty()) { DateTime startTime = queryParam["StartTime"].ToDate(); DateTime endTime = queryParam["EndTime"].ToDate(); expression = expression.And(t => t.F_CreateDate >= startTime && t.F_CreateDate <= endTime); } // 关键字 if (!queryParam["keyword"].IsEmpty()) { string keyword = queryParam["keyword"].ToString(); expression = expression.And(t => t.F_ProcessName.Contains(keyword) || t.F_SchemeName.Contains(keyword)); } return this.BaseRepository().FindList(expression, pagination); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取我的流程信息列表 /// /// 用户主键 /// 分页参数 /// 查询条件 /// public IEnumerable GetMyPageList(string userId, Pagination pagination, string queryJson) { try { var expression = LinqExtensions.True(); var queryParam = queryJson.ToJObject(); expression = expression.And(t => t.F_CreateUserId == userId); // 操作时间 if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty()) { DateTime startTime = queryParam["StartTime"].ToDate(); DateTime endTime = queryParam["EndTime"].ToDate(); expression = expression.And(t => t.F_CreateDate >= startTime && t.F_CreateDate <= endTime); } // 关键字 if (!queryParam["keyword"].IsEmpty()) { string keyword = queryParam["keyword"].ToString(); expression = expression.And(t => t.F_ProcessName.Contains(keyword) || t.F_SchemeName.Contains(keyword)); } return this.BaseRepository().FindList(expression, pagination); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取流程实例信息(正在运行的) /// /// 实例主键 /// public IEnumerable GetListByProcessIds(string processIds) { try { return this.BaseRepository().FindList(t => processIds.Contains(t.F_Id) && t.F_IsFinished == 0 && t.F_EnabledMark == 1); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取全部流程实例 /// /// /// public IEnumerable GetListByAllProcessIds(string processIds) { try { return this.BaseRepository().FindList(t => processIds.Contains(t.F_Id)); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion #region 提交数据 /// /// 删除流程实例 /// /// public void DeleteEntity(string keyValue) { try { this.BaseRepository().Delete(t => t.F_Id == keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 保存流程实例 /// /// 主键 /// 实体 public void SaveEntity(string keyValue, WfProcessInstanceEntity entity) { try { if (string.IsNullOrEmpty(keyValue)) { entity.Create(); this.BaseRepository().Insert(entity); } else { entity.Modify(keyValue); this.BaseRepository().Update(entity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion } }