Exemplo n.º 1
0
        /// <summary>
        /// Gets the EVS Mapping file path for clinical trial dynamic listing pages from the configuration
        /// </summary>
        public static string GetEvsMappingFilePath()
        {
            string loc = "";
            BasicClinicalTrialSearchAPISection config = (BasicClinicalTrialSearchAPISection)ConfigurationManager.GetSection(CONFIG_SECTION_NAME);

            if (config == null)
            {
                throw new ConfigurationErrorsException("The configuration section, " + CONFIG_SECTION_NAME + ", cannot be found");
            }

            if (config.TermMappingFiles == null)
            {
                throw new ConfigurationErrorsException(CONFIG_SECTION_NAME + "error: termMappingFiles cannot be null or empty");
            }

            if (config.TermMappingFiles[EVS_MAPPING_NAME] == null)
            {
                throw new ConfigurationErrorsException(EVS_MAPPING_NAME + "error: element cannot be null or empty");
            }

            if (string.IsNullOrWhiteSpace(config.TermMappingFiles[EVS_MAPPING_NAME].FilePath))
            {
                throw new ConfigurationErrorsException(EVS_MAPPING_NAME + "error: element's filePath cannot be null or empty");
            }

            loc = config.TermMappingFiles[EVS_MAPPING_NAME].FilePath;
            return(loc);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the URL for the ClinicalTrials API from the configuration
        /// </summary>
        public static string GetAPIUrl()
        {
            string url = "";
            BasicClinicalTrialSearchAPISection config = (BasicClinicalTrialSearchAPISection)ConfigurationManager.GetSection(CONFIG_SECTION_NAME);

            if (config == null)
            {
                throw new ConfigurationErrorsException("The configuration section, " + CONFIG_SECTION_NAME + ", cannot be found");
            }

            if (string.IsNullOrWhiteSpace(config.APIProtocol))
            {
                throw new ConfigurationErrorsException(CONFIG_SECTION_NAME + "error: apiProtocol cannot be null or empty");
            }

            if (string.IsNullOrWhiteSpace(config.APIHost))
            {
                throw new ConfigurationErrorsException(CONFIG_SECTION_NAME + "error: apiHost cannot be null or empty");
            }

            url = string.Format("{0}://{1}", config.APIProtocol, config.APIHost);

            if (!string.IsNullOrWhiteSpace(config.APIPort))
            {
                url += ":" + config.APIPort;
            }

            return(url);
        }