public static string PaymentVNM(string msisdn, string serviceId, string serviceState, string content, string servicename) { var info = new ChargingTransactionInfo(); info.ServiceId = serviceId; info.UserName = ConfigurationManager.AppSettings["user"]; info.UserPass = ConfigurationManager.AppSettings["pass"]; info.CpId = ConfigurationManager.AppSettings["userid"]; info.UserId = msisdn; info.ServiceState = serviceState; string returnValue = string.Empty; try { log.Info("---------- Dich vu ket noi : " + servicename + " ----------------"); log.Info(string.Format(" Begin Charging Request: userID:{0}; serviceID:{1}", msisdn, serviceId)); returnValue = exDebit(info, content, servicename); if (returnValue == "1") { return("1"); } } catch (Exception ex) { log.Info(" == Error PaymentVNM: " + ex.Message); log.Info(" == Error PaymentVNM: " + ex.StackTrace); log.Error(" "); log.Error(" "); } return(returnValue); }
public static string exDebit(ChargingTransactionInfo info, string content, string servicename) { string success; string resp = string.Empty; try { CHARGING wsCgw = new CHARGING(); log.Info("Call Deduct method: " + info.UserId + " | " + info.ServiceId + " | " + info.UserName + " | " + info.UserPass + " | " + info.CpId + " | " + content); content = TrimLength(content, 30); resp = wsCgw.extDebit2(info.UserName, info.UserPass, info.CpId, info.UserId, info.ServiceId, REQUEST_TIMEOUT, content); log.Info("resp: " + resp); string[] arrResult = resp.Split(','); int sResult = int.Parse(arrResult[0].Replace("Result:", "")); string sDetail = arrResult[1].Replace("Detail:", ""); log.Info("Response Result (VNM Result Code): " + resp); log.Info("Action: " + content); log.Error(" "); log.Error(" "); if (sResult == Constant.E_OK) { success = "1"; } else { success = resp; } } catch (Exception ex) { try { Thread.Sleep(2000); CHARGING wsCgw = new CHARGING(); log.Info("Call Deduct method: " + info.UserId + " | " + info.ServiceId + " | " + info.UserName + " | " + info.UserPass + " | " + info.CpId + " | " + content); resp = wsCgw.extDebit2(info.UserName, info.UserPass, info.CpId, info.UserId, info.ServiceId, REQUEST_TIMEOUT, content); log.Info("resp: " + resp); string[] arrResult = resp.Split(','); int sResult = int.Parse(arrResult[0].Replace("Result:", "")); string sDetail = arrResult[1].Replace("Detail:", ""); log.Info("Response Result (VNM Result Code): " + resp); log.Info("Action: " + content); log.Error(" "); log.Error(" "); if (sResult == Constant.E_OK) { success = "1"; } else { success = resp; } } catch (Exception ex1) { //throw ex; log.Info("Error exDebit 3G: " + ex.Message); log.Error(" "); log.Error(" "); AlertVnmCharging(info.UserId, "Loi ket noi Webservice VNM Charging 2G | Error:" + ex1.Message, "0", "0", "0", "0", 0, 0, 0, 0, 0, "0", "0"); success = resp; } } try { //Log Transaction 4A var entity = new WapTransactionLog4AEntity(); entity.WapTransactionName = servicename; entity.WapTransactionType = 0; entity.WapTransactionDetail = content; entity.WapTransactionOn = DateTime.Now; entity.WapTransactionMobile = info.UserId; entity.WapTransactionOperator = "Vietnamobile"; entity.WapTransactionAmount = ConvertUtility.ToInt32(info.ServiceId); entity.ErrorCode = ConvertUtility.ToInt32(success); entity.ErrorDetail = resp; entity.WapTransactionUserName = info.UserName; entity.WapTransactionPassword = info.UserPass; entity.WapTransactionCpId = info.CpId; WapTransactionLog4AInSert(entity); //End Log Transaction 4A } catch (Exception ex) { //throw ex; log.Info("Error inSert log 4A " + ex.Message); log.Error(" "); log.Error(" "); } return(success); }