private static void Execute(Logger logger) { logger.Info("Start"); MSMQUtils MSMQ = new MSMQUtils(); // Initialization WebRequests WebRequests client = new WebRequests(); SharedLibrary.Utils.WebRequestsUtils.InitializeWebRequest(Config.InitialUrl, out client, Config); // Get Request string htmlResponse = SharedLibrary.Utils.WebRequestsUtils.Get(ref client, logger, Config.InitialUrl); // Checking if html response is valid if (String.IsNullOrWhiteSpace(htmlResponse)) { logger.Fatal("HtmlResponse is null or empty"); return; } client.Dispose(); // Loading htmlResponse into HtmlDocument HtmlDocument map = new HtmlDocument(); map.LoadHtml(htmlResponse); //Scrape Urls logger.Trace("Scraping section urls..."); List <Section> sections = ScrapeSections(map); // Check if any section was processed if (sections == null || sections.Count == 0) { logger.Fatal("Couldn't build any section object. Aborting program"); goto Exit; } // Let's save the section's object if (!String.IsNullOrWhiteSpace(Config.TargetQueue) && MongoUtilsObj.IsValidMongoData(Config)) { // Send messages to Queue logger.Trace("Sending message to configuration queue..."); SendMessage(Config.TargetQueue, sections); logger.Trace("Sending message to MongoCollection..."); SendMessage(sections); } else { logger.Fatal("Error to save section's object. You need to check if there is something wrong with the information in the mongo/queue fields in the input file."); } Exit: logger.Info("End"); }