Exemplo n.º 1
0
        public virtual object Execute(CommandContext commandContext)
        {
            EnsureUtil.EnsureNotNull("taskId", TaskId);
            ITaskManager taskManager = commandContext.TaskManager;
            TaskEntity   task        = taskManager.FindTaskById(TaskId);

            EnsureUtil.EnsureNotNull("Cannot find ITask with id " + TaskId, "ITask", task);

            foreach (var checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.CheckTaskWork(task);
            }

            TaskDefinition taskDefinition = task.TaskDefinition;

            if (taskDefinition != null)
            {
                var taskFormHandler = taskDefinition.TaskFormHandler;
                taskFormHandler.SubmitFormVariables(Properties, task);
            }
            else
            {
                // set variables on standalone ITask
                task.Variables = Properties;
            }

            // complete or resolve the ITask
            if (DelegationState.Pending.Equals(task.DelegationState))
            {
                task.Resolve();
                task.CreateHistoricTaskDetails(UserOperationLogEntryFields.OperationTypeResolve);
            }
            else
            {
                task.Complete();
                task.CreateHistoricTaskDetails(UserOperationLogEntryFields.OperationTypeComplete);
            }

            return(null);
        }
Exemplo n.º 2
0
        public virtual object Execute(CommandContext commandContext)
        {
            EnsureUtil.EnsureNotNull("taskId", TaskId);

            ITaskManager taskManager = commandContext.TaskManager;
            TaskEntity   task        = taskManager.FindTaskById(TaskId);

            EnsureUtil.EnsureNotNull("Cannot find ITask with id " + TaskId, "ITask", task);

            CheckTaskPriority(task, commandContext);

            task.Priority = Priority;

            task.CreateHistoricTaskDetails(UserOperationLogEntryFields.OperationTypeSetPriority);
            return(null);
        }
Exemplo n.º 3
0
        public virtual object Execute(CommandContext commandContext)
        {
            EnsureUtil.EnsureNotNull("taskId", TaskId);

            ITaskManager taskManager = commandContext.TaskManager;
            TaskEntity   task        = taskManager.FindTaskById(TaskId);

            EnsureUtil.EnsureNotNull("Cannot find ITask with id " + TaskId, "ITask", task);

            CheckClaimTask(task, commandContext);

            if (!ReferenceEquals(UserId, null))
            {
                if (!ReferenceEquals(task.Assignee, null))
                {
                    if (!task.Assignee.Equals(UserId))
                    {
                        // When the ITask is already claimed by another user, throw exception. Otherwise, ignore
                        // this, post-conditions of method already met.
                        throw new TaskAlreadyClaimedException(task.Id, task.Assignee);
                    }
                }
                else
                {
                    task.Assignee = UserId;
                }
            }
            else
            {
                // ITask should be assigned to no one
                task.Assignee = null;
            }

            task.CreateHistoricTaskDetails(UserOperationLogEntryFields.OperationTypeClaim);

            return(null);
        }
Exemplo n.º 4
0
        public virtual object Execute(CommandContext commandContext)
        {
            EnsureUtil.EnsureNotNull("Task", Task);

            string operation = string.Empty;

            if (Task.Revision == 0)
            {
                try
                {
                    CheckCreateTask(Task, commandContext);
                    Task.SaveTask(null);
                    Task.Update();
                    commandContext.HistoricTaskInstanceManager.CreateHistoricTask(Task);
                    operation = UserOperationLogEntryFields.OperationTypeCreate;
                    Task.ExecuteMetrics(ESS.FW.Bpm.Engine.Management.Metrics.ActivtyInstanceStart);
                }
                catch (NullValueException e)
                {
                    throw new NotValidException(e.Message, e);
                }
            }
            else
            {
                CheckTaskAssign(Task, commandContext);
                Task.Update();
                operation = UserOperationLogEntryFields.OperationTypeUpdate;
            }


            Task.FireAuthorizationProvider();
            Task.FireEvent();
            Task.CreateHistoricTaskDetails(operation);

            return(null);
        }
Exemplo n.º 5
0
 protected internal override void CompleteTask(TaskEntity task)
 {
     task.Resolve();
     task.CreateHistoricTaskDetails(UserOperationLogEntryFields.OperationTypeResolve);
 }