Exemple #1
0
        /// <summary>
        /// Merges the "enclosure" element, which is empty but has attributes.
        /// </summary>
        /// <param name="xmlReader"></param>
        public void ReadEnclosure(XmlReader xmlReader)
        {
            if (xmlReader.HasAttributes)
            {
                m_Enclosure = new Enclosure();
                xmlReader.MoveToFirstAttribute();
                do
                {
                    switch (xmlReader.Name)
                    {
                    case "url":
                        m_Enclosure.Url = xmlReader.Value;
                        break;

                    case "length":
                        m_Enclosure.Size = xmlReader.Value;
                        break;

                    case "type":
                        m_Enclosure.Type = xmlReader.Value;
                        break;
                    }
                }while (xmlReader.MoveToNextAttribute());
                xmlReader.MoveToElement();

                Debug.WriteLine("\tFound Enclosure: " + m_Enclosure.Url);
            }
        }
Exemple #2
0
        /// <summary>
        /// Retrieves an enclosure object (if any) from the XmlNode.
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        public Enclosure GetEnclosure(XmlNode xmlNode, string strXPath)
        {
            Enclosure enclosure = new Enclosure();

            try
            {
                XmlNode node = xmlNode.SelectSingleNode(strXPath);
                if (node != null)
                {
                    foreach (XmlAttribute xmlAttr in node.Attributes)
                    {
                        string attrName = xmlAttr.Name;
                        if (attrName == "url")
                        {
                            enclosure.Url = xmlAttr.InnerText;
                        }
                        else if (attrName == "length")
                        {
                            enclosure.Size = xmlAttr.InnerText;
                        }
                        else if (attrName == "type")
                        {
                            enclosure.Type = xmlAttr.InnerText;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(String.Format("{0} thrown in GetEnclosure(): {1}", ex.GetType(), ex.Message));
            }
            return(enclosure);
        }
Exemple #3
0
 public Headline(string title, DateTime dtPublished, DateTime dtReceived, string author, string desc, string category, Enclosure enc)
 {
     m_strTitle      = title;
     m_datePublished = dtPublished;
     m_dateReceived  = dtReceived;
     m_strAuthor     = author;
     m_strDesc       = desc;
     m_strCategory   = category;
     m_enclosure     = enc;
 }
        public override void Run()
        {
            HeadlineCollection headlines = new HeadlineCollection();

            try
            {
                //DateTime now = DateTime.Now;
                DateTime now = DateTime.FromFileTime(0);

                string strFileName = Names.FeedsFolder + m_feedNode.FileName;
                if (File.Exists(strFileName))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(strFileName);

                    FeedManager = new FeedManager(xmlDoc.NameTable);
                    FeedManager.TransferNamespaces(xmlDoc);

                    XmlNodeList xmlNodes = xmlDoc.SelectNodes("/rss/channel//item");

                    foreach (XmlNode xmlNode in xmlNodes)
                    {
                        string    title       = FeedManager.GetNodeContent(xmlNode, "title");
                        DateTime  dtPublished = FeedManager.GetNodeDate(xmlNode, "pubDate", now);
                        DateTime  dtReceived  = FeedManager.GetNodeDate(xmlNode, "comshak:rcvDate", now);
                        string    author      = FeedManager.GetNodeContent(xmlNode, "author");
                        string    desc        = FeedManager.GetNodeContent(xmlNode, "description", NCEncoding.String, NCType.Text);
                        string    link        = FeedManager.GetNodeContent(xmlNode, "link");
                        string    categ       = FeedManager.GetNodeContent(xmlNode, "category");
                        Enclosure enc         = FeedManager.GetEnclosure(xmlNode, "enclosure");

                        Headline headline = new Headline(title, dtPublished, dtReceived, author, desc, categ, enc);
                        headline.Link = link;
                        headlines.Add(headline);
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                Utils.DbgOutExc("ReadChannelThread::Run()", ex);
            }
            catch (XmlException xmlEx)
            {
                Utils.DbgOutExc("ReadChannelThread::Run()", xmlEx);
            }
            //catch (Exception ex)
            //{
            //	Utils.DbgOutExc("ReadChannelThread::Run()", ex);
            //}
            finally
            {
                m_form.Invoke(new OnEndCallback(OnEnd), new object[] { headlines });
            }
        }
Exemple #5
0
 public void CopyFrom(RssItem item)
 {
     if (item != null)
     {
         m_strTitle       = item.m_strTitle;
         m_strLink        = item.m_strLink;
         m_strDescription = item.m_strDescription;
         m_strAuthor      = item.m_strAuthor;
         m_strCategory    = item.m_strCategory;
         m_strRetain      = item.m_strRetain;
         m_dtPublished    = item.m_dtPublished;
         m_dtReceived     = item.m_dtReceived;
         m_Enclosure      = item.m_Enclosure;
         m_ncEncoding     = item.m_ncEncoding;
         m_ncDescType     = item.m_ncDescType;
     }
 }