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)); }
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); }
public string GetPreview(string text, string commentID) { var info = GetPrevHTMLComment(text, commentID); var defComment = new CommentsList(); ConfigureComments(defComment, null); return(CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, true, false)); }
public CommentsHub(IArticleRepository articleRepo, IUserRepository usersRepo, ICommentsRepository commentsRepo, INotifiactionsRepository notifyRepo) { commentsHelper = new CommentsHelper(); notifiCountCache = new NotificationsCountService(notifyRepo); articleRepository = articleRepo; usersRepository = usersRepo; commentsRepository = commentsRepo; notoficationsRepository = notifyRepo; }
void BindReceivedMessage() { ReceiveMessageInfo receiveMessage = CommentsHelper.GetReceiveMessage(this.receiveMessageId); this.litAddresser.Text = "管理员"; this.litTitle.Text = receiveMessage.Title; this.litContent.Text = receiveMessage.PublishContent; this.litDate.Time = receiveMessage.PublishDate; CommentsHelper.PostMessageIsRead(this.receiveMessageId); }
void messagesList_RowDeleted(object sender, GridViewDeleteEventArgs e) { Label label = (Label)this.messagesList.Rows[e.RowIndex].FindControl("lblMessage"); if (label != null) { CommentsHelper.DeleteSendedMessage(Convert.ToInt64(label.Text)); } this.BindData(); }
protected void favorites_ItemCommand(object sender, DataListCommandEventArgs e) { int favoriteId = (int)this.favorites.DataKeys[e.Item.ItemIndex]; if (e.CommandName == "Edit") { this.favorites.EditItemIndex = e.Item.ItemIndex; this.BindList(); } if (e.CommandName == "Cancel") { this.favorites.EditItemIndex = -1; this.BindList(); } if (e.CommandName == "Update") { TextBox box = (TextBox)e.Item.FindControl("txtTags"); TextBox box2 = (TextBox)e.Item.FindControl("txtRemark"); if (box.Text.Length > 100) { this.ShowMessage("修改商品收藏信息失败,标签信息的长度限制在100个字符以內", false); return; } if (box2.Text.Length > 500) { this.ShowMessage("修改商品收藏信息失败,备注信息的长度限制在500個字符以內", false); return; } if (CommentsHelper.UpdateFavorite(favoriteId, Globals.HtmlEncode(box.Text.Trim()), Globals.HtmlEncode(box2.Text.Trim())) > 0) { this.favorites.EditItemIndex = -1; this.BindList(); this.ShowMessage("成功的修改了收藏夹的信息", true); } else { this.ShowMessage("没有修改你要修改的內容", false); } } if (e.CommandName == "Deleted") { if (CommentsHelper.DeleteFavorite(favoriteId) > 0) { this.BindList(); this.ShowMessage("成功删除了选择的收藏商品", true); } else { this.ShowMessage("删除失败", false); } } }
private void BindData() { DbQueryResult memberSendedMessages = CommentsHelper.GetMemberSendedMessages(new MessageBoxQuery { PageIndex = this.pager.PageIndex, PageSize = this.pager.PageSize, Sernder = HiContext.Current.User.Username }); this.messagesList.DataSource = memberSendedMessages.Data; this.messagesList.DataBind(); this.pager.TotalRecords = memberSendedMessages.TotalRecords; }
void BindSendMessage() { if (string.IsNullOrEmpty(this.Page.Request.QueryString["SendMessageId"])) { base.GotoResourceNotFound(); } SendMessageInfo sendedMessage = CommentsHelper.GetSendedMessage(long.Parse(this.Page.Request.QueryString["SendMessageId"])); this.litAddresser.Text = HiContext.Current.User.Username; this.litTitle.Text = sendedMessage.Title; this.litDate.Time = sendedMessage.PublishDate; this.litContent.Text = sendedMessage.PublishContent; }
/// <summary> /// 执行 /// </summary> public override void Execute() { CommentsHelper CommentsHelper = HelperFactory.GetHelper <CommentsHelper>(); if (!string.IsNullOrEmpty(ArticleIDByRedirect)) { Records = CommentsHelper.ArticleIDQueryComments(ArticleIDByRedirect, this.StartIndexs, PageSize, null, true); } else { Records = CommentsHelper.ArticleIDQueryComments(ArticleID, this.StartIndexs, PageSize, null, true); } }
void BindData() { SendedMessageQuery query = new SendedMessageQuery(); query.PageIndex = this.pager.PageIndex; query.PageSize = this.pager.PageSize; query.UserName = HiContext.Current.User.Username; DbQueryResult sendedMessages = CommentsHelper.GetSendedMessages(query); this.messagesList.DataSource = sendedMessages.Data; this.messagesList.DataBind(); this.pager.TotalRecords = sendedMessages.TotalRecords; }
protected void btnDeleteSelect_Click(object sender, EventArgs e) { string ids = this.Page.Request["CheckboxGroup"]; if (!CommentsHelper.DeleteFavorites(ids)) { this.ShowMessage("删除失败", false); } else { this.BindList(); } }
private void BindPtAndReviewsAndReplys() { UserProductReviewAndReplyQuery userProductReviewAndReplyQuery = new UserProductReviewAndReplyQuery(); userProductReviewAndReplyQuery.PageIndex = this.pager.PageIndex; userProductReviewAndReplyQuery.PageSize = this.pager.PageSize; int totalRecords = 0; DataSet userProductReviewsAndReplys = CommentsHelper.GetUserProductReviewsAndReplys(userProductReviewAndReplyQuery, out totalRecords); this.dlstPts.DataSource = userProductReviewsAndReplys.Tables[0].DefaultView; this.dlstPts.DataBind(); this.pager.TotalRecords = totalRecords; }
void BindPtConsultationReply() { ProductConsultationAndReplyQuery query = new ProductConsultationAndReplyQuery(); query.PageIndex = this.pagerConsultationReply.PageIndex; query.UserId = HiContext.Current.User.UserId; query.Type = ConsultationReplyType.NoReply; int total = 0; DataSet productConsultationsAndReplys = CommentsHelper.GetProductConsultationsAndReplys(query, out total); this.dlstPtConsultationReply.DataSource = productConsultationsAndReplys.Tables[0].DefaultView; this.dlstPtConsultationReply.DataBind(); this.pagerConsultationReply.TotalRecords = total; }
private void BindPtConsultationReplyed() { ProductConsultationAndReplyQuery productConsultationAndReplyQuery = new ProductConsultationAndReplyQuery(); productConsultationAndReplyQuery.PageIndex = this.pagerConsultationReplyed.PageIndex; productConsultationAndReplyQuery.UserId = HiContext.Current.User.UserId; productConsultationAndReplyQuery.Type = ConsultationReplyType.Replyed; int totalRecords = 0; DataSet productConsultationsAndReplys = CommentsHelper.GetProductConsultationsAndReplys(productConsultationAndReplyQuery, out totalRecords); this.dlstPtConsultationReplyed.DataSource = productConsultationsAndReplys.Tables[0].DefaultView; this.dlstPtConsultationReplyed.DataBind(); this.pagerConsultationReplyed.TotalRecords = totalRecords; }
protected override ISpanned Convert(List <FeedEngagementModel> engagementList, Type targetType, object parameter, CultureInfo culture) { int allowedTotal = 3; if (parameter != null) { allowedTotal = (Int32)parameter; } if (engagementList == null) { return(CommentsHelper.BuildComments(engagementList)); } List <FeedEngagementModel> commentList = new List <FeedEngagementModel>(); foreach (FeedEngagementModel engagement in engagementList) { if (commentList.Count == allowedTotal) { break; } var ContainErrorEmoji = engagement.Notes.Contains('?'); if (!ContainErrorEmoji) { try { var convertStr = string.Join("-", System.Text.RegularExpressions.Regex.Matches(engagement.Notes, @"..").Cast <System.Text.RegularExpressions.Match>().ToList()); string[] tempArr = convertStr.Split('-'); byte[] decBytes = new byte[tempArr.Length]; for (int i = 0; i < tempArr.Length; i++) { decBytes[i] = System.Convert.ToByte(tempArr[i], 16); } string strWithEmoji = Encoding.BigEndianUnicode.GetString(decBytes, 0, decBytes.Length); engagement.Notes = strWithEmoji; commentList.Add(engagement); } catch (FormatException) { commentList.Add(engagement); } } else if (engagement.EngagementType == "COMMENT") { commentList.Add(engagement); } } return(CommentsHelper.BuildComments(commentList)); }
protected override void AttachChildControls() { this.dlstPts = (ThemedTemplatedList)this.FindControl("dlstPts"); this.pager = (Pager)this.FindControl("pager"); this.litReviewCount = (System.Web.UI.WebControls.Literal) this.FindControl("litReviewCount"); PageTitle.AddSiteNameTitle("我参与的评论", HiContext.Current.Context); if (!this.Page.IsPostBack) { if (this.litReviewCount != null) { this.litReviewCount.Text = CommentsHelper.GetUserProductReviewsCount().ToString(); } this.BindPtAndReviewsAndReplys(); } }
void ReplyClicked(Comment model) { var source = tvComments.Source as CustomListSource <Comment>; var newExpandedCommentId = string.IsNullOrEmpty(model.ParentCommentId) ? model.Id : model.ParentCommentId; if (expandedCommentId == newExpandedCommentId) { SetExpandedCommentId(null); source.Items = CommentsHelper.GetCommentsWithReply(source.AllItems, expandedCommentId); tvComments.ReloadData(); return; } SetExpandedCommentId(newExpandedCommentId); source.Items = CommentsHelper.GetCommentsWithReply(source.AllItems, expandedCommentId); tvComments.ReloadData(); }
/// <summary> /// 启用或禁用评论 /// </summary> /// <param name="state"></param> void SetState(int state) { List <string> ids = GetIDs(); if (ids.Count < 1) { MessageLabel.Text = "你没有选择任何一条记录"; MessagePanel.Visible = true; return; } string aTitle = ""; string content = ""; foreach (string id in ids) { Comments c = new Comments(); c.ID = id; c.State = state; CommentsHelper.UpdateComments(c, new string[] { "ID", "State" }); c = CommentsHelper.GetComment(id, new string[] { "Content" }); string con = c.Content; if (c.Content.Length > 10) { con = c.Content.Substring(0, 10); } aTitle += String.Format("{0};", con); } MessageLabel.Text = string.Format("您已经成功启用{0}条评论", ids.Count.ToString()); content = string.Format("启用了{0}条评论:“{1}”", ids.Count.ToString(), aTitle); if (state == 0) { MessageLabel.Text = string.Format("您已经成功禁用{0}条评论", ids.Count.ToString()); content = string.Format("禁用了{0}条评论:“{1}”", ids.Count.ToString(), aTitle); } AddLog("评论管理", content); MessagePanel.Visible = true; LoadComments(); }
void BindData() { ReceivedMessageQuery query = new ReceivedMessageQuery(); query.PageIndex = this.pager.PageIndex; query.PageSize = this.pager.PageSize; query.UserName = HiContext.Current.User.Username; DbQueryResult receivedMessages = CommentsHelper.GetReceivedMessages(query); if (((DataTable)receivedMessages.Data).Rows.Count <= 0) { query.PageIndex = this.messagesList.PageIndex - 1; receivedMessages = CommentsHelper.GetReceivedMessages(query); this.messagesList.DataSource = receivedMessages.Data; } this.messagesList.DataSource = receivedMessages.Data; this.messagesList.DataBind(); this.pager.TotalRecords = receivedMessages.TotalRecords; }
private void BindData() { MessageBoxQuery messageBoxQuery = new MessageBoxQuery(); messageBoxQuery.PageIndex = this.pager.PageIndex; messageBoxQuery.PageSize = this.pager.PageSize; messageBoxQuery.Accepter = HiContext.Current.User.Username; DbQueryResult memberReceivedMessages = CommentsHelper.GetMemberReceivedMessages(messageBoxQuery); if (((DataTable)memberReceivedMessages.Data).Rows.Count <= 0) { messageBoxQuery.PageIndex = this.messagesList.PageIndex - 1; memberReceivedMessages = CommentsHelper.GetMemberReceivedMessages(messageBoxQuery); this.messagesList.DataSource = memberReceivedMessages.Data; } this.messagesList.DataSource = memberReceivedMessages.Data; this.messagesList.DataBind(); this.pager.TotalRecords = memberReceivedMessages.TotalRecords; }
private void BindList() { Pagination page = new Pagination(); page.PageIndex = this.pager.PageIndex; page.PageSize = this.pager.PageSize; string tags = string.Empty; if (!string.IsNullOrEmpty(this.Page.Request.QueryString["keyword"])) { tags = this.Page.Request.QueryString["keyword"]; } DbQueryResult favorites = CommentsHelper.GetFavorites(tags, page); this.favorites.DataSource = favorites.Data; this.favorites.DataBind(); this.txtKeyWord.Text = tags; this.pager.TotalRecords = favorites.TotalRecords; }
public void BindingData() { bool enableCache = (CDHelper.Config.EnableCache == "true"); List <Comments> result = null; List <Comments> list = CommentsHelper.GetAllComments(AccountID, 0, 5); if (list != null) { foreach (Comments comments in list) { if (comments.Content.Length > 25) { comments.Content = comments.Content.Substring(0, 25) + "..."; } } } result = list; DataGridView.DataSource = result; DataGridView.DataBind(); }
private void btnDeleteSelect_Click(object sender, System.EventArgs e) { System.Collections.Generic.IList <long> list = new System.Collections.Generic.List <long>(); foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.messagesList.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow.FindControl("checkboxCol"); if (checkBox != null && checkBox.Checked) { list.Add(System.Convert.ToInt64(this.messagesList.DataKeys[gridViewRow.RowIndex].Value)); } } if (list.Count > 0) { CommentsHelper.DeleteMemberMessages(list); this.BindData(); } else { this.ShowMessage("请选中要删除的信息", false); } }
void btnRefer_Click(object sender, EventArgs e) { string str = ""; if (string.IsNullOrEmpty(this.txtTitle.Text) || (this.txtTitle.Text.Length > 60)) { str = str + Formatter.FormatErrorMessage("标题不能为空,长度限制在1-60个字符内"); } if (string.IsNullOrEmpty(this.txtContent.Text) || (this.txtContent.Text.Length > 300)) { str = str + Formatter.FormatErrorMessage("内容不能为空,长度限制在1-300个字符内"); } if (!string.IsNullOrEmpty(str)) { this.ShowMessage(str, false); } else { IList <SendMessageInfo> sendMessageList = new List <SendMessageInfo>(); IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>(); SendMessageInfo item = new SendMessageInfo(); ReceiveMessageInfo info2 = new ReceiveMessageInfo(); item.Addresser = info2.Addresser = HiContext.Current.User.Username; item.Addressee = info2.Addressee = "admin"; item.Title = info2.Title = this.txtTitle.Text.Replace("~", ""); item.PublishContent = info2.PublishContent = this.txtContent.Text.Replace("~", ""); sendMessageList.Add(item); receiveMessageList.Add(info2); this.txtTitle.Text = string.Empty; this.txtContent.Text = string.Empty; if (CommentsHelper.SendMessage(sendMessageList, receiveMessageList) > 0) { this.ShowMessage("发送信息成功", true); } else { this.ShowMessage("发送信息失败", true); } } }
protected void DeleteBtn_Click(object sender, EventArgs e) { if (DemoSiteMessage) { return; //是否是演示站点 } List <string> ids = GetIDs(); if (ids.Count < 1) { MessageLabel.Text = "你没有选择任何一条记录"; MessagePanel.Visible = true; return; } string aTitle = ""; foreach (string id in ids) { Comments c = CommentsHelper.GetComment(id, new string[] { "Content" }); CommentsHelper.DeleteComment(id); string con = c.Content; if (c.Content.Length > 10) { con = c.Content.Substring(0, 10); } aTitle += String.Format("{0};", con); } //记录日志 string content = string.Format("删除了{0}条评论:“{1}”", ids.Count.ToString(), aTitle); AddLog("评论管理", content); MessageLabel.Text = string.Format("您已经成功删除{0}条记录", ids.Count.ToString()); MessagePanel.Visible = true; LoadComments(); }
private string RenderComments(IList <CommentInfo> comments, string userPageLinkWithParam, int commentLevel) { var sb = new StringBuilder(); if (comments != null && comments.Count > 0) { foreach (var comment in comments) { comment.CommentBody = HtmlUtility.GetFull(comment.CommentBody, ProductId); sb.Append( CommentsHelper.GetOneCommentHtmlWithContainer( this, comment, commentLevel == 1 || commentLevel > maxDepthLevel, cmnts => RenderComments(cmnts, userPageLinkWithParam, commentLevel + 1), ref commentIndex ) ); } } return(sb.ToString()); }
private void btnDeleteSelect_Click(object sender, EventArgs e) { IList <long> messageList = new List <long>(); foreach (GridViewRow row in this.messagesList.Rows) { CheckBox box = (CheckBox)row.FindControl("checkboxCol"); if ((box != null) && box.Checked) { messageList.Add(Convert.ToInt64(this.messagesList.DataKeys[row.RowIndex].Value)); } } if (messageList.Count > 0) { CommentsHelper.DeleteMemberMessages(messageList); this.BindData(); } else { this.ShowMessage("请选中要删除的信息", false); } }
private string GetHTMLComment(Comment comment, bool isPreview) { var creator = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy); var commentInfo = new CommentInfo { CommentID = comment.ID.ToString(), UserID = comment.CreateBy, TimeStamp = comment.CreateOn, TimeStampStr = comment.CreateOn.Ago(), UserPost = creator.UserInfo.Title, IsRead = true, Inactive = comment.Inactive, CommentBody = comment.Content, UserFullName = DisplayUserSettings.GetFullUserName(creator.UserInfo), UserAvatar = Global.GetHTMLUserAvatar(creator.UserInfo) }; var defComment = new CommentsList(); ConfigureComments(defComment, null); if (!isPreview) { var targetID = Convert.ToInt32(comment.TargetUniqID.Split('_')[1]); var target = Global.EngineFactory.GetMessageEngine().GetByID(targetID); Discussion = target; commentInfo.IsEditPermissions = ProjectSecurity.CanEditComment(Discussion, comment); commentInfo.IsResponsePermissions = ProjectSecurity.CanCreateComment(Discussion); commentInfo.IsRead = true; } return(CommentsHelper.GetOneCommentHtmlWithContainer( defComment, commentInfo, comment.Parent == Guid.Empty, false)); }
void GetData() { var apiTask = new ServiceApi().GetComments(PostId); apiTask.HandleError(); apiTask.OnSucess(response => { source = new CustomListSource <Comment> (response.Result, GetCell, (arg1, arg2) => UITableView.AutomaticDimension); source.Items = CommentsHelper.GetCommentsWithReply(source.AllItems, expandedCommentId); source.NoContentText = "No Comments"; tvComments.Source = source; Count = response.Result.Count; LoadingScreen.Hide(); UpdateParent?.Invoke(Name, Count); tvComments.ReloadData(); if (response.Result.Any()) { tvComments.ScrollToRow(NSIndexPath.FromRowSection(source.Items.Count - 1, 0), UITableViewScrollPosition.Bottom, false); } }); }