Esempio n. 1
0
        public void ProcessKeyword(ChatMessage chatMessage, ProcessKeywordMode mode)
        {
            if (chatMessage == null)
            {
                return;
            }

            ChatMessageCollection messages = new ChatMessageCollection();

            messages.Add(chatMessage);

            ProcessKeyword(messages, mode);
        }
Esempio n. 2
0
        private void ProcessKeyword(DoingCollection doings, ProcessKeywordMode mode)
        {
            if (doings.Count == 0)
            {
                return;
            }

            KeywordReplaceRegulation keyword = AllSettings.Current.ContentKeywordSettings.ReplaceKeywords;

            bool needProcess = false;

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

            if (needProcess)
            {
                RevertableCollection <Doing> doingsWithReverter = DoingDao.Instance.GetDoingsWithReverters(doings.GetKeys());

                if (doingsWithReverter != null)
                {
                    if (keyword.Update(doingsWithReverter))
                    {
                        DoingDao.Instance.UpdateDoingKeywords(doingsWithReverter);
                    }

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

            if (mode == ProcessKeywordMode.TryUpdateKeyword)
            {
                foreach (Doing doing in doings)
                {
                    CommentBO.Instance.ProcessKeyword(doing.CommentList, mode);
                }
            }
        }
Esempio n. 3
0
        private void ProcessKeyword(Doing doing, ProcessKeywordMode mode)
        {
            //更新关键字模式,如果这个记录并不需要处理,直接退出
            if (mode == ProcessKeywordMode.TryUpdateKeyword)
            {
                if (AllSettings.Current.ContentKeywordSettings.ReplaceKeywords.NeedUpdate <Doing>(doing) == false)
                {
                    return;
                }
            }

            DoingCollection doings = new DoingCollection();

            doings.Add(doing);

            ProcessKeyword(doings, mode);
        }
Esempio n. 4
0
        private void ProcessKeyword(ImpressionRecord record, ProcessKeywordMode mode)
        {
            //更新关键字模式,如果这个文章并不需要处理,直接退出
            if (mode == ProcessKeywordMode.TryUpdateKeyword)
            {
                if (AllSettings.Current.ContentKeywordSettings.ReplaceKeywords.NeedUpdate(record) == false)
                {
                    return;
                }
            }

            ImpressionRecordCollection records = new ImpressionRecordCollection();

            records.Add(record);

            ProcessKeyword(records, mode);
        }
Esempio n. 5
0
        public void ProcessKeyword(Comment comment, ProcessKeywordMode mode)
        {
            //更新关键字模式,如果这个评论并不需要处理,直接退出
            if (mode == ProcessKeywordMode.TryUpdateKeyword)
            {
                if (AllSettings.Current.ContentKeywordSettings.ReplaceKeywords.NeedUpdate <Comment>(comment) == false)
                {
                    return;
                }
            }

            CommentCollection comments = new CommentCollection();

            comments.Add(comment);

            ProcessKeyword(comments, mode);
        }
Esempio n. 6
0
        private void ProcessKeyword(ImpressionRecordCollection records, ProcessKeywordMode mode)
        {
            if (records.Count == 0)
            {
                return;
            }

            KeywordReplaceRegulation keyword = AllSettings.Current.ContentKeywordSettings.ReplaceKeywords;

            bool needProcess = false;

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

            if (needProcess)
            {
                RevertableCollection <ImpressionRecord> recordsWithReverter = ImpressionDao.Instance.GetImpressionRecordsWithReverters(records.GetKeys());

                if (recordsWithReverter != null)
                {
                    if (keyword.Update(recordsWithReverter))
                    {
                        ImpressionDao.Instance.UpdateImpressionRecordKeywords(recordsWithReverter);
                    }

                    //将新数据填充到旧的列表
                    recordsWithReverter.FillTo(records);
                }
            }
        }
Esempio n. 7
0
        public void ProcessKeyword(ChatMessageCollection messages, ProcessKeywordMode mode)
        {
            if (messages.Count == 0)
            {
                return;
            }

            KeywordReplaceRegulation keyword = AllSettings.Current.ContentKeywordSettings.ReplaceKeywords;

            bool needProcess = false;

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

            if (needProcess)
            {
                RevertableCollection <ChatMessage> messagesWithReverter = ChatDao.Instance.GetChatMessageWithReverters(messages.GetKeys());

                if (messagesWithReverter != null)
                {
                    if (keyword.Update(messagesWithReverter))
                    {
                        ChatDao.Instance.UpdateChatMessageKeywords(messagesWithReverter);
                    }

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