Ejemplo n.º 1
0
        /// <summary>
        /// 触发评论事件
        /// </summary>
        /// <param name="notification"></param>
        public void Handler(ReviewEvent reviewEvent)
        {
            Tidings tidings = null;
            string  url     = "../article/detail.html?id=" + reviewEvent.ArticleId + "&read=1";

            if (reviewEvent.Comment.CommentType == CommentType.文章)//评论文章
            {
                Article article = _articleRepository.SelectById(reviewEvent.ArticleId);
                tidings = new Tidings(reviewEvent.Comment.Guid, reviewEvent.Comment.PostUser, reviewEvent.Comment.Content, article.Author, false, url, article.Title, DateTime.Now);
            }
            else//回复评论
            {
                Comment comment = _commentRepository.SelectById(reviewEvent.Comment.AdditionalData);//被评论的数据;
                tidings = new Tidings(reviewEvent.Comment.Guid, reviewEvent.Comment.PostUser, reviewEvent.Comment.Content
                                      , comment.PostUser, false, url, comment.Content, DateTime.Now);
            }
            _tidingsRepository.Insert(tidings);
            int     count   = _tidingsRepository.SelectCountByAccount(reviewEvent.Comment.RevicerUser);
            Message message = new Message();

            message.Data = count;
            _singalrContent.SendClientMessage(reviewEvent.Comment.RevicerUser, message);

            string sql    = "SELECT config_value where config_key=@key";
            string result = _repository.SelectSingle(sql, new { key = "MAIL_CONFIG_KEY" }).config_value;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 触发评论事件
        /// </summary>
        /// <param name="notification"></param>
        public void Handler(ReviewWhiperEvent reviewEvent)
        {
            try
            {
                Tidings tidings = null;
                string  url     = "../whisper/whisper.html?id=" + reviewEvent.WhiperId + "&read=1";
                if (reviewEvent.Comment.CommentType == CommentType.微语)
                {
                    Whisper whisper = _whisperRepository.SelectById(reviewEvent.WhiperId);
                    tidings = new Tidings(reviewEvent.Comment.Guid, reviewEvent.Comment.PostUser, reviewEvent.Comment.Content, whisper.Account, false, url, whisper.Content, DateTime.Now);
                }
                else//回复评论
                {
                    Comment comment = _commentRepository.SelectById(reviewEvent.Comment.AdditionalData);//被评论的数据;
                    tidings = new Tidings(reviewEvent.Comment.Guid, reviewEvent.Comment.PostUser, reviewEvent.Comment.Content
                                          , comment.PostUser, false, url, comment.Content, DateTime.Now);
                }
                _tidingsRepository.Insert(tidings);
                JsonSerializerSettings jsonSerializerSettings = new JsonContractResolver().SetJsonSerializerSettings();
                List <Whisper>         whispers = _cacheClient.ListRange <Whisper>(ConstantKey.CACHE_SQUARE_WHISPER, 0, 5, jsonSerializerSettings).GetAwaiter().GetResult();

                IList <Comment> comments     = _commentRepository.SelectByIds(reviewEvent.WhisperCommentGuids);
                int             index        = 0;
                Whisper         cacheWhisper = null;
                for (int i = 0; i < whispers.Count; i++)
                {
                    if (whispers[i].Id != reviewEvent.WhiperId)
                    {
                        continue;
                    }
                    index        = i;
                    cacheWhisper = new Whisper(
                        whispers[i].Id,
                        whispers[i].Account,
                        whispers[i].AccountName,
                        whispers[i].Content,
                        whispers[i].IsPassing,
                        string.Join(",", comments.Select(s => s.Guid)),
                        comments,
                        Convert.ToDateTime(whispers[i].CreateDate));
                    whispers[i] = cacheWhisper;
                }
                if (cacheWhisper == null)
                {
                    return;
                }
                _cacheClient.ListInsert(ConstantKey.CACHE_SQUARE_WHISPER, index, cacheWhisper);
                int     count   = _tidingsRepository.SelectCountByAccount(reviewEvent.Comment.RevicerUser);
                Message message = new Message();
                message.Data = count;
                _singalrContent.SendClientMessage(reviewEvent.Comment.RevicerUser, message);
                //首页微语
                message.Data = whispers;
                _singalrContent.SendAllClientsMessage(message);
            }
            catch (AggregateException ex)
            {
                new LogUtils().LogError(ex, "Blog.Domain.ReviewWhisperEventHandler", ex.Message, reviewEvent.Comment.PostUser);
            }
        }
Ejemplo n.º 3
0
        public void Handler(DoneTidingsCommand command)
        {
            _tidingsRepository.Done(command.Id);
            Tidings tidings = _tidingsRepository.SelectById(command.Id);

            _eventBus.RaiseEventAsync(new DoneEvent(tidings.ReviceUser));
        }