Exemple #1
0
        public override void StartBuiness(Dtos.TransInfoDto transInfoDto)
        {
            if (transInfoDto.Activity == null)
            {
                throw new Exception("并发结束节点解析有误!");
            }

            var groupName = XmlHelper.GetSafeValue(transInfoDto.Activity, ActivityConst.GROUPNAME);

            // 生成记录节点
            var routingInfo        = transInfoDto.Persistence.CreateParallelRoutingInfo(transInfoDto.TaskId, transInfoDto.InstanceId, groupName);
            var startParalle       = XmlHelper.GetAllActivitiesByType(XElement.Parse(transInfoDto.TemplateXml), EnumExt.ActivityTypeEnum.Process).First(p => XmlHelper.GetSafeValue(p, ActivityConst.GROUPNAME) == groupName);
            var nextActivityCounts = XmlHelper.GetAllNextActivities(transInfoDto.TemplateXml, Guid.Parse(XmlHelper.GetSafeValue(startParalle, ActivityConst.ID)));

            if (nextActivityCounts != null)
            {
                if (routingInfo.GroupCounter == nextActivityCounts.Count())
                {
                    var copyInfo = transInfoDto.GetCopyInfo();
                    copyInfo.GroupName  = groupName;
                    routingInfo.Finshed = true;
                    End(copyInfo);
                }
            }

            base.StartBuiness(transInfoDto);
        }
Exemple #2
0
        public override void StartBuiness(Dtos.TransInfoDto transInfoDto)
        {
            var allParents = XmlHelper.GetAllForwardActivities(transInfoDto.TemplateXml, transInfoDto.InstanceNodeId);
            // 生成记录节点
            var routingInfo = transInfoDto.Persistence.CreateParallelRoutingInfo(transInfoDto.TaskId, transInfoDto.InstanceId, _groupStart + this.GroupName);

            if (routingInfo.GroupCounter == allParents.Count())
            {
                var copyInfo = transInfoDto.GetCopyInfo();
                copyInfo.GroupName  = _groupStart + copyInfo.GroupName;
                routingInfo.Finshed = true;

                End(copyInfo);
            }

            base.StartBuiness(transInfoDto);
        }
Exemple #3
0
        public override void EndBuiness(Dtos.TransInfoDto transInfoDto)
        {
            var copyDto = transInfoDto.GetCopyInfo();

            // 将当前的流程节点设置成end状态
            var currentActivity = copyDto.Persistence.GetActivity(transInfoDto.TaskId, copyDto.InstanceId, copyDto.InstanceNodeId);

            if (currentActivity != null)
            {
                copyDto.Persistence.FinishActivity(currentActivity);
            }

            var nextActivities = XmlHelper.GetAllNextActivities(copyDto.TemplateXml, copyDto.InstanceNodeId);

            // 启动新流程,记录到流程的ID,任务ID等信息
            if (nextActivities != null)
            {
                copyDto.NextActivities = nextActivities.ToList();
            }


            base.EndBuiness(copyDto);
        }
        public override void StartBuiness(Dtos.TransInfoDto transInfo)
        {
            // 启动新流程,记录到流程的ID,任务ID等信息
            IPersistence        p             = transInfo.Persistence;
            SubRoutingsBookmark submitRouting = JsonHelper.JsonToT <SubRoutingsBookmark>(XmlHelper.GetSafeValue(transInfo.Activity, ActivityConst.DETAILS));

            this.TemplateName = submitRouting.TemplateName;
            this.TemplateId   = submitRouting.TemplateId;
            this.Name         = submitRouting.Name;

            // 生成回归点
            NSNodeInfo nsNodeInfo = new NSNodeInfo();

            nsNodeInfo.Id         = Guid.NewGuid();
            nsNodeInfo.TaskId     = transInfo.TaskId;
            nsNodeInfo.InstanceId = transInfo.InstanceId;
            nsNodeInfo.NodeName   = this.Name;
            nsNodeInfo.ParentId   = transInfo.ParentId;
            nsNodeInfo.RunState   = EnumExt.RunStateConst.RUNNING;
            nsNodeInfo.CreateTime = DateTime.Now;
            nsNodeInfo.NodeId     = Guid.Parse(XmlHelper.GetSafeValue(transInfo.Activity, ActivityConst.ID));
            p.CreateActivity(nsNodeInfo);

            // 生成路由信息
            NSRoutingInfo nsRoutingInfo = new NSRoutingInfo();

            nsRoutingInfo.Id           = Guid.NewGuid();
            nsRoutingInfo.ParentId     = nsNodeInfo.Id;
            nsRoutingInfo.InstanceId   = Guid.NewGuid();
            nsRoutingInfo.TaskId       = transInfo.TaskId;
            nsRoutingInfo.GroupName    = ActivityConst.GROUPNAME_INSTANCE;
            nsRoutingInfo.GroupCounter = transInfo.GroupCounter;

            p.CreateRoutingInfo(nsRoutingInfo);

            for (int i = 0; i < transInfo.GroupCounter; i++)
            {
                // 流程实例信息
                NSInstanceInfo insanceInfo = new NSInstanceInfo();
                insanceInfo.InstanceName = submitRouting.TemplateName;
                insanceInfo.RunState     = EnumExt.RunStateConst.RUNNING;
                insanceInfo.StartTime    = DateTime.Now;
                insanceInfo.TemplateId   = this.TemplateId;
                insanceInfo.Id           = Guid.NewGuid();
                insanceInfo.TaskId       = transInfo.TaskId;
                insanceInfo.TemplateName = this.TemplateName;
                insanceInfo.ParentNodeId = nsNodeInfo.Id;
                p.CreateInstance(insanceInfo);


                TransInfoDto copyInfo = transInfo.GetCopyInfo();
                copyInfo.InstanceId  = insanceInfo.Id;
                copyInfo.TemplateXml = p.GetTemplateInfo(insanceInfo.TemplateId).TemplateText;
                // 生成子流程的第一个节点
                var startActivities = XmlHelper.GetTemplateFirstActivity(XElement.Parse(copyInfo.TemplateXml));
                if (startActivities != null)
                {
                    new RoutingHost().RoutingFactory(startActivities.ToList(), copyInfo);
                }
            }

            base.StartBuiness(transInfo);
        }