Exemplo n.º 1
0
        public virtual IComment Execute(ICommandContext commandContext)
        {
            // Validate task
            if (!(taskId is null))
            {
                ITaskEntity task = commandContext.TaskEntityManager.FindById <ITaskEntity>(taskId);

                if (task == null)
                {
                    logger.LogWarning("Cannot find task with id " + taskId, typeof(ITask));
                    return(null);
                }

                if (task.Suspended)
                {
                    throw new ActivitiException(SuspendedTaskException);
                }
            }

            if (!(processInstanceId is null))
            {
                IExecutionEntity execution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(processInstanceId);

                if (execution == null)
                {
                    logger.LogWarning("Cannot find task with id " + taskId, typeof(ITask));
                    return(null);
                    //throw new ActivitiObjectNotFoundException("execution " + processInstanceId + " doesn't exist", typeof(IExecution));
                }

                if (execution.Suspended)
                {
                    throw new ActivitiException(SuspendedExceptionMessage);
                }
            }

            IUserInfo      user    = Authentication.AuthenticatedUser;
            ICommentEntity comment = commandContext.CommentEntityManager.Create();

            comment.UserId            = user.Id;
            comment.Type              = (type is null) ? CommentEntityFields.TYPE_COMMENT : type;
            comment.Time              = commandContext.ProcessEngineConfiguration.Clock.CurrentTime;
            comment.TaskId            = taskId;
            comment.ProcessInstanceId = processInstanceId;
            comment.Action            = EventFields.ACTION_ADD_COMMENT;

            string eventMessage = message.Replace("\\s+", " ");

            if (eventMessage.Length > 163)
            {
                eventMessage = eventMessage.Substring(0, 160) + "...";
            }
            comment.Message = eventMessage;

            comment.FullMessage = message;

            commandContext.CommentEntityManager.Insert(comment);

            return(comment);
        }
Exemplo n.º 2
0
 public static ICommentDomainEntity ConvertToDomain(this ICommentEntity entity)
 {
     return(new Comment
     {
         Entry = new Entry {
             Id = entity.EntryId
         },
         Author = new User {
             Id = entity.AuthorId
         },
         Id = entity.Id,
         Body = entity.Body,
         Timestamp = entity.Timestamp
     });
 }
        /// <summary>
        /// Update a comment
        /// </summary>
        /// <param name="processType">Process type</param>
        /// <param name="commentHandle">Comment handle</param>
        /// <param name="text">Comment text</param>
        /// <param name="blobType">Blob type</param>
        /// <param name="blobHandle">Blob handle</param>
        /// <param name="reviewStatus">Review status</param>
        /// <param name="lastUpdatedTime">Last updated time</param>
        /// <param name="commentEntity">Comment entity</param>
        /// <returns>Update comment task</returns>
        public async Task UpdateComment(
            ProcessType processType,
            string commentHandle,
            string text,
            BlobType blobType,
            string blobHandle,
            ReviewStatus reviewStatus,
            DateTime lastUpdatedTime,
            ICommentEntity commentEntity)
        {
            commentEntity.Text            = text;
            commentEntity.BlobType        = blobType;
            commentEntity.BlobHandle      = blobHandle;
            commentEntity.ReviewStatus    = reviewStatus;
            commentEntity.LastUpdatedTime = lastUpdatedTime;

            await this.commentsStore.UpdateComment(StorageConsistencyMode.Strong, commentHandle, commentEntity);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="userId"></param>
        /// <param name="groupId"></param>
        /// <param name="type"></param>
        /// <param name="create"></param>
        /// <param name="forceNullUserId"></param>
        public virtual void CreateIdentityLinkComment(string taskId, string userId, string groupId, string type, bool create, bool forceNullUserId)
        {
            if (HistoryEnabled)
            {
                string         authenticatedUserId = Authentication.AuthenticatedUser.Id;
                ICommentEntity comment             = CommentEntityManager.Create();
                comment.UserId = authenticatedUserId;
                comment.Type   = CommentEntityFields.TYPE_EVENT;
                comment.Time   = Clock.CurrentTime;
                comment.TaskId = taskId;
                if (userId is object || forceNullUserId)
                {
                    if (create)
                    {
                        comment.Action = EventFields.ACTION_ADD_USER_LINK;
                    }
                    else
                    {
                        comment.Action = EventFields.ACTION_DELETE_USER_LINK;
                    }
                    comment.MessageParts = new string[] { userId, type };
                }
                else
                {
                    if (create)
                    {
                        comment.Action = EventFields.ACTION_ADD_GROUP_LINK;
                    }
                    else
                    {
                        comment.Action = EventFields.ACTION_DELETE_GROUP_LINK;
                    }
                    comment.MessageParts = new string[] { groupId, type };
                }

                CommentEntityManager.Insert(comment);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="taskId"></param>
 /// <param name="processInstanceId"></param>
 /// <param name="attachmentName"></param>
 /// <param name="create"></param>
 public virtual void CreateAttachmentComment(string taskId, string processInstanceId, string attachmentName, bool create)
 {
     if (HistoryEnabled)
     {
         string         userId  = Authentication.AuthenticatedUser.Id;
         ICommentEntity comment = CommentEntityManager.Create();
         comment.UserId            = userId;
         comment.Type              = CommentEntityFields.TYPE_EVENT;
         comment.Time              = Clock.CurrentTime;
         comment.TaskId            = taskId;
         comment.ProcessInstanceId = processInstanceId;
         if (create)
         {
             comment.Action = EventFields.ACTION_ADD_ATTACHMENT;
         }
         else
         {
             comment.Action = EventFields.ACTION_DELETE_ATTACHMENT;
         }
         comment.MessageParts = new string[] { attachmentName };
         CommentEntityManager.Insert(comment);
     }
 }
Exemplo n.º 6
0
 public CommentService(ICommentEntity entity)
 {
     this.entity = entity;
 }
        /// <summary>
        /// Update a comment
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="commentHandle">Comment handle</param>
        /// <param name="commentEntity">Comment entity</param>
        /// <returns>Update comment task</returns>
        public async Task UpdateComment(StorageConsistencyMode storageConsistencyMode, string commentHandle, ICommentEntity commentEntity)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Comments);

            ObjectTable table     = this.tableStoreManager.GetTable(ContainerIdentifier.Comments, TableIdentifier.CommentsObject) as ObjectTable;
            Operation   operation = Operation.Replace(table, commentHandle, commentHandle, commentEntity as CommentEntity);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }