private void Save() { var searchJob = new SearchJob() { SearchDate = DateTime.Now }; var requiredComplexeKeywords = _jhDbContext.Keywords.ToList().Where(x => x.IsComplexe || x.IsRequired).ToList(); Result = Result.Where(x => x.Value.GetRequiredMatches(requiredComplexeKeywords).Count > 0).ToDictionary(x => x.Key, x => x.Value); CurrentCachedUrls.ForEach(x => x.SearchJob = searchJob); _jhDbContext.SearchJobs.Add(searchJob); _jhDbContext.ResultEntities.AddRange(Result.Select(x => new ResultEntity() { Description = x.Value.Description, Path = x.Key, Provider = x.Value.Provider, PublishDate = x.Value.PublishDate, Publisher = x.Value.Publisher, RefUrl = x.Value.RefUrl, SearchJob = searchJob, Title = x.Value.Title, })); _jhDbContext.CachedUrls.AddRange(CurrentCachedUrls); _jhDbContext.SaveChanges(); }
public void Start() { //Ping //Search Process(); //match SearchState = SearchState.Match; int i = 0; HashSet <string> NotFoundPaths = new HashSet <string>(); foreach (var searchResult in Result) { i++; int progressPourcentage = i * 100 / Result.Count; string progress = $"{progressPourcentage} %"; try { var cachedUrl = InitDescription(searchResult); CurrentCachedUrls.Add(cachedUrl); } catch (EntityResultNoLongerAvailableException) { NotFoundPaths.Add(searchResult.Key); } } Result = Result.Where(x => !NotFoundPaths.Contains(x.Key)).ToDictionary(x => x.Key, x => x.Value); //Save Save(); //Complete SearchState = SearchState.Complete; }