public SlideFeed Parse(string lastGuid) { if (_dom.DocumentElement.Name == "items") { return(ParseLegacy(lastGuid)); } var slideFeed = new SlideFeed(); var items = _dom.SelectNodes(@"slidefeed/item"); foreach (XmlNode item in items) { string guid = item.Attributes["guid"].Value; if (guid == lastGuid) { break; } SlideFeedItem slideFeedItem = GetSlideFeedItem(item); if (slideFeedItem != null) { slideFeed.Items.Add(slideFeedItem); } } return(slideFeed); }
private SlideFeed ParseLegacy(string lastGuid) { var slideFeed = new SlideFeed(); foreach (XmlNode item in _dom.DocumentElement.ChildNodes) { string guid = item.SelectSingleNode("guid").InnerText; if (guid == lastGuid) { break; } var slideFeedItem = new SlideFeedItem() { Guid = item.SelectSingleNode("guid").InnerText }; slideFeedItem.Add(new DateParameter("PublishedDate", item.SelectSingleNode("date").InnerText, "d MMMM yyyy HH:mm")); slideFeedItem.Add(new TextParameter("ClickThroughUrl", item.SelectSingleNode("url").InnerText)); slideFeedItem.Add(new TextParameter("TitleText", item.SelectSingleNode("title").InnerText)); slideFeedItem.Add(new ImageParameter("MasterImage", item.SelectSingleNode("image").InnerText)); if (item.SelectSingleNode("credit") != null) { slideFeedItem.Add(new TextParameter("ImageCreditText", item.SelectSingleNode("credit").InnerText)); } slideFeed.Items.Add(slideFeedItem); } return(slideFeed); }
public virtual void Run() { try { LastRunHadError = false; SlideFeed slideFeed = GetSlideFeed(); var channelssidesList = new List <ChannelsSlide>(); foreach (var item in slideFeed.Items) { try { AddSlide(item, channelssidesList); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(new ApplicationException(string.Format("Error creating slide/r/nURL: {0}/r/nGUID: {1}", URL, item.Guid), ex)); LastErrorDate = DateTime.Now; LastRunHadError = true; } } LastChecked = DateTime.Now; if (slideFeed.Items.Count > 0) { LastItem = slideFeed.Items[0].Guid; Channel.ContentLastAddedDate = DateTime.Now; Channel.MadeDirtyLastDate = DateTime.Now; } foreach (var channelssilde in channelssidesList) { Channel.AssignedSlides.Add(channelssilde); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(new ApplicationException(string.Format("Error running feed/r/nURL: {0}", URL), ex)); LastErrorDate = DateTime.Now; LastRunHadError = true; } }