public void SessionReceiver(Receiver receiver, Message message)
        {
            try
            {
                var tradeConfirmationMsg = message.GetContent();
                _Log.WarnFormat("Received message : {0}", tradeConfirmationMsg);

                var tradeConfirmationDomainModel = TradeConfirmationDM.ParseXML(tradeConfirmationMsg);
                if (tradeConfirmationDomainModel.TrdHandlInst != TradeHandlingInstr.Trade_Confirmation)
                {
                    //the received message is not trade confirmation message, log and ingored it
                    _Log.WarnFormat("The received message is not trade confirmation message, log and ingored it: {0}", tradeConfirmationMsg);
                    //remove the message from the broadcast queue
                    //receiver.Session.Acknowledge();
                }
            }
            catch (Exception ex)
            {
                _Log.Error(string.Format("Process the recived message failed. Message text:{0}, CorreclationID:{1}", message.GetContent(), message.CorrelationId), ex);
            }
        }
Пример #2
0
        public static TradeConfirmationDM ParseXML(string fixmlStr)
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(fixmlStr);
            XmlNode rootNode = xdoc.DocumentElement;

            //
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(xdoc.NameTable);

            nsmgr.AddNamespace("ns", "www.eurexchange.com/technology");

            //
            TradeConfirmationDM domainModel = new TradeConfirmationDM();

            var trdCaptRptNode = rootNode.SelectSingleNode("/ns:FIXML/ns:TrdCaptRpt", nsmgr);

            if (trdCaptRptNode == null)
            {
                throw new NotSupportedException("This domain class only support TradeComfirmation FIXML message!");
            }

            domainModel.RptID    = trdCaptRptNode.Attributes["RptID"].Value;
            domainModel.TransTyp = EnumUtil <TradeReportTransType> .Parse(int.Parse(trdCaptRptNode.Attributes["TransTyp"].Value));

            domainModel.RptTyp = EnumUtil <TradeReportType> .Parse(int.Parse(trdCaptRptNode.Attributes["RptTyp"].Value));

            domainModel.TrdTyp = EnumUtil <TrdType> .Parse(int.Parse(trdCaptRptNode.Attributes["TrdTyp"].Value));

            domainModel.TrdHandlInst = EnumUtil <TradeHandlingInstr> .Parse(int.Parse(trdCaptRptNode.Attributes["TrdHandlInst"].Value));

            if (trdCaptRptNode.Attributes["OrigTrdHandlInst"] != null)
            {
                domainModel.OrigTrdHandlInst = EnumUtil <OrigTradeHandlingInstr> .Parse(int.Parse(trdCaptRptNode.Attributes["OrigTrdHandlInst"].Value));
            }
            domainModel.TrnsfrRsn = trdCaptRptNode.Attributes["TrnsfrRsn"].Value;
            if (trdCaptRptNode.Attributes["TotNumTrdRpts"] != null)
            {
                domainModel.TotNumTrdRpts = trdCaptRptNode.Attributes["TotNumTrdRpts"].Value;
            }
            if (trdCaptRptNode.Attributes["RptRefID"] != null)
            {
                domainModel.RptRefID = trdCaptRptNode.Attributes["RptRefID"].Value;
            }
            domainModel.MtchID     = trdCaptRptNode.Attributes["MtchID"].Value;
            domainModel.LastQty    = decimal.Parse(trdCaptRptNode.Attributes["LastQty"].Value);
            domainModel.LastPx     = decimal.Parse(trdCaptRptNode.Attributes["LastPx"].Value);
            domainModel.Ccy        = trdCaptRptNode.Attributes["Ccy"].Value;
            domainModel.LastMkt    = trdCaptRptNode.Attributes["LastMkt"].Value;
            domainModel.TrdDt      = trdCaptRptNode.Attributes["TrdDt"].Value;
            domainModel.BizDt      = trdCaptRptNode.Attributes["BizDt"].Value;
            domainModel.MLegRptTyp = EnumUtil <MultiLegReportingType> .Parse(int.Parse(trdCaptRptNode.Attributes["MLegRptTyp"].Value));

            if (trdCaptRptNode.Attributes["SettlDt"] != null)
            {
                domainModel.SettlDt = trdCaptRptNode.Attributes["SettlDt"].Value;
            }
            domainModel.LastUpdateTm = trdCaptRptNode.Attributes["LastUpdateTm"].Value;

            domainModel.Hdr     = new StandardHeader(trdCaptRptNode, nsmgr);
            domainModel.Pty     = GetPtyList(trdCaptRptNode, nsmgr);
            domainModel.Instrmt = new Instrument(trdCaptRptNode, nsmgr);
            //
            var amtNode = trdCaptRptNode.SelectSingleNode("./ns:Amt", nsmgr);

            if (amtNode != null)
            {
                domainModel.Amt = new PositionAmountData(amtNode);
            }

            domainModel.TrdRegTS = new TrdRegTimestamps(trdCaptRptNode, nsmgr);
            domainModel.RptSide  = new TrdCapRptSideGrp(trdCaptRptNode, nsmgr);

            return(domainModel);
        }