Exemplo n.º 1
0
 public async Task <IEnumerable <object> > GetTextContains(IEnumerable <object> objects)
 {
     SearchText = SearchText.RemoveDiacritics(!CaseSensitive);
     return(await Task.Run(() => objects.Where(n => SearchProperty == null ? true
                : SearchProperty.GetValue(n, null) == null ? false
                : (SearchProperty.GetValue(n, null).ToString() ?? "").RemoveDiacritics(!CaseSensitive).Contains(SearchText))));
 }
Exemplo n.º 2
0
 public async Task <IEnumerable <object> > GetBetweenValues(IEnumerable <object> objects)
 {
     return(await Task.Run(() => objects.Where(n => SearchProperty == null ? true
                  : SearchProperty.GetValue(n, null) == null ? false
                   : ((double.Parse(SearchProperty.GetValue(n, null).ToString()) > double.Parse(SearchText)) &&
                      double.Parse(SearchProperty.GetValue(n, null).ToString()) < double.Parse(SearchText2)))));
 }
Exemplo n.º 3
0
            public void When_index_is_between_0_and_2_Then_returns_webElement_at_matching_index(
                int index,
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value
                )
            {
                // Arrange
                var expected = webElements.ElementAt(index);

                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(
                    locator,
                    value,
                    webDriver,
                    index,
                    150.Milliseconds());

                // Act
                var actual = sut.Find();

                // Assert
                actual.ShouldBe(expected);
            }
        IEnumerable <Person> Search(SearchProperty filter, string searchString)
        {
            IEnumerable <Person> result;

            if (filter != SearchProperty.Alle)
            {
                var f    = Enum.GetName(typeof(SearchProperty), filter);
                var prop = properties["Art"];
                result = from p in people
                         where p.Art.Contains(f)
                         select p;
            }
            else
            {
                result = from p in people
                         select p;
            }
            if (!string.IsNullOrEmpty(searchString))
            {
                var searchLower = searchString.ToLower();

                result = from p in result
                         where p.SafeDisplayName.ToLower().Contains(searchLower) || p.Organisation != null && p.Organisation.ToLower().Contains(searchLower) || p.Personalbereich != null && p.Personalbereich.ToLower().Contains(searchLower)
                         select p;
            }
            return(result);
        }
Exemplo n.º 5
0
 public Search(string name, SearchProperty filter)
 {
     Name     = name;
     Text     = "";
     Property = filter;
     Results  = new Collection <Person>();
 }
Exemplo n.º 6
0
            public void When_index_is_between_0_and_2_Then_returns_webElement_at_matching_index(
                int index,
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value
                )
            {
                // Arrange
                var expected = webElements.ElementAt(index);

                using var cancellationTokenSource1 = new CancellationTokenSource(TimeSpan.FromMilliseconds(100));
                using var cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromMilliseconds(130));
                var cancellationToken1 = cancellationTokenSource1.Token;
                var cancellationToken2 = cancellationTokenSource2.Token;

                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(locator, value, webDriver, index, 200.Milliseconds());

                // Act
                var actual = sut.Get(cancellationToken1, cancellationToken2);

                // Assert
                actual.ShouldBe(expected);
            }
        protected string QuerySingleItem(string term, SearchProperty property, double boostAll)
        {
            var boost       = property.BoostMultiplier * boostAll;
            var boostString = string.Empty;

            if (boost != 1.0)
            {
                boostString = "^" + boost.ToString(CultureInfo.InvariantCulture);
            }
            var fuzzyString   = string.Empty;
            var wildcardQuery = string.Empty;

            if (!term.Contains('"'))
            {
                // wildcard queries get lower relevance than exact matches, and ignore fuzzieness
                if (property.Wildcard)
                {
                    var halfBoost = (boost * 0.5).ToString(CultureInfo.InvariantCulture);
                    wildcardQuery = $"({property.PropertyName}:{term}*^{halfBoost} OR {property.PropertyName}_{_search.Culture}:{term}*^{halfBoost}) ";
                }
                else
                {
                    var fuzzyLocal = property.FuzzyMultiplier;
                    if (fuzzyLocal < 1.0 && fuzzyLocal > 0.0)
                    {
                        fuzzyString = "~" + fuzzyLocal;
                    }
                }
            }
            return($"({property.PropertyName}:{term}{fuzzyString}{boostString} OR {property.PropertyName}_{_search.Culture}:{term}{fuzzyString}{boostString}) {wildcardQuery}");
        }
Exemplo n.º 8
0
        private async Task OnSearchCompleted(string searchText, SearchProperty searchProperty, Task <IList <Person> > searchTask)
        {
            if (searchTask.IsFaulted)
            {
                var ev = Error;
                if (ev != null)
                {
                    ev(this, new ErrorEventArgs(searchTask.Exception));
                }
            }
            else
            {
                search.Results = new Collection <Person> (searchTask.Result);

                SetGroupedPeople();
                People = new ObservableCollection <Person> (search.Results);

                var ev = SearchCompleted;
                if (ev != null)
                {
                    ev(this, new SearchCompletedEventArgs {
                        SearchText     = searchText,
                        SearchProperty = searchProperty
                    });
                }
            }
        }
Exemplo n.º 9
0
        protected string QuerySingleItem(string term, SearchProperty property, double boostAll)
        {
            var boost       = property.BoostMultiplier * boostAll;
            var boostString = string.Empty;

            if (boost != 1.0)
            {
                boostString = "^" + boost;
            }
            var fuzzyString   = string.Empty;
            var wildcardQuery = string.Empty;

            if (!term.Contains('"'))
            {
                // wildcard queries get lower relevance than exact matches, and ignore fuzzieness
                if (property.Wildcard)
                {
                    wildcardQuery = string.Format(System.Globalization.CultureInfo.InvariantCulture, "({0}:{1}*^{2} OR {0}_{4}:{1}*^{2}) ", property.PropertyName, term, boost * 0.5, _search.Culture);
                }
                else
                {
                    double fuzzyLocal = property.FuzzyMultiplier;
                    if (fuzzyLocal < 1.0 && fuzzyLocal > 0.0)
                    {
                        fuzzyString = "~" + fuzzyLocal;
                    }
                }
            }
            return(string.Format(System.Globalization.CultureInfo.InvariantCulture, "({0}:{1}{2}{3} OR {0}_{5}:{1}{2}{3}) {4}", property.PropertyName, term, fuzzyString, boostString, wildcardQuery, _search.Culture));
        }
        public LogicPhraseDTO GetQuickSearchLogicPhrase(string text, EntitySearchDTO entitySearch)
        {
            LogicPhraseDTO quickSearchLogic = new LogicPhraseDTO();

            quickSearchLogic.AndOrType = AndOREqualType.Or;
            foreach (var item in entitySearch.EntitySearchAllColumns)
            {
                if (item.ColumnID != 0)
                {
                    SearchProperty searchProperty = new SearchProperty();
                    searchProperty.SearchColumnID = item.ID;
                    searchProperty.ColumnID       = item.ColumnID;
                    searchProperty.IsKey          = item.Column.PrimaryKey;
                    searchProperty.Value          = text;
                    LogicPhraseDTO logic = null;
                    if (item.RelationshipTail == null)
                    {
                        logic = quickSearchLogic;
                    }
                    else
                    {
                        logic           = AgentHelper.GetOrCreateSearchRepositoryFromRelationshipTail(quickSearchLogic, item.RelationshipTail, null);
                        logic.AndOrType = AndOREqualType.Or;
                    }

                    int      n;
                    var      isNumeric = int.TryParse(text, out n);
                    DateTime a;
                    var      isDateTime = DateTime.TryParse(text, out a);

                    if (item.Column.ColumnType == Enum_ColumnType.Numeric)
                    {
                        if (!isNumeric)
                        {
                            continue;
                        }
                        searchProperty.Operator = CommonOperator.Equals;
                    }
                    else if (item.Column.ColumnType == Enum_ColumnType.Date)
                    {
                        continue;
                    }
                    else if (item.Column.ColumnType == Enum_ColumnType.Boolean)
                    {
                        continue;
                    }
                    else if (item.Column.ColumnType == Enum_ColumnType.String)
                    {
                        searchProperty.Operator = CommonOperator.Contains;
                    }
                    else
                    {
                        continue;
                    }
                    logic.Phrases.Add(searchProperty);
                }
            }
            return(quickSearchLogic);
        }
 public Task <IList <Person> > SearchAsync(SearchProperty filter, string searchString, int sizeLimit, CancellationToken cancellationToken)
 {
     return(Task.Factory.StartNew(() =>
     {
         var s = Search(filter, searchString);
         var list = s.ToList();
         return (IList <Person>)list;
     }, cancellationToken));
 }
        //private DP_SearchRepository ToSearchRepositoryDTO(SearchRepository SearchRepository)
        //{
        //    var relDTO = new BizRelationship().GetRelationship(SearchRepository.SourceRelationID);
        //    DP_SearchRepository searchRepository = new DP_SearchRepository(relDTO.EntityID2);
        //    searchRepository.Name = relDTO.Name;
        //    searchRepository.HasNotRelationshipCheck = SearchRepository.HasNotRelationshipCheck;
        //    //searchRepository.HasRelationshipCheck = SearchRepository.HasRelationshipCheck;
        //    searchRepository.RelationshipFromCount = SearchRepository.RelationshipFromCount;
        //    searchRepository.RelationshipToCount = SearchRepository.RelationshipToCount;
        //    searchRepository.SourceEntityID = relDTO.EntityID1;
        //    searchRepository.SourceRelationID = relDTO.ID;
        //    searchRepository.SourceToTargetMasterRelationshipType = relDTO.MastertTypeEnum;
        //    searchRepository.SourceToTargetRelationshipType = relDTO.TypeEnum;
        //    if (SearchRepository.LogicPhrase != null)
        //        searchRepository.Phrases.Add(ToLogicPhraseDTO(SearchRepository.LogicPhrase));

        //    return searchRepository;
        //}

        private ProxyLibrary.Phrase ToColumnPhraseDTO(ColumnPhrase columnPhrase)
        {
            SearchProperty property = new SearchProperty();

            property.ColumnID       = columnPhrase.ColumnID;
            property.SearchColumnID = columnPhrase.EntitySearchColumnsID ?? 0;
            property.Operator       = (CommonOperator)Enum.Parse(typeof(CommonOperator), columnPhrase.Operator);
            property.Value          = columnPhrase.Value;
            return(property);
        }
Exemplo n.º 13
0
        public async Task <IEnumerable <object> > GetFilteredByDateTimeInterval(IEnumerable <object> objects)
        {
            DateTime result = DateTime.MinValue;

            return(await Task.Run(() => objects.Where(n => (SearchProperty == null ? true
                     : SearchProperty.GetValue(n, null) == null) ||
                                                      (!DateTime.TryParse(SearchProperty.GetValue(n, null).ToString(), out result) ? false
                     : Convert.ToDateTime(SearchProperty.GetValue(n, null)) > SearchDateFrom) &&
                                                      (Convert.ToDateTime(SearchProperty.GetValue(n, null)) <= SearchDateTo))));
        }
Exemplo n.º 14
0
 public static Card FindCardWherePropertyEquals(List <Card> cards, SearchProperty searchProperty)
 {
     for (int i = 0; i < cards.Count; i++)
     {
         if (searchProperty(cards[i]))
         {
             return(cards[i]);
         }
     }
     return(null);
 }
Exemplo n.º 15
0
        public void When_no_defaultCancellationToken_Then_DefaultCancellationToken_is_None(
            int index,
            IFindsByFluentSelector <IWebElement> webDriver,
            string locator,
            string value)
        {
            // Arrange, Act
            var actual = new SearchProperty <IWebElement>(locator, value, webDriver, index, TimeSpan.Zero);

            // Assert
            actual.DefaultTimeout.ShouldBe(TimeSpan.Zero);
        }
Exemplo n.º 16
0
        public void When_all_parameters_are_valid_Then_returns_SearchProperties(
            int index,
            IFindsByFluentSelector <IWebElement> webDriver,
            string locator,
            string value)
        {
            // Arrange, Act
            var actual = new SearchProperty <IWebElement>(locator, value, webDriver, index, 100.Milliseconds());

            // Assert
            actual.ShouldNotBeNull();
            actual.ShouldBeAssignableTo <ISearchProperty <IWebElement> >();
        }
Exemplo n.º 17
0
        ///<summary>Returns a subset of a given list of cards that match a given search property.</summary>
        public static List <Card> FindCardsWherePropertyEquals(List <Card> cards, SearchProperty searchProperty)
        {
            List <Card> ret = new List <Card>();

            for (int i = 0; i < cards.Count; i++)
            {
                if (searchProperty(cards[i]))
                {
                    ret.Add(cards[i]);
                }
            }
            return(ret);
        }
Exemplo n.º 18
0
        public void When_all_parameters_are_valid_Then_assigned_public_properties(
            int index,
            IFindsByFluentSelector <IWebElement> webDriver,
            string locator,
            string value)
        {
            // Arrange, Act
            var actual = new SearchProperty <IWebElement>(locator, value, webDriver, index, 100.Milliseconds());

            // Assert
            actual.Selector.ShouldBe(locator);
            actual.Value.ShouldBe(value);
            actual.WebDriver.ShouldBe(webDriver);
            actual.Index.ShouldBe(index);
        }
Exemplo n.º 19
0
        public void When_no_index_is_defined_Then_Index_is_0(
            IFindsByFluentSelector <IWebElement> webDriver,
            string locator,
            string value)
        {
            // Arrange, Act
            var actual = new SearchProperty <IWebElement>(
                locator,
                value,
                webDriver,
                100.Milliseconds());

            // Assert
            actual.Index.ShouldBe(0);
        }
        private void AddSearchPropertyNode(SearchProperty phrase, AdvanceSearchNode andOrNode)
        {
            var newnode = new AdvanceSearchNode();

            newnode.ParentNode = andOrNode;
            newnode.Title      = phrase.ColumnID.ToString();
            andOrNode.ChildItems.Add(newnode);
            newnode.NodeManager = andOrNode.NodeManager.AddChildItem();
            newnode.NodeManager.SetHeader(newnode.Title);
            newnode.Phrase = phrase;

            I_AdvanceSearchMenu removeMenu = newnode.NodeManager.AddMenu("حذف");

            removeMenu.Clicked += (sender1, e1) => RemoveMenu_Clicked(sender1, e1, andOrNode, newnode);
        }
Exemplo n.º 21
0
        private DR_ResultSearchView GetSearchResult(DP_SearchRepository searchItems)
        {
            CalculateFilterValues();
            if (FilterCalculationError != null)
            {
                AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowInfo("خطا در جستجو", FilterCalculationError.Message, Temp.InfoColor.Red);
                return(null);
            }
            LastFilterValues.Clear();
            foreach (var item in CurrentValues)
            {
                LastFilterValues.Add(new Tuple <int, object>(item.Item1, item.Item2));
            }

            if (RelationshipFilters != null)
            {
                foreach (var filter in RelationshipFilters)
                {
                    var valueRow = CurrentValues.FirstOrDefault(x => x.Item1 == filter.ID);
                    // var value = AgentHelper.GetValueSomeHow(AreaInitializer.SourceEditArea.ChildRelationshipInfo.ParentData, filter.ValueRelationshipTail, filter.ValueColumnID);
                    if (valueRow == null)
                    {
                        return(null);
                    }
                    DP_SearchRepository searchItem = CreateSearchItem(searchItems, filter.SearchRelationshipTail);
                    //var searchColumn = searchItem.Phrases.FirstOrDefault(x => x is SearchProperty && (x as SearchProperty).ColumnID == filter.SearchColumnID) as SearchProperty;
                    //if (searchColumn == null)
                    //{
                    var searchColumn = new SearchProperty()
                    {
                        ColumnID = filter.SearchColumnID, NotIgnoreZeroValue = true
                    };
                    searchItem.Phrases.Add(searchColumn);
                    //}
                    searchColumn.Value = valueRow.Item2;
                }
            }

            var requester = AgentUICoreMediator.GetAgentUICoreMediator.GetRequester();
            //سکوریتی داده اعمال میشود
            DR_SearchViewRequest request = new DR_SearchViewRequest(requester, searchItems);

            //request.EntityID = AreaInitializer.EntityID;
            request.EntityViewID = ViewEntityArea.EntityListView.ID;
            var result = AgentUICoreMediator.GetAgentUICoreMediator.requestRegistration.SendSearchViewRequest(request);

            return(result);
        }
Exemplo n.º 22
0
            public void When_index_is_not_defined_Then_returns_first_WebElement(
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value)
            {
                // Arrange
                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(locator, value, webDriver, 100.Milliseconds());

                // Act
                var actual = sut.Get();

                // Assert
                actual.ShouldBe(webElements.First());
            }
Exemplo n.º 23
0
            public void When_index_is_out_of_range_Then_throws_TimeoutException(
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value)
            {
                // Arrange
                var timeout         = 100.Milliseconds();
                int indexOutOfRange = webElements.Count + 1;

                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(locator, value, webDriver, indexOutOfRange, 150.Milliseconds());

                // Assert
                Assert.Throws <TimeoutException>(() => sut.Find(timeout));
            }
Exemplo n.º 24
0
        // Recherche
        public static IQueryable <TModel> Search <TModel>(this IQueryable <TModel> source, string search) where TModel : ModelBase
        {
            var queryExpr           = source.Expression;
            var type                = typeof(TModel);
            var parameterExpression = Expression.Parameter(type, "x");
            var constant            = Expression.Constant("");
            var property            = Expression.Property(parameterExpression, "lastname");
            var expression          = Expression.Equal(property, constant);

            string test = search;

            //http://xxxxx/catalog/v1/products/search?name=*napoli*&type=pizza,pate&sort=rating,name
            //search = "Firstname=iso,jean&email&firstname";
            var SearchValues = search.Trim().Split('&').Select(x => x.Trim()).ToList();

            // equal Case

            foreach (var SearchProperty in SearchValues)
            {
                var Tosplit = SearchProperty.Split("=");
                if (Tosplit.Length <= 1)
                {
                    continue;
                }

                var    propertyToincludeInSearch = Tosplit[0]; //property to Filter
                string fieldsToSearch            = Tosplit[1]; //table of properties

                //case equal
                foreach (var item in fieldsToSearch.Split(","))
                {
                    if (string.IsNullOrEmpty(item))
                    {
                        continue;
                    }

                    constant = Expression.Constant(item);
                    var property2   = Expression.Property(parameterExpression, propertyToincludeInSearch);
                    var expression2 = Expression.Equal(property2, constant);
                    expression = Expression.Or(expression, expression2);
                }
            }// End equal case

            var lambda = Expression.Lambda <Func <TModel, bool> >(expression, parameterExpression);

            return(source.Where(lambda));
        }
Exemplo n.º 25
0
            public void When_index_is_out_of_range_Then_returns_null(
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value)
            {
                // Arrange
                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                int indexOutOfRange = webElements.Count + 1;
                var sut             = new SearchProperty <IWebElement>(locator, value, webDriver, indexOutOfRange, 100.Milliseconds());

                // Act
                var actual = sut.Get();

                // Assert
                actual.ShouldBeNull();
            }
Exemplo n.º 26
0
            public void When_index_is_out_of_range_Then_throws_OperationCanceledException(
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value)
            {
                // Arrange
                using var cancellationTokenSource = new CancellationTokenSource(50.Milliseconds());
                int indexOutOfRange   = webElements.Count + 1;
                var cancellationToken = cancellationTokenSource.Token;

                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(locator, value, webDriver, indexOutOfRange, 100.Milliseconds());

                // Assert
                Assert.Throws <OperationCanceledException>(() => sut.Find(cancellationToken));
            }
        public ActionResult List(SearchProperty search, int?page)
        {
            int   bath   = Convert.ToInt32(search.BathRoom);
            int   bed    = Convert.ToInt32(search.BedRoom);
            Int64 sprice = 0;
            Int64 eprice = 0;

            if (search.Price != null)
            {
                string[] p = search.Price.Split(',');
                sprice = Convert.ToInt64(p[0]);
                eprice = Convert.ToInt64(p[1]);
            }
            //string[] price = search.Price.Split('-');
            var data = (from p in db.Property where
                        (search.Id == 0 ? true:p.Id == search.Id)
                        &&
                        (search.CityId == 0 ? true:p.CityId == search.CityId)
                        &&
                        (search.PropertyStatus == 0? true:p.PurposeID == search.PropertyStatus)
                        &&
                        (search.PropertyType == 0? true:p.TypeID == search.PropertyType)
                        &&
                        (bath == 0? true:bath <= 2 ? p.Bath == bath:p.Bath > 2)
                        &&
                        (bed == 0 ? true : bed <= 2 ? p.Bed == bed : p.Bed > 2)
                        &&
                        (sprice == 0? true:p.Price >= sprice && p.Price <= eprice)
                        orderby p.Id select p);
            //(from t in TheDC.SomeTable

            // where TheIDs.Contains(t.ID) && (
            // t.column1.Contains(TheSearchTerm) ||
            // t.column2.Contains(TheSearchTerm) ||
            // t.column3.Contains(TheSearchTerm))
            // select t.ID).ToList();
            var d = data.ToList();


            ViewBag.CityId         = CityID(search.CityId);
            ViewBag.PropertyStatus = Purpose(search.PropertyStatus);
            ViewBag.PropertyType   = PTypee(search.PropertyType);
            ViewBag.Total          = d.Count();

            return(View(data.ToPagedList(page ?? 1, 12)));
        }
Exemplo n.º 28
0
        public void When_all_parameters_are_valid_Then_assigned_public_properties(
            IFindsByFluentSelector <IWebElement> webDriver,
            string locator,
            string value)
        {
            // Act
            var actual = new SearchProperty <IWebElement>(
                locator,
                value,
                webDriver,
                50.Milliseconds());

            // Assert
            actual.DefaultTimeout.ShouldBe(50.Milliseconds());
            actual.Selector.ShouldBe(locator);
            actual.Value.ShouldBe(value);
            actual.WebDriver.ShouldBe(webDriver);
        }
        public List <SearchProperty> GetSearchRepository()
        {
            List <SearchProperty> result = new List <SearchProperty>();

            foreach (var property in SimpleColumnControls)
            {
                var value = property.ControlManager.GetValue(null);
                if (PropertyHasValue(property, value))
                {
                    SearchProperty searchProperty = new SearchProperty();
                    searchProperty.ColumnID = property.Column.ID;
                    searchProperty.IsKey    = property.Column.PrimaryKey;
                    searchProperty.Value    = value;
                    searchProperty.Operator = property.ControlManager.GetOperator();
                    result.Add(searchProperty);
                }
            }
            return(result);
        }
        public static RESTSearchResultsSerialized ProcessResults(RESTSearchResults res, SearchInputs inputs)
        {
            RESTSearchResultsSerialized SerializedResults = new RESTSearchResultsSerialized();

            SerializedResults.Inputs = inputs;

            if (res != null)
            {
                SerializedResults.ExecutionTime = res.ElapsedTime;

                if (res.PrimaryQueryResult != null && res.PrimaryQueryResult.RelevantResults != null)
                {
                    SerializedResults.TotalRows = res.PrimaryQueryResult.RelevantResults.TotalRows;

                    SerializedResults.ResultRows = res.PrimaryQueryResult.RelevantResults.RowCount;

                    SerializedResults.ResultTitle    = res.PrimaryQueryResult.RelevantResults.ResultTitle;
                    SerializedResults.SearchResults  = res.PrimaryQueryResult.RelevantResults.Table;
                    SerializedResults.ResultTitleUrl = res.PrimaryQueryResult.RelevantResults.ResultTitleUrl;
                }
                else
                {
                    SerializedResults.TotalRows = 0;

                    SerializedResults.ResultRows = 0;
                }

                SerializedResults.SpellingSuggestions = res.SpellingSuggestion;


                // set SourceId from execution results
                Guid sid = Guid.Empty;

                SearchProperty SourceId = res.Properties.Where(p => p.Key.Equals("sourceid", StringComparison.InvariantCultureIgnoreCase)).First();
                if (SourceId != null && Guid.TryParse(SourceId.Value, out sid))
                {
                    SerializedResults.Inputs.SourceId = sid;
                }
            }

            return(SerializedResults);
        }
 private static IEnumerable<IWebElement> FilterByTagAttribute(IEnumerable<IWebElement> elements, SearchProperty searchProperty)
 {
     return searchProperty.ExactMatch ?
         elements.Where(item => item.GetAttribute(searchProperty.AttributeName) != null && item.GetAttribute(searchProperty.AttributeName).Equals(searchProperty.AttributeValue)) :
         elements.Where(item => item.GetAttribute(searchProperty.AttributeName) != null && item.GetAttribute(searchProperty.AttributeName).Contains(searchProperty.AttributeValue));
 }
Exemplo n.º 32
0
		void BeginSearch (UISearchDisplayController controller)
		{
			// Remember the search criteria so we can respond only to relevant events
			lastTableView = controller.SearchResultsTableView;
			lastSearchText = searchViewModel.SearchText;
			lastSearchProperty = searchViewModel.SearchProperty;

			// Display an activity indicator
			if (lastTableView != null) {
				if (!activity.Value.IsRunning) {
					activity.Value.StartInView (lastTableView);
				}
				lastTableView.BringSubviewToFront (activity.Value);
			}

			// Begin the search
			searchViewModel.Search ();
		}
		private async Task OnSearchCompleted (string searchText, SearchProperty searchProperty, Task<IList<Person>> searchTask)
		{
			if (searchTask.IsFaulted) {
				var ev = Error;
				if (ev != null) {
					ev (this, new ErrorEventArgs (searchTask.Exception));
				}
			} else {
				search.Results = new Collection<Person> (searchTask.Result);

				SetGroupedPeople ();				
				People = new ObservableCollection<Person> (search.Results);

				var ev = SearchCompleted;
				if (ev != null) {
					ev (this, new SearchCompletedEventArgs { 
						SearchText = searchText,
						SearchProperty = searchProperty
					});
				}
			}
		}