public string Put() { //Get List of Search Scores & transform into dataTable List <SearchScore> searchScores = SearchResultHelper.PopulateSearchScoresTable("Peer"); DataTable dt = ToDataTable(searchScores); //set table name string tableName = "SearchScores"; //save to database string _connectionString = context.Database.Connection.ConnectionString; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); //Delete all data in a Table string sqlTrunc = "TRUNCATE TABLE " + tableName; SqlCommand cmd = new SqlCommand(sqlTrunc, connection); cmd.ExecuteNonQuery(); using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection)) { bulkCopy.DestinationTableName = tableName; bulkCopy.BatchSize = 5000; bulkCopy.WriteToServer(dt); } } return("SearchScores Table is updated"); }
private async void StartButton_OnClick(object sender, RoutedEventArgs e) { SetIsRunning(true); var result = await SearchManager.SearchForDuplicatesAsync(this); if (result == null) { await SetStateAsync("Search failed!"); return; } if (result.Canceled) { await SetStateAsync("Search canceled"); return; } var path = GetTargetFilePath(); await SetStateAsync($"Saving result to {path}"); if (await SearchResultHelper.SaveResultAsync(path, result)) { DirectoriesQueuedLabel.Content = $"Directories queued: 0"; await SetStateAsync("Done!"); Process.Start(path); } else { await SetStateAsync("Failed to save result"); } }
// GET api/SearchResult public List <SearchResult> Get(string ownUserId, string searchType, int resultCount) { List <SearchResult> searchResults = SearchResultHelper.GetSearchResults(ownUserId, searchType); searchResults = searchResults.OrderByDescending(x => x.TotalScore).Take(resultCount).ToList(); return(searchResults); }