您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->中小企业网站系统前台源码(SmallBusinessStarterKit)>>App-Code/News/XmlNewsProvider.cs>>代码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:中小企业网站系统前台源码(SmallBusinessStarterKit)


当前文件路径:SmallBusinessStarterKit/App_Code/News/XmlNewsProvider.cs 文件类型
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Web; 5using System.Web.Security; 6using System.Web.UI; 7using System.Web.UI.WebControls; 8using System.Xml; 9using System.Xml.Schema; 10using System.IO; 11using System.Collections.Generic; 12 13 14 15/// <summary> 16/// XML Data Layer for News Page 17/// </summary> 18public class XmlNewsProvider : NewsProvider 19{ 20 private string _xmlFile; 21 private string _xsdFile; 22 23 /// <summary> 24 /// Reads xml and xsd file names from the web.config file 25 /// </summary> 26 public XmlNewsProvider() 27 { 28 SmallBusinessDataProvidersSection sec = (ConfigurationManager.GetSection("SmallBusinessDataProviders")) as SmallBusinessDataProvidersSection; 29 string xmlFile = sec.NewsProviders[sec.NewsProviderName].Parameters["dataFile"]; 30 string xsdFile = sec.NewsProviders[sec.NewsProviderName].Parameters["schemaFile"]; 31 32 _xmlFile = HttpContext.Current.Request.MapPath("~/App_Data/" + xmlFile); 33 _xsdFile = HttpContext.Current.Request.MapPath("~/App_Data/schemas/" + xsdFile); 34 } 35 36 /// <summary> 37 /// Returns all news items 38 /// </summary> 39 public override List<NewsItem> GetAllNews() 40 { 41 DataSet dataSet = Util.ReadAndValidateXml(_xmlFile, _xsdFile); 42 List<NewsItem> list = new List<NewsItem>(); 43 foreach (DataTable t in dataSet.Tables) 44 { 45 NewsItem curr; 46 foreach (DataRow r in t.Rows) 47 { 48 curr = new NewsItem((string)r["id"], (bool)r["visible"], (string)r["title"]); 49 curr.Date = (r["date"] is DBNull) ? DateTime.MinValue : (DateTime)r["date"]; 50 curr.Content = (r["content"] is DBNull) ? String.Empty: (string)r["content"]; 51 curr.ImageUrl = (r["imageUrl"] is DBNull) ? String.Empty : (string)r["imageUrl"]; 52 curr.ImageAltText = (r["imageAltText"] is DBNull) ? String.Empty : (string)r["imageAltText"]; 53 list.Add(curr); 54 } 55 } 56 57 return list; 58 } 59 60 /// <summary> 61 /// Returns a particular news item 62 /// </summary> 63 public override NewsItem GetNewsItem(string newsItemId) 64 { 65 List<NewsItem> newsItems = GetAllNews(); 66 67 foreach (NewsItem n in newsItems) 68 { 69 if (n.Id == newsItemId) 70 return n; 71 } 72 return null; 73 } 74 75} 76
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:中小企业网站系统前台源码(SmallBusinessStarterKit)

- 某公司人事工资管理系统源码

- 勇敢者论坛2.0源码

- Ajax之用户注册实例源码

- 超越简单同学录源码

- Repeter控件开发RssFeed(附详..

- Asp.net魔兽世界代练网站系统..

- XCMS1.0Beta内容管理系统部分..

- 漂亮无限级分类源代码(三层..

51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号