public List <RunItem> Search(string s, int nrOfHits = 10) { if (s == null) { s = ""; } s = s.Trim(); var fileList = new List <RunItem>(); var sw = new Stopwatch(); sw.Start(); ICollection <RunItem> generalResult = MatcherGeneral.Search(s.ToLower(), nrOfHits); GeneralSearchTime = (int)sw.ElapsedTicks; sw.Restart(); //Console.WriteLine($" "); ICollection <RunItem> prioResult = MatcherPrio.Search(s.ToLower()); //Get all results from indexing prioResult = prioResult.Concat(generalResult).ToList(); //put the rest of the results on the stack //foreach (var runItem in prioResult) //{ // Console.WriteLine($"{runItem.Name}, {runItem.RunNrOfTimes}"); //} prioResult = prioResult.GroupBy(x => x.Name + x.URI + x.Command) .Select(x => x.OrderByDescending(p => p.RunNrOfTimes).First()).ToList(); //remove potential duplicates prioResult = prioResult.ToList().OrderByDescending(p => p.RunNrOfTimes) .ToList(); //sort prioresults since they will always have at least one runtime PrioSearchTime = (int)sw.ElapsedTicks; TotalSearchTime = GeneralSearchTime + PrioSearchTime; return(prioResult.Take(10).ToList()); }
public void AddExecutedItem(RunItem exItem) { MatcherGeneral.Remove(exItem.Name.ToLower()); exItem.RunNrOfTimes++; MatcherPrio.Replace(exItem.Name, exItem); SaveTries(); }
public void AddItem(RunItem item) { if (!MatcherPrio.DataDictionary.ContainsKey(item.Name)) { MatcherPrio.Insert(item.Name.ToLower(), item); MatcherPrio.Insert(item.KeyWords, item); } }
public void ResetItemRunCounter(RunItem exItem) { exItem.RunNrOfTimes = 0; if (exItem.Type == ItemType.File || exItem.Type == ItemType.Directory ) //Move it back to general list. Settings and other stuff will always be in the priolist. { MatcherPrio.Remove(exItem.Name.ToLower()); MatcherGeneral.Insert(exItem.Name.ToLower(), exItem); } SaveTries(); }