示例#1
0
        public long SaveComment(AlbumItem image, Comment comment)
        {
            using (var tx = DbManager.BeginTransaction())
            {
                comment.Id = DbManager.ExecuteScalar<long>(
                    Insert("photo_comment")
                    .InColumns(Mappers.CommentColumns)
                    .Values(comment.Id, comment.Text, comment.UserID, PrepareTimestamp(comment.Timestamp), comment.ItemID, comment.ParentId, comment.Inactive)
                    .Identity(1, 0L, true)
                );
                var count = UpdateImageCommentsCount(comment.ItemID);

                tx.Commit();

                NotifyCommentAdd(image, comment);
                return count;
            }
        }
示例#2
0
        private void NotifyCommentAdd(AlbumItem image, Comment newComment)
        {
            var initiatorInterceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            try
            {
                NotifyClient.AddInterceptor(initiatorInterceptor);

                var albumUrl = UrlHelper.GetAbsoluteAlbumUrl(image.Album.Id);
                var albumName = DisplayUserSettings.GetFullUserName(new Guid(image.UserID));
                var eventUrl = UrlHelper.GetAbsoluteEventUrl(image.Album.Event.Id);
                var userName = DisplayUserSettings.GetFullUserName(new Guid(newComment.UserID));
                var userUrl = CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(new Guid(newComment.UserID), ASC.Web.Community.Product.CommunityProduct.ID));
                var commentsUrl = UrlHelper.GetAbsolutePhotoUrl(image.Id);
                var commentText = newComment.Text;

                NotifyClient.SendNoticeAsync(
                            PhotoConst.NewEventComment,
                            image.Album.Event != null ? image.Album.Event.Id.ToString() : "0",
                            null,
                            new TagValue(PhotoConst.TagEventName, image.Album.Event.Name),
                            new TagValue(PhotoConst.TagUserName, userName),
                            new TagValue(PhotoConst.TagUserURL, userUrl),
                            new TagValue(PhotoConst.TagEventUrl, eventUrl),
                            new TagValue(PhotoConst.TagAlbumName, albumName),
                            new TagValue(PhotoConst.TagAlbumURL, albumUrl),
                            new TagValue(PhotoConst.TagPhotoName, image.Name),
                            new TagValue(PhotoConst.TagDate, string.Format("{0:d} {0:t}", newComment.Timestamp)),
                            new TagValue(PhotoConst.TagCommentBody, commentText),
                            new TagValue(PhotoConst.TagURL, commentsUrl));
            }
            finally
            {
                NotifyClient.RemoveInterceptor(initiatorInterceptor.Name);
            }

            PhotoUserActivityPublisher.AddComment(image, newComment);
        }
        public AjaxResponse AddComment(string parrentCommentID, string photoID, string text, string pid)
        {
            var resp = new AjaxResponse {rs1 = parrentCommentID};

            CommunitySecurity.DemandPermissions(PhotoConst.Action_AddComment);

            var storage = StorageFactory.GetStorage();
            image = storage.GetAlbumItem(Convert.ToInt64(photoID));

            var newComment = new Comment(image.Id)
                                 {
                                     Text = text,
                                     Timestamp = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                                     UserID = SecurityContext.CurrentAccount.ID.ToString()
                                 };

            if (!string.IsNullOrEmpty(parrentCommentID))
            {
                newComment.ParentId = Convert.ToInt64(parrentCommentID);
            }

            var count = storage.SaveComment(image, newComment);
            storage.ReadAlbumItem(newComment.ItemID, SecurityContext.CurrentAccount.ID.ToString());

            var odd = count%2 == 1;

            var comment = newComment;

            var info = new CommentInfo
                           {
                               CommentID = comment.Id.ToString(),
                               UserID = new Guid(comment.UserID),
                               TimeStampStr = comment.Timestamp.Ago(),
                               IsRead = true,
                               Inactive = comment.Inactive,
                               CommentBody = comment.Text,
                               UserFullName = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                               UserAvatar = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                               UserPost = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title,
                               IsEditPermissions = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment),
                               IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment)
                           };

            //postParser.Parse(comment.Text);

            var defComment = new CommentsList();
            ConfigureCommentsList(defComment, image);

            resp.rs2 = CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, newComment.ParentId == 0, odd);


            return resp;
        }
        private string GetHTMLComment(string text, string commentID)
        {
            var comment = new Comment(0)
                              {
                                  Text = text,
                                  Timestamp = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                                  UserID = SecurityContext.CurrentAccount.ID.ToString()
                              };

            if (!String.IsNullOrEmpty(commentID))
            {
                var storage = StorageFactory.GetStorage();
                comment = storage.GetComment(Convert.ToInt64(commentID));
                comment.Text = text;
            }

            return GetHTMLComment(comment, true);
        }
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var info = new CommentInfo
                           {
                               CommentID = comment.Id.ToString(),
                               UserID = new Guid(comment.UserID),
                               TimeStamp = comment.Timestamp,
                               TimeStampStr = comment.Timestamp.Ago(),
                               IsRead = true,
                               Inactive = comment.Inactive,
                               CommentBody = comment.Text,
                               UserFullName = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                               UserAvatar = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                               UserPost = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title
                           };

            if (!isPreview)
            {
                info.IsEditPermissions = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment);

                info.IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment);
            }

            var defComment = new CommentsList();
            ConfigureCommentsList(defComment, null);

            return Web.Controls.CommentInfoHelper.CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, comment.ParentId <= 0, false);
        }
		public static void UpdateComment(AlbumItem item, Comment comment, Guid authorID)
        {
            var ua =
                ApplyCustomeActivityParams(
                    ComposeActivityByPhoto(item),
                    Resources.PhotoManagerResource.UserActivity_EditComment,
                    authorID,
                    UserActivityConstants.ActivityActionType,
                    PhotoConst.EditCommentBusinessValue);
            PublishInternal(ua);
        }
 public static void AddComment(AlbumItem item, Comment newComment)
 {
     var ua =
         ApplyCustomeActivityParams(
             ComposeActivityByPhoto(item),
             Resources.PhotoManagerResource.UserActivity_AddComment,
             new Guid (newComment.UserID),
             UserActivityConstants.ActivityActionType,
             PhotoConst.AddCommentBusinessValue);
     ua.HtmlPreview = newComment.Text;
     PublishInternal(ua);
 }