Пример #1
0
 public void OnReport(object UrlBaseVisitor, SWPageRankVisitor.ReportTriggerEventArgs e)
 {
     ReportImmediately(CWLoggerEntryType.Info,e.strReport);
 }
Пример #2
0
        /// <summary>
        /// Performs the PagrRank algorithm. It is the method that is running on the 
        /// pluginThread, so it must be able to handle ThreadAbortException and
        /// ThreadInterruptedException.
        /// </summary>
        private void PerformPageRank()
        {
            try
            {
                events.Enqueue(new EventLoggerEntry(CWLoggerEntryType.Info, DateTime.Now, "CrawlWave Url Selection Plugin thread has started with ID 0x" + Thread.CurrentThread.GetHashCode().ToString("x4")));

                //Select urls from the database, update the appropriate tables and stats
                try
                {
                    ReportImmediately(CWLoggerEntryType.Info,"Starting PageRank.");
                    dbcon.Open();

                    SWRankHandlerHash rankHandler = new SWRankHandlerHash(dbcon,1, 2);
                    pageRank = new SWPageRankVisitor(dbcon, 200000, 50,  rankHandler,0.85f);
                    pageRank.OnReportTrigger += (new SWUrlBaseVisitor.ReportTrigger(OnReport));

                    if (pageRank.VisitAllURLs(pageRank))
                    {
                        ReportImmediately(CWLoggerEntryType.Info,"Succesfully calculated PageRank.");
                    }
                    //Report();
                    state = PluginState.Stopped;
                    OnStateChanged(EventArgs.Empty);
                }
                catch
                {}
                //do processing

            }
            catch(ThreadAbortException)
            {
                //The thread was asked to abort, which means it must return at once
                return;
            }
            catch(ThreadInterruptedException)
            {
                //The thread has been asked to Join. We have nothing to do but return.
                return;
            }
            finally
            {
                AddToReportQueue(CWLoggerEntryType.Info, Thread.CurrentThread.Name + " has stopped.");
            }
        }