Пример #1
0
        /// <summary>
        /// Expand Search is used for A-Z Lists on dictionaries
        /// </summary>
        /// <param name="searchText">search text</param>
        /// <param name="includeTypes">types to include</param>
        /// <param name="offset">how many results to offset</param>
        /// <param name="numResults"># of results to return</param>
        /// <param name="dictionary">The dictionary</param>
        /// <param name="language">which language</param>
        /// <param name="version">version of dictionary service</param>
        /// <returns>Collection of Dictionary Search Results</returns>
        public DictionarySearchResultCollection Expand(String searchText, String includeTypes, int offset, int maxResults, DictionaryType dictionary, String language, String version)
        {
            // Translate from types the AppManager exposes to types the Dictionary Service exposes.
            svcDictionaryType svcDictionary = TypeTranslator.Translate(dictionary);
            svcLanguage       svcLanguage   = TypeTranslator.TranslateLocaleString(language);

            DictionaryService service = new DictionaryService();

            NCI.Services.Dictionary.BusinessObjects.SearchReturn expandRet = null;
            try
            {
                expandRet = service.Expand(searchText, includeTypes, offset, maxResults, svcDictionary, svcLanguage);
            }
            catch (Exception ex)
            {
                log.Error("Error in Expand Method in Dictionary Web Service.", ex);
            }

            List <DictionarySearchResult>    expansionList = DeserializeList(expandRet.Result, svcDictionary);
            DictionarySearchResultCollection collection    = new DictionarySearchResultCollection(expansionList.AsEnumerable());

            collection.ResultsCount = expandRet.Meta.ResultCount;


            return(collection);
        }
Пример #2
0
        /// <summary>
        /// Dictionary search that will return a list of dictionary terms based on the dictionary type passed in
        /// and what kind of search is desired
        /// </summary>
        /// <param name="searchText">the text that has been typed into the search box</param>
        /// <param name="searchType">the type of search being executed</param>
        /// <param name="offset">how many to offset the first return result</param>
        /// <param name="maxResults">the max results to return<remarks>int.maxvalue should be used for retrieving all unless we have more</remarks></param>
        /// <param name="dictionary">the dictionary type (cancert term, drug, genetic)</param>
        /// <param name="language">English/Spanish</param>
        /// <returns>returns a list of dictioanry terms and related metadata</returns>
        public DictionarySearchResultCollection Search(String searchText, SearchType searchType, int offset, int maxResults, DictionaryType dictionary, String language)
        {
            // Translate from types the AppManager exposes to types the Dictionary Service exposes.
            svcDictionaryType svcDictionary = TypeTranslator.Translate(dictionary);
            svcSearchType     svcSearchType = TypeTranslator.Translate(searchType);
            svcLanguage       svcLanguage   = TypeTranslator.TranslateLocaleString(language);

            DictionaryService service = new DictionaryService();

            //sets up SearchReturn from Web Service
            NCI.Services.Dictionary.BusinessObjects.SearchReturn searchRet = null;

            //tries the dictionary service to get the strings back
            try
            {
                searchRet = service.Search(searchText, svcSearchType, offset, maxResults, svcDictionary, svcLanguage);
            }
            catch (Exception ex)
            {
                log.Error("There is an error in the Search Method of the Dictionary Service.", ex);
            }

            List <DictionarySearchResult>    resultList = DeserializeList(searchRet.Result, svcDictionary);
            DictionarySearchResultCollection collection = new DictionarySearchResultCollection(resultList.AsEnumerable());

            collection.ResultsCount = searchRet.Meta.ResultCount;
            return(collection);
        }