您目前尚未登陆,请选择【登陆】或【注册
首页->博客论坛->SpaceBuilder v1.1源代码>>BasicWebControls/Tasks/SiteMapTask.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.1源代码
当前文件:文件类型 SpaceBuider11/BasicWebControls/Tasks/SiteMapTask.cs打开代码结构图
普通视图
		            
1//------------------------------------------------------------------------------ 2// <copyright company="Tunynet"> 3// Copyright (c) Tunynet Inc. All rights reserved. 4// </copyright> 5//------------------------------------------------------------------------------ 6 7using System; 8using System.Collections.Generic; 9using System.Text; 10using TunyNet.Tasks; 11using System.Xml; 12using TunyNet.Data.Utils; 13using SpaceBuilder.Clubs.Components; 14using SpaceBuilder.Blogs.Components; 15using TunyNet.Configuration; 16 17namespace SpaceBuilder.Components 18{ 19 public class SiteMapTask : ITask 20 { 21 public void Execute(System.Xml.XmlNode node) 22 { 23 ////////////////////////////////////////////////////////////////////////////////////////////////////////// 24 25 XmlDocument xmlDoc = new XmlDocument(); 26 27 //用户站点地图生成 28 xmlDoc.Load("users.xml"); 29 //获取站点地图的根节点 30 XmlNode root = xmlDoc.SelectSingleNode("urlset"); 31 32 PersonUserQuery userQuery = new PersonUserQuery(); 33 userQuery.IgnorePaging = true; 34 userQuery.MaxRecords = 35000;//这个地方站点应该能够配置的 35 userQuery.SortBy = SortPersonUsersBy.HitTimes;//这个管理员也是应该能够配置的 36 userQuery.SortOrder = SortOrder.Descending; 37 38 PagingDataSet<PersonUser> users = Users.GetPersonUsers(userQuery); 39 40 foreach (User user in users.Records) 41 { 42 XmlElement url = xmlDoc.CreateElement("url");//生成url节点 43 44 XmlElement loc = xmlDoc.CreateElement("loc");//生成loc子节点 45 loc.InnerText = UserUrls.Instance().UserHome(user); 46 url.AppendChild(loc); 47 48 XmlElement lastmod = xmlDoc.CreateElement("lastmod");//生成lastmod子节点 49 lastmod.InnerText = Convert.ToString(user.DateCreated.Date); 50 url.AppendChild(lastmod); 51 52 XmlElement changefreq = xmlDoc.CreateElement("changefreq");//生成changefreq子节点,这个 53 changefreq.InnerText = "daily"; 54 url.AppendChild(changefreq); 55 56 XmlElement priority = xmlDoc.CreateElement("priority");//生成priority子节点 57 priority.InnerText = "1.0"; 58 url.AppendChild(priority); 59 60 root.AppendChild(url); 61 } 62 //生成一个url节点 63 64 65 //生成圈子的站点地图 66 xmlDoc.Load("clubs.xml"); 67 //xmlDoc.RemoveAll(); 68 root = xmlDoc.SelectSingleNode("urlset"); 69 userQuery.IgnorePaging = true; 70 71 ClubQuery clubQuery = new ClubQuery(); 72 clubQuery.IgnorePaging = true; 73 clubQuery.MaxRecords = 35000; //站长可设置 74 clubQuery.SortBy = SortClubsBy.HitTimes; 75 clubQuery.SortOrder = SortOrder.Descending; 76 77 PagingDataSet<Club> clubs = Clubs.Components.Clubs.GetClubs(clubQuery); 78 foreach (Club club in clubs.Records) 79 { 80 XmlElement url = xmlDoc.CreateElement("url");//生成url节点 81 82 XmlElement loc = xmlDoc.CreateElement("loc");//生成loc子节点 83 loc.InnerText = ClubUrls.Instance().ClubDomainHome(club.ClubID); 84 url.AppendChild(loc); 85 86 XmlElement lastmod = xmlDoc.CreateElement("lastmod");//生成lastmod子节点 87 lastmod.InnerText = Convert.ToString(club.CreatedDate.Date);//这个地方应该是圈子的,最新更新时间,现在做的是圈子的创建时间 88 url.AppendChild(lastmod); 89 90 XmlElement changefreq = xmlDoc.CreateElement("changefreq");//生成changefreq子节点,这个 91 changefreq.InnerText = "daily"; 92 url.AppendChild(changefreq); 93 94 XmlElement priority = xmlDoc.CreateElement("priority");//生成priority子节点 95 priority.InnerText = "1.0"; 96 url.AppendChild(priority); 97 98 root.AppendChild(url); 99 } 100 101 //生成文章站点地图 102 xmlDoc.Load("blogThreads.xml"); 103 root = xmlDoc.SelectSingleNode("urlset"); 104 BlogThreadQuery blogThreadQuery = new BlogThreadQuery(); 105 106 blogThreadQuery.IgnorePaging = true; 107 blogThreadQuery.MaxRecords = 35000; 108 blogThreadQuery.SortBy = BlogThreadSortBy.TotalViews; 109 blogThreadQuery.SortOrder = SortOrder.Descending; 110 111 PagingDataSet<BlogThread> blogThreads = Blogs.Components.BlogPosts.GetBlogThreads(blogThreadQuery); 112 foreach (BlogThread blogThread in blogThreads.Records) 113 { 114 XmlElement url = xmlDoc.CreateElement("url");//生成url节点 115 116 XmlElement loc = xmlDoc.CreateElement("loc");//生成loc子节点 117 loc.InnerText = BlogUrls.Instance().ShowPost(blogThread); 118 url.AppendChild(loc); 119 120 XmlElement lastmod = xmlDoc.CreateElement("lastmod");//生成lastmod子节点 121 lastmod.InnerText = Convert.ToString(blogThread.LastRepliedDate.Date);//这个地方应该是圈子的,最新更新时间,现在做的是圈子的创建时间 122 url.AppendChild(lastmod); 123 124 XmlElement changefreq = xmlDoc.CreateElement("changefreq");//生成changefreq子节点,这个 125 changefreq.InnerText = "daily"; 126 url.AppendChild(changefreq); 127 128 XmlElement priority = xmlDoc.CreateElement("priority");//生成priority子节点 129 priority.InnerText = "1.0"; 130 url.AppendChild(priority); 131 132 root.AppendChild(url); 133 } 134 135 xmlDoc.Load("galleryPictures.xml"); 136 root = xmlDoc.SelectSingleNode("urlset"); 137 138 ////////////////////////////////////////////////////////////////////////////////////////////////////////// 139 140 } 141 142 } 143} 144
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:SpaceBuilder v1.1源代码