コード例 #1
0
        /// <summary>
        /// 申请单流程状态转换
        /// </summary>
        /// <param name="order">申请单</param>
        /// <param name="nextStep">流程下一步</param>
        /// <param name="operation">流程操作</param>
        /// <returns>流程下一步状态</returns>
        private OrderStatus SwitchStatus(OrderModel order, WorkflowStepModel nextStep, OperateOrderModel operation)
        {
            var nextStatus = OrderStatus.Apply;

            //1, 申请
            if (operation.Operation == WorkflowOperation.Apply)
            {
                nextStatus = OrderStatus.Apply;
            }
            //2, 拒绝
            else if (operation.Operation == WorkflowOperation.Rejecte)
            {
                nextStatus = OrderStatus.Rejected;
            }
            //3, 流程未完成
            else if (nextStep != null && nextStep.Id > 0)
            {
                //3.1, 行政、财务审阅(领导已批准)
                if (nextStep.IsAdminReviewing() || nextStep.IsFinanceReviewing())
                {
                    //nextStatus = OrderStatus.Reviewing;
                    nextStatus = (order.RefOrderId == null || order.RefOrderId.Value < 1
                        ? OrderStatus.Approved
                        : OrderStatus.Revoked);
                }
                //3.2, 领导审批
                else if (nextStep.IsLeaderApproving())
                {
                    nextStatus = OrderStatus.Approving;
                }
            }
            //4, 流程结束
            else
            {
                nextStatus = (order.RefOrderId == null || order.RefOrderId.Value < 1
                    ? OrderStatus.Approved
                    : OrderStatus.Revoked);
            }

            return(nextStatus);
        }
コード例 #2
0
        /// <summary>
        /// 获取[领导审批]的下一步骤
        /// </summary>
        /// <param name="order"></param>
        /// <param name="curStep"></param>
        /// <param name="workflow"></param>
        /// <returns></returns>
        private WorkflowStepModel GetNextStepForLeaderApprove(OrderModel order, WorkflowStepModel curStep, WorkflowModel workflow)
        {
            WorkflowStepModel nextStep = null;
            var detail = order.OrderDets.FirstOrDefault(); //申请单详细

            if (detail == null || detail.IOHours == null || Math.Abs(detail.IOHours.Value) <= 0.0)
            {
                Log.Error("无效的申请单详细。");
                throw new KeyNotFoundException("无效的申请单详细。");
            }

            //在领导审批允许的范围内,则结束[领导审批],转到[行政财务审批]
            if (Math.Abs(detail.IOHours.Value) <= curStep.MaxTimes)
            {
                //行政审批
                nextStep = workflow.WorkflowSteps.FirstOrDefault(it => it.Type == WorkflowStepType.AdminReview);
                //财务审批
                nextStep = nextStep ?? workflow.WorkflowSteps.FirstOrDefault(it => it.Type == WorkflowStepType.FinanceReview);
            }
            else
            {
                curStep.NextStep = curStep.NextStep ?? Constant.WORKFLOW_INVALID_NODE;
                nextStep         = workflow.WorkflowSteps.FirstOrDefault(it => it.Id == curStep.NextStep.Value);

                //领导审批未结束, 则提示异常
                if (nextStep == null || !nextStep.IsLeaderApproving())
                {
                    Log.Error("无效的领导审批流程。");
                    throw new KeyNotFoundException("无效的领导审批流程。");
                }
            }

            if (nextStep == null)
            {
                Log.Error("无效的审批流程。");
                throw new KeyNotFoundException("无效的审批流程。");
            }

            return(nextStep);
        }