/// <summary>
        /// 修改or新增评论
        /// </summary>
        /// <returns></returns>
        public JsonResult OperationComment(CommentBody commentModel)
        {
            var model = new CommentBody();

            model.CommentDetail                     = new CommentsDetail();
            model.CommentDetail.ReplyUserId         = commentModel.CommentDetail.ReplyUserId;
            model.CommentDetail.ProjectId           = commentModel.CommentDetail.ProjectId;
            model.CommentDetail.CommentsRecordId    = commentModel.CommentDetail.CommentsRecordId;
            model.CommentDetail.ReplyContent        = commentModel.CommentDetail.ReplyContent;
            model.CommentDetail.ByReplyUserId       = commentModel.CommentDetail.ByReplyUserId;
            model.CommentDetail.ByCommentsRecordId  = commentModel.CommentDetail.ByCommentsRecordId;
            model.CommentDetail.ReplyDepth          = commentModel.CommentDetail.ReplyDepth;
            model.CommentDetail.CommentsRecordType  = commentModel.CommentDetail.CommentsRecordType;
            model.CommentDetail.CommentsRecordState = commentModel.CommentDetail.CommentsRecordState;
            model.CommentDetail.ReplyTime           = commentModel.CommentDetail.ReplyTime;
            model.CommentDetail.ChannelId           = UserContext.ChannelId;
            model.CommentDetail.RecordIp            = " ";

            BaseResponse jsonResult = new BaseResponse();

            try
            {
                if (commentModel.CommentDetail.CommentsRecordId > 0)
                {
                    //修改
                    var result = MLTCommentsRecordClient.Instance.UpdateCommentRecord(model);
                    if (result)
                    {
                        jsonResult.DoFlag = true;
                    }
                    else
                    {
                        jsonResult.DoResult = "更新失败,请重试!";
                    }
                }
                else
                {
                    //新增
                    var result = MLTCommentsRecordClient.Instance.AddCommentRecord(model.CommentDetail);
                    if (result)
                    {
                        jsonResult.DoFlag = true;
                    }
                    else
                    {
                        jsonResult.DoResult = "新增失败,请重试!";
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(jsonResult));
        }
        /// <summary>
        /// Update a comment Updates an existing comment **commentId** on node **nodeId**.
        /// </summary>
        /// <param name="nodeId">The identifier of a node.</param>
        /// <param name="commentId">The identifier of a comment.</param>
        /// <param name="commentBodyUpdate">The JSON representing the comment to be updated.</param>
        /// <param name="fields">A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. </param>
        /// <returns>CommentEntry</returns>
        public CommentEntry UpdateComment(string nodeId, string commentId, CommentBody commentBodyUpdate, List <string> fields)
        {
            // verify the required parameter 'nodeId' is set
            if (nodeId == null)
            {
                throw new ApiException(400, "Missing required parameter 'nodeId' when calling UpdateComment");
            }

            // verify the required parameter 'commentId' is set
            if (commentId == null)
            {
                throw new ApiException(400, "Missing required parameter 'commentId' when calling UpdateComment");
            }

            // verify the required parameter 'commentBodyUpdate' is set
            if (commentBodyUpdate == null)
            {
                throw new ApiException(400, "Missing required parameter 'commentBodyUpdate' when calling UpdateComment");
            }


            var path = "/nodes/{nodeId}/comments/{commentId}";

            path = path.Replace("{format}", "json");
            path = path.Replace("{" + "nodeId" + "}", ApiClient.ParameterToString(nodeId));
            path = path.Replace("{" + "commentId" + "}", ApiClient.ParameterToString(commentId));

            var    queryParams  = new Dictionary <String, String>();
            var    headerParams = new Dictionary <String, String>();
            var    formParams   = new Dictionary <String, String>();
            var    fileParams   = new Dictionary <String, FileParameter>();
            String postBody     = null;

            if (fields != null)
            {
                queryParams.Add("fields", ApiClient.ParameterToString(fields));        // query parameter
            }
            postBody = ApiClient.Serialize(commentBodyUpdate);                         // http body (model) parameter

            // authentication setting, if any
            String[] authSettings = new String[] { "basicAuth" };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling UpdateComment: " + response.Content, response.Content);
            }
            else if (((int)response.StatusCode) == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling UpdateComment: " + response.ErrorMessage, response.ErrorMessage);
            }

            return((CommentEntry)ApiClient.Deserialize(response.Content, typeof(CommentEntry), response.Headers));
        }
Beispiel #3
0
        private async Task SortAndLimitTest()
        {
            var sourceType = SourceType.FootballMatch;
            var sourceId   = 1;
            //获取刚才创建的评论主体
            CommentBody body = await Business.GetCommentBodyId(sourceType, sourceId);

            //获取评论列表
            var details = await Business.GetLatestCommentDetails(body._id, 2);
        }
Beispiel #4
0
        //public List<Comment> GetPagedComments()//(主体Id, 页号, 每页大小, 总条数)
        //{
        //    throw new NotImplementedException();
        //}
        #endregion
        #endregion
        #region 测试
        /// <summary>
        /// 创建一场评论
        /// </summary>
        public async Task CreateCommentBody(ObjectId commentBodyId, SourceType sourceType, long sourceId)//(来源type, 来源Id)
        {
            CommentBody body = new CommentBody();

            body._id          = commentBodyId;
            body.SourceType   = sourceType;
            body.SourceId     = sourceId;
            body.ControlState = ControlState.Closed;
            body.CreateTime   = DateTime.Now;
            var collection = Session.GetBsonCollection(CommentBody.CollectionName);
            await collection.InsertOneAsync(body.ToBsonDocument());
        }
Beispiel #5
0
        /// <summary>
        /// 获得评论列表
        /// </summary>
        /// <param name="ArticleId"></param>
        /// <returns></returns>
        public static List <CommentBody> GetCommentBodyList(string ArticleId)
        {
            var commentBodyList = new List <CommentBody>();
            var commentlist     = Comment.GetCommentListByArticleId(ArticleId);

            foreach (var comment in commentlist)
            {
                var commentbody = new CommentBody();
                commentbody.CommentInfo   = comment;
                commentbody.AuthorInfo    = UserInfo.GetUserInfoBySn(comment.OwnerId);
                commentbody.HasSubComment = (string.IsNullOrEmpty(comment.ReplyCommentID) && Comment.HasSubComment(comment.Sn));
                commentBodyList.Add(commentbody);
            }
            return(commentBodyList);
        }
Beispiel #6
0
        public Task SendCommentAsync(CommentBody commentBody, CancellationTokenSource cancellationTokenSource) =>
        Task.Run(async() => {
            try {
                DrivenEvent announceActor = new DrivenEvent()
                {
                    Id        = Guid.NewGuid().ToString(),
                    EventType = DrivenActorEvents.CommentPost,
                    Data      = JsonConvert.SerializeObject(commentBody),
                };

                string url         = BaseSingleton <GlobalSetting> .Instance.RestEndpoints.AnnouncementEndPoints.NewAnnounce;
                string accessToken = BaseSingleton <GlobalSetting> .Instance.UserProfile.AccesToken;

                await _requestProvider.PostAsync <object, DrivenEvent>(url, announceActor, accessToken);
            }
            catch (ServiceAuthenticationException) {
                await _identityService.LogOutAsync();
            }
            catch (Exception exc) {
                Crashes.TrackError(exc);
            }
        }, cancellationTokenSource.Token);
Beispiel #7
0
        private async Task SingleTest()
        {
            var sourceType = SourceType.FootballMatch;
            var sourceId   = 1;
            var userId1    = 1;
            var userId2    = 2;
            var userId3    = 2;
            //创建足球比赛的评论主体
            await Business.CreateCommentBody(sourceType, sourceId);

            //获取刚才创建的评论主体
            CommentBody body = await Business.GetCommentBodyId(sourceType, sourceId);

            //开启评论功能
            await Business.UpdateCommentBodyControlState(body._id, Constants.Enums.ControlState.Available);

            //检查评论开关
            ControlState controlState = await Business.GetCommentBodyControlState(body._id);

            //评论
            await Business.Comment(body._id, userId1, "我是一条评论");

            await Business.Comment(body._id, userId2, "我还是一条评论");

            await Business.Comment(body._id, userId3, "我又是一条评论");

            //获取评论列表
            var details = await Business.GetLatestCommentDetails(body._id, 2);

            //点赞
            foreach (var detail in details)
            {
                await Business.OptIn(detail._id, userId1);

                await Business.OptIn(detail._id, userId2);
            }
        }
Beispiel #8
0
 public async Task <CommentEntryFixed> CreateComment([FromRoute] string nodeId, [FromBody] CommentBody body)
 {
     return(await _alfrescoHttpClient.CreateComment(nodeId, body));
 }
Beispiel #9
0
        public async Task <CommentEntryFixed> CreateComment([FromRoute] string nodeId, [FromBody] CommentBody body)
        {
            var comment = await _alfrescoHttpClient.CreateComment(nodeId, body);

            try
            {
                var nodeInfo = await _alfrescoHttpClient.GetNodeInfo(nodeId);

                var pid = nodeInfo?.GetPid();
            }
            catch (Exception ex)
            {
                Log.Logger?.Error(ex, "Audit log failed");
            }


            return(comment);
        }