Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SiteSqlServer"].ToString();

          //	Chanel
         	  NewsRSS rss = new NewsRSS();

        NewsRSS.RssChannel channel = new NewsRSS.RssChannel();

        channel.Title = "DAA Website";

        channel.Link = "http://daa.uit.edu.vn";

        channel.Description = "University of Information Technology";

        rss.AddRssChannel(channel);

          //	Add items
          using (SqlConnection scon = new SqlConnection(ConnectionString))
        {
           scon.Open();
           using (SqlCommand scom = new SqlCommand("SELECT Top 10 [ItemID], [Title], [PublishDate], [Description] FROM [Announcements] WHERE (Datediff(day,[PublishDate],getdate())>=0 ) AND([ModuleID] = 404) AND (Datediff(day,getdate(),[ExpireDate]) > 0 or [ExpireDate] Is Null) ORDER BY [PublishDate] DESC", scon))
           {
                SqlDataReader sreader = scom.ExecuteReader();
              while (sreader.Read())
                {
                NewsRSS.RssItem item = new NewsRSS.RssItem();

                  item.Title = sreader.GetValue(1).ToString() + " (" + DateTime.Parse((sreader.GetValue(2).ToString())).ToShortDateString() + ")";

                  item.Link = "http://daa.uit.edu.vn/Th%C3%B4ngb%C3%A1om%E1%BB%9Bi.aspx?" + sreader.GetValue(0).ToString();

                  item.Description = getContent(sreader.GetValue(3).ToString());

                  rss.AddRssItem(item);
            }
           }
        }

          //	Return rss document
          Response.Clear();

          Response.ContentType = "text/xml";

          Response.Write(rss.RssDocument);

          Response.End();
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        NewsRSS rss = new NewsRSS();

        NewsRSS.RssChannel channel = new NewsRSS.RssChannel();

        channel.Title = "Nha Khoa Thuận Kiều";

        channel.Link = HttpContext.Current.Request.Url.Host;

        channel.Description = "Website Nha Khoa Thuận Kiều.";

        rss.AddRssChannel(channel);

        DataTable dt = _db.Get_All_News_IDLoai(4);

        dt = _db.Get_Rss_News(Request.QueryString["code"]);
        foreach (DataRow dr in dt.Rows)
        {
            string linkR     = HttpContext.Current.Request.Url.Host + "/news/chi-tiet.aspx?id=" + BaseView.GetStringFieldValue(dr, "id");
            string linkR_Img = "<a href='" + HttpContext.Current.Request.Url.Host
                               + "/news/chi-tiet.aspx?id=" + BaseView.GetStringFieldValue(dr, "id") + "'>" + "<img width=130 height=100 src='" + HttpContext.Current.Request.Url.Host + @"/upload/" + BaseView.GetStringFieldValue(dr, "HinhAnh") + "' ></a></br>";
            NewsRSS.RssItem item = new NewsRSS.RssItem();

            item.Title = BaseView.GetStringFieldValue(dr, "Title");

            item.Link = linkR;

            item.Description = "<![CDATA[   " + linkR_Img + BaseView.GetStringFieldValue(dr, "desc") + "]]>";

            rss.AddRssItem(item);
        }
        Response.Clear();

        Response.ContentType = "text/xml";

        Response.Write(rss.RssDocument);

        Response.End();
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(Request.QueryString["code"]))
        {
            DataRow row         = _db.get_info_url();
            string  LinksServer = BaseView.UrlServer();
            //if (row != null)
            //{
            //    LinksServer = BaseView.GetStringFieldValue(row, "links");
            //}
            NewsRSS rss = new NewsRSS();

            NewsRSS.RssChannel channel = new NewsRSS.RssChannel();

            channel.Title = "";

            channel.Link = LinksServer;

            channel.Description = "Website TMDM";

            rss.AddRssChannel(channel);

            DataTable dt = _db.Get_Rss_News(Request.QueryString["code"].Replace("'", ""));
            foreach (DataRow dr in dt.Rows)
            {
                string hinh = BaseView.GetStringFieldValue(dr, "HinhAnh");
                if (hinh.IndexOf("http") == -1 && hinh.Trim() != null)
                {
                    hinh = LinksServer + "/uploadFile/postImages/" + hinh;
                }
                else if (hinh.Trim() == "")
                {
                    hinh = LinksServer + "/uploadFile/postImages/noimg.png";
                }
                string linkR     = LinksServer + "/" + BaseView.GetStringFieldValue(dr, "url") + "";
                string linkR_Img = "<a href='" + LinksServer
                                   + "/" + BaseView.GetStringFieldValue(dr, "url") + "" + "'>" + "<img width=130 height=100 src='" + hinh + "' ></a></br>";
                NewsRSS.RssItem item = new NewsRSS.RssItem();

                item.Title = BaseView.GetStringFieldValue(dr, "Title");

                item.Link = linkR;

                // item.Description = "<![CDATA[   "+ linkR_Img + BaseView.GetStringFieldValue(dr, "desc") + "]]>";

                item.cData = linkR_Img + BaseView.GetStringFieldValue(dr, "desc");
                rss.AddRssItem(item);
            }
            Response.Clear();

            Response.ContentType = "text/xml";

            Response.Write(rss.RssDocument);

            Response.End();
        }
        else
        {
            string LinksServer = BaseView.UrlServer();
            //if (row != null)
            //{
            //    LinksServer = BaseView.GetStringFieldValue(row, "links");
            //}
            NewsRSS rss = new NewsRSS();

            NewsRSS.RssChannel channel = new NewsRSS.RssChannel();

            channel.Title = "";

            channel.Link = LinksServer;

            channel.Description = "Website TMDM";

            rss.AddRssChannel(channel);

            DataTable dt = _db.get_top_news(100);

            foreach (DataRow dr in dt.Rows)
            {
                string hinh = BaseView.GetStringFieldValue(dr, "HinhAnh");
                if (hinh.IndexOf("http") == -1 && hinh.Trim() != null)
                {
                    hinh = LinksServer + "/uploadFile/postImages/" + hinh;
                }
                else if (hinh.Trim() == "")
                {
                    hinh = LinksServer + "/uploadFile/postImages/noimg.png";
                }
                string linkR     = LinksServer + "/" + BaseView.GetStringFieldValue(dr, "url") + "";
                string linkR_Img = "<a href='" + LinksServer
                                   + "/" + BaseView.GetStringFieldValue(dr, "url") + "" + "'>" + "<img width=130 height=100 src='" + hinh + "' ></a></br>";
                NewsRSS.RssItem item = new NewsRSS.RssItem();

                item.Title = BaseView.GetStringFieldValue(dr, "Title");

                item.Link = linkR;

                // item.Description = "<![CDATA[   "+ linkR_Img + BaseView.GetStringFieldValue(dr, "desc") + "]]>";

                item.cData = linkR_Img + BaseView.GetStringFieldValue(dr, "desc");
                rss.AddRssItem(item);
            }
            Response.Clear();

            Response.ContentType = "text/xml";

            Response.Write(rss.RssDocument);

            Response.End();
        }
    }