示例#1
0
        public void BookmakrResumption()
        {
            var process = this.Prepare();

            //启动流程
            this.Evict(process);
            var r1 = new ProcessStartResumption(process);

            this._resumptionService.Add(r1);
            this._scheduler.Resume(r1);
            Thread.Sleep(1000);

            //获取任务对应的书签名
            var bookmarkName = this._sessionManager
                               .OpenSession()
                               .CreateCriteria <WorkItemCreateResumption>()
                               .Add(Expression.Eq("Process", process))
                               .UniqueResult <WorkItemCreateResumption>().HumanActivityInstance.ReferredBookmarkName;

            _log.Info(bookmarkName);

            //恢复书签
            this.Evict(process);
            var persisted = this._processService.GetProcess(process.ID);
            var r2        = new BookmarkResumption(persisted, "节点", bookmarkName, "Agree");

            this._resumptionService.Add(r2);
            this._scheduler.Resume(r2);
            Thread.Sleep(3000);
            this.AssertExecutedResumption(r2);
        }
示例#2
0
        public void AnyValid()
        {
            var process = this.Prepare();

            this.ClearResumption();
            var r1 = new BookmarkResumption(process, "节点1", "bookmark", "result", DateTime.Now.AddMinutes(3));
            var r2 = new BookmarkResumption(process, "节点1", "bookmark", "result");

            r2.SetExecuted();
            this._resumptionService.Add(r1);
            this._resumptionService.Add(r2);
            //排除延迟的
            Assert.IsFalse(this._resumptionService.AnyValidAndUnExecutedAndNoErrorResumptionsExceptDelayAt(process, DateTime.Now.AddMinutes(2)));
            //排除指定
            Assert.IsFalse(this._resumptionService.AnyValidAndUnExecutedResumptions(process, r1));
            //延迟的也属于有效
            Assert.IsTrue(this._resumptionService.AnyValidAndUnExecutedResumptions(process, r2));
        }
示例#3
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);
        }