public CommentWrapper(Comment comment) { Id = comment.Id; ParentId = comment.ParentId; Page = comment.PageName; Content = comment.Body; Author = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(comment.UserId)); LastModified = (ApiDateTime)comment.Date; Inactive = comment.Inactive; }
public Comment SaveComment(Comment comment) { if (comment == null) throw new NotImplementedException("comment"); if (comment.Id == Guid.Empty) comment.Id = Guid.NewGuid(); var i = Insert("wiki_comments") .InColumnValue("id", comment.Id.ToString()) .InColumnValue("ParentId", comment.ParentId.ToString()) .InColumnValue("PageName", comment.PageName) .InColumnValue("Body", comment.Body) .InColumnValue("UserId", comment.UserId.ToString()) .InColumnValue("Date", TenantUtil.DateTimeToUtc(comment.Date)) .InColumnValue("Inactive", comment.Inactive); db.ExecuteNonQuery(i); return comment; }
public static void DeletePageComment(Page page, Comment newComment) { UserActivity ua = ApplyCustomeActivityParams( ComposeActivityByPage(page), WikiResource.wikiAction_CommentDeleted, newComment.UserId, UserActivityConstants.ActivityActionType, UserActivityConstants.SmallActivity ); PublishInternal(ua); }
private ITagValue[] GetNotifyTags(string pageName, string patternType, Comment comment) { var page = GetPage(pageName); if (page == null) return null; var user = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID); var defPage = VirtualPathUtility.ToAbsolute(WikiManager.ViewVirtualPath); var tags = new List<ITagValue> { new TagValue(Constants.TagPageName, String.IsNullOrEmpty(page.PageName) ? WikiResource.MainWikiCaption : page.PageName), new TagValue(Constants.TagURL, CommonLinkUtility.GetFullAbsolutePath(ActionHelper.GetViewPagePath(defPage, page.PageName))), new TagValue(Constants.TagUserName, user.DisplayUserName()), new TagValue(Constants.TagUserURL, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(user.ID, CommonLinkUtility.GetProductID()))), new TagValue(Constants.TagDate, TenantUtil.DateTimeNow()), new TagValue(Constants.TagPostPreview, HtmlUtility.GetText(EditPage.ConvertWikiToHtml(page.PageName, page.Body, defPage, WikiSection.Section.ImageHangler.UrlFormat, CoreContext.TenantManager.GetCurrentTenant().TenantId), 120)), }; if (comment != null && !string.IsNullOrEmpty(pageName)) ReplyToTagProvider.Comment("wiki", pageName, comment.Id.ToString()); if (!string.IsNullOrEmpty(patternType)) { tags.Add(new TagValue(Constants.TagChangePageType, patternType)); } if (comment != null) { tags.Add(new TagValue(Constants.TagCommentBody, comment.Body)); } return tags.ToArray(); }
public Comment UpdateComment(Comment comment) { var toUpdate = GetComment(comment.Id); if(toUpdate == null) throw new ItemNotFoundException("comment not found"); if (String.IsNullOrEmpty(comment.Body)) throw new ArgumentException(@"comment content cannot be empty", "comment"); toUpdate.Body = comment.Body; toUpdate.UserId = SecurityContext.CurrentAccount.ID; toUpdate.Date = DateTime.UtcNow; var page = GetPage(comment.PageName); WikiActivityPublisher.EditPageComment(page, comment); return SaveComment(comment); }
private void NotifyCommentCreated(Page page, Comment comment) { WikiNotifyClient.SendNoticeAsync( SecurityContext.CurrentAccount.ID.ToString(), Constants.EditPage, PageNameUtil.Encode(page.PageName), null, GetNotifyTags(page.PageName, "new wiki page comment", comment)); WikiActivityPublisher.AddPageComment(page, comment); }
public Comment CreateComment(Comment comment) { if (String.IsNullOrEmpty(comment.PageName)) throw new ArgumentException(@"page name cannot be empty", "comment"); if (String.IsNullOrEmpty(comment.Body)) throw new ArgumentException(@"comment content cannot be empty", "comment"); if (comment.ParentId != Guid.Empty) { var parent = GetComment(comment.ParentId); if (parent == null) throw new ArgumentException(@"comment parent was not found", "comment"); } comment.UserId = SecurityContext.CurrentAccount.ID; comment.Date = DateTime.UtcNow; var page = GetPage(comment.PageName); //WikiActivityPublisher.AddPageComment(page, comment); NotifyCommentCreated(page, comment); return SaveComment(comment); }
public Comment SaveComment(Comment comment) { using (var dao = GetCommentDAO()) { return dao.SaveComment(comment); } }
public CommentInfo GetCommentInfo(Comment comment) { var info = new CommentInfo { CommentID = comment.Id.ToString(), UserID = comment.UserId, TimeStamp = comment.Date, TimeStampStr = comment.Date.Ago(), IsRead = true, Inactive = comment.Inactive, CommentBody = comment.Body, UserFullName = DisplayUserSettings.GetFullUserName(comment.UserId), UserAvatar = GetHtmlImgUserAvatar(comment.UserId), IsEditPermissions = CommunitySecurity.CheckPermissions(new WikiObjectsSecurityObject(comment), Common.Constants.Action_EditRemoveComment), IsResponsePermissions = true, UserPost = CoreContext.UserManager.GetUsers(comment.UserId).Title }; return info; }
private void NotifyCommentCreated(Page page, Comment comment) { WikiNotifyClient.SendNoticeAsync( SecurityContext.CurrentAccount.ID.ToString(), Constants.EditPage, PageNameUtil.ReplaceSpaces(page.PageName), null, GetNotifyTags(page.PageName, "new wiki page comment", comment)); }
public Comment UpdateComment(Comment comment) { var toUpdate = GetComment(comment.Id); if (toUpdate == null) throw new ItemNotFoundException("comment not found"); if (String.IsNullOrEmpty(comment.Body)) throw new ArgumentException(@"comment content cannot be empty", "comment"); CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(comment), ASC.Web.Community.Wiki.Common.Constants.Action_EditRemoveComment); toUpdate.Body = comment.Body; toUpdate.UserId = SecurityContext.CurrentAccount.ID; toUpdate.Date = TenantUtil.DateTimeNow(); return SaveComment(toUpdate); }