public static dynamic getCjcApiValueAsync() { string cjcApi = PriceTrigger.GetEnvironmentVariable("CJCAPI"); var result = ""; // Create a request for the URL. WebRequest request = WebRequest.Create(cjcApi); // Get the response. WebResponse response = request.GetResponse(); // Display the status. Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. // The using block ensures the stream is automatically closed. using (Stream dataStream = response.GetResponseStream()) { // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. string responseFromServer = reader.ReadToEnd(); if (responseFromServer != "") { result = GetJson(responseFromServer); } } // Close the response. response.Close(); return(result); }
/// <summary> /// This function is running for getting the price from Fxcm. /// </summary> /// <returns>string XML</returns> public static string GetWebContext() { string pageContext = ""; try { WebClient MyWebClient = new WebClient(); Byte[] pageData = null; string fxApi = PriceTrigger.GetEnvironmentVariable("FXAPI"); pageData = MyWebClient.DownloadData(fxApi); pageContext = Encoding.Default.GetString(pageData); pageContext = ConvertJson(pageContext); } catch (Exception ex) { pageContext = ex.Message.ToString(); } return(pageContext); }