private static void InsertNewResults(GrabberContext ctx, IEnumerable<SearchResult> newResults, int searchId) { foreach (var newResult in newResults) { newResult.SearchId = searchId; ctx.AddSearchResult(newResult); } }
static void Main(string[] args) { ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; GetLoginPageToGrabTheCookies(); DoLogin(); GetBaraholkaPageToGrabLogoutKey(); using (var ctx = new GrabberContext()) { ProcessSearches(ctx); } DoLogout(); }
private static void ProcessSearches(GrabberContext ctx) { foreach (var search in ctx.Searches.Where(x => x.IsActive)) { var searchResults = GetResultsFromBaraholkaSearch(search.Name); var newResults = searchResults.Except(ctx.SearchResults.Where(x => x.SearchId == search.Id)).ToList(); if (!newResults.Any()) return; // ReSharper disable once PossibleMultipleEnumeration InsertNewResults(ctx, newResults, search.Id); // ReSharper disable once PossibleMultipleEnumeration SendNotification(newResults); } }