public static void Startup()
        {
            //TO INSTANTIATE CLIENT PEER
            TransactionManager trxnManager = new TransactionManager();
            //Start up all listeners
            Logger.Log("Searching for pre-configured source servers");
            List<SourceNode> allSourceNode = new SourceNodeManager().RetrieveAll().ToList();
            Logger.Log(allSourceNode.Count + " Source server(s) found:.\t ");

            new Listener().StartListener(allSourceNode);

            //Start up all clients
            Logger.Log("Searching for pre-configured sink Clients:-->> ");
            List<SinkNode> allSinkNode = new SinkNodeManager().GetAllSinkNode().ToList();
            Logger.Log(allSinkNode.Count + " Sink Client(s) found");
            new Client().StartClient(allSinkNode);
        }
        public void DoAutoReversal()
        {
            var allLogsThatNeedsReversal = new TransactionLogManager().GetAllThatNeedsReversal();
               Iso8583Message msgFromFEP = null;
               bool needReversal = true;
               Dictionary<string, SinkNode> allSinkNodes = new SinkNodeManager().GetAllSinkNode().ToDictionary(x => x.Name);
               Dictionary<string, SourceNode> allSourceNodes = new SourceNodeManager().RetrieveAll().ToDictionary(x => x.Name);
               foreach (var log in allLogsThatNeedsReversal)
               {
               if (!log.IsReversed && log.IsReversePending)
               {
                   Iso8583Message revMsg = BuildReversalIsoMessage(log);
                   Logger.LogTransaction(revMsg);
                   if (log.SinkNode != null)
                   {
                       var sinkNode = allSinkNodes[log.SinkNode];
                       msgFromFEP = ToFEP(revMsg, sinkNode, out needReversal); //TOFEP should set needReversal to false

                       if (msgFromFEP.Fields[39].ToString() == "00")
                       {
                           Logger.LogTransaction(msgFromFEP, allSourceNodes[log.SourceNode], null, null, needReversal);
                       }
                   }

                   if (!needReversal)
                   {
                       log.IsReversePending = false;
                       log.IsReversed = true;
                       new TransactionLogManager().Update(log);
                       Logger.Log("Auto Reversal done for: " + log.OriginalDataElement);
                   }
               }
               if (log.IsReversed)
               {
                   log.IsReversePending = false;
                   log.IsReversed = true;
                   new TransactionLogManager().Update(log);
               }
               }
        }
        //Set status to inactive
        public static void Shutdown()
        {
            //TO INSTANTIATE CLIENT PEER
            TransactionManager trxnManager = new TransactionManager();

            IList<SourceNode> allSourceNode = new SourceNodeManager().RetrieveAll();

            foreach (var thisNode in allSourceNode)
            {
                thisNode.IsActive = false;
                new SourceNodeManager().Update(thisNode);
                Logger.Log(thisNode.Name + " shutting down at " + thisNode.IPAddress + " on " + thisNode.Port);
            }

            IList<SinkNode> SinkNodes = new SinkNodeManager().GetAllSinkNode();

            foreach (var sinkNode in SinkNodes)
            {
                sinkNode.IsActive = false;
                new SinkNodeManager().Update(sinkNode);
                Logger.Log(sinkNode.Name + " shutting down at " + sinkNode.IPAddress + " on " + sinkNode.Port);
                Console.WriteLine("SinkNode ShortDown" + sinkNode.IPAddress + "\t" + sinkNode.Port);
            }
        }
Exemplo n.º 4
0
        private void ClientPeerOnReceive(object sender, ReceiveEventArgs e)
        {
            var clientPeer = sender as ClientPeer;
            Logger.Log("Client Peer Receiving>>> " + clientPeer.Name);

            Iso8583Message receivedMessage = e.Message as Iso8583Message;
            SinkNode theSinkNode;
            try
            {
                var theSender = sender as ClientPeer;
                theSinkNode = new SinkNodeManager().GetById(Convert.ToInt32(theSender.Name));
            }
            catch (Exception)
            {
                 Logger.Log(String.Format("Message from Unknown Sink Node: {0}", receivedMessage));
                receivedMessage.SetResponseMessageTypeIdentifier();
                receivedMessage.Fields.Add(39, "91");   //Issuer inoperative
                clientPeer.Send(receivedMessage);
                return;
            }

            bool isValidMti;
            if (receivedMessage == null) return;
            string mtiDescription = MessageDefinition.GetMtiDescription(receivedMessage.MessageTypeIdentifier, "FEP", out isValidMti);

            if (!isValidMti)
            {

                 Logger.Log(String.Format("Invalid MTI response code {0}, {1}", receivedMessage, theSinkNode)); // work on this
                clientPeer.Send(receivedMessage);

                return;
            }

            string responseCode = receivedMessage.Fields[39].ToString();
            string responseDescription = MessageDefinition.GetResponseDescription(responseCode);
            string stan = receivedMessage.Fields[11].ToString();

            clientPeer.Send(receivedMessage);
        }