public ServicesResponse GetAdminServices(ServicesRequest request) { var response = new ServicesResponse { ResponseStatus = ResponseStatus.Success }; var settingsProvider = new SettingsProvider(); try { if (request.ActionType == ActionType.Select) { response.Services = settingsProvider.GetServices(request); } else { response.ResponseStatus = ResponseStatus.Failure; response.ResponseDescription = "Not update action"; } } catch (Exception ex) { response.ResponseStatus = ResponseStatus.Failure; response.ResponseDescription = ex.Message; } return(response); }
public List <ServicesInfo> GetListService(string idFrom, string idTo) { var sessionToken = GhnSigin(); // Get Pick Hub var servicesRequest = new ServicesRequest(); client.EndPoint = baseUri + "GetServiceList"; servicesRequest.ApiKey = apiKey; servicesRequest.ApiSecretKey = apiSecretKey; servicesRequest.ClientID = int.Parse(clientId); servicesRequest.Password = password; servicesRequest.SessionToken = sessionToken; client.PostData = JsonConvert.SerializeObject(servicesRequest); client.ContentType = RestClient.ContentTypeConst.Json; var responseServices = JsonConvert.DeserializeObject <ServicesResponse>(client.MakeRequest()); if (responseServices == null) { return(new List <ServicesInfo>()); } return(responseServices.Services); }
public List <Service> GetServices(ServicesRequest request) { var conn = GetConnection(ConnectionNames.CSPSqlDatabase); var commandWrapper = GetStoredProcCommand("dbo.Get_Services", conn); IDataReader reader = null; List <Service> tmp = new List <Service>(); try { conn.Open(); reader = commandWrapper.ExecuteReader(); FillServices(reader, tmp, 0, int.MaxValue); MakeDboLog(request.ToString(), reader.ToString(), "dbo.Get_Services"); return(tmp); } finally { if (reader != null) { reader.Close(); } commandWrapper.Dispose(); conn.Close(); } }
public async Task <HttpResponseMessage> Transaction() { string responseString = string.Empty; HttpResponseMessage response = null; if (hepler.CheckHeader(Request)) { try { var searchParamterXml = await Request.Content.ReadAsByteArrayAsync(); string searchParameter = Encoding.UTF8.GetString(searchParamterXml); XmlSerializer serializer = new XmlSerializer(typeof(ServicesRequest)); using (TextReader reader = new StringReader(searchParameter)) { ServicesRequest rechargeRequest = (ServicesRequest)serializer.Deserialize(reader); var rechargeObject = RechargeTemplate.TransactionJson; rechargeObject = rechargeObject.Replace("modeValue", rechargeRequest.mode). Replace("spkeyValue", rechargeRequest.spkey). Replace("agentidValue", rechargeRequest.agentid). Replace("accountValue", rechargeRequest.account). Replace("amountValue", rechargeRequest.amount). Replace("formatValue", rechargeRequest.format); //var query = "https://www.instantpay.in/ws/api/transaction?token=63a3c58a814a9fe4e684246673b72027&spkey=VFP&agentid=190620171120115451215&account=9261230073&amount=30&optional1=VodafoneRechargeTest&format=json"; // var query = "https://www.instantpay.in/ws/api/transaction?token=63a3c58a814a9fe4e684246673b72027&spkey=ACP&agentid=190620171120115451215&account=9829221803&amount=30&optional1=VodafoneRechargeTest&format=json"; // Code to get Cancel flight status*** Start using (var httpClient = new HttpClient()) { var httpContent = new StringContent(rechargeObject, Encoding.UTF8, "text/xml"); var requestString = "https://www.instantpay.in/ws/api/transaction?" + rechargeObject; ///Do the actual request and await the response var httpResponse = await httpClient.GetAsync(rechargeObject); //var httpResponse = await httpClient.GetAsync(query); ///If the response contains content we want to read it! if (httpResponse.Content != null) { responseString = await httpResponse.Content.ReadAsStringAsync(); Console.Write(responseString); response = Request.CreateResponse <string>(HttpStatusCode.OK, responseString); } } /*******Extract repsonse oject from xml******/ } } catch (Exception e) { response = Request.CreateResponse <string>(HttpStatusCode.NoContent, e.Message); } } return(response); }
public ServicesRequest GetServicesRequest() { var request = new ServicesRequest() { ActionType = Requests.ActionType.Select }; return(request); }
/// <summary> Setter constructor. </summary> public Services(ServicesRequest request) { Request = request; Response = new ServicesResponse(); }
public async Task <HttpResponseMessage> Services() { string responseString = string.Empty; HttpResponseMessage response = null; if (hepler.CheckHeader(Request)) { try { var searchParamterXml = await Request.Content.ReadAsByteArrayAsync(); string searchParameter = Encoding.UTF8.GetString(searchParamterXml); XmlSerializer serializer = new XmlSerializer(typeof(ServicesRequest)); using (TextReader reader = new StringReader(searchParameter)) { ServicesRequest rechargeRequest = (ServicesRequest)serializer.Deserialize(reader); var rechargeObject = RechargeTemplate.ServiceValues; rechargeObject = rechargeObject.Replace("typeValue", rechargeRequest.type); //rechargeObject = "?token=63a3c58a814a9fe4e684246673b72027&type=PREPAID"; // Code to get Cancel flight status*** Start using (var httpClient = new HttpClient()) { // var httpContent = new StringContent(rechargeObject, Encoding.UTF8, "application/json"); //var requestString = "https://www.instantpay.in/ws/api/serviceproviders"; ///Do the actual request and await the response var httpResponse = await httpClient.GetAsync(rechargeObject); ///If the response contains content we want to read it! if (httpResponse.Content != null) { responseString = await httpResponse.Content.ReadAsStringAsync(); } response = Request.CreateResponse <string>(HttpStatusCode.OK, responseString); } /*******Extract repsonse oject from xml******/ //if (response != null) //{ // var serializer1 = new XmlSerializer(typeof(Xml)); // Xml serviceResponse; // using (TextReader reader1 = new StringReader(responseString)) // { // serviceResponse = (Xml)serializer1.Deserialize(reader1); // } // if (serviceResponse == null) // { // response = Request.CreateResponse<string>(HttpStatusCode.NoContent, "No Content Found"); // } // else // { // XmlSerializer cancelationRequest = new XmlSerializer(typeof(Xml)); // var responseXml = ""; // using (var sww = new StringWriter()) // { // using (XmlWriter writer = XmlWriter.Create(sww)) // { // cancelationRequest.Serialize(writer, serviceResponse); // responseXml = sww.ToString(); // Your XML // } // } // response = Request.CreateResponse<string>(HttpStatusCode.OK, responseXml); // } // } } } catch (Exception e) { response = Request.CreateResponse <string>(HttpStatusCode.NoContent, e.Message); } } return(response); }