/// <summary>
 /// Default behaviour: just leave the activity with no extra functionality.
 /// </summary>
 public virtual void Execute(IExecutionEntity execution)
 {
     Leave(execution);
 }
Exemplo n.º 2
0
        public override void Execute(IExecutionEntity execution)
        {
            ICommandContext    commandContext    = Context.CommandContext;
            ITaskEntityManager taskEntityManager = commandContext.TaskEntityManager;

            ITaskEntity task = taskEntityManager.Create();

            task.Execution         = execution;
            task.TaskDefinitionKey = userTask.Id;
            task.IsRuntimeAssignee();

            task.CanTransfer  = userTask.CanTransfer;
            task.OnlyAssignee = task.OnlyAssignee;

            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;
            ExpressionManager expressionManager = processEngineConfiguration.ExpressionManager;


            string         activeTaskName;
            string         activeTaskDescription;
            string         activeTaskDueDate;
            string         activeTaskCategory;
            string         activeTaskSkipExpression;
            string         activeTaskPriority;
            string         activeTaskFormKey;
            string         activeTaskAssignee;
            string         activeTaskOwner;
            IList <string> activeTaskCandidateUsers;
            IList <string> activeTaskCandidateGroups;

            if (Context.ProcessEngineConfiguration.EnableProcessDefinitionInfoCache)
            {
                JToken taskElementProperties = Context.GetBpmnOverrideElementProperties(userTask.Id, execution.ProcessDefinitionId);
                activeTaskName            = GetActiveValue(userTask.Name, DynamicBpmnConstants.USER_TASK_NAME, taskElementProperties);
                activeTaskDescription     = GetActiveValue(userTask.Documentation, DynamicBpmnConstants.USER_TASK_DESCRIPTION, taskElementProperties);
                activeTaskDueDate         = GetActiveValue(userTask.DueDate, DynamicBpmnConstants.USER_TASK_DUEDATE, taskElementProperties);
                activeTaskPriority        = GetActiveValue(userTask.Priority, DynamicBpmnConstants.USER_TASK_PRIORITY, taskElementProperties);
                activeTaskCategory        = GetActiveValue(userTask.Category, DynamicBpmnConstants.USER_TASK_CATEGORY, taskElementProperties);
                activeTaskFormKey         = GetActiveValue(userTask.FormKey, DynamicBpmnConstants.USER_TASK_FORM_KEY, taskElementProperties);
                activeTaskSkipExpression  = GetActiveValue(userTask.SkipExpression, DynamicBpmnConstants.TASK_SKIP_EXPRESSION, taskElementProperties);
                activeTaskAssignee        = GetActiveValue(userTask.Assignee, DynamicBpmnConstants.USER_TASK_ASSIGNEE, taskElementProperties);
                activeTaskOwner           = GetActiveValue(userTask.Owner, DynamicBpmnConstants.USER_TASK_OWNER, taskElementProperties);
                activeTaskCandidateUsers  = GetActiveValueList(userTask.CandidateUsers, DynamicBpmnConstants.USER_TASK_CANDIDATE_USERS, taskElementProperties);
                activeTaskCandidateGroups = GetActiveValueList(userTask.CandidateGroups, DynamicBpmnConstants.USER_TASK_CANDIDATE_GROUPS, taskElementProperties);
            }
            else
            {
                activeTaskName            = userTask.Name;
                activeTaskDescription     = userTask.Documentation;
                activeTaskDueDate         = userTask.DueDate;
                activeTaskPriority        = userTask.Priority;
                activeTaskCategory        = userTask.Category;
                activeTaskFormKey         = userTask.FormKey;
                activeTaskSkipExpression  = userTask.SkipExpression;
                activeTaskAssignee        = userTask.Assignee;
                activeTaskOwner           = userTask.Owner;
                activeTaskCandidateUsers  = userTask.CandidateUsers;
                activeTaskCandidateGroups = userTask.CandidateGroups;
            }

            if (!string.IsNullOrWhiteSpace(activeTaskName))
            {
                string name;
                try
                {
                    name = (string)expressionManager.CreateExpression(activeTaskName).GetValue(execution);
                }
                catch (ActivitiException e)
                {
                    name = activeTaskName;
                    log.LogWarning("property not found in task name expression " + e.Message);
                }
                task.Name = name;
            }

            if (!string.IsNullOrWhiteSpace(activeTaskDescription))
            {
                string description;
                try
                {
                    description = (string)expressionManager.CreateExpression(activeTaskDescription).GetValue(execution);
                }
                catch (ActivitiException e)
                {
                    description = activeTaskDescription;
                    log.LogWarning("property not found in task description expression " + e.Message);
                }
                task.Description = description;
            }

            if (!string.IsNullOrWhiteSpace(activeTaskDueDate))
            {
                object dueDate = expressionManager.CreateExpression(activeTaskDueDate).GetValue(execution);
                if (dueDate != null)
                {
                    if (dueDate is DateTime)
                    {
                        task.DueDate = (DateTime)dueDate;
                    }
                    else if (dueDate is string)
                    {
                        string businessCalendarName;
                        if (!string.IsNullOrWhiteSpace(userTask.BusinessCalendarName))
                        {
                            businessCalendarName = expressionManager.CreateExpression(userTask.BusinessCalendarName).GetValue(execution).ToString();
                        }
                        else
                        {
                            businessCalendarName = DueDateBusinessCalendar.NAME;
                        }

                        IBusinessCalendar businessCalendar = Context.ProcessEngineConfiguration.BusinessCalendarManager.GetBusinessCalendar(businessCalendarName);
                        task.DueDate = businessCalendar.ResolveDuedate((string)dueDate);
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("Due date expression does not resolve to a Date or Date string: " + activeTaskDueDate);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(activeTaskPriority))
            {
                object priority = expressionManager.CreateExpression(activeTaskPriority).GetValue(execution);
                if (priority != null)
                {
                    if (priority is string)
                    {
                        try
                        {
                            task.Priority = Convert.ToInt32((string)priority);
                        }
                        catch (FormatException e)
                        {
                            throw new ActivitiIllegalArgumentException("Priority does not resolve to a number: " + priority, e);
                        }
                    }
                    else if (priority is int || priority is long)
                    {
                        task.Priority = ((int)priority);
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("Priority expression does not resolve to a number: " + activeTaskPriority);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(activeTaskCategory))
            {
                object category = expressionManager.CreateExpression(activeTaskCategory).GetValue(execution);
                if (category != null)
                {
                    if (category is string)
                    {
                        task.Category = category.ToString();
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("Category expression does not resolve to a string: " + activeTaskCategory);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(activeTaskFormKey))
            {
                object formKey = expressionManager.CreateExpression(activeTaskFormKey).GetValue(execution);
                if (formKey != null)
                {
                    if (formKey is string)
                    {
                        task.FormKey = formKey.ToString();
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("FormKey expression does not resolve to a string: " + activeTaskFormKey);
                    }
                }
            }

            taskEntityManager.Insert(task, execution);

            bool skipUserTask = false;

            if (!string.IsNullOrWhiteSpace(activeTaskSkipExpression))
            {
                IExpression skipExpression = expressionManager.CreateExpression(activeTaskSkipExpression);
                skipUserTask = SkipExpressionUtil.IsSkipExpressionEnabled(execution, skipExpression) && SkipExpressionUtil.ShouldSkipFlowElement(execution, skipExpression);
            }

            // Handling assignments need to be done after the task is inserted, to have an id
            if (!skipUserTask)
            {
                HandleAssignments(taskEntityManager, activeTaskAssignee, activeTaskOwner, activeTaskCandidateUsers, activeTaskCandidateGroups, task, expressionManager, execution);
            }

            processEngineConfiguration.ListenerNotificationHelper.ExecuteTaskListeners(task, BaseTaskListenerFields.EVENTNAME_CREATE);

            // All properties set, now fire events
            if (Context.ProcessEngineConfiguration.EventDispatcher.Enabled)
            {
                IActivitiEventDispatcher eventDispatcher = Context.ProcessEngineConfiguration.EventDispatcher;
                eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.TASK_CREATED, task));
                if (task.Assignee is object)
                {
                    eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.TASK_ASSIGNED, task));
                }
            }

            if (skipUserTask)
            {
                taskEntityManager.DeleteTask(task, null, false, false);
                Leave(execution);
            }
        }
 public override void Trigger(IExecutionEntity execution, string signalName, object signalData, bool throwError = true)
 {
     LeaveIntermediateCatchEvent(execution);
 }
Exemplo n.º 4
0
        protected internal virtual IHistoricActivityInstanceEntity CreateHistoricActivityInstanceEntity(IExecutionEntity execution)
        {
            IIdGenerator idGenerator = ProcessEngineConfiguration.IdGenerator;

            string processDefinitionId = execution.ProcessDefinitionId;
            string processInstanceId   = execution.ProcessInstanceId;

            IHistoricActivityInstanceEntity historicActivityInstance = HistoricActivityInstanceEntityManager.Create();

            historicActivityInstance.Id = idGenerator.GetNextId();
            historicActivityInstance.ProcessDefinitionId = processDefinitionId;
            historicActivityInstance.ProcessInstanceId   = processInstanceId;
            historicActivityInstance.ExecutionId         = execution.Id;
            historicActivityInstance.ActivityId          = execution.ActivityId;
            if (execution.CurrentFlowElement != null)
            {
                historicActivityInstance.ActivityName = execution.CurrentFlowElement.Name;
                historicActivityInstance.ActivityType = ParseActivityType(execution.CurrentFlowElement);
            }
            DateTime now = Clock.CurrentTime;

            historicActivityInstance.StartTime = now;

            // Inherit tenant id (if applicable)
            if (execution.TenantId is object)
            {
                historicActivityInstance.TenantId = execution.TenantId;
            }

            HistoricActivityInstanceEntityManager.Insert(historicActivityInstance);
            return(historicActivityInstance);
        }
        public override void Execute(IExecutionEntity execution)
        {
            try
            {
                bool isSkipExpressionEnabled = SkipExpressionUtil.IsSkipExpressionEnabled(execution, skipExpression);
                if (!isSkipExpressionEnabled || (isSkipExpressionEnabled && !SkipExpressionUtil.ShouldSkipFlowElement(execution, skipExpression)))
                {
                    if (Context.ProcessEngineConfiguration.EnableProcessDefinitionInfoCache)
                    {
                        JToken taskElementProperties = Context.GetBpmnOverrideElementProperties(serviceTaskId, execution.ProcessDefinitionId);
                        if (taskElementProperties != null && taskElementProperties[DynamicBpmnConstants.SERVICE_TASK_EXPRESSION] != null)
                        {
                            string overrideExpression = taskElementProperties[DynamicBpmnConstants.SERVICE_TASK_EXPRESSION].ToString();
                            if (!string.IsNullOrWhiteSpace(overrideExpression) && !overrideExpression.Equals(expression.ExpressionText))
                            {
                                expression = Context.ProcessEngineConfiguration.ExpressionManager.CreateExpression(overrideExpression);
                            }
                        }
                    }

                    object value = expression.GetValue(execution);
                    if (resultVariable is object)
                    {
                        execution.SetVariable(resultVariable, value);
                    }
                }

                Leave(execution);
            }
            catch (Exception exc)
            {
                Exception cause = exc;
                BpmnError error = null;
                while (cause != null)
                {
                    if (cause is BpmnError)
                    {
                        error = (BpmnError)cause;
                        break;
                    }
                    cause = cause.InnerException;
                }

                if (error != null)
                {
                    ErrorPropagation.PropagateError(error, execution);
                }
                else
                {
                    string errorCode = execution.CurrentFlowElement.GetExtensionElementAttributeValue("errorCode");
                    if (string.IsNullOrWhiteSpace(errorCode) == false)
                    {
                        error = new BpmnError(errorCode, exc.Message);
                        ErrorPropagation.PropagateError(error, execution);
                    }
                    else
                    {
                        throw new ActivitiException("Could not execute service task expression", exc);
                    }
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Called when the wrapped <seealso cref="ActivityBehavior"/> calls the <seealso cref="AbstractBpmnActivityBehavior#leave(ActivityExecution)"/> method. Handles the completion of one of the parallel instances
 /// </summary>
 public override void Leave(IExecutionEntity execution)
 {
     Leave(execution, null);
 }
Exemplo n.º 7
0
        // private static Logger log = LoggerFactory.getLogger(typeof(ExclusiveGatewayActivityBehavior));

        /// <summary>
        /// The default behaviour of BPMN, taking every outgoing sequence flow (where the condition evaluates to true), is not valid for an exclusive gateway.
        ///
        /// Hence, this behaviour is overridden and replaced by the correct behavior: selecting the first sequence flow which condition evaluates to true (or which hasn't got a condition) and leaving the
        /// activity through that sequence flow.
        ///
        /// If no sequence flow is selected (ie all conditions evaluate to false), then the default sequence flow is taken (if defined).
        /// </summary>
        public override void Leave(IExecutionEntity execution)
        {
            if (log.IsEnabled(LogLevel.Debug))
            {
                log.LogDebug($"Leaving exclusive gateway '{execution.CurrentActivityId}'");
            }

            ExclusiveGateway exclusiveGateway = (ExclusiveGateway)execution.CurrentFlowElement;

            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;

            if (!(processEngineConfiguration is null) && processEngineConfiguration.EventDispatcher.Enabled)
            {
                processEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateActivityEvent(ActivitiEventType.ACTIVITY_COMPLETED, exclusiveGateway.Id, exclusiveGateway.Name, execution.Id, execution.ProcessInstanceId, execution.ProcessDefinitionId, exclusiveGateway));
            }

            SequenceFlow outgoingSequenceFlow  = null;
            SequenceFlow defaultSequenceFlow   = null;
            string       defaultSequenceFlowId = exclusiveGateway.DefaultFlow;

            // Determine sequence flow to take
            foreach (SequenceFlow sequenceFlow in exclusiveGateway.OutgoingFlows)
            {
                string skipExpressionString = sequenceFlow.SkipExpression;
                if (!SkipExpressionUtil.IsSkipExpressionEnabled(execution, skipExpressionString))
                {
                    bool conditionEvaluatesToTrue = ConditionUtil.HasTrueCondition(sequenceFlow, execution);
                    if (conditionEvaluatesToTrue && (defaultSequenceFlowId is null || !defaultSequenceFlowId.Equals(sequenceFlow.Id)))
                    {
                        if (log.IsEnabled(LogLevel.Debug))
                        {
                            log.LogDebug($"Sequence flow '{sequenceFlow.Id}'selected as outgoing sequence flow.");
                        }
                        outgoingSequenceFlow = sequenceFlow;
                        break;
                    }
                }
                else if (SkipExpressionUtil.ShouldSkipFlowElement(Context.CommandContext, execution, skipExpressionString))
                {
                    outgoingSequenceFlow = sequenceFlow;
                    break;
                }

                // Already store it, if we would need it later. Saves one for loop.
                if (!(defaultSequenceFlowId is null) && defaultSequenceFlowId.Equals(sequenceFlow.Id))
                {
                    defaultSequenceFlow = sequenceFlow;
                }
            }

            // We have to record the end here, or else we're already past it
            Context.CommandContext.HistoryManager.RecordActivityEnd(execution, null);

            // Leave the gateway
            if (outgoingSequenceFlow != null)
            {
                execution.CurrentFlowElement = outgoingSequenceFlow;
            }
            else
            {
                if (defaultSequenceFlow != null)
                {
                    execution.CurrentFlowElement = defaultSequenceFlow;
                }
                else
                {
                    // No sequence flow could be found, not even a default one
                    throw new ActivitiException("No outgoing sequence flow of the exclusive gateway '" + exclusiveGateway.Id + "' could be selected for continuing the process");
                }
            }

            base.Leave(execution);
        }
Exemplo n.º 8
0
 public static IDictionary <string, IList <ExtensionElement> > GetFlowElementExtensionElements(IExecutionEntity execution)
 {
     return(GetFlowElement(execution).ExtensionElements);
 }
Exemplo n.º 9
0
 public static IDictionary <string, IList <ExtensionElement> > GetListenerExtensionElements(IExecutionEntity execution)
 {
     return(execution.CurrentActivitiListener.ExtensionElements);
 }
 public virtual void Trigger(IExecutionEntity execution, string signalName, object signalData, bool throwError = true)
 {
     // concrete activity behaviours that do accept signals should override this method;
     throw new ActivitiException("this activity isn't waiting for a trigger");
 }
Exemplo n.º 11
0
 /// <summary>
 /// Returns for the activityId of the passed <seealso cref="IDelegateExecution"/> the
 /// <seealso cref="Map"/> of <seealso cref="ExtensionElement"/> instances. These represent the
 /// extension elements defined in the BPMN 2.0 XML as part of that particular
 /// activity.
 /// <para>
 /// If the execution is currently being used for executing an
 /// <seealso cref="IExecutionListener"/>, the extension elements of the listener will be
 /// used. Use the <seealso cref="#getFlowElementExtensionElements(DelegateExecution)"/>
 /// or <seealso cref="#getListenerExtensionElements(DelegateExecution)"/> instead to
 /// specifically get the extension elements of either the flow element or the
 /// listener.
 /// </para>
 /// </summary>
 public static IDictionary <string, IList <ExtensionElement> > GetExtensionElements(IExecutionEntity execution)
 {
     if (IsExecutingExecutionListener(execution))
     {
         return(GetListenerExtensionElements(execution));
     }
     else
     {
         return(GetFlowElementExtensionElements(execution));
     }
 }
 public virtual void LeaveIgnoreConditions(IExecutionEntity execution)
 {
     bpmnActivityBehavior.PerformIgnoreConditionsOutgoingBehavior(execution);
 }
 public virtual void Leave(IExecutionEntity execution, object signalData)
 {
     bpmnActivityBehavior.PerformDefaultOutgoingBehavior(execution);
 }
 /// <summary>
 /// Default way of leaving a BPMN 2.0 activity: evaluate the conditions on the outgoing sequence flow and take those that evaluate to true.
 /// </summary>
 public virtual void Leave(IExecutionEntity execution)
 {
     Leave(execution, null);
 }
Exemplo n.º 15
0
 public override void Execute(IExecutionEntity execution)
 {
     base.Execute(execution);
 }
Exemplo n.º 16
0
 public static IList <FieldExtension> GetListenerFields(IExecutionEntity execution)
 {
     return(execution.CurrentActivitiListener.FieldExtensions);
 }
Exemplo n.º 17
0
 public override void LastExecutionEnded(IExecutionEntity execution)
 {
     base.LastExecutionEnded(execution);
 }
Exemplo n.º 18
0
 /// <summary>
 /// To be used in an <seealso cref="ActivityBehavior"/> or <seealso cref="ICSharpDelegate"/>: leaves
 /// according to the default BPMN 2.0 rules: all sequenceflow with a condition
 /// that evaluates to true are followed.
 /// </summary>
 public static void LeaveDelegate(IExecutionEntity delegateExecution)
 {
     Context.Agenda.PlanTakeOutgoingSequenceFlowsOperation(delegateExecution, true);
 }
Exemplo n.º 19
0
 public override void Leave(IExecutionEntity execution, object signalData)
 {
     base.Leave(execution, signalData);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Returns whether or not the provided execution is being use for executing an <seealso cref="IExecutionListener"/>.
 /// </summary>
 public static bool IsExecutingExecutionListener(IExecutionEntity execution)
 {
     return(execution.CurrentActivitiListener != null);
 }
Exemplo n.º 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parentExecution"></param>
        /// <param name="subProcessInstance"></param>
        /// <param name="initialElement"></param>
        public virtual void RecordSubProcessInstanceStart(IExecutionEntity parentExecution, IExecutionEntity subProcessInstance, FlowElement initialElement)
        {
            if (IsHistoryLevelAtLeast(HistoryLevel.ACTIVITY))
            {
                IHistoricProcessInstanceEntity historicProcessInstance = HistoricProcessInstanceEntityManager.Create(subProcessInstance);

                // Fix for ACT-1728: startActivityId not initialized with subprocess instance
                if (historicProcessInstance.StartActivityId is null)
                {
                    historicProcessInstance.StartActivityId = initialElement.Id;
                }
                HistoricProcessInstanceEntityManager.Insert(historicProcessInstance, false);

                // Fire event
                IActivitiEventDispatcher activitiEventDispatcher = EventDispatcher;
                if (activitiEventDispatcher != null && activitiEventDispatcher.Enabled)
                {
                    activitiEventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance));
                }

                IHistoricActivityInstanceEntity activitiyInstance = FindActivityInstance(parentExecution, false, true);
                if (activitiyInstance != null)
                {
                    activitiyInstance.CalledProcessInstanceId = subProcessInstance.ProcessInstanceId;
                }
            }
        }
Exemplo n.º 22
0
 public override void Completed(IExecutionEntity execution)
 {
     base.Completed(execution);
 }
Exemplo n.º 23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="variable"></param>
        /// <param name="sourceActivityExecution"></param>
        /// <param name="useActivityId"></param>
        public virtual void RecordHistoricDetailVariableCreate(IVariableInstanceEntity variable, IExecutionEntity sourceActivityExecution, bool useActivityId)
        {
            if (IsHistoryLevelAtLeast(HistoryLevel.FULL))
            {
                IHistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = HistoricDetailEntityManager.CopyAndInsertHistoricDetailVariableInstanceUpdateEntity(variable);

                if (useActivityId && sourceActivityExecution != null)
                {
                    IHistoricActivityInstanceEntity historicActivityInstance = FindActivityInstance(sourceActivityExecution, false, false);
                    if (historicActivityInstance != null)
                    {
                        historicVariableUpdate.ActivityInstanceId = historicActivityInstance.Id;
                    }
                }
            }
        }
Exemplo n.º 24
0
 public override void Completing(IExecutionEntity execution, IExecutionEntity subProcessInstance)
 {
     base.Completing(execution, subProcessInstance);
 }
Exemplo n.º 25
0
        protected internal virtual void HandleAssignments(ITaskEntityManager taskEntityManager, string assignee, string owner, IList <string> candidateUsers, IList <string> candidateGroups, ITaskEntity task, ExpressionManager expressionManager, IExecutionEntity execution)
        {
            if (!string.IsNullOrWhiteSpace(assignee))
            {
                object assigneeExpressionValue = expressionManager.CreateExpression(assignee).GetValue(execution);
                string assigneeValue           = null;
                if (assigneeExpressionValue != null)
                {
                    assigneeValue = assigneeExpressionValue.ToString();
                }
                string assigneeUser = null;
                //TODO: 考虑性能问题,暂时不获取人员
                //if (string.IsNullOrWhiteSpace(assigneeValue) == false)
                //{
                //    assigneeUser = AsyncHelper.RunSync(() => userService.GetUser(assigneeValue))?.FullName;
                //}
                taskEntityManager.ChangeTaskAssigneeNoEvents(task, assigneeValue, assigneeUser);
            }

            if (!string.IsNullOrWhiteSpace(owner))
            {
                object ownerExpressionValue = expressionManager.CreateExpression(owner).GetValue(execution);
                string ownerValue           = null;
                if (ownerExpressionValue != null)
                {
                    ownerValue = ownerExpressionValue.ToString();
                }

                taskEntityManager.ChangeTaskOwner(task, ownerValue);
            }

            if (candidateGroups != null && candidateGroups.Count > 0)
            {
                foreach (string candidateGroup in candidateGroups)
                {
                    IExpression groupIdExpr = expressionManager.CreateExpression(candidateGroup);
                    object      value       = groupIdExpr.GetValue(execution);
                    if (value is string)
                    {
                        IList <string> candidates = ExtractCandidates((string)value);
                        task.AddCandidateGroups(candidates);
                    }
                    else if (value is ICollection)
                    {
                        task.AddCandidateGroups((ICollection <string>)value);
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("Expression did not resolve to a string or collection of strings");
                    }
                }
            }

            if (candidateUsers != null && candidateUsers.Count > 0)
            {
                foreach (string candidateUser in candidateUsers)
                {
                    IExpression userIdExpr = expressionManager.CreateExpression(candidateUser);
                    object      value      = userIdExpr.GetValue(execution);
                    if (value is string)
                    {
                        IList <string> candidates = ExtractCandidates((string)value);
                        task.AddCandidateUsers(candidates);
                    }
                    else if (value is ICollection)
                    {
                        task.AddCandidateUsers((ICollection <string>)value);
                    }
                    else
                    {
                        throw new ActivitiException("Expression did not resolve to a string or collection of strings");
                    }
                }
            }

            if (userTask.CustomUserIdentityLinks != null && userTask.CustomUserIdentityLinks.Count > 0)
            {
                foreach (string customUserIdentityLinkType in userTask.CustomUserIdentityLinks.Keys)
                {
                    foreach (string userIdentityLink in userTask.CustomUserIdentityLinks[customUserIdentityLinkType])
                    {
                        IExpression idExpression = expressionManager.CreateExpression(userIdentityLink);
                        object      value        = idExpression.GetValue(execution);
                        if (value is string)
                        {
                            IList <string> userIds = ExtractCandidates((string)value);
                            foreach (string userId in userIds)
                            {
                                task.AddUserIdentityLink(userId, customUserIdentityLinkType);
                            }
                        }
                        else if (value is ICollection)
                        {
                            IEnumerator userIdSet = ((ICollection)value).GetEnumerator();
                            while (userIdSet.MoveNext())
                            {
                                task.AddUserIdentityLink((string)userIdSet.Current, customUserIdentityLinkType);
                            }
                        }
                        else
                        {
                            throw new ActivitiException("Expression did not resolve to a string or collection of strings");
                        }
                    }
                }
            }

            if (userTask.CustomGroupIdentityLinks != null && userTask.CustomGroupIdentityLinks.Count > 0)
            {
                foreach (string customGroupIdentityLinkType in userTask.CustomGroupIdentityLinks.Keys)
                {
                    foreach (string groupIdentityLink in userTask.CustomGroupIdentityLinks[customGroupIdentityLinkType])
                    {
                        IExpression idExpression = expressionManager.CreateExpression(groupIdentityLink);
                        object      value        = idExpression.GetValue(execution);
                        if (value is string)
                        {
                            IList <string> groupIds = ExtractCandidates((string)value);
                            foreach (string groupId in groupIds)
                            {
                                task.AddGroupIdentityLink(groupId, customGroupIdentityLinkType);
                            }
                        }
                        else if (value is ICollection)
                        {
                            IEnumerator groupIdSet = ((ICollection)value).GetEnumerator();
                            while (groupIdSet.MoveNext())
                            {
                                task.AddGroupIdentityLink((string)groupIdSet.Current, customGroupIdentityLinkType);
                            }
                        }
                        else
                        {
                            throw new ActivitiException("Expression did not resolve to a string or collection of strings");
                        }
                    }
                }
            }
        }
Exemplo n.º 26
0
        protected internal override int CreateInstances(IExecutionEntity execution)
        {
            int nrOfInstances = base.CreateInstances(execution);

            return(nrOfInstances);
        }
 public override void Execute(IExecutionEntity execution)
 {
     // Do nothing: waitstate behavior
 }
Exemplo n.º 28
0
 protected internal override void DeleteChildExecutions(IExecutionEntity parentExecution, bool deleteExecution, ICommandContext commandContext)
 {
     base.DeleteChildExecutions(parentExecution, deleteExecution, commandContext);
 }
 /// <summary>
 /// Should be subclassed by the more specific types.
 /// For an intermediate catch without type, it's simply leaving the event.
 /// </summary>
 public virtual void EventCancelledByEventGateway(IExecutionEntity execution)
 {
     Context.CommandContext.ExecutionEntityManager.DeleteExecutionAndRelatedData(execution, DeleteReasonFields.EVENT_BASED_GATEWAY_CANCEL, false);
 }
Exemplo n.º 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="variableInstance"></param>
        /// <param name="value"></param>
        /// <param name="sourceActivityExecution"></param>
        protected internal override void UpdateVariableInstance(IVariableInstanceEntity variableInstance, object value, IExecutionEntity sourceActivityExecution)
        {
            base.UpdateVariableInstance(variableInstance, value, sourceActivityExecution);

            // Dispatch event, if needed
            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;

            if (processEngineConfiguration is object && processEngineConfiguration.EventDispatcher.Enabled)
            {
                processEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateVariableEvent(ActivitiEventType.VARIABLE_UPDATED, variableInstance.Name, value, variableInstance.Type, variableInstance.TaskId, variableInstance.ExecutionId, ProcessInstanceId, ProcessDefinitionId));
            }
        }