Exemplo n.º 1
0
        /// <summary>
        /// 添加栏目函数
        /// </summary>
        /// <param name="xmlpath">XML栏目文件</param>
        /// <param name="XmlData">为空 "" </param>
        /// <![CDATA[调用方法 XmlFileAllNodes(Server.MapPath("treeout.xml"), "")]]>
        /// <returns></returns>
        public string XmlFileAllNodes(string xmlpath, String XmlData)
        {
            System.Xml.XmlDataDocument MyXml = new System.Xml.XmlDataDocument();
            if (XmlData == "")
            {
                MyXml.Load(xmlpath);//得到XML数据
            }
            else
            {
                MyXml.LoadXml(XmlData);
            }

            for (int i = 0; i < MyXml.DocumentElement.ChildNodes.Count; i++)
            {
                try
                {                                         //得到树状结构
                    if (XmlFileAllNodesCloumnLvTemp == 0) //一级节点
                    {
                        System.Web.HttpContext.Current.Response.Write(TextData.EStr(XmlFileAllNodesCloumnLvTemp, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") + XmlFileAllNodesColumnsIDTemp + MyXml.DocumentElement.ChildNodes[i].Attributes.GetNamedItem("Cont").Value + XmlFileAllNodesCloumnLvTemp + "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<br/>");
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Response.Write(TextData.EStr(XmlFileAllNodesCloumnLvTemp, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") + XmlFileAllNodesColumnsIDTemp + MyXml.DocumentElement.ChildNodes[i].Attributes.GetNamedItem("Cont").Value + XmlFileAllNodesCloumnLvTemp + "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<br/>");
                        //如果是子节点
                    }
                    XmlFileAllNodesColumnsIDTemp += 1;
                    XmlFileAllNodesCloumnLvTemp++;
                    XmlFileAllNodes(xmlpath, MyXml.DocumentElement.ChildNodes[i].OuterXml);//得到这个XML文件下的所有子节点
                    XmlFileAllNodesCloumnLvTemp--;
                }
                catch (System.Xml.XmlException)//这里如是最下层就不进行下一次的调用自己了
                {
                }
            }
            return("");
        }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        TypeStr.Split('\r').ToList().ForEach((o) =>
        {
            o.Trim().Replace("\n", "").Split('\t').ToList().ForEach((p) =>
            {
                Response.Write(p + "<br/>");
            });
            Response.Write("<hr/>");
        });


        Response.Write("1".ToPingYing());



        //搜索工作线程
        BaiduSearchCompare searchCompare = null;



        searchCompare = new BaiduSearchCompare();

        //searchCompare.DoWorkAsync("仙逆", "仙逆");
        //searchCompare.DoWorkAsync("天珠变", "天珠变");
        //searchCompare.DoWorkAsync("遮天", "遮天");
        //searchCompare.DoWorkAsync("吞噬星空", "吞噬星空");
        //searchCompare.DoWorkAnsycComplete += new EventHandler<SearchCompareEventArgs>(searchCompare_DoWorkAnsycComplete);

        System.Threading.Tasks.Task task = System.Threading.Tasks.Task.Factory.StartNew(() =>
        {
            string key = "仙逆";
            var result = searchCompare.DoWork(key);
            searchCompare_DoWorkAnsycComplete(searchCompare, new SearchCompareEventArgs()
            {
                Reslut = result,
                ToKen  = key
            });
        }
                                                                                        );



        task.ContinueWith((xo) =>
        {
            #region 处理异常
            try { xo.Wait(); }
            catch (AggregateException ex) { ex.Handle((exp) => { return(true); }); }
            #endregion

            string key = "凡人修仙传";
            var result = searchCompare.DoWork(key);
            searchCompare_DoWorkAnsycComplete(searchCompare, new SearchCompareEventArgs()
            {
                Reslut = result,
                ToKen  = key
            });

            //表示异步已经处理
            if (xo.Exception != null)
            {
                xo.Exception.Handle((ex) =>
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message + "|||||" + ex.StackTrace);
                    return(true);
                });
            }
        })

        .ContinueWith((xo) =>
        {
            #region 处理异常
            try { xo.Wait(); }
            catch (AggregateException ex) { ex.Handle((exp) => { return(true); }); }
            #endregion
            string key = "仙逆";
            var result = searchCompare.DoWork(key);
            searchCompare_DoWorkAnsycComplete(searchCompare, new SearchCompareEventArgs()
            {
                Reslut = result,
                ToKen  = key
            });

            //表示异步已经处理
            if (xo.Exception != null)
            {
                xo.Exception.Handle((ex) =>
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message + "|||||" + ex.StackTrace);
                    return(true);
                });
            }
        })

        .ContinueWith((xo) =>
        {
            #region 处理异常
            try { xo.Wait(); }
            catch (AggregateException ex) { ex.Handle((exp) => { return(true); }); }
            #endregion
            string key = "天珠变";
            var result = searchCompare.DoWork(key);
            searchCompare_DoWorkAnsycComplete(searchCompare, new SearchCompareEventArgs()
            {
                Reslut = result,
                ToKen  = key
            });

            //表示异步已经处理
            if (xo.Exception != null)
            {
                xo.Exception.Handle((ex) =>
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message + "|||||" + ex.StackTrace);
                    return(true);
                });
            }
        })

        .ContinueWith((xo) =>
        {
            #region 处理异常
            try { xo.Wait(); }
            catch (AggregateException ex) { ex.Handle((exp) => { return(true); }); }
            #endregion
            string key = "遮天";
            var result = searchCompare.DoWork(key);
            searchCompare_DoWorkAnsycComplete(searchCompare, new SearchCompareEventArgs()
            {
                Reslut = result,
                ToKen  = key
            });

            //表示异步已经处理
            if (xo.Exception != null)
            {
                xo.Exception.Handle((ex) =>
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message + "|||||" + ex.StackTrace);
                    return(true);
                });
            }
        })


        .ContinueWith((xo) =>
        {
            #region 处理异常
            try { xo.Wait(); }
            catch (AggregateException ex) { ex.Handle((exp) => { return(true); }); }
            #endregion
            //表示异步已经处理
            if (xo.Exception != null)
            {
                xo.Exception.Handle((ex) =>
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message + "|||||" + ex.StackTrace);
                    return(true);
                });
            }

            System.Diagnostics.Debug.Write("任务完成" + tong.EStr(50, "/"));
        });



        try
        {
            //输出章节结果
            Response.Write(
                string.Join("<br/>\r\n", (from p in searchCompare.DoWork("仙逆")
                                          // orderby p.index
                                          select p.ToString()

                                          ).ToArray()
                            ));
        }
        catch
        {
        }

        //列表页面分析
        SingleListPageAnalyse analyse = null;
        analyse = new SingleListPageAnalyse("http://www.78xs.com/article/7/5319/Default.shtml");//.GetResult<List<string>>();
        //analyse = new SingleListPageAnalyse("http://www.yankuai.com/files/article/html/1/1845/");
        // analyse = new SingleListPageAnalyse("http://www.qidian.com/BookReader/1264634.aspx");
        while (true)
        {
            System.Threading.Thread.Sleep(2);
            if (analyse.ListPageContentUrls.Count > 200)
            {
                //输出章节结果
                Response.Write(
                    string.Join("<br/>\r\n", (from p in analyse.ListPageContentUrls
                                              // orderby p.index
                                              select "" + p.index + "\t " + p.Title + "\t\t " + p.Url

                                              ).ToArray()
                                ));

                break;
            }
        }
        //analyse = new SingleListPageAnalyse("http://www.baidu.com/s?bs=xml+linq+GetElementsByTagName&f=8&rsv_bp=1&wd=xml+linq++TagName&inputT=718");


        //输出Web数据
        // Response.Write("http://www.qlili.com".GetWeb());


        Skybot.Cache.RecordsCacheManager.Instance.UpdateRecord(RecordType.Page, "" + 6);


        // Response.Write();
        Response.Write(tygdb.分类表.Count());
        // 序列化测试();

        #region 处理异常
        try { task.Wait(); }
        catch (AggregateException ex) { ex.Handle((exp) => { return(true); }); }
        #endregion


        return;

        Skybot.Cache.TabPageEntity page = new TabPageEntity()
        {
            Record = tygdb.文章表.First()
        };
    }