public static string Cooperation(WorkflowContext context, ExecutingContext executeContext) { string resultTo = String.Empty; Node current = context.Current; AbstractWorkflow workflowService = WorkflowGlobalServiceProvider.Resolve <AbstractWorkflow>(); IWorkflowCooperationService workflowCooperationService = workflowService.NodeService.WorkflowCooperationService; IStrategyService strategyService = (IStrategyService)Utils.CreateInstance(current.Assistant); string instanceID = context.Instance.InstanceID; workflowService.NodeService.WorkflowCooperationService.Persistent(new WorkflowCooperation { NodeID = current.NID, InstanceID = context.Instance.InstanceID, TransitionID = context.TransitionID, CreateTime = DateTime.Now }); IList <WorkflowCooperation> records = workflowCooperationService.Query(instanceID).Where(e => e.NodeID == current.NID).ToList(); executeContext.Result = strategyService.Check(records); if (executeContext.Result) { IWorkflowCooperationDecision workflowCooperationDecision = (IWorkflowCooperationDecision)Utils.CreateInstance(current.Cooperation); resultTo = workflowCooperationDecision.Execute(records); workflowService.NodeService.WorkflowCooperationService.Delete(instanceID, current.NID); } else { workflowService.Actions.ForEach(pluin => pluin.ActionExecute(executeContext)); } return(resultTo); }
protected void Discuss(WorkflowContext context, Node current, ExecutingContext executeContext, string actorID) { string instanceID = context.Instance.InstanceID; IWorkflowCooperationService workflowCooperationService = workflowService.NodeService.WorkflowCooperationService; IStrategyService strategyService = workflowService.StrategyService; workflowService.NodeService.WorkflowCooperationService.Persistent(new WorkflowCooperation { NID = Guid.NewGuid().ToString(), NodeID = current.NID, InstanceID = context.Instance.InstanceID, TransitionID = context.TransitionID, CreateDateTime = DateTime.Now }); IList <WorkflowCooperation> records = workflowCooperationService.Query(instanceID) .Where(e => e.NodeID == current.NID) .ToList(); executeContext.Result = strategyService.Check(records); if (executeContext.Result) { string to = strategyService.Use().Execute(records); Transition transition = current.Transitions.FirstOrDefault(e => e.NID == to); Node node = workflowService.NodeService.Query(current.InstanceID) .Where(e => e.ID == transition.Destination).FirstOrDefault(); this.Invoke(node, instanceID, transition, new ExecutingContext() { From = current, To = node, Instance = context.Instance, Data = context.Data, Result = executeContext.Result, Direction = executeContext.Direction }, actorID, context); } else { workflowService.Actions.ForEach(pluin => pluin.ActionExecute(executeContext)); } }