예제 #1
0
 public virtual void CheckDeleteHistoricTaskInstance(HistoricTaskInstanceEventEntity task)
 {
     if (task != null && !TenantManager.IsAuthenticatedTenant(task.TenantId))
     {
         throw Log.ExceptionCommandWithUnauthorizedTenant("delete the historic ITask instance '" + task.Id + "'");
     }
 }
        protected internal virtual void InitTaskInstanceEvent(HistoricTaskInstanceEventEntity evt, TaskEntity taskEntity, IHistoryEventType eventType)
        {
            string processDefinitionKey        = null;
            ProcessDefinitionEntity definition = taskEntity.ProcessDefinition;

            if (definition != null)
            {
                processDefinitionKey = definition.Key;
            }

            string processDefinitionId = taskEntity.ProcessDefinitionId;
            string processInstanceId   = taskEntity.ProcessInstanceId;
            string executionId         = taskEntity.ExecutionId;

            string caseDefinitionKey = null;
            //CaseDefinitionEntity caseDefinition = taskEntity.CaseDefinition;
            //if (caseDefinition != null)
            //{
            //    caseDefinitionKey = caseDefinition.Key;
            //}

            string caseDefinitionId = taskEntity.CaseDefinitionId;
            string caseExecutionId  = taskEntity.CaseExecutionId;
            string caseInstanceId   = taskEntity.CaseInstanceId;
            string tenantId         = taskEntity.TenantId;

            evt.Id        = taskEntity.Id;
            evt.EventType = eventType.EventName;
            evt.TaskId    = taskEntity.Id;

            evt.ProcessDefinitionKey = processDefinitionKey;
            evt.ProcessDefinitionId  = processDefinitionId;
            evt.ProcessInstanceId    = processInstanceId;
            evt.ExecutionId          = executionId;

            evt.CaseDefinitionKey = caseDefinitionKey;
            evt.CaseDefinitionId  = caseDefinitionId;
            evt.CaseExecutionId   = caseExecutionId;
            evt.CaseInstanceId    = caseInstanceId;

            evt.Assignee          = taskEntity.Assignee;
            evt.Description       = taskEntity.Description;
            evt.DueDate           = taskEntity.DueDate;
            evt.FollowUpDate      = taskEntity.FollowUpDate;
            evt.Name              = taskEntity.Name;
            evt.Owner             = taskEntity.Owner;
            evt.ParentTaskId      = taskEntity.ParentTaskId;
            evt.Priority          = taskEntity.Priority;
            evt.TaskDefinitionKey = taskEntity.TaskDefinitionKey;
            evt.TenantId          = tenantId;

            ExecutionEntity execution = taskEntity.GetExecution();

            if (execution != null)
            {
                evt.ActivityInstanceId = execution.ActivityInstanceId;
            }
        }
        public virtual HistoryEvent CreateTaskInstanceMigrateEvt(IDelegateTask task)
        {
            // create event instance
            HistoricTaskInstanceEventEntity evt = LoadTaskInstanceEvent(task);

            // initialize event
            InitTaskInstanceEvent(evt, (TaskEntity)task, HistoryEventTypes.TaskInstanceMigrate);

            return(evt);
        }
        public virtual HistoryEvent CreateTaskInstanceCreateEvt(IDelegateTask task)
        {
            // create event instance
            HistoricTaskInstanceEventEntity evt = NewTaskInstanceEventEntity(task);

            // initialize event
            InitTaskInstanceEvent(evt, (TaskEntity)task, HistoryEventTypes.TaskInstanceCreate);

            evt.StartTime = ClockUtil.CurrentTime;

            return(evt);
        }
예제 #5
0
        //delete permission ////////////////////////////////////////

        public virtual void CheckDeleteHistoricTaskInstance(HistoricTaskInstanceEventEntity task)
        {
            //deleting unexisting historic ITask instance should be silently ignored
            //see javaDoc HistoryService.deleteHistoricTaskInstance
            if (task != null)
            {
                if (!ReferenceEquals(task.ProcessDefinitionKey, null))
                {
                    AuthorizationManager.CheckAuthorization(Permissions.DeleteHistory, Resources.ProcessDefinition,
                                                            task.ProcessDefinitionKey);
                }
            }
        }
        public virtual object Execute(CommandContext commandContext)
        {
            EnsureUtil.EnsureNotNull("taskId", TaskId);

            HistoricTaskInstanceEventEntity task =
                commandContext.HistoricTaskInstanceManager.FindHistoricTaskInstanceById(TaskId);

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

            commandContext.HistoricTaskInstanceManager.DeleteHistoricTaskInstanceById(TaskId);
            return(null);
        }
        protected internal override HistoricTaskInstanceEventEntity LoadTaskInstanceEvent(IDelegateTask task)
        {
            var taskId = task.Id;

            HistoricTaskInstanceEventEntity cachedEntity = FindInCache <HistoricTaskInstanceEventEntity>(typeof(HistoricTaskInstanceEventEntity), taskId);

            if (cachedEntity != null)
            {
                return(cachedEntity);
            }
            else
            {
                return(NewTaskInstanceEventEntity(task));
            }
        }
예제 #8
0
        protected internal override HistoricTaskInstanceEventEntity loadTaskInstanceEvent(DelegateTask task)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String taskId = task.getId();
            string taskId = task.Id;

            HistoricTaskInstanceEventEntity cachedEntity = findInCache(typeof(HistoricTaskInstanceEventEntity), taskId);

            if (cachedEntity != null)
            {
                return(cachedEntity);
            }
            else
            {
                return(newTaskInstanceEventEntity(task));
            }
        }
        public virtual HistoryEvent CreateTaskInstanceCompleteEvt(IDelegateTask task, string deleteReason)
        {
            // create event instance
            HistoricTaskInstanceEventEntity evt = LoadTaskInstanceEvent(task);

            // initialize event
            InitTaskInstanceEvent(evt, (TaskEntity)task, HistoryEventTypes.TaskInstanceComplete);

            // set end time
            evt.EndTime = ClockUtil.CurrentTime;
            if (evt.StartTime != null)
            {
                evt.DurationInMillis = ((DateTime)evt.EndTime).Ticks - ((DateTime)evt.StartTime).Ticks;
            }

            // set delete reason
            evt.DeleteReason = deleteReason;

            return(evt);
        }