/// <summary>
        /// 执行核心
        /// </summary>
        /// <param name="returnInfo">返回信息</param>
        /// <param name="flowIn">流程输入</param>
        /// <param name="findFlowCensorshipOut">查找流程关卡输出</param>
        /// <param name="connectionId">连接ID</param>
        protected override void ExecCore(ReturnInfo <bool> returnInfo, FlowInInfo <FlowAuditInfo> flowIn,
                                         FlowCensorshipOutInfo findFlowCensorshipOut, string connectionId = null)
        {
            // 更新工作流状态
            WorkflowPersistence.UpdateFlowStatusAndCensorshipAndHandlerById(findFlowCensorshipOut.Workflow, connectionId);

            // 更新当前工作流处理状态
            WorkflowHandlePersistence.UpdateHandleStatusById(findFlowCensorshipOut.CurrConcreteCensorship.WorkflowHandles[0], connectionId);

            string actionStr = flowIn.Flow.ActionType == ActionType.SEND ? "送件" : "退件";

            if (findFlowCensorshipOut.NextConcreteCensorshipHandles.IsNullOrLength0())
            {
                returnInfo.SetSuccessMsg($"申请单号[{findFlowCensorshipOut.Workflow.ApplyNo}]已{actionStr},等待其他人处理");
                return;
            }
            else
            {
                WorkflowHandleInfo updateEf = new WorkflowHandleInfo()
                {
                    Id = flowIn.Flow.HandleId,
                    FlowCensorshipId   = flowIn.Flow.WorkflowHandle.FlowCensorshipId,
                    ConcreteConcreteId = flowIn.Flow.WorkflowHandle.ConcreteConcreteId,
                    WorkflowId         = flowIn.Flow.WorkflowHandle.WorkflowId
                };
                updateEf.SetModifyInfo();

                if (flowIn.Flow.ActionType == ActionType.SEND)
                {
                    WorkflowHandlePersistence.UpdateEfficacyedNotIdByWorkflowIdAndFlowCensorshipId(updateEf, connectionId);
                }
                else
                {
                    WorkflowHandlePersistence.UpdateEfficacyedNotIdByWorkflowId(updateEf, connectionId);
                }

                // 插入下一个处理者
                IList <WorkflowHandleInfo> handlers = new List <WorkflowHandleInfo>();
                foreach (var c in findFlowCensorshipOut.NextConcreteCensorshipHandles)
                {
                    foreach (var h in c.WorkflowHandles)
                    {
                        h.WorkflowId = findFlowCensorshipOut.Workflow.Id;
                        handlers.Add(h);
                    }
                }

                ReturnInfo <bool> reHandle = WorkflowHandle.Add(handlers, connectionId);
                if (reHandle.Failure())
                {
                    returnInfo.FromBasic(reHandle);
                    return;
                }
            }

            StringBuilder msg = new StringBuilder($"申请单号[{findFlowCensorshipOut.Workflow.ApplyNo}]");

            if (findFlowCensorshipOut.ActionType == ActionType.SEND)
            {
                msg.AppendFormat("已送到[{0}]", findFlowCensorshipOut.Workflow.CurrHandlers);
                if (findFlowCensorshipOut.IsNextEndCensorship())
                {
                    msg.Append(",审核通过,流程结束");
                }
                else
                {
                    msg.Append("审核");
                }
            }
            else
            {
                msg.AppendFormat("已退给[{0}]", findFlowCensorshipOut.Workflow.CurrHandlers);
                if (findFlowCensorshipOut.IsNextApplicantCensorship())
                {
                    msg.Append(",审核驳回,流程结束");
                }
                else
                {
                    msg.Append("审核");
                }
            }

            returnInfo.SetMsg(msg.ToString());
        }
Exemple #2
0
        /// <summary>
        /// 执行流程后
        /// </summary>
        /// <param name="flowCensorshipOut">流程关卡输出</param>
        /// <param name="flowIn">流程输入</param>
        /// <param name="isSuccess">是否成功</param>
        /// <param name="connectionId">连接ID</param>
        /// <param name="currUser">当前用户</param>
        /// <returns>返回信息</returns>
        public override ReturnInfo <bool> AfterExecFlow(FlowCensorshipOutInfo flowCensorshipOut, object flowIn, bool isSuccess, string connectionId = null, BasicUserInfo currUser = null)
        {
            ReturnInfo <bool> returnInfo = new ReturnInfo <bool>();

            if (isSuccess)
            {
                // 当前为申请者关卡
                if (flowCensorshipOut.IsCurrApplicantCensorship() &&
                    (flowCensorshipOut.ActionType == ActionType.SAVE || flowCensorshipOut.ActionType == ActionType.SEND))
                {
                    FlowInInfo <FlowInitInfo <PersonTimeInfo> > conFlowIn;
                    ConcreteFormInfoT form = ToApplyConcreteFormInfo(flowCensorshipOut, flowIn, returnInfo, out conFlowIn);
                    if (returnInfo.Failure())
                    {
                        return(returnInfo);
                    }

                    ReturnInfo <ConcreteFormInfo> reFormInfo = FormDataReaderFactory.Create(conFlowIn.Flow.WorkflowCode).ReaderByWorkflowId(flowCensorshipOut.Workflow.Id, connectionId, currUser);
                    if (reFormInfo.Failure())
                    {
                        returnInfo.FromBasic(reFormInfo);

                        return(returnInfo);
                    }
                    if (reFormInfo.Data != null)
                    {
                        switch (reFormInfo.Data.FlowStatus)
                        {
                        case FlowStatusEnum.AUDITING:
                            returnInfo.SetFailureMsg("此表单在审核中不允许重复申请");

                            return(returnInfo);

                        case FlowStatusEnum.AUDIT_PASS:
                            returnInfo.SetFailureMsg("此表单已审核通过不允许重复申请");

                            return(returnInfo);

                        case FlowStatusEnum.AUDIT_NOPASS:
                            returnInfo.SetFailureMsg("此表单已审核驳回不允许重复申请");

                            return(returnInfo);
                        }

                        form.SetModifyInfo(currUser);
                    }
                    else
                    {
                        form.SetCreateInfo(currUser);
                    }

                    form.ApplyNo    = flowCensorshipOut.Workflow.ApplyNo;
                    form.WorkflowId = flowCensorshipOut.Workflow.Id;
                    form.FlowStatus = flowCensorshipOut.Workflow.FlowStatus;

                    returnInfo = FormService.Set(form, connectionId, currUser);
                } // 下一关卡如果是结束关卡(送件)或是申请关卡(退件)
                else if ((flowCensorshipOut.IsNextEndCensorship() && flowCensorshipOut.ActionType == ActionType.SEND) ||
                         (flowCensorshipOut.IsNextApplicantCensorship() && flowCensorshipOut.ActionType == ActionType.RETURN))
                {
                    ConcreteFormInfoT form = typeof(ConcreteFormInfoT).CreateInstance <ConcreteFormInfoT>();
                    form.WorkflowId = flowCensorshipOut.Workflow.Id;
                    form.FlowStatus = flowCensorshipOut.Workflow.FlowStatus;
                    form.SetModifyInfo(currUser);

                    returnInfo = FormService.ModifyFlowStatusByWorkflowId(form, connectionId, currUser);
                }
            }

            return(returnInfo);
        }