Exemple #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////


        #region Get Methods
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        public IList <Snippet> GetSnippetsForSearch(string searchText, out Dictionary <string, string[]> misSpellings, out int totNum,
                                                    out int totNumWithNonDefOp, out SortedDictionary <string, int> tagsOccurrences, int maxNum = int.MaxValue, int start = 0, bool onlyCreated = false, int onlyOfGroup = 0,
                                                    ItemSortField field = ItemSortField.Relevance, SortDirection direction = SortDirection.Descent)
        {
            //check for erroneous input:
            misSpellings       = null;
            totNum             = 0;
            totNumWithNonDefOp = 0;
            tagsOccurrences    = null;
            if ((maxNum <= 0) || (start < 0))
            {
                SetLastError(log, ErrorCodes.WRONG_INPUT, string.Format("Input error: userID={0}, searchText={1}, maxNum={2}, start={3}",
                                                                        CurrentUserID, searchText.PrintNull(), maxNum, start));
                return(new List <Snippet>());
            }

            //send the request and parse the response:
            string querystring = string.Format("query={0}&maxNum={1}&start={2}&onlyCreated={3}&onlyOfGroup={4}&field={5}&direction={6}",
                                               HttpUtility.UrlEncode(searchText), maxNum, start, onlyCreated, onlyOfGroup, field, direction);
            S2CResListBaseEntity <SnippetComm> resp = SendReqListBaseEntity <SnippetComm>(SEARCH_SNIPPET_URL, querystring, false, false);

            //build the result:
            IList <Snippet> snips = resp.GetListFromResp <SnippetComm, Snippet>(out totNum);

            misSpellings = resp.GetMiscFromResp <SnippetComm>(out totNumWithNonDefOp);
            return(snips);
        }