123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Configuration;
- using System.Data.Entity;
- using Autofac;
- using EMIS.DataLogic.SystemDAL;
- using EMIS.Entities;
- using EMIS.ViewModel.SystemView;
- using Bowin.Common.JSON;
- using EMIS.CommonLogic.PlugworkflowServices;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Utility;
- using System.Linq.Expressions;
- using EMIS.Utility.FormValidate;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.WorkflowManage;
- using EMIS.Utility;
- using EMIS.DataLogic.StudentManage.StudentProfile;
- namespace EMIS.CommonLogic.SystemServices
- {
- public class BaseWorkflowServices<TEntity> : BaseServices, IBaseWorkflowServices<TEntity> where TEntity : class
- {
- protected Func<List<Guid>, Guid, bool> DataRangeUserFunc { get; set; }
- public Lazy<IWorkflowServices> WorkflowServices { get; set; }
- public StudentDAL StudentDAL { get; set; }
- private string tableName { get; set; }
- /// <summary>
- ///
- /// </summary>
- public BaseWorkflowServices()
- {
- tableName = typeof(TEntity).Name;
- var scope = AutofacHelper.RequestLifetimeScope;
- StudentDAL = scope.Resolve<StudentDAL>();
- }
- /// <summary>
- /// 查询对应的接入流程表开始流程环节的Pid(对应的流程环节Pid)
- /// </summary>
- /// <returns></returns>
- public int? GetStartStatus()
- {
- return WorkflowServices.Value.GetStartStatus(tableName);
- }
- /// <summary>
- /// 查询对应的接入流程表已退回流程环节Pid(注:不包含开始环节、结束环节且为[BP]标识)
- /// </summary>
- /// <returns></returns>
- public int? GetSendBackStatus()
- {
- return WorkflowServices.Value.GetSendBackStatus(tableName);
- }
- /// <summary>
- /// 查询对应的接入流程表已通过流程环节Pid(注:不包含开始环节、结束环节且为[PASS]标识)
- /// </summary>
- /// <returns></returns>
- public int? GetPassNoEndStatus()
- {
- return WorkflowServices.Value.GetPassNoEndStatus(tableName);
- }
- /// <summary>
- /// 查询对应的结束流程环节Pid
- /// </summary>
- /// <returns></returns>
- public List<int?> GetEndStatus()
- {
- return WorkflowServices.Value.GetEndStatus(tableName);
- }
- /// <summary>
- /// 查询对应的结束流程环节且正常结束的流程环节Pid(注:结束环节且不为[BP]标识的)
- /// </summary>
- /// <returns></returns>
- public int? GetCorrectEndStatus()
- {
- return WorkflowServices.Value.GetCorrectEndStatus(tableName);
- }
- /// <summary>
- /// 查询对应的接入流程表非正常结束的流程环节Pid(注:通常为结束环节且为[BP]标识的)
- /// </summary>
- /// <returns></returns>
- public List<int?> GetBackpointStatus()
- {
- return WorkflowServices.Value.GetBackpointStatus(tableName);
- }
- /// <summary>
- /// 查询对应的接入流程表中开始环节、审核流程环节Pid(注:不包含结束、非正常[BP]结束环节)
- /// </summary>
- /// <returns></returns>
- public List<int?> GetStartApproveStatusList()
- {
- return WorkflowServices.Value.GetStartApproveStatusList(tableName);
- }
- /// <summary>
- /// 查询重录待审,重新录入环节Pid(用于期末设定学生名单背景颜色)
- /// </summary>
- /// <returns></returns>
- public List<int?> GetRebutStatus()
- {
- return WorkflowServices.Value.GetRebutStatus(tableName);
- }
- /// <summary>
- /// 查询对应的接入流程表中全部流程环节信息(WorkflowStatusView)
- /// </summary>
- /// <returns></returns>
- public List<WorkflowStatusView> GetStatusViewList()
- {
- return WorkflowServices.Value.GetStatusViewList(tableName);
- }
- /// <summary>
- /// 查询对应的接入流程表中审核流程环节信息(WorkflowStatusView,不包含开始、结束、非正常[BP]结束环节)
- /// </summary>
- /// <returns></returns>
- public List<WorkflowStatusView> GetApproveStatusViewList()
- {
- return WorkflowServices.Value.GetApproveStatusViewList(tableName);
- }
- /// <summary>
- /// 重载方法,根据当前流程环节ID获取全部审批动作
- /// </summary>
- /// <returns></returns>
- public List<ActionView> GetActionView()
- {
- return WorkflowServices.Value.GetActionView(tableName);
- }
- /// <summary>
- /// 查询开始流程环节的动作列表List
- /// </summary>
- /// <returns></returns>
- public List<ActionView> GetStartActionView()
- {
- return WorkflowServices.Value.GetStartActionView(tableName);
- }
- /// <summary>
- /// 根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView)
- /// </summary>
- /// <param name="formID">表单ID</param>
- /// <param name="userID">当前用户ID</param>
- /// <returns></returns>
- public List<ActionView> GetActionView(Guid formID, Guid userID)
- {
- try
- {
- return WorkflowServices.Value.GetActionView(tableName, formID, userID);
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 查询对应的工作流程中是否有对应的操作权限
- /// </summary>
- /// <param name="formID"></param>
- /// <param name="userID"></param>
- /// <returns></returns>
- public bool IsCanApprove(Guid formID, Guid userID)
- {
- try
- {
- var action = this.WorkflowServices.Value.GetActionView(tableName, formID, userID).FirstOrDefault();
- if (StudentDAL.StudentRepository.GetSingle(x => x.UserID == userID) == null)
- {
- return WorkflowServices.Value.IsCanApprove(tableName, userID, action.ActionID, new List<Guid> { formID }, DataRangeUserFunc);
- }
- else
- {
- return WorkflowServices.Value.IsCanApprove(tableName, userID, action.ActionID, new List<Guid> { formID });
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="userID"></param>
- /// <param name="formIDs"></param>
- /// <returns></returns>
- public List<WorkflowPermissionView> IsCanApprove(Guid userID, List<Guid> formIDs)
- {
- return WorkflowServices.Value.IsCanApprove(tableName, userID, formIDs);
- }
- /// <summary>
- /// 根据当前用户ID、actionID、formIDs判断是否有权限
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public bool GetRangeUserList(Guid userID, Guid actionID, List<Guid> formIDs)
- {
- return WorkflowServices.Value.IsCanApprove(tableName, userID, actionID, formIDs, DataRangeUserFunc);
- }
- /// <summary>
- /// 启动对应的流程并执行指定的动作至下一环节(提交)
- /// </summary>
- /// <param name="formID">需要提交的记录主键ID</param>
- /// <param name="userID">提交人ID</param>
- /// <param name="comment">提交意见</param>
- public void StartUp(List<Guid> formIDList, Guid userID, string comment = "")
- {
- try
- {
- if (StudentDAL.StudentRepository.GetSingle(x => x.UserID == userID) == null)
- {
- WorkflowServices.Value.BatchStartUp(tableName, formIDList, userID, comment, DataRangeUserFunc);
- }
- else
- {
- WorkflowServices.Value.BatchStartUp(tableName, formIDList, userID, comment, null);
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 重载方法,启动对应的流程并执行指定的动作至下一环节(提交),适用于开始节点有两个以上动作时
- /// </summary>
- /// <param name="formID">需要提交的记录主键ID</param>
- /// <param name="userID">提交人ID</param>
- /// <param name="actionID">动作ID</param>
- /// <param name="comment">提交意见</param>
- public void StartUp(Guid formID, Guid userID, Guid actionID, string comment)
- {
- try
- {
- if (StudentDAL.StudentRepository.GetSingle(x => x.UserID == userID) == null)
- {
- WorkflowServices.Value.StartUp(tableName, formID, userID, actionID, comment, DataRangeUserFunc);
- }
- else
- {
- WorkflowServices.Value.StartUp(tableName, formID, userID, actionID, comment, null);
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 审核流程(不包括提交——不包含流程启动)
- /// </summary>
- /// <param name="formID">需要审核的记录主键ID</param>
- /// <param name="userID">审核人ID</param>
- /// <param name="actionID">审核动作ID</param>
- /// <param name="comment">提交意见</param>
- public void Approve(List<Guid> formIDList, Guid userID, Guid actionID, string comment = "")
- {
- try
- {
- if (StudentDAL.StudentRepository.GetSingle(x => x.UserID == userID) == null)
- {
- WorkflowServices.Value.BatchApprove(tableName, formIDList, userID, actionID, comment, DataRangeUserFunc);
- }
- else
- {
- WorkflowServices.Value.BatchApprove(tableName, formIDList, userID, actionID, comment, null);
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 工作流流程状态修改(通常用于取消申请、撤销等环节)
- /// </summary>
- /// <param name="formID">表单ID</param>
- /// <param name="status">状态:A为活动,D为结束、其他的自己定义</param>
- /// <param name="description">描述改变内容</param>
- public void ModifyProcessState(Guid formID, string status, string description)
- {
- try
- {
- WorkflowServices.Value.ModifyProcessState(tableName, formID, status, description);
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 查询对应的审核历史信息列表List(WorkflowApproveHistoryView)
- /// </summary>
- /// <param name="formID">需要获取的记录主键ID</param>
- /// <returns></returns>
- public IList<ViewModel.SystemView.WorkflowApproveHistoryView> GetApproveHistoryViewList(Guid formID)
- {
- try
- {
- return WorkflowServices.Value.GetApproveHistoryViewList(tableName, formID);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 根据相应的信息查询待办信息View
- /// </summary>
- /// <typeparam name="T">视图类型</typeparam>
- /// <param name="query">查询视图,指定一个IQueryable决定如何获取表单记录</param>
- /// <param name="userID">待办用户ID</param>
- /// <param name="pkSelector">指定主键列</param>
- /// <param name="pageIndex">页码</param>
- /// <param name="pageSize">每页行数</param>
- /// <returns></returns>
- public IGridResultSet<T> QueryByPendingJob<T, TOrder>(IQueryable<T> query, Guid userID, Expression<Func<T, Guid>> pkSelector,
- Expression<Func<T, TOrder>> orderby, bool isDescending = false, int? pageIndex = null, int? pageSize = null)
- {
- try
- {
- return WorkflowServices.Value.QueryByPendingJob(tableName, query, userID, pkSelector, orderby, isDescending, pageIndex, pageSize);
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|