コード例 #1
0
        public override bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing,
                                          string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup,
                                          string nextExecRoleIDs, string nextExecOrgIDs, string execComment)
        {
            string tmplCode = Request["TmplCode"];
            var    formInfo = baseEntities.Set <S_UI_Form>().Where(c => c.Code == tmplCode).OrderByDescending(c => c.ID).FirstOrDefault(); //获取最新一个版本即可
            var    entity   = this.GetEntityByID <T>(taskExec.S_WF_InsFlow.FormInstanceID);
            bool   flag     = false;

            Workflow.Logic.BusinessFacade.FlowFO flowFO = new Workflow.Logic.BusinessFacade.FlowFO();
            flag = flowFO.ExecTask(taskExec.ID, routing.ID, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment, Request["RoutingID"]);
            //流程表单定义的流程逻辑
            ExecFlowLogic(routing.Code, taskExec.S_WF_InsFlow.FormInstanceID, "");
            SetFormFlowInfo(taskExec.S_WF_InsFlow);
            if (flag)
            {
                if (entity == null)
                {
                    throw new Formula.Exceptions.BusinessException("实体ID为空,未能找到相关实体对象,无法执行逻辑");
                }
                OnFlowEnd(entity, taskExec, routing);
            }
            this.BusinessEntities.SaveChanges();
            if (routing != null)
            {
                routing.ExeLogic();
                this.entities.SaveChanges();
            }
            return(flag);
        }
コード例 #2
0
ファイル: ProjectFormContorllor.cs プロジェクト: 15831944/EPC
        public override bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing,
                                          string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup,
                                          string nextExecRoleIDs, string nextExecOrgIDs, string execComment)
        {
            string tmplCode = Request["TmplCode"];
            var    formInfo = baseEntities.Set <S_UI_Form>().Where(c => c.Code == tmplCode).OrderByDescending(c => c.ID).FirstOrDefault(); //获取最新一个版本即可
            var    entity   = this.GetEntityByID <T>(taskExec.S_WF_InsFlow.FormInstanceID);
            bool   flag     = false;

            Workflow.Logic.BusinessFacade.FlowFO flowFO = new Workflow.Logic.BusinessFacade.FlowFO();
            flag = flowFO.ExecTask(taskExec.ID, routing.ID, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment, Request["RoutingID"]);
            //流程表单定义的流程逻辑
            ExecFlowLogic(routing.Code, taskExec.S_WF_InsFlow.FormInstanceID, "");
            this.AfterExeTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment);
            SetFormFlowInfo(taskExec.S_WF_InsFlow);

            var nextStep         = this.entities.Set <S_WF_InsDefStep>().SingleOrDefault(c => c.ID == routing.EndID);
            var allTaskUserIDs   = taskExec.S_WF_InsFlow.S_WF_InsTaskExec.Select(a => a.TaskUserID).Distinct().ToList();
            var allTaskUserNames = taskExec.S_WF_InsFlow.S_WF_InsTaskExec.Select(a => a.TaskUserName).Distinct().ToList();

            allTaskUserIDs.AddRange(nextExecUserIDs.Split(','));
            allTaskUserNames.AddRange(nextExecUserNames.Split(','));
            if (flag)
            {
                if (entity == null)
                {
                    throw new Formula.Exceptions.BusinessException("实体ID为空,未能找到相关实体对象,无法执行逻辑");
                }
                OnFlowEnd(entity, taskExec, routing);
                this.SendEndNotice(formInfo, entity, string.Join(",", allTaskUserIDs.Distinct()), string.Join(",", allTaskUserNames.Distinct()), nextStep.Name);
            }
            else if (taskExec.S_WF_InsTask.Type == StepTaskType.Inital.ToString())
            {
                if (formInfo == null)
                {
                    throw new Formula.Exceptions.BusinessException("编号为【" + tmplCode + "】的表单定义不存在");
                }
                if (entity == null)
                {
                    throw new Formula.Exceptions.BusinessException("实体ID为空,未能找到相关实体对象,无法执行逻辑");
                }
                this.SendStartNotice(formInfo, entity, string.Join(",", allTaskUserIDs.Distinct()), string.Join(",", allTaskUserNames.Distinct()), nextStep.Name);
            }
            else if (taskExec.S_WF_InsTask.Type == StepTaskType.Normal.ToString())
            {
                if (formInfo == null)
                {
                    throw new Formula.Exceptions.BusinessException("编号为【" + tmplCode + "】的表单定义不存在");
                }
                if (entity == null)
                {
                    throw new Formula.Exceptions.BusinessException("实体ID为空,未能找到相关实体对象,无法执行逻辑");
                }
                this.SendStepNotice(formInfo, entity, string.Join(",", allTaskUserIDs.Distinct()), string.Join(",", allTaskUserNames.Distinct()), nextStep.Name);
            }
            this.BusinessEntities.SaveChanges();
            //执行路由的流程逻辑(部分逻辑执行时需要前后上下文关系数据,故需要放在基类的流程逻辑中执行)
            if (routing != null)
            {
                routing.ExeLogic();
                this.entities.SaveChanges();
            }
            return(flag);
        }