コード例 #1
0
        public static CommentInfo ConvertComment(Comment comment, IList<Comment> commentList)
        {
            var userID = comment.UserID;

            CommentInfo c = new CommentInfo
                {
                    CommentID = comment.ID.ToString(),
                    UserID = userID,
                    TimeStamp = comment.Datetime,
                    TimeStampStr = comment.Datetime.Ago(),
                    Inactive = comment.Inactive,
                    CommentBody = comment.Content,
                    UserFullName = DisplayUserSettings.GetFullUserName(userID),
                    UserAvatar = BookmarkingServiceHelper.GetHTMLUserAvatar(userID),
                    IsEditPermissions = BookmarkingPermissionsCheck.PermissionCheckEditComment(comment),
                    IsResponsePermissions = BookmarkingPermissionsCheck.PermissionCheckCreateComment(),
                    UserPost = BookmarkingServiceHelper.GetUserInfo(userID).Title
                };

            var commentsList = new List<CommentInfo>();

            var childComments = GetChildComments(comment, commentList);
            if (childComments != null)
            {
                foreach (var item in childComments)
                {
                    commentsList.Add(ConvertComment(item, commentList));
                }
            }
            c.CommentList = commentsList;
            return c;
        }
コード例 #2
0
 public BookmarkCommentWrapper(Comment comment)
 {
     CreatedBy = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(comment.UserID));
     Updated=Created = (ApiDateTime) comment.Datetime;
     Id = comment.ID;
     Text = comment.Content;
     if (!string.IsNullOrEmpty(comment.Parent))
         ParentId = new Guid(comment.Parent);
 }
コード例 #3
0
		private static IList<Comment> GetChildComments(Comment c, IList<Comment> comments)
		{
			var children = new List<Comment>();
			var commentID = c.ID.ToString();
			foreach (var comment in comments)
			{
				if (commentID.Equals(comment.Parent))
				{
					children.Add(comment);
				}
			}
			return children;
		}
コード例 #4
0
 private static IList<Comment> GetChildComments(Comment c, IList<Comment> comments)
 {
     var commentID = c.ID.ToString();
     return comments.Where(comment => commentID.Equals(comment.Parent)).ToList();
 }
コード例 #5
0
ファイル: BookmarkApi.cs プロジェクト: ridhouan/teamlab.v6.5
 public BookmarkCommentWrapper AddBookmarkComment(long id, string content, Guid parentId)
 {
     var comment = new Comment()
                       {
                                 ID = Guid.NewGuid(),
                               BookmarkID = id,
                               Content = content,
                               Datetime = DateTime.UtcNow,
                               UserID = SecurityContext.CurrentAccount.ID,
                               Parent = parentId.ToString()
                           };
     BookmarkingDao.AddComment(comment);
     return new BookmarkCommentWrapper(comment);
 }
コード例 #6
0
 private string GetOneCommentHtmlWithContainer(Comment comment)
 {
     return CommentsHelper.GetOneCommentHtmlWithContainer(
         Comments,
         BookmarkingConverter.ConvertComment(comment, BookmarkingServiceHelper.GetCurrentInstanse().BookmarkToAdd.Comments),
         comment.Parent.Equals(Guid.Empty.ToString(), StringComparison.CurrentCultureIgnoreCase),
         false);
 }
コード例 #7
0
        private string GetHTMLComment(string text, string commentID)
        {
            var comment = new Comment
                {
                    Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                    UserID = SecurityContext.CurrentAccount.ID
                };

            if (!String.IsNullOrEmpty(commentID))
            {
                comment = _serviceHelper.GetCommentById(commentID);

                comment.Parent = string.Empty;
            }
            comment.Content = HtmlUtility.GetFull(text);

            var defComment = new CommentsList();

            ConfigureComments(defComment);

            var ci = BookmarkingConverter.ConvertComment(comment, BookmarkingServiceHelper.GetCurrentInstanse().BookmarkToAdd.Comments);
            ci.IsEditPermissions = false;
            ci.IsResponsePermissions = false;

            var isRoot = string.IsNullOrEmpty(comment.Parent) || comment.Parent.Equals(Guid.Empty.ToString(), StringComparison.CurrentCultureIgnoreCase);

            return CommentsHelper.GetOneCommentHtmlWithContainer(defComment, ci, isRoot, false);
        }
コード例 #8
0
        public AjaxResponse AddComment(string parrentCommentID, long bookmarkID, string text, string pid)
        {
            var resp = new AjaxResponse { rs1 = parrentCommentID };

            var comment = new Comment
                {
                    Content = HtmlUtility.GetFull(text),
                    Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                    UserID = SecurityContext.CurrentAccount.ID
                };

            var parentID = Guid.Empty;
            try
            {
                if (!string.IsNullOrEmpty(parrentCommentID))
                {
                    parentID = new Guid(parrentCommentID);
                }
            }
            catch
            {
                parentID = Guid.Empty;
            }
            comment.Parent = parentID.ToString();
            comment.BookmarkID = bookmarkID;
            comment.ID = Guid.NewGuid();

            _serviceHelper.AddComment(comment);

            resp.rs2 = GetOneCommentHtmlWithContainer(comment);

            return resp;
        }
コード例 #9
0
ファイル: BookmarkApi.cs プロジェクト: vipwan/CommunityServer
        public BookmarkCommentWrapper AddBookmarkComment(long id, string content, Guid parentId)
        {
            var bookmark = BookmarkingDao.GetBookmarkByID(id);
            if (bookmark == null) throw new ItemNotFoundException("bookmark not found");

            var comment = new Comment
                {
                    ID = Guid.NewGuid(),
                    BookmarkID = id,
                    Content = content,
                    Datetime = DateTime.UtcNow,
                    UserID = SecurityContext.CurrentAccount.ID,
                    Parent = parentId.ToString()
                };
            BookmarkingDao.AddComment(comment);
            return new BookmarkCommentWrapper(comment);
        }
コード例 #10
0
 private static FeedComment ToFeedComment(Comment comment)
 {
     return new FeedComment(comment.UserID)
         {
             Id = comment.ID.ToString(),
             Description = HtmlSanitizer.Sanitize(comment.Content),
             Date = comment.Datetime
         };
 }
コード例 #11
0
        private static Comment ToComment(object[] r)
        {
            var comment = new Comment
                {
                    Bookmark = new Bookmark
                        {
                            ID = Convert.ToInt64(r[0]),
                            URL = Convert.ToString(r[1]),
                            Name = Convert.ToString(r[2]),
                            Description = Convert.ToString(r[3]),
                            UserCreatorID = new Guid(Convert.ToString(r[4])),
                            Date = Convert.ToDateTime(Convert.ToString(r[5]))
                        }
                };

            if (r[6] != null)
            {
                comment.ID = new Guid(Convert.ToString(r[6]));
                comment.Content = Convert.ToString(r[7]);
                comment.UserID = new Guid(Convert.ToString(r[8]));
                comment.Datetime = Convert.ToDateTime(Convert.ToString(r[9]));
            }
            return comment;
        }
コード例 #12
0
 public static bool PermissionCheckEditComment(Comment c)
 {
     return CommunitySecurity.CheckPermissions(new BookmarkPermissionSecurityObject(c.UserID, c.ID), BookmarkingBusinessConstants.BookmarkEditCommentAction);
 }