Пример #1
0
        /// <summary>
        /// Term suggestions from what is being typed into the search box.  Used for autosuggest
        /// </summary>
        /// <param name="searchText">the string being typed</param>
        /// <param name="searchType">Type of search being done (contains, starts with, etc.)</param>
        /// <param name="dictionary">Which dictionary is being searched</param>
        /// <param name="language">Language</param>
        /// <returns>returns list of suggestions</returns>
        public DictionarySuggestionCollection SearchSuggest(String searchText, SearchType searchType, 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);

            //Set up variables we will use
            List <DictionarySuggestion> list    = new List <DictionarySuggestion>();
            DictionaryService           service = new DictionaryService();
            SuggestReturnMeta           meta    = new SuggestReturnMeta();

            NCI.Services.Dictionary.BusinessObjects.SuggestReturn suggestRet = null;

            try
            {
                service.SearchSuggest(searchText, svcSearchType, svcDictionary, svcLanguage);
            }
            catch (Exception ex)
            {
                log.Error("Error in search suggest method in Dictionary Web Service.", ex);
            }

            //sets up the suggest so the list of suggestions
            DictionarySuggestion suggest = new DictionarySuggestion();

            foreach (NCI.Services.Dictionary.BusinessObjects.DictionarySuggestion m in suggestRet.Result)
            {
                //get properties and set them then add to list
                suggest.ID   = m.ID;
                suggest.Term = m.Term;
                list.Add(suggest);
            }
            //create return variable based on list
            DictionarySuggestionCollection result = new DictionarySuggestionCollection(list.AsEnumerable());

            result.ResultsCount = suggestRet.Meta.ResultCount;
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Get Term from Dictionary Service to be deserialized and returned to the app module
        /// </summary>
        /// <param name="termId">int of the CDR ID</param>
        /// <param name="dictionary">which dictionary is being passed through</param>
        /// <param name="language">English/Spanish term</param>
        /// <param name="version">the version of the dictionary service</param>
        /// <param name="audience">The Term's desired audience.
        ///     Supported values are:
        ///         Patient
        ///         HealthProfessional
        /// </param>
        /// <returns>the term deserialized and the meta data from the database</returns>
        public DictionaryTerm GetTerm(int termId, DictionaryType dictionary, String language, String version, AudienceType audience)
        {
            // Translate from types the AppManager exposes to types the Dictionary Service exposes.
            svcDictionaryType svcDictionary = TypeTranslator.Translate(dictionary);
            svcLanguage       svcLanguage   = TypeTranslator.TranslateLocaleString(language);
            svcAudienceType   svcAudience   = TypeTranslator.Translate(audience);

            //sets up Dictionary Service so methods can be called
            DictionaryService service = new DictionaryService();

            //Sets up the services return type so that the meta data can be transfered to this term return.

            NCI.Services.Dictionary.BusinessObjects.TermReturn termRet = null;
            try
            {
                termRet = service.GetTerm(termId, svcDictionary, svcLanguage, svcAudience);
            }
            catch (Exception ex)
            {
                log.Error("Error in Dictionary Web Service for Get Term.", ex);
            }

            //String of JSON returned from the Database to be deserialized.
            DictionaryTerm dicTerm = null;

            try
            {
                //deserialize term details as returned by the service layer (termret.term)
                dicTerm = JsonConvert.DeserializeObject <DictionaryTerm>(termRet.Term);
            }
            catch (JsonReaderException ex)
            {
                log.Error("Error in Json string from service.", ex);
            }

            return(dicTerm);
        }