コード例 #1
0
        private bool changeState(ScheduleItemCommentAddress commentAddress, EntityState state, string pluginEventName)
        {
            bool commentStateChanged    = false;
            ScheduleItemComment comment = getComment(commentAddress);

            using (TransactionScope transaction = new TransactionScope())
            {
                if (comment != null && comment.State != state)
                {
                    commentRepository.ChangeState(comment.ID, state);

                    commentStateChanged = commentRepository.GetComment(comment.ID).State == state;
                }

                if (commentStateChanged)
                {
                    cache.InvalidateItem(comment);
                }

                transaction.Complete();
            }

            if (commentStateChanged)
            {
                pluginEngine.ExecuteAll(pluginEventName, new { context, parent = new ScheduleItemSmallReadOnly(comment.ScheduleItem), comment = new CommentReadOnly(comment, absolutePathHelper.GetAbsolutePath(comment)) });
            }

            return(commentStateChanged);
        }