public void SubProcessCreateResumption() { //父流程 var parent = this.PrepareParentProcess(); //创建子流程类型 this.CreateProcessType(SubProcessTypeName); //创建子流程节点实例 var sub = new SubProcessActivityInstance(parent.ID, SubProcessNodeIndex, 1, SubProcessNode, "bookmark"); this._processService.CreateActivityInstance(sub); //子流程创建调度 var r = new SubProcessCreateResumption(parent, sub); this._resumptionService.Add(r); this._scheduler.Resume(r); this.AssertExecutedResumption(r); Assert.IsTrue(sub.SubProcessId.HasValue); this.EvictAll(); //发起的子流程 var subProcess = this._processService.GetProcess(sub.SubProcessId.Value); Assert.AreEqual(parent.ID, subProcess.ParentProcessId.Value); Assert.AreEqual(SubProcessTypeName, subProcess.ProcessType.Name); }
private void Init(SubProcessActivityInstance subProcessActivityInstance) { this.SubProcessActivityInstance = subProcessActivityInstance; if (this.SubProcessActivityInstance == null) throw new InvalidOperationException("SubProcessActivityInstance不能为空"); }
private void Init(SubProcessActivityInstance subProcessActivityInstance) { this.SubProcessActivityInstance = subProcessActivityInstance; if (this.SubProcessActivityInstance == null) { throw new InvalidOperationException("SubProcessActivityInstance不能为空"); } }
public void SubProcess() { var instance = new SubProcessActivityInstance(Guid.NewGuid(), 0, 1, "人工节点", "bookmark"); this._processService.CreateActivityInstance(instance); Assert.AreNotEqual(0, instance.ID); this.Evict(instance); var instance2 = this._processService.GetActivityInstance(instance.ID); Assert.IsNotNull(instance2); Assert.IsInstanceOf<SubProcessActivityInstance>(instance2); }
public void GetSubProcessActivityInstances() { var process1 = this.CreateProcess(); var process2 = this.CreateProcess(); var instance = new SubProcessActivityInstance(process1.ID, 0, 1, "人工节点", "bookmark", process2.ID); this._processService.CreateActivityInstance(instance); var instance2 = this._processService.GetSubProcessActivityInstances(process1, process2); Assert.IsNotNull(instance2); Assert.AreEqual(instance.ID, instance2.ID); }
public void SubProcess() { var instance = new SubProcessActivityInstance(Guid.NewGuid(), 0, 1, "人工节点", "bookmark"); this._processService.CreateActivityInstance(instance); Assert.AreNotEqual(0, instance.ID); this.Evict(instance); var instance2 = this._processService.GetActivityInstance(instance.ID); Assert.IsNotNull(instance2); Assert.IsInstanceOf <SubProcessActivityInstance>(instance2); }
void IWaitingResumptionHandle.Resume(WaitingResumption waitingResumption) { var r = waitingResumption as SubProcessCompleteResumption; var subProcess = r.SubProcess; var parentProcess = r.Process; //尝试从父流程中获取启动该子流程的节点实例信息 SubProcessActivityInstance sub = this._processService.GetSubProcessActivityInstances(parentProcess, subProcess); if (sub == null) { throw new InvalidOperationException(string.Format("没有在父流程“{0}”#{1}中找到启动子流程“{2}”#{3}的子流程节点实例" , parentProcess.Title , parentProcess.ID , subProcess.Title , subProcess.ID)); } //将子流程的流程变量传递给父流程 var dict = subProcess.GetDataFields(); foreach (string key in dict.Keys) { parentProcess.UpdateDataField(key, dict[key]); } //唤醒父流程 var persisted = this._processService.GetWorkflowInstance(parentProcess).WorkflowInstance; var instance = WorkflowBuilder.CreateInstance(parentProcess, this._parser); instance.Load(persisted); instance.Update(parentProcess.GetInputs()); instance.ResumeBookmark(sub.ReferredBookmarkName, null); //目前不允许在调度项中生成新的非延迟调度项,无法保证预期顺序,需要有类似核心的quack机制 ////创建父流程唤醒调度项 //this._resumption.Add(new BookmarkResumption(parentProcess // , sub.ActivityName // , sub.ReferredBookmarkName // , string.Empty)); //将子流程节点置为完成 sub.SetAsComplete(); this._processService.UpdateActivityInstance(sub); }
/// <summary> /// 初始化子流程待创建请求记录 /// </summary> /// <param name="process"></param> /// <param name="subProcessActivityInstance"></param> public SubProcessCreateResumption(Process process, SubProcessActivityInstance subProcessActivityInstance) : base(process, WaitingResumption.MaxPriority) { this.Init(subProcessActivityInstance); }
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); }