public TelkomModels.TelkomInquiryResponse InquiryTelkom(ref TelkomModels.TelkomInquiryRequest AutoInqRequest, string ip) { string wsStartTime = DateTime.Now.ToString(ConstantModels.FORMATDATETIME); TelkomHelper telkomHelper = new TelkomHelper(); TelkomModels.PSWServiceRequest PswRequest = new TelkomModels.PSWServiceRequest(); TelkomModels.TelkomInquiryResponse AutoInqResponse = new TelkomModels.TelkomInquiryResponse(); TelkomModels.PSWServiceInquiryResponse GetInqResponse = new TelkomModels.PSWServiceInquiryResponse(); Random random = new Random(); PswRequest.SubProduct = ConstantModels.SubProductINQ_Telkom; PswRequest.SequenceTrx = DateTime.Now.ToString("HHmmssfff") + random.Next(0, 9).ToString(); PswRequest.InputData = AutoInqRequest.billingNumber; PswRequest.Data1 = helper.GetSourceAccount(AutoInqRequest.institutionCode, ConstantModels.FeatureCode_Telkom); GetInqResponse = PSWServiceInquiryTelkom(ref PswRequest); if (GetInqResponse == null) { AutoInqResponse.responseCode = ConstantModels.TIMEOUTCODEINQ; AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(ConstantModels.TIMEOUTCODEINQ); } else if (GetInqResponse.RC == "00") //success { double totalAmount = 0; List <TelkomModels.TelkomBillingDetailsData> billDetail = new List <TelkomModels.TelkomBillingDetailsData>(); string[] splitData1 = ((GetInqResponse.Data1).Replace("||", "~")).Split('~'); int countData1 = splitData1.Length - 1; AutoInqResponse.responseCode = ConstantModels.SUCCESSCODEINQ; AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(ConstantModels.SUCCESSCODEINQ); AutoInqResponse.data.name = splitData1[0].ToString().Trim(); AutoInqResponse.data.billingCode = helper.Base64Encode(GetInqResponse.Data1 + "~" + GetInqResponse.Data2); for (int i = 1; i <= countData1; i++) { string[] splitBillDetail = splitData1[i].Split('#'); totalAmount += Convert.ToDouble(String.IsNullOrEmpty(splitBillDetail[1].ToString()) ? "0" : splitBillDetail[1].ToString()); TelkomModels.TelkomBillingDetailsData listBillDetail = new TelkomModels.TelkomBillingDetailsData(); if (!String.IsNullOrEmpty(splitBillDetail[0].ToString()) || !String.IsNullOrEmpty(splitBillDetail[1].ToString())) { listBillDetail.referenceNumber = splitBillDetail[0].ToString(); listBillDetail.amount = splitBillDetail[1].ToString(); billDetail.Add(listBillDetail); } } AutoInqResponse.data.totalAmount = (totalAmount.ToString() == "0" ? null : totalAmount.ToString()); AutoInqResponse.data.billingDetail = billDetail; } else if (GetInqResponse.RC == ConstantModels.TIMEOUTCODEINQ) { AutoInqResponse.responseCode = ConstantModels.TIMEOUTCODEINQ; AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(GetInqResponse.RC); } else if (GetInqResponse.RC == ConstantModels.EXCEPTIONCODEINQ) { AutoInqResponse.responseCode = ConstantModels.EXCEPTIONCODEINQ; AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(GetInqResponse.RC); } else //fail { AutoInqResponse.responseCode = ResponseCodeModels.GetResponseCodePSW(GetInqResponse.RC); AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(AutoInqResponse.responseCode); } string wsEndTime = DateTime.Now.ToString(ConstantModels.FORMATDATETIME); telkomHelper.InsertLogInquiryTelkom(AutoInqRequest, PswRequest, AutoInqResponse, wsStartTime, wsEndTime, ip, (GetInqResponse == null ? "" : GetInqResponse.RC)); return(AutoInqResponse); }
public void InsertLogInquiryTelkom(TelkomModels.TelkomInquiryRequest InqRequest, TelkomModels.PSWServiceRequest PswRequest, TelkomModels.TelkomInquiryResponse InqResponse, string wsStartTime, string wsEndTime, string ip, string rc_psw) { string errMsg = ""; if (InqResponse.responseCode != "0100") { errMsg = ""; } string sql = "INSERT INTO TELKOMINQUIRYLOG ([CREATEDTIME],[WS_STARTTIME],[WS_ENDTIME],[ACTION],[INSTITUTION_CODE],[TRANSACTION_DATE],[TRANSACTION_TIME]" + ",[CHANNEL_ID],[PRODUCT_ID],[SUB_PRODUCT],[SEQUENCE_TRX],[BILLING_NUMBER],[SOURCE_ACCOUNT],[KEY],[RC],[RC_DESC],[ERRMSG],[IP_ADDRESS]) " + "VALUES (@createdTime, @wsStartTime, @wsEndTime, @action, @institutionCode, @transactionDate, @transactionTime, @channelId, @productId, @subProduct, " + "@sequenceTrx, @billingNumber, @sourceAccount, @key, @rc, @rcDesc, @errmsg, @ip)"; SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.Text; sqlCommand.CommandText = sql; sqlCommand.Parameters.Add("@createdTime", SqlDbType.VarChar).Value = DateTime.Now.ToString(ConstantModels.FORMATDATETIME); sqlCommand.Parameters.Add("@wsStartTime", SqlDbType.VarChar).Value = wsStartTime; sqlCommand.Parameters.Add("@wsEndTime", SqlDbType.VarChar).Value = wsEndTime; sqlCommand.Parameters.Add("@action", SqlDbType.VarChar).Value = "INQUIRY_TELKOM"; sqlCommand.Parameters.Add("@institutionCode", SqlDbType.VarChar).Value = InqRequest.institutionCode; sqlCommand.Parameters.Add("@transactionDate", SqlDbType.VarChar).Value = PswRequest.Transdate; sqlCommand.Parameters.Add("@transactionTime", SqlDbType.VarChar).Value = PswRequest.Transtime; sqlCommand.Parameters.Add("@channelId", SqlDbType.VarChar).Value = PswRequest.ChannelID; sqlCommand.Parameters.Add("@productId", SqlDbType.VarChar).Value = PswRequest.ProductID; sqlCommand.Parameters.Add("@subProduct", SqlDbType.VarChar).Value = PswRequest.SubProduct; sqlCommand.Parameters.Add("@sequenceTrx", SqlDbType.VarChar).Value = PswRequest.SequenceTrx; sqlCommand.Parameters.Add("@billingNumber", SqlDbType.VarChar).Value = InqRequest.billingNumber; sqlCommand.Parameters.Add("@sourceAccount", SqlDbType.VarChar).Value = PswRequest.Data1; sqlCommand.Parameters.Add("@key", SqlDbType.VarChar).Value = PswRequest.Key; sqlCommand.Parameters.Add("@rc", SqlDbType.VarChar).Value = InqResponse.responseCode; sqlCommand.Parameters.Add("@rcDesc", SqlDbType.VarChar).Value = InqResponse.responseDescription; sqlCommand.Parameters.Add("@errmsg", SqlDbType.VarChar).Value = errMsg; sqlCommand.Parameters.Add("@ip", SqlDbType.VarChar).Value = ip; util.ExecuteSqlCommand(sqlCommand); }