public bool StartProcess(Guid processKey, string processInstanceName, string user) { bool result = false; if (string.IsNullOrWhiteSpace(processInstanceName)) { throw new BpmnVariableEmptyException("processInstanceName"); } BpmnProcess proc = procStore.FindById(processKey); if (proc == null) { throw new BpmnProcessNotFoundException(string.Format("Bpmn Process with key: '{0}' not found.", processKey.ToString())); } ProcessInstance pi = new ProcessInstance(); pi.ProcessKey = processKey; pi.ProcessInstanceName = processInstanceName; pi.Owner = user; //Add to history AddHistory(proc.Name, pi.ProcessInstanceName, "", string.Format("User: {0} Started Process '{1}'", user, proc.Name), user); ProcessItemDefinition[] startedItem = itemDefStore.GetStartEvent(processKey).ToArray(); if (startedItem != null) { foreach (var started in startedItem) { Guid[] nextItems = itemDefStore.GetSequenceFlow(started.Key).ToArray(); if (nextItems != null) { foreach (var item in nextItems) { ProcessItemDefinition def = itemDefStore.FindById(item); if (def != null && IsTask(def.ItemType)) { ProcessTask t = new ProcessTask(); t.ProcessKey = proc.Key; t.ProcessInstanceId = pi.ProcessInstanceId; t.ProcessItemDefinitionId = def.Key; t.ProcessTaskName = def.ItemName; taskStore.Create(t); //Add to history AddHistory(proc.Name, pi.ProcessInstanceName, t.ProcessTaskName, string.Format("User: {0} Created Task '{1}'", user, proc.Name), user); } } } } } return(result); }
public void DefineProcess(tProcess process, Guid definitionKey) { BpmnProcess procDef = new BpmnProcess(); procDef.DefinitionKey = definitionKey; procDef.Id = process.id; procDef.Name = process.name; procDef.IsExecutable = process.isExecutable; procDef.IsClosed = process.isClosed; processStore.Create(procDef); //SetProperty(process.property); Dictionary <string, Guid> ItemsKeys = new Dictionary <string, Guid>(); //Dictionary<Guid, ProcessItemDefinition> itemProcs = new Dictionary<Guid, ProcessItemDefinition>(); foreach (var item in process.Items.OfType <tFlowNode>()) { BpmnFlowNode node = new BpmnFlowNode(); node.Id = item.id; node.Name = item.name; node.ItemType = ProcessItem.GetProcessType(item); ItemsKeys.Add(item.id, node.Key); flowNodeStore.Create(node); } foreach (var flow in process.Items.OfType <tSequenceFlow>()) { BpmnSequenceFlow seqFlow = new BpmnSequenceFlow(); seqFlow.Id = flow.id; seqFlow.Name = flow.name; Guid ItemSourceRef; if (ItemsKeys.TryGetValue(flow.sourceRef, out ItemSourceRef)) { seqFlow.ItemSourceRef = ItemSourceRef; } Guid ItemTargetRef; if (ItemsKeys.TryGetValue(flow.targetRef, out ItemTargetRef)) { seqFlow.ItemSourceTarget = ItemTargetRef; } if (flow.conditionExpression != null) { seqFlow.ConditionExpression = string.Join(" ", flow.conditionExpression.Text); } sequenceFlowStore.Create(seqFlow); } }
public void LoadBpmn(string path) { Process = new BpmnProcess(TestFileLoader.Load(path)); }
public SimpleTaskTests(ITestOutputHelper output) { Output = output; process = new BpmnProcess(TestFileLoader.Load(@"Bpmn20/simple-task.bpmn")); }