/// <summary>
        /// 设置实体
        /// </summary>
        /// <param name="sqlBuilder">Sql语句生成器</param>
        /// <param name="workTaskInstanceEntity">实体</param>
        private void SetEntity(SQLBuilder sqlBuilder, WorkTaskInstanceEntity workTaskInstanceEntity)
        {
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldWorkFlowId, workTaskInstanceEntity.WorkFlowId);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldWorkTaskId, workTaskInstanceEntity.WorkTaskId);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldWorkFlowInsId, workTaskInstanceEntity.WorkFlowInsId);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldPreviousTaskId, workTaskInstanceEntity.PreviousTaskId);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldTaskInsCaption, workTaskInstanceEntity.TaskInsCaption);
            if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
            {
                sqlBuilder.SetValue(WorkTaskInstanceTable.FieldStartTime, workTaskInstanceEntity.StartTime != null ? BusinessLogic.GetOracleDateFormat(System.DateTime.Parse(workTaskInstanceEntity.StartTime.ToString()), "yyyy-mm-dd hh24:mi:ss") : workTaskInstanceEntity.StartTime);
                sqlBuilder.SetValue(WorkTaskInstanceTable.FieldEndTime, workTaskInstanceEntity.EndTime != null ? BusinessLogic.GetOracleDateFormat(System.DateTime.Parse(workTaskInstanceEntity.EndTime.ToString()), "yyyy-mm-dd hh24:mi:ss") : workTaskInstanceEntity.EndTime);
            }
            else
            {
                sqlBuilder.SetValue(WorkTaskInstanceTable.FieldStartTime, workTaskInstanceEntity.StartTime);
                sqlBuilder.SetValue(WorkTaskInstanceTable.FieldEndTime, workTaskInstanceEntity.EndTime);
            }

            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldStatus, workTaskInstanceEntity.Status);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldOperatedDes, workTaskInstanceEntity.OperatedDes);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldOperatorInsId, workTaskInstanceEntity.OperatorInsId);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldSuccessMsg, workTaskInstanceEntity.SuccessMsg);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldOutTimeed, workTaskInstanceEntity.OutTimeed);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldReminded, workTaskInstanceEntity.Reminded);
            sqlBuilder.SetValue(WorkTaskInstanceTable.FieldTaskInsDescription, workTaskInstanceEntity.TaskInsDescription);
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="workTaskInstanceEntity">实体</param>
        public int UpdateEntity(WorkTaskInstanceEntity workTaskInstanceEntity)
        {
            var sqlBuilder = new SQLBuilder(DBProvider);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, workTaskInstanceEntity);
            sqlBuilder.SetWhere(WorkTaskInstanceTable.FieldWorkTaskInsId, workTaskInstanceEntity.WorkTaskInsId);
            return(sqlBuilder.EndUpdate());
        }
        /// <summary>
        /// 创建新任务实例
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">任务实例实体</param>
        /// <returns>主键</returns>
        public string CreateWorkTaskInstance(UserInfo userInfo, WorkTaskInstanceEntity entity)
        {
            string returnValue = string.Empty;
            var    parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowInstanceService_CreateWorkTaskInstance);

            ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, dbProvider =>
            {
                var manager = new WorkTaskInstanceManager(dbProvider, userInfo);
                // 调用方法,并且返回运行结果
                returnValue = manager.Create(entity);
            });
            return(returnValue);
        }
        /// <summary>
        /// 创建新任务实例
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>主键</returns>
        public string Create(WorkTaskInstanceEntity entity)
        {
            string returnString = string.Empty;

            try
            {
                returnString = AddEntity(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(returnString);
        }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="workTaskInstanceEntity">实体</param>
        public string AddEntity(WorkTaskInstanceEntity workTaskInstanceEntity)
        {
            var sequence = string.Empty;

            this.Identity = false;
            if (!string.IsNullOrEmpty(workTaskInstanceEntity.WorkTaskInsId))
            {
                sequence = workTaskInstanceEntity.WorkTaskInsId.ToString();
            }
            var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, WorkTaskInstanceTable.FieldWorkTaskInsId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(workTaskInstanceEntity.WorkFlowInsId))
                {
                    sequence = BusinessLogic.NewGuid();
                    workTaskInstanceEntity.WorkTaskInsId = sequence;
                }
                sqlBuilder.SetValue(WorkTaskInstanceTable.FieldWorkTaskInsId, workTaskInstanceEntity.WorkTaskInsId);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(WorkTaskInstanceTable.FieldWorkTaskInsId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(WorkTaskInstanceTable.FieldWorkTaskInsId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(workTaskInstanceEntity.WorkTaskInsId))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            workTaskInstanceEntity.WorkTaskInsId = sequence;
                        }
                        sqlBuilder.SetValue(WorkTaskInstanceTable.FieldWorkTaskInsId, workTaskInstanceEntity.WorkTaskInsId);
                    }
                }
            }
            this.SetEntity(sqlBuilder, workTaskInstanceEntity);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                int eCount = sqlBuilder.EndInsert();
            }
            return(sequence);
        }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="workTaskInstanceEntity">实体</param>
 public int Update(WorkTaskInstanceEntity workTaskInstanceEntity)
 {
     return(this.UpdateEntity(workTaskInstanceEntity));
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="workTaskInstanceEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(WorkTaskInstanceEntity workTaskInstanceEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(workTaskInstanceEntity));
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="workTaskInstanceEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(WorkTaskInstanceEntity workTaskInstanceEntity)
 {
     return(this.AddEntity(workTaskInstanceEntity));
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 流程启动,草稿和启动两种状态
        /// </summary>
        public string Start()
        {
            try
            {
                if (string.IsNullOrEmpty(WorkFlowInstanceId))
                {
                    WorkFlowInstanceId = BusinessLogic.NewGuid();
                }
                if (string.IsNullOrEmpty(WorkTaskInstanceId))
                {
                    WorkTaskInstanceId = BusinessLogic.NewGuid();
                }
                if (string.IsNullOrEmpty(OperatorInstanceId))
                {
                    OperatorInstanceId = BusinessLogic.NewGuid();
                }
                if (string.IsNullOrEmpty(UserId))
                {
                    return(WorkFlowConst.IsNullUserIdCode);
                }
                if (CurrentUser == null)
                {
                    return(WorkFlowConst.IsNullUser);
                }
                if (string.IsNullOrEmpty(WorkFlowId))
                {
                    return(WorkFlowConst.IsNullWorkFlowIdCode);
                }
                if (string.IsNullOrEmpty(WorkTaskId))
                {
                    return(WorkFlowConst.IsNullWorkTaskIdCode);
                }
                if (string.IsNullOrEmpty(CommandName))
                {
                    return(WorkFlowConst.IsNullCommandNameCode);
                }
                if (string.IsNullOrEmpty(WorkFlowNo))
                {
                    return(WorkFlowConst.IsNullWorkFlowNoCode);
                }
                if (string.IsNullOrEmpty(WorkflowInsCaption))
                {
                    return(WorkFlowConst.IsNullWorkflowInsCaption);
                }

                if (RDIFrameworkService.Instance.WorkFlowHelperService.IsTaskInsCompleted(this.CurrentUser, WorkTaskInstanceId))
                {
                    return(WorkFlowConst.InstanceIsCompletedCode);//流程实例已完成,不能重复提交
                }
                //检查是否已经保存过草稿。如果已经保存过则不需要再创建实例,只保存业务表单数据,
                //此处的处理与交互节点的处理不同,需要加判断。

                if (RDIFrameworkService.Instance.WorkFlowInstanceService.WorkTaskInstanceExist(this.CurrentUser, WorkTaskInstanceId) == false)//实例不存在,说明未保存过
                {
                    //创建流程实例
                    var workflowInstance = new WorkFlowInstanceEntity()
                    {
                        WorkFlowId        = WorkFlowId,
                        WorkFlowInsId     = WorkFlowInstanceId,
                        WorkFlowNo        = WorkFlowNo,
                        FlowInsCaption    = WorkflowInsCaption,
                        Description       = Description,
                        Priority          = Priority,
                        Status            = Status,
                        NowTaskId         = WorkTaskId,//当前流程所处流程模板的位置
                        IsSubWorkflow     = IsSubWorkflow ? 1: 0,
                        MainWorkflowInsId = MainWorkflowInsId,
                        MainWorktaskId    = MainWorktaskId,
                        MainWorkflowId    = MainWorkflowId,
                        MainWorktaskInsId = MainWorktaskInsId
                    };

                    RDIFrameworkService.Instance.WorkFlowInstanceService.CreateWorkFlowInstance(this.CurrentUser, workflowInstance);

                    //创建启动节点的任务实例
                    var workTaskInstance = new WorkTaskInstanceEntity
                    {
                        WorkFlowId     = WorkFlowId,
                        WorkTaskId     = WorkTaskId,
                        WorkFlowInsId  = WorkFlowInstanceId,
                        WorkTaskInsId  = WorkTaskInstanceId,
                        TaskInsCaption = RDIFrameworkService.Instance.WorkFlowTemplateService.GetWorkTaskCaption(this.CurrentUser, WorkTaskId)
                    };

                    if (IsSubWorkflow)//是子流程调用,需要放到未认领任务中
                    {
                        workTaskInstance.PreviousTaskId = WorkTaskInstanceId;
                        workTaskInstance.Status         = "1";
                    }
                    else//不是子流程调用,启动节点直接放入已认领任务中
                    {
                        workTaskInstance.PreviousTaskId = WorkTaskInstanceId;//开始节点的前一节点等于自己
                        workTaskInstance.Status         = "2";
                    }

                    RDIFrameworkService.Instance.WorkFlowInstanceService.CreateWorkTaskInstance(this.CurrentUser, workTaskInstance);

                    //创建启动节点的处理人实例
                    var operatorInstance = new OperatorInstanceEntity
                    {
                        OperatorInsId = OperatorInstanceId,
                        WorkFlowId    = WorkFlowId,
                        WorkTaskId    = WorkTaskId,
                        WorkFlowInsId = WorkFlowInstanceId,
                        WorkTaskInsId = WorkTaskInstanceId,
                        UserId        = UserId,
                        OperRealtion  = 0,
                        OperContent   = UserId
                    };
                    var userEnity = RDIFrameworkService.Instance.UserService.GetEntity(this.CurrentUser, UserId);
                    var userName  = userEnity == null || string.IsNullOrEmpty(userEnity.UserName)
                        ? "未找到处理人"
                        : userEnity.UserName;

                    operatorInstance.OperContentText = userName;
                    operatorInstance.OperType        = 3;
                    if (IsSubWorkflow) //是子流程调用,需要放到未认领任务中
                    {
                        operatorInstance.OperStatus = "0";
                    }
                    else //不是子流程调用,启动节点直接放入已认领任务中
                    {
                        operatorInstance.OperStatus = "3";
                    }
                    RDIFrameworkService.Instance.WorkFlowInstanceService.CreateOperatorInstance(this.CurrentUser, operatorInstance);
                }

                if (!IsDraft)//不是草稿状态,提交任务
                {
                    var result = RDIFrameworkService.Instance.WorkFlowHelperService.CreateNextTaskInstance(this.CurrentUser, UserId, WorkFlowId, WorkTaskId, WorkFlowInstanceId, WorkTaskInstanceId, OperatorInstanceId, CommandName);
                    if (result != WorkFlowConst.SuccessCode)
                    {
                        var e = new WorkFlowEventArgs(this)
                        {
                            ResultMsg = result
                        };
                        OnRunFail(this, e);
                        return(result);
                    }
                    else
                    {
                        var e = new WorkFlowEventArgs(this)
                        {
                            ResultMsg = WorkFlowConst.SuccessMsg
                        };
                        OnRunSuccess(this, e);
                    }
                }
                return(WorkFlowConst.SuccessCode);
            }
            catch (Exception ex)
            {
                var msg = string.Format(WorkFlowConst.EngineErrorMsg, ex.Message);
                var e   = new WorkFlowEventArgs(this)
                {
                    ResultMsg = msg
                };
                OnRunFail(this, e);
                return(WorkFlowConst.OtherErrorCode);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 指定处理人
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="workFlowId">流程模板Id</param>
        /// <param name="workTaskId">任务模板Id</param>
        /// <param name="workFlowInstanceId">流程实例Id</param>
        /// <param name="workTaskInstanceId">任务实例Id</param>
        /// <param name="operParam">处理者参数</param>
        /// <returns>是否成功</returns>
        public bool AssignUser(string userId, string workFlowId, string workTaskId, string workFlowInstanceId, string workTaskInstanceId, OperParameter operParam)
        {
            if (string.IsNullOrEmpty(operParam.OperContent))
            {
                return(false);
            }

            switch (operParam.OperRule)
            {
            case "1":
            {
                //创建处理人实例
                var operInsEntity = new OperatorInstanceEntity()
                {
                    OperatorInsId   = BusinessLogic.NewGuid(),
                    WorkFlowId      = workFlowId,
                    WorkTaskId      = workTaskId,
                    WorkFlowInsId   = workFlowInstanceId,
                    WorkTaskInsId   = workTaskInstanceId,  //此时是新任务Id
                    UserId          = "",
                    OperRealtion    = operParam.OperRelation,
                    OperContent     = operParam.OperContent,
                    OperContentText = operParam.OperContenText,
                    OperType        = operParam.OperType//此处保留原来的处理类型
                };
                string successCode = new OperatorInstanceManager(this.DBProvider).Create(operInsEntity);

                //给处理者发送信息
                if (!string.IsNullOrEmpty(successCode) && successCode.Length > 0)
                {
                    var messageEntity = new CiMessageEntity
                    {
                        Id           = BusinessLogic.NewGuid(),
                        FunctionCode = MessageFunction.Remind.ToString(),
                        ReceiverId   = DefaultRole.Administrator.ToString(),
                        Title        = "业务流程消息",
                        MSGContent   = "你有一待办任务,请到未认领任务界面认领。",
                        IsNew        = 1,
                        ReadCount    = 0,
                        Enabled      = 1,
                        DeleteMark   = 0
                    };

                    var messageManager = new CiMessageManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo);
                    messageManager.BatchSend(operInsEntity.OperContent, null, null, messageEntity, false);
                }

                if ((userId == operParam.OperContent) && (operParam.IsJumpSelf))    //处理者是提交人,自动处理
                {
                    var wfrun = new WorkFlowRuntime();
                    wfrun.Run(userId, operInsEntity.OperatorInsId, "提交");
                }
            }
            break;

            case "2":
            {
                //创建任务实例
                var newTaskId         = BusinessLogic.NewGuid();//新任务实例Id
                var workTaskInsEntity = new WorkTaskInstanceEntity()
                {
                    WorkFlowId     = workFlowId,
                    WorkTaskId     = workTaskId,
                    WorkFlowInsId  = workFlowInstanceId,
                    WorkTaskInsId  = newTaskId,
                    PreviousTaskId = workTaskInstanceId,    //此时是当前任务Id
                    TaskInsCaption = new WorkTaskManager(this.DBProvider).GetTaskCaption(workTaskId),
                    Status         = "1",
                };
                new WorkTaskInstanceManager(this.DBProvider).Create(workTaskInsEntity);

                //创建处理人实例
                var operInsEntity = new OperatorInstanceEntity()
                {
                    OperatorInsId   = BusinessLogic.NewGuid(),
                    WorkFlowId      = workFlowId,
                    WorkTaskId      = workTaskId,
                    WorkFlowInsId   = workFlowInstanceId,
                    WorkTaskInsId   = newTaskId,
                    UserId          = "",
                    OperRealtion    = operParam.OperRelation,
                    OperContent     = operParam.OperContent,
                    OperContentText = operParam.OperContenText,
                    OperType        = 3,//此处修改为指定处理人
                };
                string successCode = new OperatorInstanceManager(this.DBProvider).Create(operInsEntity);

                //给处理者发送信息
                if (!string.IsNullOrEmpty(successCode) && successCode.Length > 0)
                {
                    var messageEntity = new CiMessageEntity
                    {
                        Id           = BusinessLogic.NewGuid(),
                        FunctionCode = MessageFunction.Remind.ToString(),
                        ReceiverId   = DefaultRole.Administrator.ToString(),
                        Title        = "业务流程消息",
                        MSGContent   = "你有一待办任务,请到未认领任务界面认领。",
                        IsNew        = 1,
                        ReadCount    = 0,
                        Enabled      = 1,
                        DeleteMark   = 0
                    };

                    var messageManager = new CiMessageManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo);
                    messageManager.BatchSend(operInsEntity.OperContent, null, null, messageEntity, false);
                }
                if ((userId == operParam.OperContent) && (operParam.IsJumpSelf))    //处理者是提交人,自动处理
                {
                    var wfrun = new WorkFlowRuntime();
                    wfrun.Run(userId, operInsEntity.OperatorInsId, "提交");
                }
            }
            break;
            }
            return(true);
        }
        /// <summary>
        /// 创建所有符合条件的任务实例
        /// </summary>
        /// <param name="userId">处理人Id</param>
        /// <param name="workFlowId">工作流模板id</param>
        /// <param name="workTaskId">当前任务Id</param>
        /// <param name="workFlowInstanceId">工作流实例Id</param>
        /// <param name="workTaskInstanceId">原任务实例Id</param>
        /// <param name="operatorInstanceId">处理者实例Id</param>
        /// <param name="commandName">命令</param>
        /// <returns>
        /// 000002:没有配置后续任务
        /// 000000:操作成功
        /// </returns>
        public string CreateNextTaskInstance(string userId, string workFlowId, string workTaskId, string workFlowInstanceId, string workTaskInstanceId, string operatorInstanceId, string commandName)
        {
            var userName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(userId).UserName;

            var dt = GetLineEndTasks(workFlowId, workTaskId, commandName);

            if (dt != null && dt.Rows.Count > 0)
            {
                var condition        = "";                  //条件
                var priority         = "";                  //优先级,只执行优先级最高的分支,如果优先级相同 那么同时执行。
                var endTaskId        = "";                  //后续任务节点Id
                var endoperRule      = "";                  //新任务处理者策略
                var startoperRule    = "";                  //当前任务处理者策略
                var taskType         = "";                  //节点类型
                var endTaskTypeAndOr = "";                  //控制节点专用,表示and/or
                var operParam        = new OperParameter(); //创建处理者参数

                #region 配置了后续节点
                var l = dt.Rows.Count;
                var branchPriority = dt.Rows[0]["PRIORITY"].ToString();//优先级
                //遍历满足条件的所有任务节点
                for (var i = 0; i < l; i++)
                {
                    var dr = dt.Rows[i];
                    condition            = dr["CONDITION"].ToString();
                    priority             = dr["PRIORITY"].ToString();
                    endTaskId            = dr["ENDTASKID"].ToString();
                    endoperRule          = dr["ENDOPERRULE"].ToString();
                    startoperRule        = dr["STARTOPERRULE"].ToString();
                    taskType             = dr["ENDTASKTYPEID"].ToString();
                    endTaskTypeAndOr     = dr["ENDTASKTYPEANDOR"].ToString();
                    operParam.OperRule   = endoperRule;
                    operParam.IsJumpSelf = Convert.ToBoolean(dr["ISJUMPSELF"]);
                    if (priority != branchPriority)
                    {
                        break;                                                                                          //只执行优先级最高的分支
                    }
                    if (ExpressPass(userId, workFlowId, workTaskId, workFlowInstanceId, workTaskInstanceId, condition)) //满足条件的任务节点
                    {
                        switch (taskType)
                        {
                        case "2":    //结束节点
                        {
                            #region 结束节点
                            //产生一个结束节点的实例
                            var newEndTaskId   = BusinessLogic.NewGuid();      //新任务处理者实例Id
                            var endWorktaskIns = new WorkTaskInstanceEntity
                            {
                                WorkFlowId     = workFlowId,
                                WorkTaskId     = endTaskId,
                                WorkFlowInsId  = workFlowInstanceId,
                                WorkTaskInsId  = newEndTaskId,
                                PreviousTaskId = workTaskInstanceId,
                                TaskInsCaption = new WorkTaskManager(this.DBProvider, this.UserInfo).GetTaskCaption(endTaskId),
                                Status         = "2"//结束节点不需要再处理,但此处不能为3,设置结束实例会修改该值=3
                            };
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(endWorktaskIns);

                            //设置处理者实例正常结束
                            new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                            //设置任务实例正常结束
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, newEndTaskId);        //结束节点实例 结束
                            //设置流程实例正常结束
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetWorkflowInstanceOver(workFlowInstanceId);
                            //设定流程实例的当前位置
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.WorkflowOverMsg, workTaskInstanceId);        //结束节点单独处理,任务提交给谁了
                            //检查是否子流程调用
                            DataTable operInfo = new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).GetWorkflowInstance(workFlowInstanceId);
                            if (operInfo != null && operInfo.Rows.Count > 0)
                            {
                                var isSubWorkflow     = false;    //是否是子流程调用
                                var mainWorkflowInsId = "";
                                var mainWorktaskId    = "";
                                var mainWorkflowId    = "";
                                var mainWorktaskInsId = "";
                                isSubWorkflow     = BusinessLogic.ConvertIntToBoolean(operInfo.Rows[0][WorkFlowInstanceTable.FieldIsSubWorkflow]);
                                mainWorkflowInsId = operInfo.Rows[0][WorkFlowInstanceTable.FieldMainWorkflowInsId].ToString();  //主流程实例Id
                                mainWorktaskId    = operInfo.Rows[0][WorkFlowInstanceTable.FieldMainWorktaskId].ToString();     //子流程节点模板Id
                                mainWorkflowId    = operInfo.Rows[0][WorkFlowInstanceTable.FieldMainWorkflowId].ToString();     //主流程模板Id
                                mainWorktaskInsId = operInfo.Rows[0][WorkFlowInstanceTable.FieldMainWorktaskInsId].ToString();  //主任务实例Id,进入子节点前的任务节点实例
                                if (isSubWorkflow)
                                {
                                    //创建一个子流程节点实例痕迹,表示子流程节点处理完成
                                    var newTaskId        = BusinessLogic.NewGuid(); //新任务处理者实例Id
                                    var workTaskInstance = new WorkTaskInstanceEntity {
                                        WorkFlowId     = mainWorkflowId,
                                        WorkTaskId     = mainWorktaskId,
                                        WorkFlowInsId  = mainWorkflowInsId,
                                        WorkTaskInsId  = newTaskId,
                                        PreviousTaskId = mainWorktaskInsId,
                                        TaskInsCaption = "子流程",
                                        Status         = "3"
                                    };
                                    new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(workTaskInstance);
                                    var result = CreateNextTaskInstance(userId, mainWorkflowId, mainWorktaskId, mainWorkflowInsId, newTaskId, operatorInstanceId, "提交");
                                    if (result != WorkFlowConst.SuccessCode)
                                    {
                                        return(result);
                                    }
                                }
                            }
                            #endregion
                            break;
                        }

                        case "3":
                        {
                            #region 交互节点
                            switch (endoperRule)
                            {
                            case "1":
                            {
                                //创建一个任务实例
                                var newTaskId        = BusinessLogic.NewGuid();     //新任务处理者实例Id
                                var workTaskInstance = new WorkTaskInstanceEntity
                                {
                                    WorkFlowId     = workFlowId,
                                    WorkTaskId     = endTaskId,
                                    WorkFlowInsId  = workFlowInstanceId,
                                    WorkTaskInsId  = newTaskId,
                                    PreviousTaskId = workTaskInstanceId,
                                    TaskInsCaption = new WorkTaskManager(this.DBProvider, this.UserInfo).GetTaskCaption(endTaskId),
                                    Status         = "1"
                                };
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(workTaskInstance);
                                //创建多个处理人
                                var result = CreateOperInstance(userId, workTaskInstanceId, workTaskId, workFlowId, endTaskId, workFlowInstanceId, newTaskId, operParam);            //创建处理者实例
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            break;

                            case "2":
                            {
                                //创建任务实例和处理人
                                var result = CreateOperInstance(userId, workTaskInstanceId, workTaskId, workFlowId, endTaskId, workFlowInstanceId, workTaskInstanceId, operParam);
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            break;
                            }

                            //设置处理者实例正常结束
                            new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                            //设置任务实例正常结束
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                            //设定流程实例的当前位置
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                            //设定任务实例成功提交信息
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.SuccessMsg, workTaskInstanceId);
                            #endregion
                            break;
                        }

                        case "4":    //控制节点
                        {
                            #region 控制节点
                            //设置处理者实例正常结束
                            new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                            //设置任务实例正常结束
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                            //设定流程实例的当前位置
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                            //设定任务实例成功提交信息
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.SuccessMsg, workTaskInstanceId);
                            //******start检查判断节点前面的所以节点的任务实例是否都完成


                            //取控制节点前端所以节点,进行逐个判断
                            var dtstart = GetLineStartTasks(workFlowId, endTaskId);
                            var allPass = true;        //全部通过
                            foreach (DataRow dr1 in dtstart.Rows)
                            {
                                var taskId = dr1["STARTTASKID"].ToString();
                                if (endTaskTypeAndOr == WorkConst.Command_Or)                                  //or分支
                                {
                                    if (IsPassJudge(workFlowId, workFlowInstanceId, taskId, endTaskTypeAndOr)) //判断每个节点实例是否完成
                                    {
                                        allPass = true;
                                        break;        //如果有一个通过即可。
                                    }
                                    allPass = false;
                                }
                                else                                                                            //and分支
                                {
                                    if (!IsPassJudge(workFlowId, workFlowInstanceId, taskId, endTaskTypeAndOr)) //判断每个节点实例是否完成
                                    {
                                        allPass = false;
                                        break;        //如果有一个未完成的,不产生新的实例,流程等待。
                                    }
                                }
                            }

                            //********end检查判断节点前面的所以节点的任务实例结束

                            //如果判断节点前面的流程实例全部完成,自动进行递归,创建下一任务实例。
                            if (allPass)
                            {
                                //创建一个判断节点实例
                                var newTaskId        = BusinessLogic.NewGuid(); //新任务处理者实例Id
                                var workTaskInstance = new WorkTaskInstanceEntity
                                {
                                    WorkFlowId     = workFlowId,
                                    WorkTaskId     = endTaskId,
                                    WorkFlowInsId  = workFlowInstanceId,
                                    WorkTaskInsId  = newTaskId,
                                    PreviousTaskId = workTaskInstanceId,
                                    TaskInsCaption = endTaskTypeAndOr,
                                    Status         = "3"
                                };
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(workTaskInstance);
                                var result = CreateNextTaskInstance(userId, workFlowId, endTaskId, workFlowInstanceId, newTaskId, operatorInstanceId, "提交");
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            #endregion
                            break;
                        }

                        case "5":    //查看节点
                        {
                            #region 查看节点
                            switch (endoperRule)
                            {
                            case "1":
                            {
                                //创建一个任务实例
                                var newTaskId        = BusinessLogic.NewGuid();     //新任务处理者实例Id
                                var workTaskInstance = new WorkTaskInstanceEntity
                                {
                                    WorkFlowId     = workFlowId,
                                    WorkTaskId     = endTaskId,
                                    WorkFlowInsId  = workFlowInstanceId,
                                    WorkTaskInsId  = newTaskId,
                                    PreviousTaskId = workTaskInstanceId,
                                    TaskInsCaption = new WorkTaskManager(this.DBProvider, this.UserInfo).GetTaskCaption(endTaskId),
                                    Status         = "1"
                                };
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(workTaskInstance);

                                //创建多个处理人
                                var result = CreateOperInstance(userId, workTaskInstanceId, workTaskId, workFlowId, endTaskId, workFlowInstanceId, newTaskId, operParam);            //创建任务实例
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            break;

                            case "2":
                            {
                                //创建任务实例和处理人

                                var result = CreateOperInstance(userId, workTaskInstanceId, workTaskId, workFlowId, endTaskId, workFlowInstanceId, workTaskInstanceId, operParam);
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            break;
                            }
                            //设置处理者实例正常结束
                            new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                            //设置任务实例正常结束
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                            //设定流程实例的当前位置
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                            //设定任务实例成功提交信息
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.SuccessMsg, workTaskInstanceId);
                            #endregion
                            break;
                        }

                        case "6":    //子流程节点
                        {
                            #region 子流程节点
                            var subWf = new SubWorkFlowManager(this.DBProvider, this.UserInfo).GetSubWorkflowTable(workFlowId, endTaskId);
                            if (subWf != null && subWf.Rows.Count > 0)
                            {
                                var subWorkflowId      = subWf.Rows[0][SubWorkFlowTable.FieldSubWorkFlowId].ToString();
                                var subStartTaskId     = subWf.Rows[0][SubWorkFlowTable.FieldSubStartTaskId].ToString();
                                var subWorkflowCaption = subWf.Rows[0][SubWorkFlowTable.FieldSubWorkFlowCaption].ToString();
                                //*******进入子流程
                                var wfruntime = new WorkFlowRuntime
                                {
                                    UserId             = userId,
                                    WorkFlowId         = subWorkflowId,
                                    WorkTaskId         = subStartTaskId,
                                    WorkFlowInstanceId = BusinessLogic.NewGuid(),
                                    WorkTaskInstanceId = BusinessLogic.NewGuid(),
                                    IsSubWorkflow      = true,
                                    MainWorkflowId     = workFlowId,
                                    MainWorkflowInsId  = workFlowInstanceId,
                                    MainWorktaskId     = endTaskId,
                                    MainWorktaskInsId  = workTaskInstanceId,       //记录进入子流程之前的任务实例
                                    WorkFlowNo         = "subWorkflow",
                                    CommandName        = "提交",
                                    WorkflowInsCaption = subWorkflowCaption,
                                    IsDraft            = true//开始节点需要交互,草稿状态,暂不提交
                                };
                                wfruntime.Start();
                                //设置处理者实例正常结束
                                new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                                //设置任务实例正常结束
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                                //设定流程实例的当前位置
                                new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                                //设定任务实例成功提交信息
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.SuccessMsg, workTaskInstanceId);
                            }
                            #endregion
                            break;
                        }
                        }
                    }
                }
                #endregion
            }
            else
            {   //未配置后续节点
                return(WorkFlowConst.NoFoundTaskCode);
            }
            return(WorkFlowConst.SuccessCode);
        }