//UtilityLogic utility = new UtilityLogic();
        public void BeginProcess()
        {
            UtilityLogic.LogMessage("Initializing nodes...");
            var nodes = new NodeRepository().GetAll();

            if (nodes == null || nodes.Count() < 1)
            {
                UtilityLogic.LogError("No node is configured!");
            }
            else
            {
                foreach (var node in nodes)
                {
                    try
                    {
                        CbaListener.StartUpListener(node.ID.ToString(), node.HostName, Convert.ToInt32(node.Port));
                        UtilityLogic.LogMessage(node.Name + " now listening on port " + node.Port);
                    }
                    catch (Exception ex)
                    {
                        UtilityLogic.LogError("Message: " + ex.Message + " \t InnerException " + ex.InnerException);
                    }
                }
            }
        }
Пример #2
0
        private static Iso8583Message ProcessCashWithrawal(Iso8583Message msg, CustomerAccount customerAccount, decimal amount, decimal charge, decimal totalCharges, decimal totalAmt)
        {
            UtilityLogic.LogMessage("Processing cash withdrawal");
            //for withdrawal, get the fromAccount, the amount and charge. Check the available balance and ...
            if (!(new CustomerAccountLogic().CustomerAccountHasSufficientBalance(customerAccount, totalAmt)))
            {
                msg.Fields.Add(39, "51");   //not sufficient funds (Insufficient balance)   in customer's account
                return(msg);
            }
            //perform withdrawal
            try
            {
                //check if a GL account is set for the atm
                var atmGl = new GlAccountRepository().GetByName("ATMGL");
                var withdrawalIncomeGl = glRepo.GetByName("WithdrawalIncomeGl");
                if (atmGl == null || withdrawalIncomeGl == null)
                {
                    msg.Fields.Add(39, ResponseCode.ISSUER_OR_SWITCH_INOPERATIVE);   //Issuer or switch inoperative.
                    return(msg);
                }
                if (atmGl.AccountBalance < (amount + charge))
                {
                    msg.Fields.Add(39, "51");       //insufficient funds (in the ATM)
                    return(msg);
                }

                //DEBIT AND CREDIT
                DebitCustomer(customerAccount, totalAmt);
                CreditGl(atmGl, amount);
                CreditGl(withdrawalIncomeGl, totalCharges); //same gl for both onus and remote on-us

                msg.Fields.Add(39, "00");                   //successful transaction
                UtilityLogic.LogMessage("Withdrawal Transaction successful");
                return(msg);
            }
            catch (Exception ex)
            {
                UtilityLogic.LogError("Error:  " + ex.Message + "   Inner Exception:      " + ex.InnerException);
                msg.Fields.Add(39, "06");       //ERROR!
                return(msg);
            }
        }
Пример #3
0
        static void Listener_Receive(object sender, ReceiveEventArgs e)
        {
            try
            {
                UtilityLogic.LogMessage("Message received!");
                var            client = sender as ClientPeer;
                Iso8583Message msg    = e.Message as Iso8583Message;
                switch (GetTransactionSource(msg))
                {
                case MessageSource.OnUs:
                    msg = TransactionManager.ProcessMessage(msg, MessageSource.OnUs);
                    break;

                case MessageSource.RemoteOnUs:
                    msg = TransactionManager.ProcessMessage(msg, MessageSource.RemoteOnUs);
                    //do nothing yet
                    break;

                case MessageSource.NotOnUs:
                    //redirect to interswitch
                    msg.Fields.Add(39, "31");       //bank not supported
                    break;

                default:
                    break;
                }

                PeerRequest request = new PeerRequest(client, msg);
                request.Send();
                client.Close();
                client.Dispose();
            }
            catch (Exception ex)
            {
                UtilityLogic.LogError("Error processing the incoming meaasgae");
                UtilityLogic.LogError("Message: " + ex.Message + " \t InnerException " + ex.InnerException);
            }
        }