Ejemplo n.º 1
0
        public string PreformSearch(string jsonData, SeekitConfiguration configuration)
        {
            StreamWriter requestWriter;
            var retval = string.Empty;
            var webRequest = WebRequest.Create(new Uri(configuration.ApiUrl, "search")) as HttpWebRequest;
            if (webRequest != null) {
                webRequest.Method = "POST";
                webRequest.Timeout = 20000;
                webRequest.ContentType = "application/json";
                using (requestWriter = new StreamWriter(webRequest.GetRequestStream())) {
                    requestWriter.Write(jsonData);
                }

                var response = (HttpWebResponse)webRequest.GetResponse();
                try {
                    var streamReader = new StreamReader(response.GetResponseStream(), true);
                    try {
                        retval = streamReader.ReadToEnd();
                    } finally {
                        streamReader.Close();
                    }
                } finally {
                    response.Close();
                }

            }
            return retval;
        }
Ejemplo n.º 2
0
        public string FetchAllFacets(SeekitConfiguration configuration,string lang, string modelName)
        {
            var retval = string.Empty;
            var facetsApiPath = string.Format("facets?client={0}", configuration.ClientGuid);

            if (!string.IsNullOrEmpty(modelName))
                facetsApiPath += "&lang=" + lang;

            if(!string.IsNullOrEmpty(modelName))
                facetsApiPath += "&modeltype=" + modelName;

            var webRequest = WebRequest.Create(new Uri(configuration.ApiUrl, facetsApiPath)) as HttpWebRequest;
            if (webRequest != null) {
                webRequest.Method = "GET";
                webRequest.Timeout = 20000;
                webRequest.ContentType = "application/json";

                var response = (HttpWebResponse)webRequest.GetResponse();
                try {
                    var streamReader = new StreamReader(response.GetResponseStream(), true);
                    try {
                        retval = streamReader.ReadToEnd();
                    } finally {
                        streamReader.Close();
                    }
                } finally {
                    response.Close();
                }

            }
            return retval;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the configuration details from the web/app config file.
 /// </summary>
 /// <returns>SeekitConfiguration or null if not available in config</returns>
 public static SeekitConfiguration GetConfiguration()
 {
     return _configuration ?? (_configuration = ConfigurationManager.GetSection("seekit") as SeekitConfiguration);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the configuration details from the web/app config file.
 /// </summary>
 /// <returns>SeekitConfiguration or null if not available in config</returns>
 public static SeekitConfiguration GetConfiguration()
 {
     return(_configuration ?? (_configuration = ConfigurationManager.GetSection("seekit") as SeekitConfiguration));
 }