partial void DeleteSession(Session instance);
partial void InsertSession(Session instance);
partial void UpdateSession(Session instance);
private static void Main(string[] args) { SessionKey = Guid.NewGuid(); Errors = new List<string>(); UriFoundCount = 0; // set number of connections allowed to recommend limit // <see href="http://support.microsoft.com/kb/821268" /> ServicePointManager.DefaultConnectionLimit = 12 * Environment.ProcessorCount; Console.ForegroundColor = ConsoleColor.Red; Console.Write("Enter Domain: "); Console.ForegroundColor = ConsoleColor.Green; string url = Console.ReadLine(); if (!url.StartsWith("http://")) url = "http://" + url; Console.ForegroundColor = ConsoleColor.Red; Console.Write("Enter Number of Processors (" + 12 * Environment.ProcessorCount + " recommended): "); Console.ForegroundColor = ConsoleColor.Green; string cprocessors = Console.ReadLine(); int processors; if (!Int32.TryParse(cprocessors, out processors)) processors = 1; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Starting scan of {0} with {1} thread{2}", url, processors, processors == 1 ? String.Empty : "s"); Console.ResetColor(); using (var dc = new CrawlerDataContext()) { Session session = new Session { SessionKey = SessionKey, ScanDate = DateTime.UtcNow, Url = url }; dc.Sessions.InsertOnSubmit(session); dc.SubmitChanges(); } Robot bot = new Robot(new Uri(url)); bot.MaxProcessorsAllowed = processors; bot.UriProcessingFinished += new EventHandler<UriProcessingFinishedEventArgs>(bot_UriProcessingFinished); bot.UriFound += new EventHandler<UriFoundEventArgs>(bot_UriFound); bot.Scan(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Processing Done"); if (Errors.Count > 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Errors"); Console.ResetColor(); for (int i = 0; i < Errors.Count; i++) { if (i % 2 == 0) Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(Errors[i]); Console.ResetColor(); } } Console.Read(); }