Exemplo n.º 1
0
        protected internal virtual void DeleteTask(string taskId, CommandContext commandContext)
        {
            ITaskManager taskManager = commandContext.TaskManager;
            TaskEntity   task        = taskManager.FindTaskById(taskId);

            if (task != null)
            {
                if (!ReferenceEquals(task.ExecutionId, null))
                {
                    throw new ProcessEngineException("The ITask cannot be deleted because is part of a running process");
                }
                if (!ReferenceEquals(task.CaseExecutionId, null))
                {
                    throw new ProcessEngineException(
                              "The ITask cannot be deleted because is part of a running case instance");
                }

                CheckDeleteTask(task, commandContext);

                string reason = (ReferenceEquals(DeleteReason, null) || DeleteReason.Length == 0)
                    ? TaskEntity.DeleteReasonDeleted
                    : DeleteReason;
                task.Delete(reason, Cascade);
            }
            else if (Cascade)
            {
                context.Impl.Context.CommandContext.HistoricTaskInstanceManager.DeleteHistoricTaskInstanceById(taskId);
            }
        }