Example #1
0
        /// <summary>
        /// Creates a uBlogsyPost Document 
        /// </summary>
        /// <param name="item"></param>
        /// <param name="parentId"></param>
        /// <returns></returns>
        private IContent CreatePost(RssItem item, int parentId)
        {
            // create post item
            var postDic = new Dictionary<string, object>()
            {
                {"uBlogsyPostDate", item.Date},
                {"uBlogsyPostAuthor", TxtAuthor.Text},
                {"uBlogsyContentBody", item.Description},
                {"uBlogsyContentTitle", item.Title}
            };

            return IContentHelper.CreateContentNode(item.Title, "uBlogsyPost", postDic, parentId, false);
        }
Example #2
0
        /// <summary>
        /// Parses the xml document in order to retrieve the RSS items.
        /// </summary>
        private void ParseItems(XmlDocument doc)
        {
            _Items.Clear();
            XmlNodeList nodes = doc.SelectNodes("rss/channel/item");

            foreach (XmlNode node in nodes)
            {
                RssItem item = new RssItem();
                ParseElement(node, "title", ref item.Title);
                ParseElement(node, "description", ref item.Description);
                ParseElement(node, "link", ref item.Link);

                string date = null;
                ParseElement(node, "pubDate", ref date);
                DateTime.TryParse(date, out item.Date);

                _Items.Add(item);
            }
        }
Example #3
0
        /// <summary>
        /// Returns true of a post exists with the same name and date
        /// </summary>
        /// <param name="item"></param>
        /// <param name="parentFolder"></param>
        /// <returns></returns>
        private bool PostExists(RssItem item, IContent parentFolder)
        {
            var descendants = ContentService.GetDescendants(parentFolder.Id).Where(x => x.ContentType.Alias == "uBlogsyPost");
            foreach (var post in descendants)
            {
                if (post.Name.Flatten() == item.Title.Flatten() && post.GetValue<DateTime>("uBlogsyPostDate") == item.Date)
                {
                    return true;
                }
            }

            return false;
        }
Example #4
0
        /// <summary>
        /// Parses the xml document in order to retrieve the RSS items.
        /// </summary>
        private void ParseItems(XmlDocument doc)
        {
            _Items.Clear();
            XmlNodeList nodes = doc.SelectNodes("rss/channel/item");

            foreach (XmlNode node in nodes)
            {
                RssItem item = new RssItem();
                ParseElement(node, "title", ref item.Title);
                ParseElement(node, "description", ref item.Description);
                ParseElement(node, "link", ref item.Link);

                string date = null;
                ParseElement(node, "pubDate", ref date);
                DateTime.TryParse(date, out item.Date);

                _Items.Add(item);
            }
        }