public string GetToken() { TBOAUTH authenticate = new TBOAUTH(); authenticate.ClientId = "ApiIntegrationNew"; authenticate.UserName = "******"; authenticate.Password = "******"; authenticate.EndUserIp = Dns.GetHostEntry(Dns.GetHostName()).AddressList[1].ToString(); //"122.166.15.26"; string requestdata = Newtonsoft.Json.JsonConvert.SerializeObject(authenticate); string authurl = "http://api.tektravels.com/SharedServices/SharedData.svc/rest/Authenticate"; string responsedata; responsedata = TBOPostJson.GetResponse(requestdata, authurl); DataSet lds_auth = new DataSet(); //lds_auth.ReadXml(AppDomain.CurrentDomain.BaseDirectory + "Authenticate.xml"); lds_auth.ReadXml(TBOPostJson.GenerateStreamFromString(responsedata)); string tokenid; tokenid = ""; if (int.Parse(lds_auth.Tables["Error"].Rows[0]["ErrorCode"].ToString()) == 0) { // no error has occured if (int.Parse(lds_auth.Tables["Main"].Rows[0]["Status"].ToString()) == 1) { // status is ok tokenid = lds_auth.Tables["Main"].Rows[0]["TokenId"].ToString(); } } return(tokenid); }
public void GetCountry(string tokenid) { Country authenticate = new Country() { ClientId = "ApiIntegrationNew", EndUserIp = Dns.GetHostEntry(Dns.GetHostName()).AddressList[1].ToString(), //"122.166.15.26"; TokenId = tokenid, }; string requestdata = Newtonsoft.Json.JsonConvert.SerializeObject(authenticate); string authurl = "http://api.tektravels.com/SharedServices/SharedData.svc/rest/CountryList"; string responsedata = TBOPostJson.GetResponse(requestdata, authurl); DataSet lds_auth = new DataSet(); lds_auth.ReadXml(TBOPostJson.GenerateStreamFromString(responsedata)); string lsz_countrylist = ""; if (int.Parse(lds_auth.Tables["Error"].Rows[0]["ErrorCode"].ToString()) == 0) { if (int.Parse(lds_auth.Tables["Main"].Rows[0]["Status"].ToString()) == 1) { // status is ok lsz_countrylist = lds_auth.Tables["Main"].Rows[0]["CountryList"].ToString(); } } if (lsz_countrylist != "") { DataSet lds_country = new DataSet(); lds_country.ReadXml(TBOPostJson.GenerateStreamFromString(lsz_countrylist)); for (int i = 0; i < lds_country.Tables["Country"].Rows.Count; i++) { BLayer.TBO.UpdateCountry((lds_country.Tables["Country"].Rows[i][0]).ToString(), (lds_country.Tables["Country"].Rows[i][1]).ToString()); } } }