Beispiel #1
0
        public void SubProcessCompleteResumption()
        {
            #region 父子流程创建
            //父流程
            var parent = this.PrepareParentProcess();
            //将父流程设置到子流程节点
            TestHelper.UpdateCurrentNode(parent, SubProcessNodeIndex);
            //运行父子流程
            var start = new ProcessStartResumption(parent);
            this._resumptionService.Add(start);
            this._scheduler.Resume(start);
            Thread.Sleep(1000);
            //运行子流程创建调度
            var r_sub = this._resumptionService.GetValidWaitingResumptions(parent).First(o =>
                                                                                         o is SubProcessCreateResumption) as SubProcessCreateResumption;
            this._scheduler.Resume(r_sub);
            parent = this._processService.GetProcess(parent.ID);
            //获取子流程
            var subProcess = this._processService.GetProcess(r_sub.SubProcessActivityInstance.SubProcessId.Value);
            #endregion

            //创建子流程完成调度项
            TestHelper.ChangeProcessStatus(parent, ProcessStatus.Running);
            TestHelper.ChangeProcessStatus(subProcess, ProcessStatus.Completed);
            var r = new SubProcessCompleteResumption(parent, subProcess);
            this._resumptionService.Add(r);

            //执行子流程结束调度
            this._scheduler.Resume(r);
            //同时会恢复父流程书签
            Thread.Sleep(5000);
            this.AssertExecutedResumption(r);

            this.Evict(subProcess);
            this.Evict(parent);
            parent     = this._processService.GetProcess(parent.ID);
            subProcess = this._processService.GetProcess(subProcess.ID);
            //子流程应为完成状态
            Assert.AreEqual(ProcessStatus.Completed, subProcess.Status);
            //由于父流程在最后一个节点,也应为完成
            Assert.AreEqual(ProcessStatus.Completed, parent.Status);
        }
Beispiel #2
0
        public void Create()
        {
            var process    = this.Prepare();
            var subProcess = this.PrepareSubProcess(process);

            //流程发起调度
            WaitingResumption r = new ProcessStartResumption(process);

            this._resumptionService.Add(r);
            this.Evict(r);
            WaitingResumption r2 = this._resumptionService.Get(r.ID);

            Assert.IsNotNull(r2);
            Assert.IsInstanceOf <ProcessStartResumption>(r2);
            //书签恢复调度
            r = new BookmarkResumption(process, "节点1", "bookmark", "result");
            this._resumptionService.Add(r);
            this.Evict(r);
            r2 = this._resumptionService.Get(r.ID);
            Assert.IsNotNull(r2);
            Assert.IsInstanceOf <BookmarkResumption>(r2);
            //错误恢复调度
            r = new ErrorResumption(process, 0);
            this._resumptionService.Add(r);
            this.Evict(r);
            r2 = this._resumptionService.Get(r.ID);
            Assert.IsNotNull(r2);
            Assert.IsInstanceOf <ErrorResumption>(r2);
            //人工任务创建调度
            var h = new HumanActivityInstance(process.ID, 0, 1, "节点", "bookmark", new string[] { "houkun" });

            this._processService.CreateActivityInstance(h);
            r = new WorkItemCreateResumption(process, h);
            this._resumptionService.Add(r);
            this.Evict(r);
            r2 = this._resumptionService.Get(r.ID);
            Assert.IsNotNull(r2);
            Assert.IsInstanceOf <WorkItemCreateResumption>(r2);
            //流程完成调度
            TestHelper.ChangeProcessStatus(subProcess, ProcessStatus.Completed);
            r = new SubProcessCompleteResumption(process, subProcess);
            this._resumptionService.Add(r);
            this.Evict(r);
            r2 = this._resumptionService.Get(r.ID);
            Assert.IsNotNull(r2);
            Assert.IsInstanceOf <SubProcessCompleteResumption>(r2);
            //子流程启动调度
            var sub = new SubProcessActivityInstance(process.ID, 0, 1, "节点", "bookmark");

            this._processService.CreateActivityInstance(sub);
            r = new SubProcessCreateResumption(process, sub);
            this._resumptionService.Add(r);
            this.Evict(r);
            r2 = this._resumptionService.Get(r.ID);
            Assert.IsNotNull(r2);
            Assert.IsInstanceOf <SubProcessCreateResumption>(r2);
            //节点实例取消调度
            r = new ActivityInstanceCancelResumption(process, h);
            this._resumptionService.Add(r);
            this.Evict(r);
            r2 = this._resumptionService.Get(r.ID);
            Assert.IsNotNull(r2);
            Assert.IsInstanceOf <ActivityInstanceCancelResumption>(r2);
        }