private JsonConverter CreateCovariantSearchSelector <T, TResult>(ISearchRequest originalSearchDescriptor) where T : class where TResult : class { SearchPathInfo.CloseOverAutomagicCovariantResultSelector(this.Infer, originalSearchDescriptor); return(originalSearchDescriptor.TypeSelector == null ? null : new ConcreteTypeConverter <TResult>(originalSearchDescriptor.TypeSelector)); }
public ISearchResponse <T> Search(ISearchRequest searchRequest) { var json = GetQueryJSonFromRequest(searchRequest, ElasticsearchContext.ElasticClient); var searchResponse = ElasticsearchContext.ElasticClient.Search <T>(searchRequest); return(searchResponse); }
private IQueryable <DbEntry <TEntity> > CreateQuery(ISearchRequest <TEntity> request) { var query = _container.GetItemLinqQueryable <DbEntry <TEntity> >( continuationToken: request.ContinuationToken, requestOptions: new QueryRequestOptions { MaxItemCount = request.PageSize }) .AsQueryable(); if (!string.IsNullOrEmpty(request.Query)) { var tokens = _model.Analyzer.AnalyzeQuery(request.Query); foreach (var token in tokens) { query = query.Where(x => x.All.Contains(token)); } } if (request.Filter != null) { query = query.Where(request.Filter.RemapTo <DbEntry <TEntity>, TEntity, bool>(x => x.Original)); } if (request.SortBy != null) { query = request.SortDirection == SortDirection.Ascending ? query.OrderBy(request.SortBy.RemapTo <DbEntry <TEntity>, TEntity, object>(x => x.Normalized)) : query.OrderByDescending(request.SortBy.RemapTo <DbEntry <TEntity>, TEntity, object>(x => x.Normalized)); } return(query); }
public ISearchResult Search(ISearchRequest request) { ISearchResult result = null; // implement searching here return(result); }
public async Task <IEnumerable <Reservation> > GetForYearlySalesReportAsync(ISearchRequest searchRequest, int?year, int?userId, string userFullName) { var query = _dbSet.Include(x => x.User).Include(x => x.Invoice).AsQueryable(); if (year.HasValue) { query = query.Where(x => x.CreatedAt.Year == year); } if (userId.HasValue) { query = query.Where(x => x.UserId == userId); } if (!string.IsNullOrWhiteSpace(userFullName)) { userFullName = userFullName.ToLower(); query = query.Where(x => (x.User.FirstName + " " + x.User.LastName).ToLower().StartsWith(userFullName)); } query = ApplySorting(query, searchRequest); if (searchRequest.Includes.Count() > 0) { query = AddIncludes(query, searchRequest.Includes); } return(await query.ToListAsync()); }
/// <inheritdoc /> public ISearchResponse <TResult> Search <T, TResult>(ISearchRequest request) where T : class where TResult : class => Dispatcher.Dispatch <ISearchRequest, SearchRequestParameters, SearchResponse <TResult> >( request, (p, d) => LowLevelDispatch.SearchDispatch <SearchResponse <TResult> >(p, d) );
public ScrollAllObservable(IOpenSearchClient client, IScrollAllRequest scrollAllRequest, CancellationToken cancellationToken = default) { _scrollAllRequest = scrollAllRequest; _searchRequest = scrollAllRequest?.Search ?? new SearchRequest <T>(); switch (_scrollAllRequest) { case IHelperCallable helperCallable when helperCallable.ParentMetaData is object: _searchRequest.RequestParameters.SetRequestMetaData(helperCallable.ParentMetaData); break; default: _searchRequest.RequestParameters.SetRequestMetaData(RequestMetaDataFactory.ScrollHelperRequestMetaData()); break; } if (_searchRequest.Sort == null) { _searchRequest.Sort = FieldSort.ByDocumentOrder; } _searchRequest.RequestParameters.Scroll = _scrollAllRequest.ScrollTime.ToTimeSpan(); _client = client; _compositeCancelTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); _compositeCancelToken = _compositeCancelTokenSource.Token; _backPressure = _scrollAllRequest.BackPressure; }
private string ConvertToJsonQuery(ISearchRequest searchRequest) { string jsonQuery = string.Empty; jsonQuery = Client.Serializer.SerializeToString(searchRequest); return(jsonQuery); }
public SearchResponse Search(ISearchRequest searchRequest) { var request = new RestRequest("gis/search"); request.Method = Method.GET; // Add params request.AddParameter("area", searchRequest.Area.ToString(true), ParameterType.QueryString); request.AddParameter("price", searchRequest.Price); request.AddParameter("status", string.Join(",", searchRequest.StatusTypes)); request.AddParameter("prop_types", string.Join(",", searchRequest.PropertyTypes)); request.AddParameter("cdom", searchRequest.CDOM); request.AddParameter("year", searchRequest.Year); request.AddParameter("beds", searchRequest.Beds); request.AddParameter("baths", searchRequest.Baths); request.AddParameter("garages", searchRequest.Garages); request.AddParameter("acres", searchRequest.Acres); request.AddParameter("sqft", searchRequest.SqFt); request.AddParameter("max_results", searchRequest.MaxResults); request.AddParameter("options", searchRequest.Options ?? string.Join(",", searchRequest.SearchOptionTypes)); var response = PeformSessionRequest <SearchResponse>(request); return(response.Data); }
private void UpdateCriteriaUI(ISearchRequest criteria) { //prevent event handler processing _ignoreEvent = true; // Update the UI trackbars //Special conversions tbPrice.Ranges[0].Start = _converter.ConvertPriceToProgress(criteria.Price.Min, (int)tbPrice.Maximum); tbPrice.Ranges[0].End = _converter.ConvertPriceToProgress(criteria.Price.Max, (int)tbPrice.Maximum); tbAcres.Ranges[0].Start = _converter.ConvertAcresToProgress(criteria.Acres.Min, (int)tbAcres.Maximum); tbAcres.Ranges[0].End = _converter.ConvertAcresToProgress(criteria.Acres.Max, (int)tbAcres.Maximum); tbSqFt.Ranges[0].Start = _converter.ConvertSqFtToProgress(criteria.SqFt.Min, (int)tbSqFt.Maximum); tbSqFt.Ranges[0].End = _converter.ConvertSqFtToProgress(criteria.SqFt.Max, (int)tbSqFt.Maximum); tbBaths.Ranges[0].Start = _converter.ConvertBathsToProgress(criteria.Baths.Min, (int)tbBaths.Maximum); tbBaths.Ranges[0].End = _converter.ConvertBathsToProgress(criteria.Baths.Max, (int)tbBaths.Maximum); //Generic conversions tbBeds.Ranges[0].Start = _converter.ConvertRealValueToUiValue(criteria.Beds.Min, (int)tbBeds.Minimum, (int)tbBeds.Maximum); tbBeds.Ranges[0].End = _converter.ConvertRealValueToUiValue(criteria.Beds.Max, (int)tbBeds.Minimum, (int)tbBeds.Maximum); tbYear.Ranges[0].Start = _converter.ConvertRealValueToUiValue(criteria.Year.Min, (int)tbYear.Minimum, (int)tbYear.Maximum); tbYear.Ranges[0].End = _converter.ConvertRealValueToUiValue(criteria.Year.Max, (int)tbYear.Minimum, (int)tbYear.Maximum); tbGarages.Ranges[0].Start = _converter.ConvertRealValueToUiValue(criteria.Garages.Min, (int)tbGarages.Minimum, (int)tbGarages.Maximum); tbGarages.Ranges[0].End = _converter.ConvertRealValueToUiValue(criteria.Garages.Max, (int)tbGarages.Minimum, (int)tbGarages.Maximum); tbTOM.Value = _converter.ConvertRealValueToUiValue(criteria.CDOM, (int)tbTOM.Minimum, (int)tbTOM.Maximum); //Update the UI dropdowns PopulateCheckedListBox(listingStatusCheckedListBox, criteria.StatusTypes); PopulateCheckedListBox(propertyTypeCheckedListBox, criteria.PropertyTypes); PopulateCheckedListBox(searchOptionsCheckedListBox, criteria.SearchOptionTypes); numericUpDown1.Value = _converter.ConvertRealValueToUiValue(criteria.MaxResults, (int)numericUpDown1.Minimum, (int)numericUpDown1.Maximum); //Resume normal event handler function UpdateLabels(criteria); _ignoreEvent = false; }
protected override Expression <Func <Event, object> > GetSortExpression(ISearchRequest searchRequest) { switch (searchRequest.SortColumn) { case nameof(Event.Title): return(x => x.Title); case nameof(Event.Description): return(x => x.Description); case nameof(Event.Author): return(x => x.Author.FirstName + ' ' + x.Author.LastName); case nameof(Event.Type): return(x => x.Type.Name); case nameof(Event.DateAndTime): return(x => x.DateAndTime); case nameof(Event.Promoter): return(x => x.Promoter); default: return(x => x.Id); } }
public void ApplyFilter(ISearchRequest searchRequest) { var client = ServiceLocator.Current.GetInstance<IElasticClient>(); var infer = client.Infer; //no filter created by code if (searchRequest.Filter == null) { searchRequest.Filter = new FilterContainer(); searchRequest.Filter.Bool = new BoolFilterDescriptor<IContent>(); searchRequest.Filter.Bool.Must = new List<IFilterContainer>(); } //filter created by code else if (searchRequest.Filter != null && searchRequest.Filter.Bool == null) { searchRequest.Filter.Bool = new BoolFilterDescriptor<IContent>(); var mustList = new List<IFilterContainer>(); if (searchRequest.Filter.Term != null) { //keep termfilter created by code var name = infer.PropertyPath(searchRequest.Filter.Term.Field); mustList.Add(new FilterDescriptor<IContent>().Term(name, searchRequest.Filter.Term.Value)); searchRequest.Filter.Term = null; } //kepp termsfilter created by code if (searchRequest.Filter.Terms != null) { var name = infer.PropertyPath(searchRequest.Filter.Terms.Field); var terms = ((ITermsFilter)searchRequest.Filter.Terms).Terms; mustList.Add(new FilterDescriptor<IContent>().Terms(name, terms.Cast<string>(), searchRequest.Filter.Terms.Execution)); searchRequest.Filter.Terms = null; } searchRequest.Filter.Bool.Must = mustList; } }
protected override Expression <Func <Movie, object> > GetSortExpression(ISearchRequest searchRequest) { switch (searchRequest.SortColumn) { case nameof(Movie.Title): return(x => x.Title); case nameof(Movie.Year): return(x => x.Year); case nameof(Movie.Duration): return(x => x.Duration); case nameof(Movie.Country): return(x => x.Country); case nameof(Movie.Directors): return(x => x.Directors); case nameof(Movie.Actors): return(x => x.Actors); default: return(x => x.Id); } }
private IQueryable <Screening> GetFilteredQueryable(ISearchRequest searchRequest, string searchTerm, int?movieId, string hall, decimal?price, ref TimingStatus?status, DateTime?screeningDate) { var query = _dbSet.AsQueryable(); if (status == null) { status = TimingStatus.SCHEDULED; } query = ApplyFilter(query, searchTerm, movieId, hall, price, status, screeningDate); if (searchRequest.SortOrder == null || searchRequest.SortColumn == null) { searchRequest.SortOrder = SortOrder.DESC; searchRequest.SortColumn = nameof(Screening.DateAndTime); } query = ApplySorting(query, searchRequest); if (searchRequest.Includes.Count() > 0) { query = AddIncludes(query, searchRequest.Includes); } return(query); }
public CatalogsResultViewModel(ISearchResultBase result, ISearchRequest request) : this() { _request = request as CatalogSearchRequest; CatalogSearchResult catalogsResult = result as CatalogSearchResult; _catalogs = catalogsResult.Catalogs; }
protected string GetSearchType(ISearchRequest descriptor, MultiSearchDescriptor multiSearchDescriptor) { if (descriptor._SearchType != null) { switch (descriptor._SearchType.Value) { case SearchTypeOptions.Count: return("count"); case SearchTypeOptions.DfsQueryThenFetch: return("dfs_query_then_fetch"); case SearchTypeOptions.DfsQueryAndFetch: return("dfs_query_and_fetch"); case SearchTypeOptions.QueryThenFetch: return("query_then_fetch"); case SearchTypeOptions.QueryAndFetch: return("query_and_fetch"); case SearchTypeOptions.Scan: return("scan"); } } return(multiSearchDescriptor._QueryString.GetQueryStringValue <string>("search_type")); }
public async Task <int> CountAsync(ISearchRequest <TEntity> request) { var query = CreateQuery(request); var result = await query.CountAsync().ConfigureAwait(false); return(result.Resource); }
public async Task <IPagedList <Screening> > GetPagedAsync(ISearchRequest searchRequest, string searchTerm, int?movieId, string hall, decimal?price, TimingStatus?status, DateTime?screeningDate) { var query = GetFilteredQueryable(searchRequest, searchTerm, movieId, hall, price, ref status, screeningDate); var pagedList = await ApplyPaginationAsync(query, searchRequest.PageIndex, searchRequest.PageSize); return(pagedList); }
/// <inheritdoc/> public Task <ISearchResponse <TResult> > SearchAsync <T, TResult>(ISearchRequest request, CancellationToken cancellationToken = default(CancellationToken)) where T : class where TResult : class => this.Dispatcher.DispatchAsync <ISearchRequest, SearchRequestParameters, SearchResponse <TResult>, ISearchResponse <TResult> >( request, cancellationToken, (p, d, c) => this.LowLevelDispatch.SearchDispatchAsync <SearchResponse <TResult> >(p, d, c) );
/// <summary> /// 初始化sort /// </summary> /// <param name="searchRequest"></param> /// <param name="sorts"></param> public static ISearchRequest InitSort(this ISearchRequest searchRequest, List <ISort> sorts) { if (sorts != null) { searchRequest.Sort = sorts; } return(searchRequest); }
/// <summary> /// 初始化query /// </summary> /// <param name="searchRequest"></param> /// <param name="predicate"></param> public static ISearchRequest InitQueryContainer(this ISearchRequest searchRequest, IPredicate predicate) { if (predicate != null) { searchRequest.Query = predicate.GetQuery(searchRequest.Query); } return(searchRequest); }
protected string GetSearchType(ISearchRequest descriptor, IMultiSearchRequest multiSearchRequest) { if (descriptor.SearchType != null) { return(descriptor.SearchType.Value.GetStringValue()); } return(multiSearchRequest.RequestParameters.GetQueryStringValue <string>("search_type")); }
public TravelersController(IRepositoryWrapper repo, IWeatherRequest weatherRequest, ISearchRequest searchRequest, IGoogleServices googleServices, IHikingProject hikingService) { _repo = repo; _searchRequest = searchRequest; _googleServices = googleServices; _hikingService = hikingService; _weatherRequest = weatherRequest; }
/// <summary> /// Optionally specify more search options such as facets, from/to etcetera. /// </summary> public MoreLikeThisDescriptor <T> Search(Func <SearchDescriptor <T>, SearchDescriptor <T> > searchDescriptor) { searchDescriptor.ThrowIfNull("searchDescriptor"); var d = searchDescriptor(new SearchDescriptor <T>()); this._Search = d; return(this); }
protected virtual ISearchRequest ApplyDefaultSearchValues(ISearchRequest searchRequest) { searchRequest.SortColumn = CurrentSortPropertyName; searchRequest.SortOrder = CurrentSortOrder; searchRequest.PageSize = Paging.DEFAULT_PAGE_SIZE; searchRequest.PageIndex = Paging.DEFAULT_PAGE_INDEX; return(searchRequest); }
/// <inheritdoc/> public Task <ISearchResponse <TResult> > SearchAsync <T, TResult>(ISearchRequest request) where T : class where TResult : class => this.Dispatcher.DispatchAsync <ISearchRequest, SearchRequestParameters, SearchResponse <TResult>, ISearchResponse <TResult> >( request, (p, d) => this.LowLevelDispatch.SearchDispatchAsync <SearchResponse <TResult> >( this.AttachCustomConverterWhenNeeded <T, TResult>(p.RouteValues, request), d ) );
/// <inheritdoc/> public ISearchResponse <TResult> Search <T, TResult>(ISearchRequest request) where T : class where TResult : class => this.Dispatcher.Dispatch <ISearchRequest, SearchRequestParameters, SearchResponse <TResult> >( request, (p, d) => this.LowLevelDispatch.SearchDispatch <SearchResponse <TResult> >( this.CovariantConverterWhenNeeded <T, TResult, ISearchRequest, SearchRequestParameters>(p.RouteValues, request), d ) );
public SearchDataReader( TContext arg0, SqlDataReader arg1, ISearchRequest arg2 ) : base() { Field1 = arg1; Field2 = arg2; }
public ISearchRequest ToRequest() { if (_searchRequest == null) { var sd = new SearchDescriptor <TEntity>(); var func = ToFunc(); _searchRequest = func?.Invoke(sd) ?? sd; } return(_searchRequest); }
public QueryableProvider(IElasticClient client) { _queryBuilder = new QueryBuilder <T>(); _mappingIndex = _queryBuilder.GetMappingIndex(); _request = new SearchRequest(_mappingIndex.IndexName) { Size = 10000 }; _client = client; }
/// <inheritdoc/> public Task <ISearchResponse <TResult> > SearchAsync <T, TResult>(ISearchRequest request, CancellationToken cancellationToken = default(CancellationToken)) where T : class where TResult : class => this.Dispatcher.DispatchAsync <ISearchRequest, SearchRequestParameters, SearchResponse <TResult>, ISearchResponse <TResult> >( request, cancellationToken, (p, d, c) => this.LowLevelDispatch.SearchDispatchAsync <SearchResponse <TResult> >( this.CovariantConverterWhenNeeded <T, TResult, ISearchRequest, SearchRequestParameters>(p.RouteValues, request), d, c ) );
public ISearchResponse <TResult> Search <T, TResult>(ISearchRequest request) where T : class where TResult : class { var pathInfo = ((IPathInfo <SearchRequestParameters>)request).ToPathInfo(_connectionSettings); var status = this.RawDispatch.SearchDispatch <SearchResponse <TResult> >(pathInfo, request); return(status.Success ? status.Response : CreateInvalidInstance <SearchResponse <TResult> >(status)); }
public void ApplyFilter(ISearchRequest searchRequest) { var principalInfo = EPiServer.Security.PrincipalInfo.Current; var mustlist = ((List<IFilterContainer>) searchRequest.Filter.Bool.Must); if (principalInfo == null || principalInfo.RoleList.All(string.IsNullOrEmpty)) mustlist.Add(new FilterDescriptor<IContent>().Term(Constants.AclFieldName, "Everyone")); else { var list = new List<string>(principalInfo.RoleList) { "Everyone" }; mustlist.Add(new FilterDescriptor<IContent>().Terms(Constants.AclFieldName, list, TermsExecution.Or)); } }
public void ApplyFilter(ISearchRequest searchRequest) { if (searchRequest.Filter.Bool.MustNot == null) { searchRequest.Filter.Bool.MustNot = new List<IFilterContainer>(); } ((List<IFilterContainer>)searchRequest.Filter.Bool.MustNot).Add( new FilterDescriptor<IVersionable>().Range(x => x.OnField(o => o.StartPublish).GreaterOrEquals(DateTime.Now.ToString("s"))) ); ((List<IFilterContainer>)searchRequest.Filter.Bool.MustNot).Add( new FilterDescriptor<IVersionable>().Range(x => x.OnField(o => o.StopPublish).LowerOrEquals(DateTime.Now.ToString("s"))) ); }
public SearchBarViewModel(SearchType searchType) { _searchType = searchType; if (_searchType == SearchType.ObjectSearch) { _searchRequest = new ObjectSearchRequest(); _watermarkText = "Enter text to search for objects..."; } else { _searchRequest = new CatalogSearchRequest(); _watermarkText = "Enter text to search for catalogs..."; } _segments = new ObservableCollection<TextBoxSegment>(); //_searchOptions = new SearchOptionsViewModel(); //_searchOptions.PropertyChanged += _searchOptions_PropertyChanged; }
/// <summary> /// Builds the Search Request, prepares it and then executes it /// </summary> private void doSearch() { searchRunning = true; startTime = DateTime.Now; flowResults.Blocks.Clear(); matches = new System.Collections.ObjectModel.ObservableCollection<MatchingItem>(); matchingLinesForCurrentSelection.Clear(); listViewMatches.ItemsSource = matches; listViewMatchesForSelection.ItemsSource = matchingLinesForCurrentSelection; runningProgress.Visibility = System.Windows.Visibility.Visible; #region Build search strings and search folders if (searchRequest == null) { searchRequest = new SearchRequestFilesystem(); } if (_searchStringsChanged) { searchRequest.SearchStrings.Clear(); for (int index = 0; index < textBoxSearchStrings.LineCount; index++) { string line = textBoxSearchStrings.GetLineText(index).Trim(); if (line.Length > 0) { searchRequest.AddSearchString(line); } } } if (_foldersChanged) { searchRequest.SearchContainers.Clear(); for (int index = 0; index < dirChooser.InternalTextBox.LineCount; index++) { string line = dirChooser.InternalTextBox.GetLineText(index).Trim(); if (line.Length > 0) { searchRequest.AddSearchContainer(line); } } } #endregion #region Build includes if (_includeFilesChanged) { searchRequest.IncludeItemStrings.Clear(); string[] lines = textBoxIncludeFiles.Text.Split('\n'); for (int index = 0; index < lines.Length; index++) { string line = lines[index].Trim(); if (line.Length > 0) { searchRequest.AddIncludeItemString(line); } } } if (_includeFoldersChanged) { searchRequest.IncludeContainerStrings.Clear(); string[] lines = textBoxIncludeFolders.Text.Split('\n'); for (int index = 0; index < lines.Length; index++) { string line = lines[index].Trim(); if (line.Length > 0) { searchRequest.AddIncludeContainerString(line); } } } #endregion #region Build excludes if (_excludeFilesChanged) { searchRequest.ExcludeItemStrings.Clear(); string[] lines = textBoxExcludeFiles.Text.Split('\n'); for (int index = 0; index < lines.Length; index++) { string line = lines[index].Trim(); if (line.Length > 0) { searchRequest.AddExcludeItemString(line); } } } if (_excludeFoldersChanged) { searchRequest.ExcludeContainerStrings.Clear(); string[] lines = textBoxExcludeFolders.Text.Split('\n'); for (int index = 0; index < lines.Length; index++) { string line = lines[index].Trim(); if (line.Length > 0) { searchRequest.AddExcludeContainerString(line); } } } #endregion //Update the history popups with the values from this search updateHistoryPopups(); searchRequest.SetRecurse(chkRecurse.IsChecked.Value); searchRequest.SetCaseSensitive(chkCaseSensitive.IsChecked.Value); searchRequest.SetSearchBinaries(chkBinaries.IsChecked.Value); searchRequest.NotifyProgress += new NotifyProgressEventHandler(searchRequest_NotifyProgress); search = new SearchFilesystem(); search.ItemSearched += new ItemSearchedEventHandler(search_ItemSearched); setChangedStatus(false); //Reset the changed status now that the search is about to run performSearchOnSeparateThread(search, searchRequest); }
public PageableCatalogResultViewModel(ISearchResultBase result, ISearchRequest request) { _request = request as CatalogSearchRequest; CatalogSearchResult catalogsResult = result as CatalogSearchResult; _catalogs = new PageableCollection<Catalog>(catalogsResult.Catalogs); }
public ISearchRequest GetRequest() { if(_searchType == SearchType.ObjectSearch) { _searchRequest = new ObjectSearchRequest(); } else { _searchRequest = new CatalogSearchRequest(); } _searchRequest.SearchTerm = _searchText; return _searchRequest; }
//public bool IsSearchActive //{ // get { return _isSearchActive; } // set // { // _isSearchActive = value; // NotifyPropertyChanged(this, new PropertyChangedEventArgs("IsSearchActive")); // } //} //public void OnSearch(SearchCommandParameters parameters) //{ // if (_isSearchActive) // { // if (SearchCancelled != null) // SearchCancelled(this, EventArgs.Empty); // _isSearchActive = false; // } // else // { // if (SearchStarted != null) // SearchStarted(this, EventArgs.Empty); // _isSearchActive = true; // } //} public ISearchRequest GetRequest() { _searchRequest = new ObjectSearchRequest(); //_searchRequest.SearchTerm = _searchText; return _searchRequest; }
/// <summary> /// Clears everything out ready to perform a new search /// </summary> /// <param name="sender">Component triggering this event</param> /// <param name="e">Standard event args</param> private void NewSearchRequest_OnClick(object sender, RoutedEventArgs e) { matchingLinesForCurrentSelection.Clear(); matches.Clear(); searchRequest = new SearchRequestFilesystem(); resetUI(); }
public void ApplyFilter(ISearchRequest searchRequest) { ((List<IFilterContainer>)searchRequest.Filter.Bool.Must).Add( new FilterDescriptor<IContent>().Term(Constants.InheritanceFieldName, searchRequest.ClrType.ToSimpleAssemblyName()) ); }
/// <summary> /// Prepare and execute the search on a separate thread. /// </summary> /// <param name="search">The search to run</param> /// <param name="request">The search request to action</param> private void performSearchOnSeparateThread(ISearch search, ISearchRequest request) { List<Task> tasks = new List<Task>(); var token = tokenSource.Token; var t = Task.Factory.StartNew(() => { prepareAndSearch(request, search); this.Dispatcher.BeginInvoke(new Action(() => updateStatus("") ) , null); }, token); tasks.Add(t); Task.Factory.ContinueWhenAll(tasks.ToArray(), result => { this.Dispatcher.BeginInvoke(new Action(() => searchComplete()) , null); }); }
/// <summary> /// Update the screen based on the contents of the Search Request which has just been loaded /// </summary> /// <param name="loadSearchRequest"></param> /// <param name="filename"></param> private void populateScreenFromSearchRequest(ISearchRequest loadSearchRequest, string filename) { loadUIContainer(textBoxSearchStrings, loadSearchRequest.SearchStrings); loadUIContainer(dirChooser.InternalTextBox, loadSearchRequest.SearchContainers); loadUIContainer(textBoxIncludeFiles, loadSearchRequest.IncludeItemStrings); loadUIContainer(textBoxIncludeFolders, loadSearchRequest.IncludeContainerStrings); loadUIContainer(textBoxExcludeFiles, loadSearchRequest.ExcludeItemStrings); loadUIContainer(textBoxExcludeFolders, loadSearchRequest.ExcludeContainerStrings); chkBinaries.IsChecked = loadSearchRequest.SearchBinaries; chkCaseSensitive.IsChecked = loadSearchRequest.CaseSensitive; chkRecurse.IsChecked = loadSearchRequest.Recurse; setWindowTitle(filename); //Mark all the change tracking variables as false _searchStringsChanged = false; _foldersChanged = false; _includeFilesChanged = false; _includeFoldersChanged = false; _excludeFilesChanged = false; _excludeFoldersChanged = false; }
/// <summary> /// Prepares the search and then runs it. /// </summary> /// <param name="request">The search request to action</param> /// <param name="search">The search to run</param> private void prepareAndSearch(ISearchRequest request, ISearch search) { updateStatus("Determining which files to search..."); updateDocument(flowResults, "Determining which files to search..."); setChangedStatus(false); if (!request.IsPrepared) { request.Prepare(); } string displayString = string.Format("Searching {0} {1} ...", searchRequest.Urls.Count, searchRequest.Urls.Count == 1 ? "file" : "files"); updateDocument(flowResults, displayString); updateStatus(displayString); if (!cancellingSearch) { try { search.Search(request, true); } catch (Exception exception) { cancelRunningSearch(); updateDocument(flowResults, "Search aborted due to error: " + exception.Message); updateStatus("Search aborted due to error: " + exception.Message); } } }
private void LoadSearchRequest_OnClick(object sender, RoutedEventArgs e) { OpenFileDialog opendialog = new OpenFileDialog(); opendialog.DefaultExt = DEFAULT_REQUEST_EXTENSION; opendialog.Filter = DEFAULT_REQUEST_FILTER; opendialog.CheckFileExists = true; opendialog.Multiselect = false; if (opendialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (searchRequest == null) { searchRequest = new SearchRequestFilesystem(); } searchRequest = searchRequest.LoadSearchRequest(opendialog.FileName); if (searchRequest != null) { searchRequestUrl = opendialog.FileName; populateScreenFromSearchRequest(searchRequest, searchRequestUrl); } } }