private void BindContent() { BehaviorAdvicePageItem item = Sitecore.Context.Item; litCommentsCount.Text = CommunityHelper.GetTotalComments(item.BlogId.Raw, item.BlogPostId.Raw).ToString(); litHelpfulCount.Text = CommunityHelper.GetTotalLikes(item.ContentId.Raw).ToString(); }
private void SortFavorites() { String sort = ddlSort.SelectedValue; List <FavoritesModel> favoritesList = CommunityHelper.GetFavorites(CurrentMember.MemberId); if (sort == UnderstoodDotOrg.Common.Constants.MyAccountSearchValues.MostRecent.ToString()) { favoritesList = favoritesList.OrderByDescending(x => x.Date).ToList(); } else if (sort == UnderstoodDotOrg.Common.Constants.MyAccountSearchValues.OldestToNewest.ToString()) { favoritesList = favoritesList.OrderBy(x => x.Date).ToList(); } else if (sort == UnderstoodDotOrg.Common.Constants.MyAccountSearchValues.NumberOfComments.ToString()) { favoritesList = favoritesList.OrderByDescending(x => x.ReplyCount).ToList(); } else if (sort == UnderstoodDotOrg.Common.Constants.MyAccountSearchValues.RecentComments.ToString()) { favoritesList = favoritesList.OrderByDescending(x => x.RecentCommentDate).ToList(); } if ((favoritesList != null) && (favoritesList.Count != 0)) { pnlFavorites.Visible = true; rptFavorites.DataSource = favoritesList; rptFavorites.DataBind(); } else { pnlNoFavorites.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (CurrentMember.ScreenName == null) { pnlNoProfile.Visible = true; } else { List <GroupCardModel> groupsList = TelligentService.GetUserGroups(CurrentMember.ScreenName); ddlGroups.DataSource = groupsList; ddlGroups.DataValueField = "Url"; ddlGroups.DataTextField = DictionaryConstants.TitleLabel; ddlGroups.DataBind(); if (ddlGroups.Items.Count != 0) { pnlGroups.Visible = true; divStartADiscussion.Visible = true; hypStartADiscussion.NavigateUrl = ddlGroups.SelectedItem.Value + "/MyDiscussion%20Board"; var commentsList = CommunityHelper.ReadComments(); var commentsByGroup = commentsList.Where(x => x.ParentTitle == ddlGroups.SelectedItem.Text); if (commentsList != null) { rptComments.DataSource = commentsByGroup; rptComments.DataBind(); } } else { pnlNoGroups.Visible = true; } } } }
private void AddContentTypeId(Item item, string blogId, string blogPostId) { using (var webClient = new WebClient()) { try { webClient.Headers.Add("Rest-User-Token", CommunityHelper.TelligentAuth()); var requestUrl = CommunityHelper.GetApiEndPoint(String.Format("blogs/{0}/posts/{1}.xml", blogId, blogPostId)); var xml = webClient.DownloadString(requestUrl); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); XmlNode node = xmlDoc.SelectSingleNode("Response/BlogPost"); XmlNode auth = xmlDoc.SelectSingleNode("Response/BlogPost/Author"); var contentTypeId = node["ContentTypeId"].InnerText; item.Editing.BeginEdit(); try { item["ContentTypeId"] = contentTypeId; } catch { } item.Editing.EndEdit(); } catch { } // TODO: Add logging } }
public ReplyModel(XmlNode node) { this.AuthorName = node.SelectSingleNode("Author/Username").InnerText; this.Body = CommunityHelper.FormatString100(node.SelectSingleNode("Body").InnerText); this.ReplyDate = UnderstoodDotOrg.Common.Helpers.DataFormatHelper.FormatDate(node.SelectSingleNode("Date").InnerText); this.Date = Convert.ToDateTime((node.SelectSingleNode("Date").InnerText)); this.ContentId = node.SelectSingleNode("ContentId").InnerText; this.ContentTypeId = node.SelectSingleNode("ContentTypeId").InnerText; }
private void createCommunityUser() { //pulling this out of membership manager for now until we find the best place. //It had been in AddMember berfore but there is no screen name available when we Add a member. //create Telligent user: var tMember = TelligentService.GetPosesMember(this.CurrentMember.ScreenName); //if we have a screen name and it doesn't exist in Telligent yet... if (!string.IsNullOrEmpty(this.CurrentMember.ScreenName) && !string.IsNullOrEmpty(this.CurrentUser.Email) && tMember == null) { try { bool communitySuccess = CommunityHelper.CreateUser(this.CurrentMember.ScreenName, this.CurrentUser.Email); //bool communitySuccess = CommunityHelper.CreateUser(CurrentMember.ScreenName, CurrentUser.Email); if (communitySuccess == false) { // ¡Ay, caramba! // give them a nice "I'm sorry" please try again later message. //uxErrorMessage.Text = "<font color=red> </ font> "; //uxErrorMessage.Visible = true; //err = true; //dont progress. stop and display an error. throw new Exception("I'm sorry, the Community User failed to be created properly."); } } catch (Exception ex) { //bg: we need a generic procedure for handling errors so that we can display important data properly without being gross //uxErrorMessage.Text = "<font color=red>I'm sorry, an error has occured while trying to create the Community User. <hr> " + // "Message: " + ex.Message + Environment.NewLine + // "Source: " + ex.Source + Environment.NewLine + "<hr>" + // "Stack Trace: " + ex.StackTrace + Environment.NewLine + // "Inner Message: " + ex.InnerException.Message + Environment.NewLine + // "Inner Source: " + ex.InnerException.Source + Environment.NewLine + // "Inner Stack Trace: " + ex.InnerException.StackTrace + // "</font>"; //uxErrorMessage.Visible = true; //err = true; throw ex; } } //if (!string.IsNullOrEmpty(CurrentMember.ScreenName)) //optional to the user //{ // if (mode != Constants.QueryStrings.Registration.ModeEdit) // { // } // } //} }
private void PopulateSortOptions() { var options = CommunityHelper.GetCommentSortOptions(); if (options.Any()) { rptSortOptions.DataSource = options; rptSortOptions.DataBind(); } }
protected void ddlGroups_SelectedIndexChanged(object sender, EventArgs e) { var commentsList = CommunityHelper.ReadComments(); if (commentsList != null) { rptComments.DataSource = commentsList.Where(x => x.ParentTitle == ddlGroups.SelectedItem.Text); rptComments.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { BlogsPostPageItem blogCig = new BlogsPostPageItem(Sitecore.Context.Item); litFormattedDate.Text = blogCig.Date.DateTime.ToString("M/dd/yyyy"); BlogsAuthorPageItem author = Sitecore.Context.Database.GetItem(blogCig.Author.Raw); linkAuthor.HRef = linkAuthor2.HRef = linkAuthor3.HRef = LinkManager.GetItemUrl(author); litAuthorBio.Text = CommunityHelper.FormatString100(author.Biography.Text) + "..."; litAuthor.Text = litAuthor2.Text = author.Name; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var items = CommunityHelper.GetMyAccountCommentsSortOptions(); foreach (var item in items) { ddlSort.Items.Add(new ListItem() { Text = item.Description, Value = item.Value }); } ddlSort.DataBind(); foreach (ListItem item in ddlSort.Items) { if (item.Value == UnderstoodDotOrg.Common.Constants.MyAccountSearchValues.MostRecent.ToString()) { ddlSort.SelectedValue = item.Value; break; } } SortComments(); } if (string.IsNullOrEmpty(CurrentMember.ScreenName)) { pnlNoProfile.Visible = true; //TODO: add navigate URL for hypCompleteYourProfile } else { int totalComments; var commentsList = TelligentService.GetUserCommentsByScreenName(CurrentMember.ScreenName, 1, Constants.PUBLIC_PROFILE_COMMENTS_PER_PAGE, out totalComments); if ((commentsList != null) && (commentsList.Count != 0)) { pnlComments.Visible = true; rptComments.DataSource = commentsList; rptComments.DataBind(); } else { pnlNoComments.Visible = true; } } }
private void CreateTelligentPost(Item item, int blogId) { var requestUrl = string.Format( "{0}api.ashx/v2/blogs/{1}/posts.xml", Settings.GetSetting(Constants.Settings.TelligentConfig), blogId); var values = new NameValueCollection { // Append ID to keep title unique { "Title", String.Format("{0} {1}", item.Name, item.ID.ToString()) }, { "Body", item.ID.ToString() } }; try { using (var webClient = new WebClient()) { var adminKeyBase64 = CommunityHelper.TelligentAuth(); webClient.Headers.Add("Rest-User-Token", adminKeyBase64); var xml = Encoding.UTF8.GetString(webClient.UploadValues(requestUrl, values)); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); var node = xmlDoc.SelectSingleNode("Response/BlogPost"); var blogPostId = node["Id"].InnerText; var contentId = node["ContentId"].InnerText; var contentTypeId = node["ContentTypeId"].InnerText; var telligentUrl = node["Url"].InnerText; using (new Sitecore.Data.Items.EditContext(item, updateStatistics: false, silent: true)) { item["BlogPostId"] = blogPostId; item["BlogId"] = blogId.ToString(); item["ContentId"] = contentId; item["ContentTypeId"] = contentTypeId; item["TelligentUrl"] = telligentUrl; } } } catch (Exception ex) { Sitecore.Diagnostics.Log.Error( String.Format("Telling post handler failed: {0}", requestUrl), ex, this); } }
private void Page_Load(object sender, EventArgs e) { string blogId = Request.QueryString["BlogId"]; List <UnderstoodDotOrg.Domain.TelligentCommunity.BlogPost> dataSource = CommunityHelper.ListBlogPosts(blogId, "100"); foreach (var item in dataSource) { BlogsPostPageItem blogPost = Sitecore.Context.Database.GetItem("/Sitecore/Content/Home/Community and Events/Blogs/" + item.BlogName + "/" + item.Title); item.Author = blogPost.Author.Rendered; item.Body = CommunityHelper.FormatString100(CommunityHelper.FormatRemoveHtml(blogPost.Body.Raw)); item.AuthorUrl = "/Community and Events/Blogs/Author/" + item.Author; } rptBlogInfo.DataSource = dataSource; rptBlogInfo.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { var dataSource = CommunityHelper.ListBlogPosts(Settings.GetSetting(Constants.Settings.TelligentBlogIds), "3"); foreach (var item in dataSource) { if (item.Title.Contains("{")) { string[] s = item.Title.Split('{'); item.Title = s[0].Trim(); } } rptMostShared.DataSource = dataSource; rptMostShared.DataBind(); }
private void BindContent() { BehaviorAdvicePageItem item = Sitecore.Context.Item; ActivityLog log = new ActivityLog(); litCommentsCount.Text = CommunityHelper.GetTotalComments(item.BlogId.Raw, item.BlogPostId.Raw).ToString(); Guid contentId; int helpfulCount = 0; if (Guid.TryParse(Model.BehaviorAdvicePage.ContentId.Raw, out contentId)) { helpfulCount = log.GetActivityCountByValue(contentId, Constants.UserActivity_Values.FoundHelpful_True); } litHelpfulCount.Text = helpfulCount.ToString(); }
protected void Page_Load(object sender, EventArgs e) { var commentsList = TelligentService.ReadComments(Settings.GetSetting(Constants.Settings.TelligentBlogIds)); if (commentsList.Any()) { litAuthor.Text = commentsList[0].AuthorDisplayName; litCommentSnippet.Text = CommunityHelper.FormatString100(commentsList[0].Body); litDateTime.Text = commentsList[0].PublishedDate; string[] s = commentsList[0].ParentTitle.Split('{'); litTitle.Text = s[0]; linkReadMore.HRef = linkTitle.HRef = commentsList[0].Url; } else { this.Visible = false; } }
public Comment(XmlNode xn) { if (xn != null) { XmlNode author = xn.SelectSingleNode("User"); string commentId = xn["CommentId"].InnerText; string commentDate = xn["CreatedDate"].InnerText; DateTime parsedDate = DateTime.Parse(commentDate); Id = commentId; //Url = xn["Url"].InnerText; // ParentId = xn["ParentId"].InnerText; // ContentId = xn["ContentId"].InnerText; IsApproved = xn["IsApproved"].InnerText; ReplyCount = xn["ReplyCount"].InnerText; CommentId = commentId; CommentContentTypeId = xn["CommentContentTypeId"].InnerText; Body = xn["Body"].InnerText; PublishedDate = UnderstoodDotOrg.Common.Helpers.DataFormatHelper.FormatDate(commentDate); AuthorId = author["Id"].InnerText; AuthorAvatarUrl = author["AvatarUrl"].InnerText; AuthorDisplayName = author["DisplayName"].InnerText; AuthorProfileUrl = author["ProfileUrl"].InnerText; AuthorUsername = author["Username"].InnerText; Likes = CommunityHelper.GetTotalLikes(commentId).ToString(); CommentDate = parsedDate; ParentTitle = xn["Content"]["Application"]["Container"]["HtmlName"].InnerText; CommentTitle = xn["Content"]["HtmlName"].InnerText; SitecoreItemId = CommentTitle.Substring(CommentTitle.IndexOf("{")); if (!string.IsNullOrEmpty(SitecoreItemId)) { CommentTitle = CommentTitle.Replace(SitecoreItemId, ""); } SitecoreItem = !string.IsNullOrEmpty(SitecoreItemId) ? Sitecore.Context.Database.GetItem(SitecoreItemId) : null; Type = xn["Content"]["Application"]["HtmlName"].InnerText; Url = SitecoreItem != null?SitecoreItem.GetUrl() : "/"; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var items = CommunityHelper.GetMyAccountFavoritesSortOptions(); foreach (var item in items) { ddlSort.Items.Add(new ListItem() { Text = item.Description, Value = item.Value }); } ddlSort.DataBind(); foreach (ListItem item in ddlSort.Items) { if (item.Value == UnderstoodDotOrg.Common.Constants.MyAccountSearchValues.MostRecent.ToString()) { ddlSort.SelectedValue = item.Value; break; } } SortFavorites(); } var favoritesList = CommunityHelper.GetFavorites(CurrentMember.MemberId); if ((favoritesList != null) && (favoritesList.Count != 0)) { pnlFavorites.Visible = true; rptFavorites.DataSource = favoritesList; rptFavorites.DataBind(); } else { pnlNoFavorites.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { int page; int sortBy; if (int.TryParse(ResultPage, out page) && int.TryParse(SortBy, out sortBy)) { int pageSize = Constants.ARTICLE_COMMENTS_PER_PAGE; int totalResults; bool hasMoreResults; var sortOptions = CommunityHelper.GetCommentSortOptions(); CommentSortOption sortOption = null; try { sortOption = sortOptions[sortBy]; } catch { return; } // Fallback for no sorting if (sortBy == 0) { sortOption = new CommentSortOption { Value = Constants.TelligentCommentSort.CreateDate, SortAscending = true }; } var comments = TelligentService.ReadComments(BlogId, PostId, page, pageSize, sortOption, out totalResults, out hasMoreResults); if (comments.Any()) { commentsControl.Comments = comments; phMoreResults.Visible = hasMoreResults; } } }
private void BindData(Item thePage) { string BlogId = ""; string BlogPostId = ""; if (thePage.InheritsTemplate(DefaultArticlePageItem.TemplateId)) { BlogId = new DefaultArticlePageItem(thePage).BlogId.Raw; BlogPostId = new DefaultArticlePageItem(thePage).BlogPostId.Raw; } else if (thePage.InheritsTemplate(BehaviorToolsAdvicePageItem.TemplateId)) { BlogId = new BehaviorAdvicePageItem(thePage).BlogId.Raw; BlogPostId = new BehaviorAdvicePageItem(thePage).BlogPostId.Raw; } ActivityLog tempLog = new ActivityLog(); //ContentId, ActivityValue int helpfulCount = tempLog.GetActivityCountByValue(new Guid(Sitecore.Context.Item.ID.ToString()), Constants.UserActivity_Values.FoundHelpful_True); int commentCount = 0; if (!string.IsNullOrEmpty(BlogId) && !string.IsNullOrEmpty(BlogPostId)) { commentCount = CommunityHelper.GetTotalComments(BlogId, BlogPostId); } lblHelpfulCount.Text = lblHelpfulCountMobile.Text = helpfulCount.ToString(); lblCommentCount.Text = lblCommentCountMobile.Text = commentCount.ToString(); ltlFoundThisHelpful.Text = ltlFoundThisHelpfulMobile.Text = DictionaryConstants.FoundThisHelpful; string commentLabel = DictionaryConstants.PluralCommentLabel; if (commentCount == 1) { commentLabel = DictionaryConstants.SingleCommentLabel; } ltlComments.Text = ltlCommentsMobile.Text = commentLabel; }
private void createCommunityUser() { var tMember = TelligentService.GetPosesMember(this.CurrentMember.ScreenName); //if we have a screen name and it doesn't exist in Telligent yet... if (!string.IsNullOrEmpty(this.CurrentMember.ScreenName) && !string.IsNullOrEmpty(this.CurrentUser.Email) && tMember == null) { try { bool communitySuccess = CommunityHelper.CreateUser(this.CurrentMember.ScreenName, this.CurrentUser.Email); if (communitySuccess == false) { throw new Exception("I'm sorry, the Community User failed to be created properly."); } } catch (Exception ex) { throw ex; } } }
protected void Page_Load(object sender, EventArgs e) { MyAccountItem context = (MyAccountItem)Sitecore.Context.Item; var item = Sitecore.Context.Database.GetItem(Constants.Pages.MyAccountFavorites); hypFavoritesTab.NavigateUrl = Sitecore.Links.LinkManager.GetItemUrl(item); hypFavoritesTab.Text = context.SeeAllFavoritesText; var favoritesList = CommunityHelper.GetFavorites(CurrentMember.MemberId); litCount.Text = favoritesList != null?favoritesList.Count.ToString() : "0"; if ((favoritesList != null) && (favoritesList.Count != 0)) { pnlFavorites.Visible = true; rptFavorites.DataSource = favoritesList.Count < 3 ? favoritesList.GetRange(0, favoritesList.Count) : favoritesList.GetRange(0, 3); rptFavorites.DataBind(); } else { pnlNoFavorites.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { Guid?ContentId = new Guid(blogCig.ContentId.Raw); // Guid ContentId = new Guid(blogCig.ContentId.Raw); // Guid MemberId = this.CurrentMember.MemberId; ActivityLog log = new ActivityLog(); //bool washelpful = log.FoundItemHelpful(ContentId, MemberId); int likeCount = log.GetActivityCountByValue(new Guid(blogCig.ContentId.Raw), Constants.UserActivity_Values.FoundHelpful_True); string commentCount = CommunityHelper.GetTotalComments(blogCig.BlogId, blogCig.BlogPostId).ToString(); //to get if the content was NOT helpful //bool wasNOThelpful = log.FoundItemNotHelpful(ContentId, MemberId); //LikeCount.Text = CommunityHelper.GetTotalLikes(ContentId.ToString()).ToString(); var blogId = blogCig.BlogId.Raw; var blogPostId = blogCig.BlogPostId.Raw; CommentCount.Text = commentCount; LikeCount.Text = likeCount.ToString(); var blogPostInfo = CommunityHelper.ReadBlogBody(Int32.Parse(blogId), Int32.Parse(blogPostId)); btnLike.CommandArgument = btnUnlike.CommandArgument = blogPostInfo.ContentId + "&" + blogPostInfo.ContentTypeId; }
public static bool InsertNewReview(CSMUserReview review) { bool success = false; review.ReviewId = Guid.NewGuid(); string commentId = CommunityHelper.PostComment(review.BlogId, review.BlogPostId, review.ReviewBody, review.UserScreenName); string sql = "INSERT INTO [CSMUserReviews] " + "([ReviewId] " + ",[MemberId] " + ",[CSMItemId] " + ",[Rating] " + ",[RatedGradeId] " + ",[GradeAppropriateness] " + ",[Created] " + ",[LastModified] " + ",[TelligentCommentId] " + ",[ReviewTitle] " + ",[IThinkItIs]) " + "VALUES " + "(@ReviewId, " + "@MemberId, " + "@CSMId, " + "@ReviewRating, " + "@GradeId, " + "@GradeNumber, " + "CURRENT_TIMESTAMP, " + "CURRENT_TIMESTAMP, " + "@CommentId, " + "@ReviewTitle, " + "@IThinkItIs) "; try { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["membership"].ConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@CSMId", review.CSMItemId); cmd.Parameters.AddWithValue("@MemberId", review.MemberId); cmd.Parameters.AddWithValue("@GradeId", review.RatedGradeId); cmd.Parameters.AddWithValue("@ReviewRating", review.Rating); cmd.Parameters.AddWithValue("@CommentId", commentId); cmd.Parameters.AddWithValue("@ReviewId", review.ReviewId); cmd.Parameters.AddWithValue("@ReviewTitle", review.ReviewTitle); cmd.Parameters.AddWithValue("@IThinkItIs", review.IThinkItIs); cmd.Parameters.AddWithValue("@GradeNumber", review.GradeAppropriateness); cmd.ExecuteNonQuery(); success = true; } if (success) { InsertAllIssues(review.UserReviewIssues, review.ReviewId); } } } catch (Exception ex) { throw ex; } success = true; return(success); }