Ejemplo n.º 1
0
        public void ProcessKeyword(CommentCollection comments, ProcessKeywordMode mode)
        {
            if (comments.Count == 0)
            {
                return;
            }

            KeywordReplaceRegulation keyword = AllSettings.Current.ContentKeywordSettings.ReplaceKeywords;

            bool needProcess = false;

            //更新关键字模式,只在必要的情况下才取恢复信息并处理
            if (mode == ProcessKeywordMode.TryUpdateKeyword)
            {
                needProcess = keyword.NeedUpdate <Comment>(comments);
            }
            //填充原始内容模式,始终都要取恢复信息,但不处理
            else
            {
                needProcess = true;
            }

            if (needProcess)
            {
                RevertableCollection <Comment> commentsWithReverter = CommentDao.Instance.GetCommentsWithReverters(comments.GetKeys());

                if (commentsWithReverter != null)
                {
                    if (keyword.Update(commentsWithReverter))
                    {
                        CommentDao.Instance.UpdateCommentKeywords(commentsWithReverter);
                    }

                    //将新数据填充到旧的列表
                    commentsWithReverter.FillTo(comments);
                }
            }
        }