子流程节点
Inheritance: NodeBase
Esempio n. 1
0
 /// <summary>
 /// 创建子流程时,重新生成runner信息
 /// </summary>
 /// <param name="runner"></param>
 /// <param name="subProcessNode"></param>
 /// <returns></returns>
 private WfAppRunner CopyActivityForwardRunner(WfAppRunner runner, 
     Performer performer,
     SubProcessNode subProcessNode)
 {
     WfAppRunner subRunner = new WfAppRunner();
     subRunner.AppInstanceCode = runner.AppInstanceCode;
     subRunner.AppInstanceID = runner.AppInstanceID;
     subRunner.AppName = runner.AppName;
     subRunner.UserID = performer.UserID;
     subRunner.UserName = performer.UserName;
     subRunner.ProcessGUID = subProcessNode.SubProcessGUID;
     return subRunner;
 }
        public static WfRuntimeManager CreateRuntimeInstanceStartup(WfAppRunner runner,
            ProcessInstanceEntity parentProcessInstance,
            SubProcessNode subProcessNode,
            ref WfExecutedResult result)
        {
            //检查流程是否可以被启动
            var rmins = new WfRuntimeManagerStartup();
            rmins.WfExecutedResult = result = new WfExecutedResult();

            var pim = new ProcessInstanceManager();
            ProcessInstanceEntity processInstance = null;

            if (subProcessNode == null)
            {
                //正常流程启动
                processInstance = pim.GetProcessInstanceLatest(runner.AppName,
                    runner.AppInstanceID,
                    runner.ProcessGUID);
            }
            else
            {
                //子流程启动
                processInstance = pim.GetProcessInstanceLatest(runner.AppName,
                    runner.AppInstanceID,
                    subProcessNode.SubProcessGUID);
            }

            //不能同时启动多个主流程
            if (processInstance != null
                && processInstance.ParentProcessInstanceID == null
                && processInstance.ProcessState == (short)ProcessStateEnum.Running)
            {
                result.Status = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.Started_IsRunningAlready;
                result.Message = "流程已经处于运行状态,如果要重新启动,请先终止当前流程实例!";
                return rmins;
            }

            rmins.AppRunner = runner;
            rmins.ParentProcessInstance = parentProcessInstance;
            rmins.InvokedSubProcessNode = subProcessNode;

            //获取流程第一个可办理节点
            rmins.ProcessModel = new ProcessModel(runner.ProcessGUID);
            var firstActivity = rmins.ProcessModel.GetFirstActivity();

            rmins.AppRunner.NextActivityPerformers = ActivityResource.CreateNextActivityPerformers(firstActivity.ActivityGUID,
                runner.UserID,
                runner.UserName);

            rmins.ActivityResource = new ActivityResource(runner, rmins.AppRunner.NextActivityPerformers);

            return rmins;
        }
Esempio n. 3
0
        /// <summary>
        /// 把XML节点转换为ActivityEntity实体对象
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        internal ActivityEntity ConvertXmlActivityNodeToActivityEntity(XmlNode node)
        {
            ActivityEntity entity = new ActivityEntity();
            entity.ActivityName = XMLHelper.GetXmlAttribute(node, "name");
            entity.ActivityCode = XMLHelper.GetXmlAttribute(node, "code");
            entity.ActivityGUID = XMLHelper.GetXmlAttribute(node, "id");
            entity.ProcessGUID = ProcessEntity.ProcessGUID;

            //节点类型信息
            XmlNode typeNode = node.SelectSingleNode("ActivityType");
            entity.ActivityType = (ActivityTypeEnum)Enum.Parse(typeof(ActivityTypeEnum), XMLHelper.GetXmlAttribute(typeNode, "type"));
            entity.ActivityTypeDetail = ConvertXmlNodeToActivityTypeDetail(typeNode);

            if (entity.ActivityType == ActivityTypeEnum.SubProcessNode)
            {
                //子流程节点
                var subProcessNode = new SubProcessNode(entity);
                subProcessNode.SubProcessGUID = XMLHelper.GetXmlAttribute(typeNode, "subid");
                entity.Node = subProcessNode;
            }

            //任务完成类型信息
            XmlNode implementNode = node.SelectSingleNode("Implement");
            if (implementNode != null)
            {
                entity.TaskImplementDetail = new TaskImplementDetail();
                entity.TaskImplementDetail.ImplementationType = (ImplementationTypeEnum)Enum.Parse(typeof(ImplementationTypeEnum), XMLHelper.GetXmlAttribute(implementNode, "type"));

                //完成类型的详细信息
                XmlNode contentNode = implementNode.SelectSingleNode("Content");
                if (contentNode != null)
                {
                    entity.TaskImplementDetail.Assembly = XMLHelper.GetXmlAttribute(contentNode, "assembly");
                    entity.TaskImplementDetail.Interface = XMLHelper.GetXmlAttribute(contentNode, "interface");
                    entity.TaskImplementDetail.Method = XMLHelper.GetXmlAttribute(contentNode, "method");
                    entity.TaskImplementDetail.Content = contentNode.InnerText;
                }
            }

            //节点的Split Join 类型
            string gatewaySplitJoinType = XMLHelper.GetXmlAttribute(typeNode, "gatewaySplitJoinType");
            if (!string.IsNullOrEmpty(gatewaySplitJoinType))
            {
                entity.GatewaySplitJoinType = (GatewaySplitJoinTypeEnum)Enum.Parse(typeof(GatewaySplitJoinTypeEnum), gatewaySplitJoinType);
            }

            string gatewayDirection = XMLHelper.GetXmlAttribute(typeNode, "gatewayDirection");
            //节点的路由信息
            if (!string.IsNullOrEmpty(gatewayDirection))
            {
                entity.GatewayDirectionType = (GatewayDirectionEnum)Enum.Parse(typeof(GatewayDirectionEnum), gatewayDirection);
            }

            return entity;
        }