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() : "/";
            }
        }
Пример #2
0
        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 = xn["Id"].InnerText;
                //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;
                CommentTitle      = xn["Content"]["HtmlName"].InnerText;
                if (CommentTitle.Contains("{"))
                {
                    CommentTitle = CommentTitle.Substring(0, CommentTitle.IndexOf("{"));
                }
                Likes = TelligentService.TelligentService.GetTotalLikes(commentId).ToString();
                //ParentTitle = xn["Content"]["Application"]["Container"]["HtmlName"].InnerText;
                //CommentTitle = xn["Content"]["HtmlName"].InnerText;
                Guid sitecoreGuid = Guid.Empty;
                // NOTE: telligent adds HTML that needs to be stripped
                Guid.TryParse(Sitecore.StringUtil.RemoveTags(xn["Content"]["HtmlDescription"].InnerText), out sitecoreGuid);
                SitecoreId  = sitecoreGuid;
                CommentDate = parsedDate;
                Type        = xn["Content"]["Application"]["HtmlName"].InnerText;
            }
        }