public void Notify(IExecutionEntity execution)
        {
            SubProcess subProcess = GetSubProcessFromExecution(execution);

            if (subProcess.HasMultiInstanceLoopCharacteristics())
            {
                var varName = subProcess.LoopCharacteristics.GetCollectionVarName();

                if (string.IsNullOrWhiteSpace(varName) == false)
                {
                    IExecutionEntity miRoot = GetMiRootExecution(execution);
                    if (miRoot is null)
                    {
                        return;
                    }

                    string varBusiKey = string.Format(SUBPROCESS_BUSINESS_KEY, execution.Id);

                    if (GetVariable <object>(miRoot, varBusiKey) != null)
                    {
                        return;
                    }

                    int nrOfExecInstances = GetVariable <int?>(execution, NUMBER_OF_EXECUTION_INSTANCES).GetValueOrDefault(0);

                    miRoot.SetVariableLocal(NUMBER_OF_EXECUTION_INSTANCES, nrOfExecInstances + 1);
                    string[] ids = JsonConvert.DeserializeObject <string[]>(execution.GetVariable(varName).ToString());

                    execution.BusinessKey = ids[nrOfExecInstances];
                    miRoot.SetVariableLocal(varBusiKey, execution.BusinessKey);
                }
            }
        }
        protected internal override object Execute(ICommandContext commandContext, IExecutionEntity execution)
        {
            if (variables is null || variables.Count == 0)
            {
                return(null);
            }

            if (isLocal)
            {
                foreach (string variableName in variables.Keys)
                {
                    execution.SetVariableLocal(variableName, variables[variableName], false);
                }
            }
            else
            {
                foreach (string variableName in variables.Keys)
                {
                    execution.SetVariable(variableName, variables[variableName], false);
                }
            }

            // ACT-1887: Force an update of the execution's revision to prevent
            // simultaneous inserts of the same
            // variable. If not, duplicate variables may occur since optimistic
            // locking doesn't work on inserts
            execution.ForceUpdate();

            return(null);
        }
Exemplo n.º 3
0
        public void Notify(IExecutionEntity execution)
        {
            IExecutionEntity miRoot = execution.Parent;

            if (miRoot.IsMultiInstanceRoot &&
                execution.CurrentFlowElement is CallActivity callActivity)
            {
                int nrOfExecInstances = ((int?)miRoot.GetVariableLocal(NUMBER_OF_EXECUTION_INSTANCES)).GetValueOrDefault(0);

                miRoot.SetVariableLocal(NUMBER_OF_EXECUTION_INSTANCES, nrOfExecInstances + 1);

                string collectionVarName = callActivity.LoopCharacteristics.GetCollectionVarName();

                string[] businessKeys = miRoot.GetVariable <JArray>(collectionVarName).ToObject <string[]>();

                execution.BusinessKey = businessKeys[nrOfExecInstances];
            }
        }
Exemplo n.º 4
0
        protected internal override void ExecuteTaskComplete(ICommandContext commandContext, ITaskEntity taskEntity, IDictionary <string, object> variables, bool localScope)
        {
            lock (syncRoot)
            {
                // Task complete logic
                CompleteTask(commandContext, taskEntity, variables, localScope);

                IActivitiEventDispatcher eventDispatcher = Context.ProcessEngineConfiguration.EventDispatcher;

                if (eventDispatcher.Enabled)
                {
                    eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateCustomTaskCompletedEvent(taskEntity, ActivitiEventType.TASK_TERMINATED));
                }

                // Continue process (if not a standalone task)
                if (taskEntity.ExecutionId is object && isTerminateExecution)
                {
                    IExecutionEntity executionEntity = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(taskEntity.ExecutionId);
                    executionEntity.SetVariableLocal(WorkflowVariable.GLOBAL_TERMINATE_TASK_VARNAME, true);
                    Context.Agenda.PlanTriggerExecutionOperation(executionEntity, variables ?? new Dictionary <string, object>());
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 设置流程实例变量
 /// </summary>
 /// <param name="execution"></param>
 /// <param name="variableName"></param>
 /// <param name="value"></param>
 internal static void SetLoopVariable(this IExecutionEntity execution, string variableName, object value)
 {
     execution.SetVariableLocal(variableName, value);
 }
 protected internal virtual void SetLoopVariable(IExecutionEntity execution, string variableName, object value)
 {
     execution.SetVariableLocal(variableName, value);
 }