public void ParseRequest(string Request)
        {
            pos           = 0;
            searchRequest = Request;

            try
            {
                searchTerms = ParseOrExpression();
            }
            catch (RequestParsingException)
            {
                searchTerms = new List <SearchTerm>();
                throw new RequestParsingException();
            }

            foreach (SearchTerm term in searchTerms)
            {
                if (term.IsPresent)
                {
                    SearchTermInfo[] searchTermInfo = client.GetSearchTerms(term.Key + term.Name, 0);

                    term.Postings = new List <PostingsParams>();
                    foreach (SearchTermInfo term2 in searchTermInfo)
                    {
                        if (term.Trunc && term2.Text.StartsWith(term.Key + term.Name) || term2.Text == term.Key + term.Name)
                        {
                            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;
            }
        }
Esempio n. 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;
            }
        }