Пример #1
0
        public string AddComplexRequest(string Request)
        {
            searchRequest      = new SearchRequest();
            searchRequest.Text = Request;
            pos = 0;

            try
            {
                searchRequest.SearchStuff = ParseOrExpression();
            }
            catch (RequestParsingException)
            {
                searchRequest.SearchStuff.SearchTerms = new List <SearchTerm>();
                throw new RequestParsingException();
            }

            SearchRequests.Add(searchRequest);
            return(searchRequest.Text);
        }
Пример #2
0
        public void ParseAddRequest(string Request)
        {
            searchRequest = null;

            foreach (SearchRequest request in SearchRequests)
            {
                if (request.Text == Request)
                {
                    searchRequest  = request;
                    CurrentRequest = searchRequest;
                }
            }

            if (searchRequest == null)
            {
                searchRequest      = new SearchRequest();
                searchRequest.Text = Request;
            }

            pos = 0;
            try
            {
                searchRequest.SearchStuff = ParseOrExpression();
            }
            catch (RequestParsingException)
            {
                searchRequest.SearchStuff.SearchTerms = new List <SearchTerm>();
                throw new RequestParsingException();
            }

            if (ProcessTerms)
            {
                foreach (SearchTerm term in searchRequest.SearchStuff.SearchTerms)
                {
                    if (term.IsPresent)
                    {
                        term.Postings = new List <PostingsParams>();
                        if (String.IsNullOrEmpty(term.Name))
                        {
                            continue;
                        }

                        SearchTermInfo[] searchTermInfo = client.GetSearchTerms(term.Key + term.Name, 0);
                        foreach (SearchTermInfo term2 in searchTermInfo)
                        {
                            if (term.Trunc && term2.Text.StartsWith(term.Key + term.Name, StringComparison.CurrentCultureIgnoreCase) || term2.Text.Equals(term.Key + term.Name, StringComparison.CurrentCultureIgnoreCase))
                            {
                                PostingsParams Posting;
                                Posting.Text = term2.Text.Substring(term.Key.Length);

                                SearchPostingInfo[] searchPostingInfo = client.GetSearchPostings(term2.Text, 0, /*i + */ 1);
                                Posting.Mfn = new List <int>();

                                foreach (SearchPostingInfo posting in searchPostingInfo)
                                {
                                    if (!Posting.Mfn.Contains(posting.Mfn) && (term.Fields.Length == 0 || term.Fields.Contains(posting.Tag)))
                                    {
                                        Posting.Mfn.Add(posting.Mfn);
                                    }
                                }

                                term.Postings.Add(Posting);
                            }
                        }
                    }
                    term.Fields = null;
                }
            }

            if (CurrentRequest != searchRequest)
            {
                SearchRequests.Add(searchRequest);
                CurrentRequest = searchRequest;
            }
        }