internal List <mTransaction> ReadJCB_INC(string filepath) { if (HttpContext.Session["UID"] == null) { return(new List <mTransaction>()); } List <mTransaction> Tran_List = new List <mTransaction>(); string error_Lines = "Terminated!!!\nError : "; try { if (!string.IsNullOrEmpty(filepath)) { //Get Trx Date string datestr = Path.GetFileName(filepath); string year = "20" + datestr.Substring(3, 2); string month = datestr.Substring(5, 2); string day = datestr.Substring(7, 2); DateTime TRXDate = DateTime.ParseExact(year + "-" + month + "-" + day, "yyyy-MM-dd", null); //Read File string[] lines = System.IO.File.ReadAllLines(filepath); foreach (string line in lines) { if (line.Substring(0, 3) == "100") { mTransaction tran = new mTransaction(); tran.CardNo = line.Substring(3, 19).Replace(" ", ""); //To Get Card Type mCardType cardType = new mCardType(); cardType.BINCode = tran.CardNo.Substring(0, 4); tran.CardType = cardType.get_card_type(); tran.ProcessingCode = line.Substring(22, 6); Double decplace_scr = 1; int dec_place = int.Parse(line.Substring(52, 1)); for (int i = 0; i < dec_place; i++) { decplace_scr = decplace_scr * 10; } tran.SettConversationRate = Convert.ToDouble(line.Substring(53, 9)) / decplace_scr; tran.CurrencyCode = line.Substring(62, 3); tran.SettCurrencyCode = line.Substring(65, 3); tran.TerminalID = line.Substring(132, 8); //This is from raw file //tran.TrxID = 0001; tran.TrxAmount = Convert.ToDouble(line.Substring(28, 12)) / 100; tran.MPU_Merchant_ID = line.Substring(140, 15); double rate = 0; if (tran.MPU_Merchant_ID.Substring(0, 3) != "202") { //To get mdr rate from db mMerchant merchant = new mMerchant(); merchant.MPU_Merchant_ID = tran.MPU_Merchant_ID; rate = merchant.get_mdr_rate_jcbnotonus(merchant); //rate = getMDRrate(mid, "MPU"); if (rate == -123) { // rate -123 means that cannot get merchant's MDR rate or merchant info does not exist // so we need to block transaction to upload and show warning Global_Error = true; error_Lines += merchant.MPU_Merchant_ID + ","; TempData["MerchantInfoError"] = error_Lines; TempData.Keep(); } tran.TRXMDRRate = rate; tran.MDRValue = (tran.TrxAmount * rate) / 100; tran.SettAmount = tran.TrxAmount - tran.MDRValue; tran.TrxDate = TRXDate; tran.TRXRemark = Session["UID"].ToString(); tran.RecordType = "JCB_Not_ONUS"; Tran_List.Add(tran); } } } } } catch (Exception ex) { TempData["MerchantInfoError"] = ex.Message; TempData.Keep(); } return(Tran_List); }
internal List <mTransaction> ReadMPU_BCOM(string filepath) { if (HttpContext.Session["UID"] == null) { return(new List <mTransaction>()); } List <mTransaction> Tran_List = new List <mTransaction>(); string error_Lines = "Terminated!!! \nError : "; try { if (!string.IsNullOrEmpty(filepath)) { //Get Trx Date string datestr = Path.GetFileName(filepath); string year = "20" + datestr.Substring(3, 2); string month = datestr.Substring(5, 2); string day = datestr.Substring(7, 2); DateTime TRXDate = DateTime.ParseExact(year + "-" + month + "-" + day, "yyyy-MM-dd", null); //Read File string[] lines = System.IO.File.ReadAllLines(filepath); foreach (var line in lines) { string[] arr = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries); mTransaction tran = new mTransaction(); tran.CardNo = arr[4].ToString(); mCardType cardtype = new mCardType(); cardtype.BINCode = tran.CardNo.Substring(0, 4).ToString(); tran.CardType = cardtype.get_card_type(); tran.TrxAmount = Convert.ToDouble(arr[5].ToString()) / 100; tran.MPU_Merchant_ID = arr[12].ToString(); tran.ProcessingCode = arr[19].ToString(); tran.TerminalID = arr[11].ToString(); if (tran.ProcessingCode.Length > 3) { tran.ProcessingCode = arr[18].ToString(); tran.TerminalID = arr[15].ToString(); } double rate = 0; mMerchant merchant = new mMerchant(); merchant.MPU_Merchant_ID = tran.MPU_Merchant_ID; rate = merchant.get_mdr_rate_mpuonus(merchant); if (rate == -123) { // rate -123 means that cannot get merchant's MDR rate or merchant info does not exist // so we need to block transaction to upload and show warning Global_Error = true; error_Lines += merchant.MPU_Merchant_ID + ","; TempData["MerchantInfoError"] = error_Lines; TempData.Keep(); } tran.TRXMDRRate = rate; tran.MDRValue = (tran.TrxAmount * rate) / 100; tran.SettAmount = tran.TrxAmount - tran.MDRValue; tran.TrxDate = TRXDate; tran.TRXRemark = Session["UID"].ToString(); tran.RecordType = "MPU_ON_US"; Tran_List.Add(tran); } } } catch (Exception ex) { TempData["MerchantInfoError"] = ex.Message; TempData.Keep(); } return(Tran_List); }