Ejemplo n.º 1
0
        /// <summary>
        /// ɾ����д�
        /// </summary>
        /// <param name="id">��д�Id</param>
        public void Delete(int id)
        {
            SensitiveWord word = sensitiveWordRepository.Get(id);

            EventBus <SensitiveWord> .Instance().OnBefore(word, new CommonEventArgs(EventOperationType.Instance().Update()));

            sensitiveWordRepository.Delete(word);
            EventBus <SensitiveWord> .Instance().OnBefore(word, new CommonEventArgs(EventOperationType.Instance().Update()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// �½�ʵ��ʱʹ��
        /// </summary>
        public static SensitiveWord New()
        {
            SensitiveWord sensitiveWord = new SensitiveWord()
            {
                Word        = string.Empty,
                Replacement = string.Empty
            };

            return(sensitiveWord);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// �����д�
        /// </summary>
        /// <param name="sensitiveWord">��д�ʵ������</param>
        public int Create(SensitiveWord sensitiveWord)
        {
            EventBus <SensitiveWord> .Instance().OnBefore(sensitiveWord, new CommonEventArgs(EventOperationType.Instance().Create()));

            int judge = sensitiveWordRepository.Create(sensitiveWord);

            EventBus <SensitiveWord> .Instance().OnAfter(sensitiveWord, new CommonEventArgs(EventOperationType.Instance().Create()));

            return(judge);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// �����д�
        /// </summary>
        /// <param name="words">��дʼ���</param>
        /// <param name="typeId">������Id</param>
        public void BatchCreate(IList <string> words, int?typeId)
        {
            if (words == null)
            {
                return;
            }

            words = words.Distinct().ToList();

            List <SensitiveWord> sensitiveWords = new List <SensitiveWord>();

            foreach (string word in words)
            {
                SensitiveWord sensitiveWord = SensitiveWord.New();
                if (word.Contains("="))
                {
                    string[] parts = word.Split('=');

                    if (parts.Count() == 2)
                    {
                        sensitiveWord.Word        = parts[0];
                        sensitiveWord.Replacement = parts[1];
                    }
                }
                else
                {
                    sensitiveWord.Word        = word;
                    sensitiveWord.Replacement = "*";
                }

                if (typeId.HasValue)
                {
                    sensitiveWord.TypeId = typeId.Value;
                }

                sensitiveWords.Add(sensitiveWord);
            }

            EventBus <SensitiveWord> .Instance().OnBatchBefore(sensitiveWords, new CommonEventArgs(EventOperationType.Instance().Create()));

            sensitiveWordRepository.BatchInsert(sensitiveWords);
            EventBus <SensitiveWord> .Instance().OnBatchAfter(sensitiveWords, new CommonEventArgs(EventOperationType.Instance().Create()));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新敏感词
 /// </summary>
 /// <param name="sensitiveWord">待更新敏感词</param>
 /// <returns></returns>
 public int Update(SensitiveWord sensitiveWord)
 {
     EventBus<SensitiveWord>.Instance().OnBefore(sensitiveWord, new CommonEventArgs(EventOperationType.Instance().Update()));
     int judge = sensitiveWordRepository.Update(sensitiveWord);
     EventBus<SensitiveWord>.Instance().OnAfter(sensitiveWord, new CommonEventArgs(EventOperationType.Instance().Update()));
     return judge;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        public static SensitiveWord New()
        {
            SensitiveWord sensitiveWord = new SensitiveWord()
            {
                Word = string.Empty,
                Replacement = string.Empty

            };

            return sensitiveWord;
        }