예제 #1
0
        public clsWalletrequest()
        {
            string        key   = "8E41AEF6156CF2221EF6A2EA6950A934";
            string        vguid = Guid.NewGuid().ToString(); //DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
            Walletrequest wr    = new Walletrequest();
            Subheader     sub   = new Subheader()
            {
                serviceRequestVersion = "1.0",
                serviceRequestId      = "WALLET",
                requestUUID           = vguid,
                channelId             = "DIGI"
            };

            wr.SubHeader = sub;
            Walletrequestbody wrb = new Walletrequestbody();
            var jsonString        = JsonConvert.SerializeObject(wrb);

            Console.WriteLine("Walletrequestbody plan -" + jsonString.ToString());

            wr.WalletRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, key);
            this.WalletRequest            = wr;
            db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
            {
                RequestGuid = vguid
                ,
                request = jsonString
            });
            db.SaveChanges();
        }
예제 #2
0
        public Bank_StatusEnquiryAPIResponse MethodClsStatusenquiryrequest(Bank_StatusEnquiryAPI bsea)
        {
            string vguid = ckv.SessionID;

            bsea.refId = bsea.sessionId; // ckv.SessionID;
            Bank_StatusEnquiryAPIResponse bcdar = new Bank_StatusEnquiryAPIResponse();
            clsStatusenquiryrequest       cser  = new clsStatusenquiryrequest();

            cser.StatusEnquiryRequest = new Statusenquiryrequest();

            try
            {
                db.Bank_StatusEnquiryAPI.Add(bsea);
                db.SaveChanges();

                Subheader sub = new Subheader()
                {
                    serviceRequestVersion = "1.0",
                    serviceRequestId      = "STATUS-ENQUIRY",
                    requestUUID           = bsea.refId,
                    channelId             = "DIGI"
                };
                cser.StatusEnquiryRequest.SubHeader = new Subheader();
                cser.StatusEnquiryRequest.SubHeader = sub;


                var jsonString = JsonConvert.SerializeObject(bsea);

                cser.StatusEnquiryRequest.StatusEnquiryRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, ckv.Key);

                var client = new RestClient(ckv.AxisSetuAPIURL + "/api/gateway/api/v1/fastag/status-enquiry");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.AddHeader("X-IBM-Client-Id", ckv.XIBMClientId);
                request.AddHeader("X-IBM-Client-Secret", ckv.XIBMClientSecret);
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("Authorization", ckv.JWT);

                var requeststr = JsonConvert.SerializeObject(cser);
                //Console.WriteLine("Request to API " + requeststr.ToString());
                request.AddParameter("application/json", requeststr.ToString(), ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
                //Console.WriteLine("AS Customer Dedupe Encrypted Reponse" + response.Content);

                APIException             apierror = JsonConvert.DeserializeObject <APIException>(response.Content);
                clsStatusenquiryresponse json     = JsonConvert.DeserializeObject <clsStatusenquiryresponse>(response.Content);
                string ser = string.Empty;
                if (apierror.httpCode != 200 && apierror.httpCode != 0) //503
                {
                    ser = JsonConvert.SerializeObject(apierror);
                    bcdar.statuscode    = apierror.errorCode;
                    bcdar.statusmessage = apierror.moreInformation + " | " + apierror.httpMessage;
                }
                else if (response.Content != string.Empty)
                {
                    ser   = EncryptionLibrary.decrypt(json.StatusEnquiryResponse.StatusEnquiryResponseBodyEncrypted, ckv.Key);
                    bcdar = JsonConvert.DeserializeObject <Bank_StatusEnquiryAPIResponse>(ser);
                    //update tollpay ecom and customer dudupe
                    if (bcdar.txnSeqNo.Length > 0 && bcdar.walletId.Length > 0)
                    {
                        //db.ecom_RFID.Where(x=>x.ecom_RFIDTagSrNo==bcdar.t)
                    }

                    db.Bank_StatusEnquiryAPIResponse.Add(bcdar);
                    db.SaveChanges();
                }
                else
                {//EncryptionLibrary.DecryptText(response.Content, akey);
                    ser = "Error";
                }

                db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
                {
                    RequestGuid       = bsea.refId,
                    subheaderMethod   = cser.StatusEnquiryRequest.SubHeader.serviceRequestId,
                    Currenttime       = DateTime.Now,
                    request           = jsonString,
                    requestEncrypted  = requeststr,
                    responseEncrypted = response.Content,
                    response          = ser
                });
                db.SaveChanges();
                return(bcdar);
            }
            catch (Exception ex)
            {
                bcdar.statusmessage = ex.Message;
                return(bcdar);
            }
        }
예제 #3
0
        public Bank_CustDedupeAPIResponse MethodClsDeduperequest(Bank_CustDedupeAPI cd)
        {
            string vguid = ckv.SessionID;

            cd.sessionId = ckv.SessionID;
            cd.refId     = null;
            //cd.refId = ckv.SessionID; //RefID Should be blank
            Bank_CustDedupeAPIResponse bcdar = new Bank_CustDedupeAPIResponse();

            try
            {
                //var config = new MapperConfiguration(cfg => {
                //    cfg.CreateMap<Bank_CustDedupeAPI, CustomerDuplex>();
                //});
                //IMapper iMapper = config.CreateMapper();
                //var source = cd;
                //var destination = iMapper.Map<Bank_CustDedupeAPI, CustomerDuplex> (source);


                var    jsonString = JsonConvert.SerializeObject(cd);
                string DedupeRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, ckv.Key);

                db.Bank_CustDedupeAPI.Add(cd);
                db.SaveChanges();

                var client = new RestClient(ckv.AxisSetuAPIURL + "/api/gateway/api/v1/fastag/customer-dedupe");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.AddHeader("X-IBM-Client-Id", ckv.XIBMClientId);
                request.AddHeader("X-IBM-Client-Secret", ckv.XIBMClientSecret);
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("Authorization", ckv.JWT);
                ClsEDeduperequest cldr = new ClsEDeduperequest();

                Subheader sd = new Subheader()
                {
                    channelId             = "DIGI",
                    requestUUID           = vguid,
                    serviceRequestId      = "Dedupe",
                    serviceRequestVersion = "1.0"
                };

                cldr.DedupeRequest           = new Deduperequest();
                cldr.DedupeRequest.SubHeader = new Subheader();
                cldr.DedupeRequest.SubHeader = sd;
                cldr.DedupeRequest.DedupeRequestBodyEncrypted = DedupeRequestBodyEncrypted;
                var requeststr = JsonConvert.SerializeObject(cldr);
                //Console.WriteLine("Request to API " + requeststr.ToString());
                request.AddParameter("application/json", requeststr.ToString(), ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
                //Console.WriteLine("AS Customer Dedupe Encrypted Reponse" + response.Content);

                APIException      apierror = JsonConvert.DeserializeObject <APIException>(response.Content);
                clsDeduperesponse json     = JsonConvert.DeserializeObject <clsDeduperesponse>(response.Content);

                if (apierror.httpCode != 200 && apierror.httpCode != 0) //503
                {
                    DedupeRequestBodyEncrypted = JsonConvert.SerializeObject(apierror);
                    bcdar.StatusCode           = apierror.errorCode;
                    bcdar.StatusMessage        = apierror.moreInformation + " | " + apierror.httpMessage;
                }
                else if (response.Content != string.Empty)
                {
                    DedupeRequestBodyEncrypted = EncryptionLibrary.decrypt(json.DedupeResponse.DedupeResponseBodyEncrypted, ckv.Key);
                    bcdar = JsonConvert.DeserializeObject <Bank_CustDedupeAPIResponse>(DedupeRequestBodyEncrypted);
                    db.Bank_CustDedupeAPIResponse.Add(bcdar);
                    db.SaveChanges();
                }
                else
                {//EncryptionLibrary.DecryptText(response.Content, akey);
                    DedupeRequestBodyEncrypted = "Error";
                }

                db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
                {
                    RequestGuid     = vguid,
                    subheaderMethod = cldr.DedupeRequest.SubHeader.serviceRequestId,

                    Currenttime       = DateTime.Now,
                    request           = jsonString,
                    requestEncrypted  = requeststr,
                    response          = DedupeRequestBodyEncrypted,
                    responseEncrypted = response.Content
                });
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                bcdar.StatusMessage = ex.Message + " - " + ex.InnerException;
                return(bcdar);
                //db.AxisSetuAPILoggers.Where(r => r.RequestGuid == vguid).FirstOrDefault().response = ex.Message;
                //db.SaveChanges();
            }



            return(bcdar);
        }
예제 #4
0
        public Bank_CreationWalletAPIResponse  MethodclsWalletrequest(Bank_CreateWalletAPI cw)
        {
            string vguid = ckv.SessionID;

            //Same few fix values
            cw.custpincode = "411042";
            cw.productId   = "5";
            // cw.sessionId = ckv.SessionID;


            try
            {
                var client = new RestClient(ckv.AxisSetuAPIURL + "/api/gateway/api/v1/fastag/wallet-vehicle-creation");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.AddHeader("X-IBM-Client-Id", ckv.XIBMClientId);
                request.AddHeader("X-IBM-Client-Secret", ckv.XIBMClientSecret);
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("Authorization", ckv.JWT);

                db.Bank_CreateWalletAPI.Add(cw);
                db.SaveChanges();

                Subheader sub = new Subheader()
                {
                    channelId             = "DIGI",
                    requestUUID           = vguid,
                    serviceRequestVersion = "1.0",
                    serviceRequestId      = "WALLET"
                };
                var jsonString = JsonConvert.SerializeObject(cw);

                string WalletRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, ckv.Key);

                ClsEWalletrequest cewr = new ClsEWalletrequest();
                cewr.WalletRequest           = new Walletrequest();
                cewr.WalletRequest.SubHeader = new Subheader();
                cewr.WalletRequest.SubHeader = sub;
                cewr.WalletRequest.WalletRequestBodyEncrypted = WalletRequestBodyEncrypted;
                var ejsonString = JsonConvert.SerializeObject(cewr);
                request.AddParameter("application/json", ejsonString.ToString(), ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);

                APIException      apierror = JsonConvert.DeserializeObject <APIException>(response.Content);
                clsWalletresponse json     = JsonConvert.DeserializeObject <clsWalletresponse>(response.Content);
                if (apierror.httpCode != 200 && apierror.httpCode != 0) //503
                {
                    WalletRequestBodyEncrypted = JsonConvert.SerializeObject(apierror);
                    bcwar.statuscode           = apierror.errorCode;
                    bcwar.statusmessage        = apierror.moreInformation + " | " + apierror.httpMessage;
                }
                else if (response.Content != string.Empty)
                {
                    WalletRequestBodyEncrypted = EncryptionLibrary.decrypt(json.WalletResponse.WalletResponseBodyEncrypted, ckv.Key);
                    bcwar = JsonConvert.DeserializeObject <Bank_CreationWalletAPIResponse>(WalletRequestBodyEncrypted);
                    if (cw.tagdispatch == "1")
                    {
                        allocateFastTag(cw);                      //You need to set tagdispatch to "1" and set tagseq to the tag sequence number. To test this, you need to get pre provisioned tag numbers from Axis bank.
                    }

                    db.Bank_CreationWalletAPIResponse.Add(bcwar);
                    db.SaveChanges();
                }
                else
                {//EncryptionLibrary.DecryptText(response.Content, akey);
                    WalletRequestBodyEncrypted = "Error";
                }

                db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
                {
                    RequestGuid       = ckv.SessionID,
                    Currenttime       = DateTime.Now,
                    subheaderMethod   = json.WalletResponse.SubHeader.serviceRequestId,
                    request           = jsonString.ToString(),
                    requestEncrypted  = ejsonString.ToString(),
                    responseEncrypted = response.Content,
                    response          = WalletRequestBodyEncrypted
                });
                db.SaveChanges();

                return(bcwar);
            }
            catch (Exception ex)
            {
                bcwar.statusmessage = ex.Message;
                return(bcwar);
            }
        }