Ejemplo n.º 1
0
        public RECHARGERESPONSE ProcessRecharge(object postdata, string apiname)
        {
            RECHARGERESPONSE rECHARGERESPONSE = new RECHARGERESPONSE();

            var httpresponse = ProcessRequest(postdata, _apiurl + apiname, _logintoken);

            using (Stream respStr = httpresponse.GetResponseStream())
            {
                using (StreamReader rdr = new StreamReader(respStr, Encoding.UTF8))
                {
                    string response = rdr.ReadToEnd();
                    rdr.Close();
                    rECHARGERESPONSE = JsonConvert.DeserializeObject <RECHARGERESPONSE>(response);
                }
            }

            return(rECHARGERESPONSE);
        }
Ejemplo n.º 2
0
        public string TransferAmount(object postdata, string apiname)
        {
            string response = string.Empty;

            var httpresponse = ProcessRequest(postdata, _apiurl + apiname, _logintoken);

            RECHARGERESPONSE rECHARGERESPONSE = new RECHARGERESPONSE();

            using (Stream respStr = httpresponse.GetResponseStream())
            {
                using (StreamReader rdr = new StreamReader(respStr, Encoding.UTF8))
                {
                    response = rdr.ReadToEnd();
                    rdr.Close();
                }
            }
            return(response);
        }
        internal void ProcessRecharge(string _number, int _operatorcode, int _amounttorecharge, string _requestid, int _rechargetype)
        {
            object postdata = new
            {
                country_code   = "IN",
                operator_code  = _operatorcode,
                number         = _number,
                amount         = _amounttorecharge,
                requestid      = _requestid,
                reqvia         = "API",
                recharge_type  = _rechargetype,
                optionalparam  = string.Empty,
                optionalparam1 = string.Empty,
            };

            try
            {
                RECHARGE WC = new RECHARGE("*****@*****.**", "Bansi@123", "http://dmtsrv.appsmith.co.in/");

                // add log or response here.
                new BAL.Log().Insert(new ENT.Log()
                {
                    logdata         = new JavaScriptSerializer().Serialize(postdata),
                    CreatedDateTime = DateTime.Now,
                    type            = COM.MyEnumration.LOGTYPE.APIREQ,
                    title           = "PROCESS - WEBSMITH API"
                });

                RECHARGERESPONSE RR = WC.ProcessRecharge(postdata, "Recharge");

                // add log or response here.
                new BAL.Log().Insert(new ENT.Log()
                {
                    logdata         = new JavaScriptSerializer().Serialize(RR),
                    CreatedDateTime = DateTime.Now,
                    type            = COM.MyEnumration.LOGTYPE.APIRES,
                    title           = "PROCESS - WEBSMITH API"
                });

                if (RR.results.Count > 0)
                {
                    // getting first item from recharge result object which got from websmith api
                    RECHARGERESPONSERESULT _result = RR.results[0];
                    if (_result.status_code == 3)
                    {
                        // update fail code here to local database.
                        new BAL.Recharge().UpdateRecharge(_requestid, _result.transNo == null ? string.Empty : _result.transNo, 3, new JavaScriptSerializer().Serialize(_result));
                    }
                    else if (_result.status_code == 4)
                    {
                        // update success code here to local database.
                        new BAL.Recharge().UpdateRecharge(
                            _requestid,
                            _result.transNo == null ? string.Empty : _result.transNo,
                            4,
                            new JavaScriptSerializer().Serialize(_result));
                    }
                }
            }
            catch (Exception ex)
            {
                ERRORREPORTING.Report(ex, Request.Url.ToString(), _LoginUserId, _ERRORKEY, new JavaScriptSerializer().Serialize(postdata));
            }
        }