示例#1
0
 partial void DeleteWebPage(WebPage instance);
示例#2
0
 partial void InsertWebPage(WebPage instance);
示例#3
0
 partial void UpdateWebPage(WebPage instance);
示例#4
0
        static void saveWebPage(PageCrawlCompletedArgs e)
        {
            // save to WebPage table

            //Process data
            var webpageContext = new WebPageDataContext(DemoParameters.connectionString);
            //var webpageContext = new WebPageDataContext();
            //IEnumerable<WebPage> wp = dbContext.WebPages.OrderBy(c => c.pageUrl);

            WebPage page = new WebPage
            {
                pageUrl = e.CrawledPage.Uri.ToString(),
                parentUrl = e.CrawledPage.ParentUri.ToString(),
                requestStartTime = e.CrawledPage.RequestStarted.ToString(),
                requestEndTime = e.CrawledPage.RequestCompleted.ToString(),
                downloadStartTime = e.CrawledPage.DownloadContentStarted.ToString(),
                downloadEndTime = e.CrawledPage.DownloadContentCompleted.ToString(),
                //pageHtml = e.CrawledPage.Content.Text
                pageHtml = ""
            };

            webpageContext.WebPages.InsertOnSubmit(page);

            try
            {
                webpageContext.SubmitChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                // Make some adjustments.
                // ...
                // Try again.
                webpageContext.SubmitChanges();
            }
            finally
            {
                if (webpageContext != null)
                    webpageContext.Dispose();
            }
        }