using Newtonsoft.Json; using Swift.API.Common; using Swift.API.ThirdPartyApiServices; using Swift.DAL.BL.Remit.Transaction; using Swift.DAL.Remittance.CustomerDeposits; using Swift.DAL.SwiftDAL; using Swift.web.Library; using System; using System.Data; using System.Threading.Tasks; namespace Swift.web.Remit.Transaction.ApproveTxn { public partial class Manage : System.Web.UI.Page { private const string ViewFunctionId = "20122800"; private readonly StaticDataDdl _sdd = new StaticDataDdl(); private readonly ApproveTransactionDao atd = new ApproveTransactionDao(); private readonly CustomerDepositDao _dao = new CustomerDepositDao(); protected void Page_Load(object sender, EventArgs e) { Authenticate(); // GetStatic.AttachConfirmMsg(ref btnApprove, "Are you sure to APPROVE this transaction?"); if (!IsPostBack) { } LoadTransaction(); if (GetRequest() == "v") { btnApprove.Text = "Verify"; GetStatic.AttachConfirmMsg(ref btnApprove, "Are you sure to verify this transaction?"); } else { GetStatic.AttachConfirmMsg(ref btnApprove, "Are you sure to approve this transaction?"); } } private void Authenticate() { _sdd.CheckAuthentication(ViewFunctionId); } private void LoadTransaction() { string tranNo = GetTranNo(); ucTran.SearchData(tranNo, "", "", "", "APPROVE", "ADMIN: VIEW TXN TO APPROVE"); ucTran.isFromApproveTxn = "Y"; divTranDetails.Visible = ucTran.TranFound; if (!ucTran.TranFound) { divControlno.InnerHtml = "

No Transaction Found

"; return; } } protected string GetTranNo() { return GetStatic.ReadQueryString("id", ""); } protected string GetRequest() { return GetStatic.ReadQueryString("requestFrom", ""); } private void Approve() { DbResult _dbRes = atd.GetTxnApproveDataIMEPay(GetStatic.GetUser(), GetTranNo()); if (_dbRes.ErrorCode != "0") { GetStatic.PrintMessage(Page, _dbRes); return; } if (_dbRes.Extra2 == "True")//is realtime { SendTransactionServices _tpSend = new SendTransactionServices(); string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":" + _dbRes.Extra1 + ":releaseTxn"; var result = _tpSend.ReleaseTransaction(new TFReleaseTxnRequest() { TfPin = _dbRes.Id, TxnId = _dbRes.Extra, RequestBy = GetStatic.GetUser(), ProviderId = _dbRes.Extra1, ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40) }); _dbRes.ErrorCode = result.ResponseCode; _dbRes.Msg = result.Msg; _dbRes.Id = ""; if (_dbRes.ErrorCode != "0") { GetStatic.AlertMessage(Page, _dbRes.ErrorCode + " " + _dbRes.Msg); GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();"); LoadTransaction(); return; } else { var dr = atd.ApproveHoldedTXN(GetStatic.GetUser(), GetTranNo()); GetStatic.AlertMessage(Page, dr.Msg); if (dr.ErrorCode.Equals("0")) { GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();"); LoadTransaction(); return; } } } else { var dr = atd.ApproveHoldedTXN(GetStatic.GetUser(), GetTranNo()); // SendApprovalMailToCustomers(); GetStatic.AlertMessage(Page, dr.Msg); if (dr.ErrorCode.Equals("0")) { //GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();"); Response.Redirect("/Remit/Transaction/ApproveTxn/holdTxnListMobile.aspx"); LoadTransaction(); return; } } } private void Verify() { var tranId = GetTranNo(); DbResult _res = new DbResult(); if (!string.IsNullOrEmpty(tranId)) { _res = _dao.VerifyCashCollect(GetStatic.GetUser(), tranId); } else { GetStatic.AlertMessage(this, "Please choose at least on record!"); } GetStatic.AlertMessage(Page, _res.Msg); if (_res.ErrorCode.Equals("0")) { GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();"); LoadTransaction(); } } private void SendApprovalMailToCustomers() { Task.Factory.StartNew(() => { SendEmail(); }); } private void SendEmail() { DataTable mailDetails = atd.GetMailDetails("system"); if (mailDetails.Rows.Count == 0 || mailDetails == null) { return; } foreach (DataRow item in mailDetails.Rows) { string res = SendEmailNotification(item); if (res != "Mail Send") { atd.ErrorEmail("system", item["rowId"].ToString()); } } } private string SendEmailNotification(DataRow item) { string msgSubject = "JME Control No.: " + item["controlNoDec"].ToString(); string toEmailId = item["createdBy"].ToString(); string msgBody = "Dear " + item["SenderName"]; msgBody += "

This is to acknowledge that you have successfully completed your transaction through JME Online Remit System."; msgBody += "

Kindly take a note of the following transaction details for your record."; msgBody += "

JME Number: " + item["controlNoDec"].ToString(); msgBody += "
Amount sent: " + item["collCurr"].ToString() + " " + GetStatic.ShowDecimal(item["tAmt"].ToString()); msgBody += "
Payment method: " + item["paymentMethod"].ToString(); msgBody += "
Pay-out country: " + item["pcountry"].ToString(); msgBody += "
Account holding bank Name: " + item["payountBankOrAgent"].ToString(); msgBody += "
Account number: " + item["accNo"].ToString(); msgBody += "
Account holder’s name: " + item["receiverName"].ToString(); msgBody += "
Payout Amount: " + item["payoutCurr"].ToString() + " " + GetStatic.ShowDecimal(item["pAmt"].ToString()); msgBody += "

You can keep track of your payment status by https://online.gmeremit.com/."; msgBody += "

If you need further assistance kindly email us at support@jme.com.np or call us at 03-5475-3913. or visit our website japanremit.com"; msgBody += "


We look forward to provide you excellent service."; msgBody += "

Thank You."; msgBody += "


Regards,"; msgBody += "
JME Online Team"; msgBody += "
Tokyo, Japan "; msgBody += "
Phone number 15886864 "; SmtpMailSetting mail = new SmtpMailSetting { MsgBody = msgBody, MsgSubject = msgSubject, ToEmails = toEmailId }; return mail.SendSmtpMail(mail); } protected void btnApprove_Click(object sender, EventArgs e) { if (GetRequest() == "v") { Verify(); } else { Approve(); } } } }