/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var core = new SearchCore(); //var group = core.Group((Reference)e.NavigationParameter); //this.DefaultViewModel["Group"] = group; //this.DefaultViewModel["Items"] = await group.Results(); }
public SearchViewModel() { core = new SearchCore(); SearchCommand = new RelayCommand(Search); db = new DbManager(); columns = new List <string>(); columns.Add("AddressId"); columns.Add("Name"); columns.Add("Surname"); columns.Add("Patronymic"); columns.Add("BirthDay"); }
static async Task Main(string[] args) { if (args.Length == 0) { Console.WriteLine("No query was specified. Please execute again with the required search terms."); return; } Console.WriteLine("SearchFight results..."); await SearchCore.GetSearchTotalResults(args.ToList()); SearchCore.Results.ForEach(result => Console.WriteLine(result)); Console.Write("Search completed. Press <Enter> to exit... "); while (Console.ReadKey().Key != ConsoleKey.Enter) { } }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("There are not words to search. Please try again."); return; } var listResult = SearchCore.GetResultOfSearch(args.ToList()); if (listResult.Count == 0) { Console.WriteLine("We have problems in the search. Please contact technical support."); return; } foreach (var result in listResult) { Console.WriteLine(result); } }
public void SearchTest() { ISearchCore searchCore = new SearchCore(); ICurrentTimeProvider timeProvider = new NowCurrentTimeProvider(); SearchWithTwoLevelCache target = new SearchWithTwoLevelCache(searchCore, timeProvider); Document doc1 = new Document("doc1", "This is a document"); Document doc2 = new Document("doc2", "This is some text"); searchCore.IndexDocument(doc1); searchCore.IndexDocument(doc2); IQuery query = new Query("document text", QueryOperator.Any); IEnumerable <string> expected = new List <string>() { doc1.Id, doc2.Id }; IEnumerable <string> actual = target.Search(query); Assert.AreEqual(0, expected.Except(actual).Count()); Assert.AreEqual(0, actual.Except(expected).Count()); Assert.AreEqual(doc1.Contents, searchCore[doc1.Id].Contents); }
private void btnSearch_Click(object sender, EventArgs e) { var searchers = new List <Searcher> { new DefSearcher(defs) }; SearchCore = new SearchCore(searchers); lwDefs.Items.Clear(); lwDefs.Columns.Clear(); lwDefs.Columns.Add("Mod", 150); lwDefs.Columns.Add("Type", 150); lwDefs.Columns.Add("Name", 150); lwDefs.Columns.Add("Label", 150); string searchText = txtSearch.Text; Console.WriteLine(searchText); var model = new SearchResponse(); var s = new System.Diagnostics.Stopwatch(); s.Start(); model.Results = SearchCore.Search(searchText); s.Stop(); model.TimeTaken = s.Elapsed; defsView.Clear(); foreach (SearchResult result in model.Results) { Def def = result.Definition; string[] items = { def.modName, def.defType, def.defName, def.label }; var listViewItem = new ListViewItem(items); lwDefs.Items.Add(listViewItem); defsView.Add(def); } }
//private void InitializeRecipes() //{ // //RecipeItem recipe1 = new RecipeItem { RecipeName = "Test1", RecipeType = "AAA", Yield = "AAA", ServingSize = "111", Comments = "AAA", RecipeDirections = "AAA", Ingredients = "AAA"}; // //RecipeItem recipe2 = new RecipeItem { RecipeName = "Test2", RecipeType = "BBB", Yield = "BBB", ServingSize = "222", Comments = "BBB", RecipeDirections = "BBB", Ingredients = "BBB" }; // //RecipeItem recipe3 = new RecipeItem { RecipeName = "Test3", RecipeType = "CCC", Yield = "CCC", ServingSize = "333", Comments = "CCC", RecipeDirections = "CCC", Ingredients = "CCC" }; // //_recipes.AddRecipe(recipe1); // //_recipes.AddRecipe(recipe2); // //_recipes.AddRecipe(recipe3); //} private void SearchButton_Click(object sender, RoutedEventArgs e) { KeywordWindow dialog = new KeywordWindow(); // To pop the KeywordWindow in the center of parent window dialog.Owner = this; // If got a return value from dialog window if (dialog.ShowDialog() == true) { // If the string return is not empty if (dialog.SearchTerms.Length != 0 && dialog.SearchTerms.Replace("\t", "").Replace(" ", "").Length != 0) { //success.... // Use StringSplitOptions.RemoveEmptyEntries to remove empty entries string[] split = dialog.SearchTerms.Split(new char [] { '\t' }, StringSplitOptions.RemoveEmptyEntries); List <Recipe> tempRecipes = new List <Recipe>(); foreach (Recipe r in ro.Recipes) { List <string> recipeStrings = new List <string>(); recipeStrings.Add(r.Title); recipeStrings.Add(r.RecipeType); recipeStrings.Add(r.ServingSize); recipeStrings.Add(r.Yield); recipeStrings.Add(r.Comment); recipeStrings.Add(r.Directions); recipeStrings.Add(AppendIngredientsToSingleString(SelectIngredients(r.RecipeID))); if (SearchCore.SearchKeywords(split, recipeStrings)) { tempRecipes.Add(r); } } // If found something if (tempRecipes.Count != 0) { TitleListBox.DataContext = tempRecipes; // Clear selection after each search TitleListBox.SelectedItem = null; ClearDataContexts(); ___Errormessagelabel_.Visibility = Visibility.Hidden; } // If found nothing else { ___Errormessagelabel_.Visibility = Visibility.Visible; string message = "Item not found"; RecipeError SEARCHERROR = new RecipeError(); SEARCHERROR.ErrorMsg = message; ___Errormessagelabel_.Content = SEARCHERROR.ErrorMsg; } } else { ___Errormessagelabel_.Visibility = Visibility.Visible; string message = "Input error"; RecipeError SEARCHERROR = new RecipeError(); SEARCHERROR.ErrorMsg = message; ___Errormessagelabel_.Content = SEARCHERROR.ErrorMsg; } } else { //message and label for ill forned text or error... ___Errormessagelabel_.Visibility = Visibility.Visible; string message = "Search canceled"; RecipeError SEARCHERROR = new RecipeError(); SEARCHERROR.ErrorMsg = message; ___Errormessagelabel_.Content = SEARCHERROR.ErrorMsg; } }
public ExistChecker(SearchCore parent) : base(parent) { }
public DegreesChecker(SearchCore parent) : base(parent) { }