Exemplo n.º 1
0
        /// <summary>
        /// Generate the feed
        /// </summary>
        /// <param name="context">Encapsulate all HTTP-specific information about an individual HTTP request.</param>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();
            context.Response.ContentType = "text/xml";

            using (XmlWriter writerRss = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8))
            {
                writerRss.WriteStartDocument();
                writerRss.WriteStartElement("rss");
                writerRss.WriteAttributeString("version", "2.0");
                writerRss.WriteStartElement("channel");
                writerRss.WriteElementString("title", GlobalRessources.SiteName);
                writerRss.WriteStartElement("ImageUrl");
                writerRss.WriteElementString("Url", "Images/logo.png");
                writerRss.WriteElementString("title", GlobalRessources.SiteName);
                writerRss.WriteElementString("link", GlobalRessources.SiteUrl);
                writerRss.WriteEndElement();
                writerRss.WriteElementString("link", GlobalRessources.SiteUrl);
                writerRss.WriteElementString("description", "Retrouvez les dernières actualités de notre association.");

                IEnumerable <News> news = _webserviceNews.GetListNewsLimited(0, 15);

                foreach (News item in news)
                {
                    writerRss.WriteStartElement("item");

                    writerRss.WriteElementString("title", item.Title);

                    writerRss.WriteStartElement("description");
                    writerRss.WriteString(string.Format("<img src=\"{0}\" width=\"100\" height=\"113\" style=\"float: left\" />", item.ImageUrl));
                    writerRss.WriteString(item.Text);
                    writerRss.WriteEndElement();

                    writerRss.WriteElementString("link", string.Format("http://www.epsilab.net/News-{0}-{1}.aspx", item.Id, item.Url));
                    writerRss.WriteElementString("pubDate", item.DateTime.ToString("f"));
                    writerRss.WriteElementString("author", string.Format("{0} {1}", item.Member.FirstName, item.Member.LastName));

                    writerRss.WriteEndElement();
                }

                writerRss.WriteEndElement();
                writerRss.WriteEndElement();
                writerRss.WriteEndDocument();

                writerRss.Flush();
                writerRss.Close();
            }

            context.Response.End();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Raised when the page is loaded
        /// </summary>
        /// <param name="sender">Element which raised the event.</param>
        /// <param name="e">Event arguments</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            // Get ads
            IEnumerable <Slide> slides = _webserviceSlides.GetSlides();

            if (!slides.Any())
            {
                repeater_TemporaryNews.Visible = false;
            }
            else
            {
                repeater_TemporaryNews.DataSource = slides;
                repeater_TemporaryNews.DataBind();
            }

            // Get 20 last news
            IEnumerable <News> news = _webserviceNews.GetListNewsLimited(0, 20);

            repeaterNews.DataSource = news;
            repeaterNews.DataBind();
        }