protected void Page_Load(object sender, EventArgs e) { System.Collections.Generic.IEnumerable <文章表> list = new List <文章表>(); string guid = Request.QueryString["guid"]; bool.TryParse(Request.QueryString["html"], out IsCresteHTMLPage); if (!string.IsNullOrEmpty(guid)) { //susucong 生成静态页面 if (QliliHelper.BaseSite.Contains("qlili.com") && System.Configuration.ConfigurationManager.AppSettings["启用Qlili获取数据"] != "0") { //使用url string result = QliliHelper.IndexBook(); if (!string.IsNullOrEmpty(result)) { currentBook = Tygdb.书名表.Where(p => p.GUID == Guid.Parse(guid)).FirstOrDefault(); Response.Write(result); currentBook.CreateStaticHTMLFile(result); Response.End(); return; } } list = Tygdb.文章表.Where(p => p.GUID == Guid.Parse(guid)).OrderBy(p => p.创建时间); if (list.Count() > 0) { var item = list.First(); BookName = item.书名; Creater = item.书名表.作者名称; LastTime = item.书名表.最后更新时间.ToString(); currentBook = item.书名表; } else { currentBook = Tygdb.书名表.Where(p => p.GUID == Guid.Parse(guid)).FirstOrDefault(); } if (list.Count() > 2) { //循环数据 list.Aggregate((c, n) => { n.一章 = c.本记录GUID; c.一章 = n.本记录GUID; return(n); }); currentBook.包含有效章节 = list.Count(); } } docList.EnableViewState = false; //System.Threading.Tasks.Task.Factory.StartNew(delegate //{ // System.Net.WebClient wc = new System.Net.WebClient(); // foreach (var item in list) // { // string url = item.GetHTMLFilePath(); // if (!System.IO.File.Exists(System.IO.Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + url))) // { // //生成静态页面 // string str = wc.DownloadString(new Uri(Request.Url, "BookIndex.aspx?guid=" + item.本记录GUID)); // item.CreateStaticHTMLFile(str); // } // // item.采集用的URL9 = url ? url : "BookIndex.aspx?guid=" + book.GUID; // } //}); docList.DataSource = list; docList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (QliliHelper.Books.Count == 0) { if (Request.Url.ToString().EndsWith(".aspx")) { if (System.IO.File.Exists(Server.MapPath("./books.xml"))) { // var d=System.IO.File.ReadAllBytes(); System.IO.StringReader sw = new System.IO.StringReader(System.IO.File.ReadAllText(Server.MapPath("./books.xml"))); var seral = new System.Xml.Serialization.XmlSerializer(Skybot.Cache.QliliHelper.Books.GetType()); var sd = seral.Deserialize(sw); Skybot.Cache.QliliHelper.Books = (List <TygModel.书名表>)sd; Skybot.Cache.QliliHelper.Books = Skybot.Cache.QliliHelper.Books.Where(p => System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + p.GetHTMLFilePath())).ToList(); } Response.Write("<!-- count 0 -->"); string url = Request.Url.LocalPath.Replace(".aspx", ".html"); if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + url)) { Server.Transfer(url); return; } //使用url string result = QliliHelper.BookList(); if (!string.IsNullOrEmpty(result)) { Response.Write(result); QliliHelper.WirteFile(url, result); Response.End(); return; } } } else { Response.Write("<!-- count " + Skybot.Cache.QliliHelper.Books.Count + " -->"); } if (!string.IsNullOrEmpty(Request.QueryString["html"])) { bool.TryParse(Request.QueryString["html"], out IsCresteHTMLPage); } ShowNews.EnableViewState = false; TypeName = "玄幻,修真,都市,穿越,网游,科幻"; if (!IsPostBack) { if (string.IsNullOrEmpty(Request["keyword"])) { BindData(); } else { BindData(Request["keyword"]); } } }