public ResultNormal submitRes(SubmitComment commentRes)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                if (string.IsNullOrEmpty(commentRes.userId))
                {
                    commentRes.userId = this.getUserId();
                }
                else
                {
                    if (commentRes.userId != this.getUserId())
                    {
                        throw new CCException("身份不明确,请登录后再尝试");
                    }
                }
                result.ResultId = _commentServices.submitResComment(commentRes);
                //创建通知消息
                this.async_CreateCommentMessage(commentRes, result.ResultId);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }
            return(result);
        }
예제 #2
0
        public long submitResComment(SubmitComment submitComment)
        {
            if (string.IsNullOrEmpty(submitComment.userId))
            {
                throw new Exception("非法操作!");
            }

            if (string.IsNullOrEmpty(submitComment.parentRefCode))
            {
                throw new Exception("数据缺少[parentRefCode]");
            }

            long result = -1;

            EComment_Res comment = new EComment_Res
            {
                authorId      = submitComment.userId,
                content       = submitComment.content,
                refCode       = submitComment.refCode,
                parentRefCode = submitComment.parentRefCode,
            };

            result = _commentResRepository.Add(comment).Result;

            return(result);
        }
 private void async_CreateCommentMessage(SubmitComment submitComment, long commentId)
 {
     Task.Run(() =>
     {
         try{
             _messageServices.CreateNotification_Comment(new MsgSubmitComment
             {
                 SubmitComment = submitComment,
                 CommentId     = commentId,
             });
         }
         catch (Exception msgEx) {
             NLogUtil.cc_ErrorTxt("【评论通知】错误:" + msgEx.Message);
         }
     });
 }