public string GetLatestExchangeRates() { try { HttpWebRequest request = DataService.CreateRequest(DataStatics.DomainForService, DataStatics.UserNameForService, DataStatics.PasswordForService, DataStatics.saportServiceURL(DataStatics.saportServiceGetLatestExchangeRates), true, true, "application/json; charset=UTF-8", "application/json; odata=verbose", "GET"); request.ContentLength = 0; WebResponse response = request.GetResponse(); string responseString = DataService.RestfulReader(response); return(responseString); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public string GetCityWeatherStatus(string cityName) { try { HttpWebRequest request = DataService.CreateRequest(DataStatics.DomainForService, DataStatics.UserNameForService, DataStatics.PasswordForService, DataStatics.saportServiceURL(DataStatics.saportServiceGetCityWeatherStatus) , true, true, "application/json; charset=UTF-8", "application/json; odata=verbose", "POST"); string parsedContent = "{\"CityName\":\"" + cityName + "\"}"; UTF8Encoding encoding = new UTF8Encoding(); Byte[] bytes = encoding.GetBytes(parsedContent); request.ContentLength = bytes.Length; Stream newStream = request.GetRequestStream(); newStream.Write(bytes, 0, bytes.Length); newStream.Close(); WebResponse response = request.GetResponse(); string responseString = DataService.RestfulReader(response); return(responseString); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public string GetSocialFeeds(string newestDate, int itemCount, string secretKey) { try { string returnString = ""; if (secretKey != null) { byte[] data = Convert.FromBase64String(secretKey); if (DataStatics.SecretKey == System.Text.Encoding.UTF8.GetString(data)) { HttpWebRequest request = DataService.CreateRequest(DataStatics.DomainForService, DataStatics.UserNameForService, DataStatics.PasswordForService, DataStatics.saportServiceURL(DataStatics.saportServiceGetSocialFeeds), true, true, "application/json; charset=UTF-8", "application/json; odata=verbose", "POST"); string parsedContent = "{\"NewestDate\":\"" + newestDate + "\",\"ItemCount\":" + itemCount + ",\"Index\":0,\"Filter\":\"All\"}"; UTF8Encoding encoding = new UTF8Encoding(); Byte[] bytes = encoding.GetBytes(parsedContent); request.ContentLength = bytes.Length; Stream newStream = request.GetRequestStream(); newStream.Write(bytes, 0, bytes.Length); newStream.Close(); WebResponse response = request.GetResponse(); returnString = DataService.RestfulReader(response); } } return(returnString); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public string CheckRemoteService(string secretKey) { try { string serviceStatus = "OFFLINE"; if (secretKey != null) { byte[] data = Convert.FromBase64String(secretKey); if (DataStatics.SecretKey == System.Text.Encoding.UTF8.GetString(data)) { serviceStatus = DataService.IsServiceUp(DataStatics.DomainForService, DataStatics.UserNameForService, DataStatics.PasswordForService, DataStatics.saportServiceURL(DataStatics.saportServiceTest), true, true, 0, "application/json; charset=UTF-8") == true ? "OK" : "OFFLINE"; } } return(serviceStatus); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
/* It includes methods related to SampleEntity */ #endregion #region Methods public static List <ExchangeRate> GetExchangeRates() { try { HttpWebRequest request = DataService.CreateRequest(DataStatics.DomainForService, DataStatics.UserNameForService, DataStatics.PasswordForService, DataStatics.saportServiceURL(DataStatics.saportServiceGetLatestExchangeRates), true, true, "application/json; charset=UTF-8", "application/json; odata=verbose", "GET"); request.ContentLength = 0; WebResponse response = request.GetResponse(); string responseString = DataService.RestfulReader(response); response.Close(); var serializer = new JavaScriptSerializer(); ExchangeObject exchangeRateObj = serializer.Deserialize <ExchangeObject>(responseString); List <ExchangeRate> exchangeRates = exchangeRateObj.Data; return(exchangeRates); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }