partial void DeleteWebPage(WebPage instance);
 partial void InsertWebPage(WebPage instance);
 partial void UpdateWebPage(WebPage instance);
Exemple #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();
            }
        }