Esempio n. 1
0
        public Post Convert(ListItem listItem, SharepointClient sp)
        {
            var link = listItem.Get <FieldUrlValue>(SharepointFields.BodyLink);

            var content = link == null ? String.Empty : _confluenceClient.GetContentByUrl(link.Url);

            var title = link == null ? String.Empty : _confluenceClient.GetTitleByUrl(link.Url);

            var metaHtml = GetPageProperties(content);

            if (metaHtml != null)
            {
                content = RemovePagePropertiesInContent(content);
            }

            if (!String.IsNullOrWhiteSpace(title))
            {
                title = _tagRegex.Replace(title, String.Empty);
            }

            var id = listItem.Get <Int32>(SharepointFields.OldID);

            var devices = listItem.Get <TaxonomyFieldValueCollection>(SharepointFields.Devices).ToSPTermList(_names);

            var body = content.ReplaceInternalLinks();

            var category = listItem.Get <TaxonomyFieldValue>(SharepointFields.Category).ToSPTerm(_categories);

            var createDate = listItem.Get <DateTime>(SharepointFields.PublicationDate);

            var urlName = link?.Description.Replace(".", "x2E").Trim(' ') ?? String.Empty;

            var relativeUrl = UrlBuilder.GetRelativePostUrl(urlName).ToString();

            var isTopPost = listItem.Get <Boolean>(SharepointFields.IsTop);

            var post = new Post
            {
                Id       = id,
                Title    = title,
                Devices  = devices,
                Body     = body,
                Category = category,
                Created  = createDate,
                Url_name = relativeUrl,
                IsTop    = isTopPost,
                MetaHtml = metaHtml
            };

            return(post);
        }
        public SiteText Convert(ListItem listItem, SharepointClient sp)
        {
            var link = listItem.Get <FieldUrlValue>(SharepointFields.BodyLink);

            var content = link == null ? String.Empty : _confluenceClient.GetContentByUrl(link.Url);

            var siteText = new SiteText
            {
                Tag  = listItem.Get <String>(SharepointFields.Title),
                Text = content.ReplaceInternalLinks()
            };

            return(siteText);
        }