public virtual object Execute(ICommandContext commandContext) { ICommentEntityManager commentManager = commandContext.CommentEntityManager; if (commentId is object) { // Delete for an individual comment IComment comment = commentManager.FindComment(commentId); if (comment == null) { throw new ActivitiObjectNotFoundException("Comment with id '" + commentId + "' doesn't exists.", typeof(IComment)); } if (comment.ProcessInstanceId is object) { commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(comment.ProcessInstanceId); } else if (comment.TaskId is object) { commandContext.TaskEntityManager.FindById <ITask>(new KeyValuePair <string, object>("id", comment.TaskId)); } commentManager.Delete((ICommentEntity)comment); } else { // Delete all comments on a task of process List <IComment> comments = new List <IComment>(); if (processInstanceId is object) { commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(processInstanceId); comments.AddRange(commentManager.FindCommentsByProcessInstanceId(processInstanceId)); } if (taskId is object) { commandContext.TaskEntityManager.FindById <ITask>(new KeyValuePair <string, object>("id", taskId)); comments.AddRange(commentManager.FindCommentsByTaskId(taskId)); } foreach (IComment comment in comments) { commentManager.Delete((ICommentEntity)comment); } } return(null); }
public virtual object Execute(ICommandContext commandContext) { ICommentEntityManager commentManager = commandContext.CommentEntityManager; if (!(commentId is null)) { // Delete for an individual comment IComment comment = commentManager.FindComment(commentId); if (comment == null) { throw new ActivitiObjectNotFoundException("Comment with id '" + commentId + "' doesn't exists.", typeof(IComment)); } if (!(comment.ProcessInstanceId is null)) { commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(comment.ProcessInstanceId); }