Пример #1
0
        /// <summary>
        /// Generates the specified param.
        /// </summary>
        /// <returns></returns>
        public string Generate()
        {
            ResolveListViewProfile();

            RssDocument rssDocument = new RssDocument();

            rssDocument.Version = "2.0";

            rssDocument.Channel = new RssChannel();
            rssDocument.Channel.Image = new RssImage();

            GenerateChannelInformation(rssDocument.Channel);

            rssDocument.Channel.Copyright = IbnConst.AssemblyCopyright;
            rssDocument.Channel.Generator = IbnConst.AssemblyCompany + "RSS Generator";
            rssDocument.Channel.WebMaster = "";

            rssDocument.Channel.Image.Link = MakeFullLink(this.Page.ResolveUrl("~/"));
            rssDocument.Channel.Image.Title = IbnConst.ProductName;
            rssDocument.Channel.TimeToLive = "30";

            rssDocument.Channel.Items = new List<RssItem>();
            rssDocument.Channel.LastBuildDate = GenerateChannelItems(rssDocument.Channel);

            //dvs[2009-05-28]: fix bug with ie (set encoding to utf-8)
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(rssDocument.ToXml(DocumentType.Rss));
            if (xmlDoc.FirstChild.NodeType == XmlNodeType.XmlDeclaration)
            {
                XmlDeclaration xmlDeclaration = (XmlDeclaration)xmlDoc.FirstChild;
                xmlDeclaration.Encoding = "utf-8";
            }

            StringWriter sw = new StringWriter();
            XmlTextWriter xw = new XmlTextWriter(sw);
            xmlDoc.WriteTo(xw);
            return sw.ToString();
        }
        internal void GetRssDoc()
        {
            try
            {
                Uri url = new Uri(FeedsUrl);

                _rssDoc = RssDocument.Load(url);
                Tickets.Clear();
                for (int i = 0; i < _rssDoc.Channel.Items.Count; i++)
                {
                    Tickets.Add(CreerTicketDepuisTitre(_rssDoc.Channel.Items[i].Title,
                                                       _rssDoc.Channel.Items[i].Description,
                                                       _rssDoc.Channel.Items[i].Guid.Text));
                }

                int numPageCourante = 2;
                bool stopSearch = false;
                while (_rssDoc.Channel.Items.Count == _nbItemParPage && !stopSearch)
                {
                    _rssDoc = RssDocument.Load(new Uri(FeedsUrl + _keyNumPage + numPageCourante));
                    for (int i = 0; i < _rssDoc.Channel.Items.Count; i++)
                    {
                        TicketItem nouvTicket = CreerTicketDepuisTitre(_rssDoc.Channel.Items[i].Title,
                                                                       _rssDoc.Channel.Items[i].Description,
                                                                       _rssDoc.Channel.Items[i].Guid.Text);
                        if (Tickets.Contains(nouvTicket))
                        {
                            stopSearch = true;
                            break;
                        }
                        else
                            Tickets.Add(nouvTicket);
                    }
                }
            }
            catch(Exception ex)
            {}
        }