コード例 #1
0
ファイル: DoingBO.cs プロジェクト: zhangbo27/bbsmax
        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);
                }
            }
        }
コード例 #2
0
ファイル: ImpressionBO.cs プロジェクト: zhangbo27/bbsmax
        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);
                }
            }
        }
コード例 #3
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);
                }
            }
        }