コード例 #1
0
        public void Run()
        {
            //开始运行
            taskflag      = 1;
            taskStartTime = DateTime.Now;
            WXGZHArticle.LogUtil.Log(url + "准备开始获取网页信息");
            FinalHtml html = new FinalHtml();

            if (html.Run(url))
            {
                WXGZHArticle.LogUtil.Log(url + "网页信息获取成功");
                try
                {
                    WXArticleInfo rs = WXArticleAdapter.GetArticle(html.HtmlString);

                    string articleid = Guid.NewGuid().ToString("N");

                    bool dbrs = WXArticleDBHelper.InseartDB(rs, articleid);

                    if (dbrs)
                    {
                        WXGZHArticle.LogUtil.Log(url + "操作完成已写入数据库!");
                    }
                    else
                    {
                        WXGZHArticle.LogUtil.Log(url + "操作失败未写入数据库!");
                    }

                    WXGZHDownload.DeDe.DeDePublic1 dede = new WXGZHDownload.DeDe.DeDePublic1();
                    if (dede.run(rs, sendtype))
                    {
                        WXGZHArticle.LogUtil.Log(url + "已发布到网站!");

                        if (WXArticleDBHelper.ResetArticleFlag(articleid, 1))
                        {
                            WXGZHArticle.LogUtil.Log(url + "数据库更新成功!");
                        }
                        else
                        {
                            WXGZHArticle.LogUtil.Log(url + "数据库更新失败!");
                        }
                    }
                    else
                    {
                        WXGZHArticle.LogUtil.Log(url + "未发布到网站!");
                    }
                    WXGZHArticle.LogUtil.Log(url + "采集及发布过程结束!");
                }
                catch (System.Exception ex)
                {
                    WXGZHArticle.LogUtil.Log(url + "采集过程出现异常!" + ex.Message);
                    WXGZHArticle.LogUtil.Log(url + ex.StackTrace);
                }
            }
            //运行结束
            taskflag = 2;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: zhanggangbz/WXGZHDownload
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            string _allhtmlinfo  = this.webBrowser1.DocumentText;
            string _bodyhtmlinfo = this.webBrowser1.Document.Body.InnerHtml;

            this.webBrowser1.Stop();

            WXArticleInfo rs = WXArticleAdapter.GetArticle(_bodyhtmlinfo);

            string articleid = Guid.NewGuid().ToString("N");

            bool dbrs = WXArticleDBHelper.InseartDB(rs, articleid);

            if (dbrs)
            {
                this.textBox2.Text += "操作完成已写入数据库!";
            }
            else
            {
                this.textBox2.Text += "操作失败未写入数据库!";
            }

            WXGZHDownload.DeDe.DeDePublic1 dede = new WXGZHDownload.DeDe.DeDePublic1();
            if (dede.run(rs))
            {
                this.textBox2.Text += "已发布到网站!";

                if (WXArticleDBHelper.ResetArticleFlag(articleid, 1))
                {
                    this.textBox2.Text += "数据库更新成功!";
                }
                else
                {
                    this.textBox2.Text += "数据库更新失败!";
                }
            }
            else
            {
                this.textBox2.Text += "未发布到网站!";
            }
            this.textBox2.Text += "采集及发布过程结束!\r\n";
        }