Example #1
0
        public EditSinkNode()
        {
            AddSection()
            .WithTitle("Edit Sink Node")
            .WithFields(
                new List <IField>()
            {
                Map(x => x.Name).AsSectionField <TextBox>().TextFormatIs(TextFormat.name).WithLength(100).Required(),
                Map(x => x.HostName).AsSectionField <TextBox>().TextFormatIs(@"^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])$").WithLength(50).Required(),
                Map(x => x.IPAddress).AsSectionField <TextBox>().WithLength(20).TextFormatIs(@"^(0[0-7]{10,11}|0(x|X)[0-9a-fA-F]{8}|(\b4\d{8}[0-5]\b|\b[1-3]?\d{8}\d?\b)|((2[0-5][0-5]|1\d{2}|[1-9]\d?)|(0(x|X)[0-9a-fA-F]{2})|(0[0-7]{3}))(\.((2[0-5][0-5]|1\d{2}|\d\d?)|(0(x|X)[0-9a-fA-F]{2})|(0[0-7]{3}))){3})$").Required(),
                Map(x => x.Port).AsSectionField <TextBox>().TextFormatIs(TextFormat.numeric).WithLength(10).Required(),
                // Map(x => x..IsActive).AsSectionField<TextBox>().TextFormatIs(TextFormat.name).WithLength(10).Required(),
            });

            AddButton().WithText("Update")
            .ConfirmWith("Please confirm operation!")
            .ApplyMod <IconMod>(x => x.WithIcon(Ext.Net.Icon.Disk))
            .SubmitTo(x =>
            {
                bool result = false;
                try
                {
                    result = new SinkNodeManager().Edit(x);
                }
                catch (Exception ex)
                {
                    err = ex.Message;
                }
                return(result);
            }).OnSuccessDisplay("Sink Node successfully Updated").OnFailureDisplay(string.Format("Failed to Update:{0}", err));
        }
Example #2
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);
        }
        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);
                }
            }
        }
        public AddSinkNode()
        {
            // SinkNodeManager _sinkNode = new SinkNodeManager();
            AddSection()
            .WithTitle("Add New Sink Node")
            .WithFields(
                new List <IField>()
            {
                Map(x => x.Name).AsSectionField <TextBox>().TextFormatIs(TextFormat.name).WithLength(100).Required(),
                Map(x => x.HostName).AsSectionField <TextBox>().TextFormatIs(@"^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])$").WithLength(50).Required(),
                Map(x => x.IPAddress).AsSectionField <TextBox>().WithLength(20).TextFormatIs(@"^(0[0-7]{10,11}|0(x|X)[0-9a-fA-F]{8}|(\b4\d{8}[0-5]\b|\b[1-3]?\d{8}\d?\b)|((2[0-5][0-5]|1\d{2}|[1-9]\d?)|(0(x|X)[0-9a-fA-F]{2})|(0[0-7]{3}))(\.((2[0-5][0-5]|1\d{2}|\d\d?)|(0(x|X)[0-9a-fA-F]{2})|(0[0-7]{3}))){3})$").Required(),
                Map(x => x.Port).AsSectionField <TextBox>().TextFormatIs(TextFormat.numeric).WithLength(10).Required(),
            });

            AddButton()
            .WithText("Add Sink Node")
            .SubmitTo(x =>
            {
                var result = false;
                try
                {
                    //x.IsActive = false;
                    result = new SinkNodeManager().AddSinkNode(x);
                }
                catch (Exception ex)
                {
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    message = ex.Message;
                    throw;
                }
                return(result);
            }).OnSuccessDisplay("Saved Successfully")
            .OnFailureDisplay(string.Format("Failed to Save SinkNode:{0}", message));
        }
        public static void Shutdown()  //Set status to inactive
        {
            //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);
            }
        }