ToString() публичный Метод

public ToString ( ) : string
Результат string
Пример #1
0
        public void ToApp(Message message, SessionID sessionID)
        {
            var msgType = message.Header.GetString(Tags.MsgType);

            if (msgType == "V")
            {
                //message.SetField(new MDUpdateType(MDUpdateType.INCREMENTAL_REFRESH));  // 265

                //message.SetField(new MDEntryType(MDEntryType.BID), false); // 269
                //message.SetField(new MDEntryType(MDEntryType.OFFER), false); // 269
                //message.SetField(new NoMDEntryTypes(1)); // 267 Should be 2 TODO

                //message.SetField(new Symbol("EUR/USD")); // 55
                //message.SetField(new NoRelatedSym(1)); // 146
            }
            Console.WriteLine("ToApp: " + msgType);
            try
            {
                bool possDupFlag = false;
                if (message.Header.IsSetField(QuickFix.Fields.Tags.PossDupFlag))
                {
                    possDupFlag = QuickFix.Fields.Converters.BoolConverter.Convert(
                        message.Header.GetField(QuickFix.Fields.Tags.PossDupFlag)); /// FIXME
                }
                if (possDupFlag)
                {
                    throw new DoNotSend();
                }
            }
            catch (FieldNotFoundException)
            { }

            Console.WriteLine();
            Console.WriteLine("OUT: " + message.ToString());
        }
Пример #2
0
 public void FromApp(QuickFix.Message message, SessionID sessionID)
 {
     Console.ForegroundColor = respColor;
     Console.WriteLine(message.ToString(true));
     Console.ForegroundColor = defColor;
     isRejectMessage         = message.IsReject();
     WaitResponseResetEvent.Set();
 }
Пример #3
0
 public void ToAdmin(QuickFix.Message message, SessionID sessionID)
 {
     DoLog(string.Format("@toAdmin <{0}>:{1}", sessionID.ToString(), message.ToString()), Fwk.Main.Common.Util.Constants.MessageType.Information);
     if (message is Logon)
     {
         message.Header.SetField(new ResetSeqNumFlag(ResetSeqNumFlag.NO));
     }
 }
Пример #4
0
 private void ClientMessageEvent(Message arg1, bool arg2)
 {
     if (InvokeRequired)
     {
         Invoke(new Action <Message, bool>(ClientMessageEvent), arg1, arg2);
         return;
     }
     AddItem(arg1.ToString());
 }
Пример #5
0
 public void FromApp(QuickFix.Message message, SessionID sessionID)
 {
     DoLog(string.Format("@fromApp<{0}>:{1}", sessionID.ToString(), message.ToString()), Fwk.Main.Common.Util.Constants.MessageType.Information);
     if (message is QuickFix.FIX44.ExecutionReport)
     {
         Thread processExecReport = new Thread(ProcesssExecutionReportMessage);
         processExecReport.Start((QuickFix.FIX44.ExecutionReport)message);
     }
 }
Пример #6
0
 public void FromAdmin(QuickFix.Message message, SessionID sessionID)
 {
     DoLog(string.Format("@fromAdmin<{0}>:{1}", sessionID.ToString(), message.ToString()), Fwk.Main.Common.Util.Constants.MessageType.Information);
     if (message is Reject)
     {
         Reject reject          = (Reject)message;
         Thread rejectPrcThread = new Thread(ProcessMessageReject);
         rejectPrcThread.Start(reject);
     }
 }
Пример #7
0
        public JsonFixMessage Wrap(QuickFix.Message fixBaseMessage, string pseudoHeader)
        {
            var jsonFixMessage = new JsonFixMessage
            {
                localPseudoHeader = pseudoHeader,
                rawFixPayload     = fixBaseMessage.ToString()
            };

            return(jsonFixMessage);
        }
Пример #8
0
 public void FromAdmin(QuickFix.Message message, SessionID sessionID)
 {
     isRejectMessage         = message.IsReject();
     Console.ForegroundColor = isRejectMessage ? ConsoleColor.DarkRed : adminRespColor;
     Console.WriteLine($"FromAdmin {message.ToString(isRejectMessage || ViewAdminMessages)}");
     Console.ForegroundColor = defColor;
     if (isRejectMessage)
     {
         WaitResponseResetEvent.Set();
     }
 }
        private void Log(Message message, string send = "Sending")
        {
            string attachName    = $"{send} message";
            var    attachContext = new StringBuilder();

            attachContext.AppendLine(send);
            if (message != null)
            {
                attachContext.AppendLine(message.ToString().Replace("\u0001", "|"));
            }
            Allure2Helper.AttachJson(attachName, attachContext.ToString());
        }
Пример #10
0
 public void FromApp(QuickFix.Message message, SessionID sessionID)
 {
     logger.Debug("IN:  " + message.ToString());
     try
     {
         Crack(message, sessionID);
     }
     catch (Exception ex)
     {
         logger.Error("==Cracker exception==");
         logger.Error(ex.ToString(), ex);
     }
 }
Пример #11
0
 public void FromApp(Message message, SessionID sessionId)
 {
     Console.WriteLine("IN:  " + message.ToString());
     try
     {
         Crack(message, sessionId);
     }
     catch (Exception ex)
     {
         Console.WriteLine("==Cracker exception==");
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.StackTrace);
     }
 }
Пример #12
0
 public void FromApp(QuickFix.Message msg, SessionID sessionID)
 {
     Console.WriteLine("FromApp - " + msg.ToString() + "@" + sessionID.ToString());
     try
     {
         Crack(msg, sessionID);
     }
     catch (Exception ex)
     {
         Console.WriteLine("==Cracker exception==");
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.StackTrace);
     }
 }
Пример #13
0
 public void FromApp(Message message, SessionID sessionID)
 {
     Console.WriteLine("IN:  " + message.ToString());
     try
     {
         Crack(message, sessionID);
     }
     catch (Exception ex)
     {
         Console.WriteLine("==Cracker exception==");
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.StackTrace);
     }
 }
Пример #14
0
        public void FromApp(QuickFix.Message msg, SessionID sessionID)
        {
            logMe("\r\n \r\n" + "FromApp :" + msg.ToString());

            if (msg is QuickFix.FIX42.ExecutionReport)
            {
                QuickFix.FIX42.ExecutionReport er = (QuickFix.FIX42.ExecutionReport)msg;

                logMe("\r\n \r\n" + "Got execution Report - ExecType = " + er.ExecType.getValue());

                if (er.ExecType.getValue() == ExecType.FILL)
                {
                    logMe("\r\n \r\n" + "FromApp : order Filled");
                }
            }
        }
Пример #15
0
        public void ProcessMessage(QuickFix.Message msg, bool isIncoming)
        {
            string clordid = msg.GetString(11);

            if (TestManager.Instance.IsCancelled)
            {
                Console.WriteLine("Ignoring inbound message - Test cancelled by user:{0}{1}", System.Environment.NewLine, msg.ToString());
                Console.ReadKey();
                if (EndOfScenarioEvent != null)
                {
                    EndOfScenarioEvent();
                }
            }
            else if (!string.IsNullOrEmpty(clordid) && !((List <string>)ConfigurationSingleton.Instance.GetIDInUseList()).Contains(clordid))
            {
                Console.WriteLine("Ignoring inbound message - unknown ClOrdID:{0}{1}", System.Environment.NewLine, msg.ToString());
                Console.WriteLine();
            }
            else
            {
                Debug.WriteLine("Q:{0} Incoming:{1} - {2}", outQ.Count.ToString(), isIncoming.ToString(), msg.ToString());

                //Console.WriteLine("Message received: {0}", msg.ToString());
                if (isIncoming)
                {
                    if (outQ.Count > 0 && outQ.Peek().Direction == MessageDirection.INBOUND)
                    {
                        RawMessage rm = outQ.Dequeue();
                        Debug.WriteLine("Q:{0} Incoming:{1} - {2}", outQ.Count.ToString(), isIncoming.ToString(), msg.ToString());
                        //Console.WriteLine();
                        //Console.WriteLine("Received: {0}", msg.ToString());
                        //Console.WriteLine("Expected: {0}", rm.Message);

                        MessageResult mr = new MessageResult(rm.Message, msg.ToString());
                        ProcessResult(mr);
                        results.Add(mr);
                    }

                    if (outQ.Count == 0)
                    {
                        ProcessResults();
                    }
                }

                SendNext();
            }
        }
Пример #16
0
        public void toAdmin(QuickFix.Message message, SessionID sessionID)
        {
            #region Documentation
            // provides you with a peak at the administrative messages that are being sent from your FIX engine to the
            // counter party. This is normally not useful for an application however it is provided for any logging you may
            // wish to do. Notice that the FIX::Message is not const. This allows you to add fields before an adminstrative
            // message before it is sent out.
            #endregion

            bool print = true;
            if (message.getHeader().isSetField(35))
            {
                MsgType msgtype = new MsgType();
                message.getHeader().getField(msgtype);
                if (msgtype.getValue() == "0")
                {
                    print = false;
                }
                else if (msgtype.getValue() == MsgType.LOGON)
                {
                    message.getHeader().setField(Username.FIELD, "wbaychidrop");
                    message.getHeader().setField(Password.FIELD, "W3aychi!");
                    //message.setField(RawData.FIELD, "W3aychi!");
                    //message.setField(RawDataLength.FIELD, "W3aychi!".Length.ToString());
                }

                //    SenderCompID sender = new SenderCompID();
                //    message.getHeader().getField(sender);

                //    if (sender.getValue().Equals("DHIRACH"))
                //    {
                //        message.getHeader().setField(SenderSubID.FIELD, "DHIRACH");
                //        message.getHeader().setField(TargetSubID.FIELD, "ITGD");
                //    }
                //    else
                //    {
                //        message.getHeader().setField(TargetSubID.FIELD, "DHIRACH");
                //        message.getHeader().setField(SenderSubID.FIELD, "ITGD");
                //    }
            }

            if (print)
            {
                Console.WriteLine("Logon Message: " + message.ToString());
            }
        }
Пример #17
0
        public void toApp(QuickFix.Message message, SessionID sessionID)
        {
            #region Documentation
            // is a callback for application messages that you are being sent to a counterparty. If you throw a DoNotSend
            // exception in this function, the application will not send the message. This is mostly useful if the
            // application has been asked to resend a message such as an order that is no longer relevant for the current
            // market. Messages that are being resent are marked with the PossDupFlag in the header set to true; If a
            // DoNotSend exception is thrown and the flag is set to true, a sequence reset will be sent in place of the
            // message. If it is set to false, the message will simply not be sent. Notice that the FIX::Message is not
            // const. This allows you to add fields before an application message before it is sent out.
            #endregion

            if (bPrintApplicationMessages)
            {
                Console.WriteLine("toApp: " + message.ToString());
            }
        }
Пример #18
0
 public void FromApp(Message message, SessionID sessionID)
 {
     try
     {
         string msgType = message.Header.GetField(QuickFix.Fields.Tags.MsgType);
         log_.OnEvent("Got message " + msgType);
         Crack(message, sessionID);
     }
     catch (QuickFix.UnsupportedMessageType)
     {
         throw;
     }
     catch (System.Exception e)
     {
         log_.OnEvent("FromApp: " + e.ToString() + " while processing msg (" + message.ToString() + ")");
     }
 }
Пример #19
0
        public void ToApp(Message message, SessionID sessionID)
        {
            try
            {
                bool possDupFlag = false;
                if (message.Header.IsSetField(QuickFix.Fields.Tags.PossDupFlag))
                {
                    possDupFlag = QuickFix.Fields.Converters.BoolConverter.Convert(
                        message.Header.GetField(QuickFix.Fields.Tags.PossDupFlag)); /// FIXME
                }
                if (possDupFlag)
                    throw new DoNotSend();
            }
            catch (FieldNotFoundException)
            { }

            Console.WriteLine();
            Console.WriteLine("OUT: " + message.ToString());
        }
Пример #20
0
        public void fromApp(QuickFix.Message message, SessionID sessionID)
        {
            // Documentation
            // is one of the core entry points for your FIX application. Every application level request will come through
            // here. If, for example, your application is a sell-side OMS, this is where you will get your new order
            // requests. If you were a buy side, you would get your execution reports here. If a FieldNotFound exception is
            // thrown, the counterparty will receive a reject indicating a conditionally required field is missing. The
            // Message class will throw this exception when trying to retrieve a missing field, so you will rarely need the
            // throw this explicitly. You can also throw an UnsupportedMessageType exception. This will result in the
            // counterparty getting a reject informing them your application cannot process those types of messages. An
            // IncorrectTagValue can also be thrown if a field contains a value that is out of range or you do not support.

            if (bPrintApplicationMessages)
            {
                Console.WriteLine("fromApp: " + message.ToString());
            }

            crack(message, sessionID);  // using the most type-safe recommendation from FIX
            // this passes to the crack function, which in-turn gives us responses via the OnMessage functions
        }
Пример #21
0
        public void ToApp(Message message, SessionID sessionId)
        {
            try
            {
                bool possDupFlag = false;
                if (message.Header.IsSetField(QuickFix.Fields.Tags.PossDupFlag))
                {
                    possDupFlag = QuickFix.Fields.Converters.BoolConverter.Convert(
                        message.Header.GetField(QuickFix.Fields.Tags.PossDupFlag)); /// FIXME
                }
                if (possDupFlag)
                {
                    throw new DoNotSend();
                }
            }
            catch (FieldNotFoundException)
            { }

            Console.WriteLine();
            Console.WriteLine("OUT: " + message.ToString());
        }
Пример #22
0
        /**
         * Callback chamado logo depois do recebimento bem sucedido de
         * mensagem FIX de aplicação.
         *
         */
        public void fromApp(QuickFix.Message message, SessionID sessionId)
        {
            try
            {
                logger.Debug("RECV(APP) <-- " + message.ToString());
                crack(message, sessionId);
            }

            catch (FieldNotFound e)
            {
                logger.Error("Campo nao encontrado na mensagem: " + e.Message, e);
            }
            catch (IncorrectTagValue e)
            {
                logger.Error("Valor da Tag incorreto na mensagem: " + e.Message);
            }
            catch (UnsupportedMessageType e)
            {
                logger.Error("Tipo de mensagem nao suportado na mensagem: " + e.Message);
            }
        }
Пример #23
0
        public void fromAdmin(QuickFix.Message message, SessionID sessionID)
        {
            #region Documentation
            // notifies you when an administrative message is sent from a counterparty to your FIX engine. This can be
            // useful for doing extra validation on logon messages such as for checking passwords. Throwing a RejectLogon
            // exception will disconnect the counterparty.
            #endregion
            bool print = true;
            if (message.getHeader().isSetField(35))
            {
                MsgType msgtype = new MsgType();
                message.getHeader().getField(msgtype);
                if (msgtype.getValue() == "0")
                {
                    print = false;
                }
            }

            if (print)
            {
                Console.WriteLine("fromAdmin: " + message.ToString());
            }
        }
Пример #24
0
        /**
         * Callback chamado logo antes do envio da mensagem FIX de controle de sessão.
         *
         */
        public void toAdmin(QuickFix.Message message, SessionID sessionId)
        {
            try
            {
                // Se for mensagem de Logon, inclui o RawData e RawDataLength na mensagem
                if (message.getHeader().getString(MsgType.FIELD).Equals("A"))
                {
                    message.setBoolean(ResetSeqNumFlag.FIELD, true);
                    message.setInt(NextExpectedMsgSeqNum.FIELD,
                                   (new NextExpectedMsgSeqNum(ConstantesMDS.BMF_SEQNUM_INICIAL)).getValue());

                    message.setField(RawData.FIELD, new RawData(senha).ToString());
                    message.setField(RawDataLength.FIELD, new RawDataLength(senha.Length).ToString());

                    if (novaSenha != null && novaSenha.Length > 0)
                    {
                        message.setField(NewPassword.FIELD, new NewPassword(novaSenha).ToString());
                        logger.Info("Enviada nova senha para alteracao!");
                    }
                }
                else if (message.getHeader().getString(MsgType.FIELD).Equals("5"))
                {
                    if (assinados)
                    {
                        cancelaInstrumentos();
                    }
                }

                logger.Debug("SEND(SES) --> " + message.ToString());
            }

            catch (FieldNotFound e)
            {
                logger.Error("Campo nao encontrado: " + e.Message, e);
            }
        }
Пример #25
0
        protected bool SendRaw(Message message, int seqNum)
        {
            lock (sync_)
            {
                string msgType = message.Header.GetField(Fields.Tags.MsgType);

                InitializeHeader(message, seqNum);

                if (Message.IsAdminMsgType(msgType))
                {
                    this.Application.ToAdmin(message, this.SessionID);

                    if (MsgType.LOGON.Equals(msgType) && !state_.ReceivedReset)
                    {
                        Fields.ResetSeqNumFlag resetSeqNumFlag = new QuickFix.Fields.ResetSeqNumFlag(false);
                        if (message.IsSetField(resetSeqNumFlag))
                            message.GetField(resetSeqNumFlag);
                        if (resetSeqNumFlag.getValue())
                        {
                            state_.Reset();
                            message.Header.SetField(new Fields.MsgSeqNum(state_.GetNextSenderMsgSeqNum()));
                        }
                        state_.SentReset = resetSeqNumFlag.Obj;
                    }
                }
                else
                {
                    this.Application.ToApp(message, this.SessionID);
                }

                string messageString = message.ToString();
                if (0 == seqNum)
                    Persist(message, messageString);
                return Send(messageString);
            }
        }
 public void fromApp(QuickFix.Message value, SessionID session)
 {
     SystemLogger.WriteOnConsoleAsync(true, value.ToString(), ConsoleColor.DarkGray, ConsoleColor.White, false);
     Handle(value);
 }
Пример #27
0
 public void OnMessage(Message message, SessionID sessionID)
 {
     Console.WriteLine(sessionID + "------client onMessage-------业务逻辑----"
        + message.ToString());
 }
Пример #28
0
 public void FromAdmin(Message msg, SessionID sessionID)
 {
     Console.WriteLine(sessionID + "------client fromAdmin-------业务逻辑----"
      + msg.ToString());
 }
Пример #29
0
 public void ToApp(Message message, SessionID sessionID)
 {
     Trace.TraceInformation(message.ToString());
 }
Пример #30
0
        protected void NextResendRequest(Message resendReq)
        {
            if (!Verify(resendReq, false, false))
                return;
            try
            {
                int msgSeqNum = 0;
                if (!(this.IgnorePossDupResendRequests && resendReq.Header.IsSetField(Tags.PossDupFlag)))
                {
                    int begSeqNo = resendReq.GetInt(Fields.Tags.BeginSeqNo);
                    int endSeqNo = resendReq.GetInt(Fields.Tags.EndSeqNo);
                    this.Log.OnEvent("Got resend request from " + begSeqNo + " to " + endSeqNo);

                    if ((endSeqNo == 999999) || (endSeqNo == 0))
                    {
                        endSeqNo = state_.GetNextSenderMsgSeqNum() - 1;
                    }

                    if (!PersistMessages)
                    {
                        endSeqNo++;
                        int next = state_.GetNextSenderMsgSeqNum();
                        if (endSeqNo > next)
                            endSeqNo = next;
                        GenerateSequenceReset(resendReq, begSeqNo, endSeqNo);
                        return;
                    }

                    List<string> messages = new List<string>();
                    state_.Get(begSeqNo, endSeqNo, messages);
                    int current = begSeqNo;
                    int begin = 0;
                    foreach (string msgStr in messages)
                    {
                        Message msg = new Message();
                        msg.FromString(msgStr, true, this.SessionDataDictionary, this.ApplicationDataDictionary, msgFactory_);
                        msgSeqNum = msg.Header.GetInt(Tags.MsgSeqNum);

                        if ((current != msgSeqNum) && begin == 0)
                        {
                            begin = current;
                        }

                        if (IsAdminMessage(msg) && !(this.ResendSessionLevelRejects && msg.Header.GetString(Tags.MsgType) == MsgType.REJECT))
                        {
                            if (begin == 0)
                            {
                                begin = msgSeqNum;
                            }
                        }
                        else
                        {

                            initializeResendFields(msg);
                            if(!ResendApproved(msg, SessionID)) 
                            {
                                continue;
                            }

                            if (begin != 0)
                            {
                                GenerateSequenceReset(resendReq, begin, msgSeqNum);
                            }
                            Send(msg.ToString());
                            begin = 0;
                        }
                        current = msgSeqNum + 1;
                    }

                    int nextSeqNum = state_.GetNextSenderMsgSeqNum();
                    if (++endSeqNo > nextSeqNum)
                    {
                        endSeqNo = nextSeqNum;
                    }

                    if (begin == 0)
                    {
                        begin = current;
                    }

                    if (endSeqNo > begin)
                    {
                        GenerateSequenceReset(resendReq, begin, endSeqNo);
                    }
                }
                msgSeqNum = resendReq.Header.GetInt(Tags.MsgSeqNum);
                if (!IsTargetTooHigh(msgSeqNum) && !IsTargetTooLow(msgSeqNum))
                {
                    state_.IncrNextTargetMsgSeqNum();
                }

            }
            catch (System.Exception e)
            {
                this.Log.OnEvent("ERROR during resend request " + e.Message);
            }
        }
Пример #31
0
 public void ToStringFieldOrder()
 {
     Message msg = new Message();
     msg.Header.SetField(new QuickFix.Fields.MsgType("A"));
     msg.Header.SetField(new QuickFix.Fields.BeginString("FIX.4.2"));
     msg.Header.SetField(new QuickFix.Fields.SenderCompID("SENDER"));
     msg.Header.SetField(new QuickFix.Fields.TargetCompID("TARGET"));
     msg.Header.SetField(new QuickFix.Fields.MsgSeqNum(42));
     string expect = "8=FIX.4.2\x01" + "9=31\x01" + "35=A\x01" + "34=42\x01" + "49=SENDER\x01" + "56=TARGET\x01" + "10=200\x01";
     Assert.That(msg.ToString(), Is.EqualTo(expect));
 }
Пример #32
0
        public void issue95()
        {
            // Parser screws up on triple-nested groups.  Contributes to ResendRequest failures.
            string msgStr = String.Join(Message.SOH, new string[]{
                "8=FIX.4.4","9=999","35=R","34=6","49=sendercompid","52=20130225-10:44:59.149","56=targetcompid", //headers
                    "131=quotereqid",
                    "146=1", // NoRelatedSym
                        "55=ABC","65=CD","48=securityid","22=1", // group
                        "711=1", // NoUnderlyings
                            "311=underlyingsymbol","312=WI","309=underlyingsecurityid","305=1",
                "10=999",""
            });

            var dd = new QuickFix.DataDictionary.DataDictionary();
            dd.Load("../../../spec/fix/FIX44.xml");

            Message msg = new Message();
            msg.FromString(msgStr, false, dd, dd, _defaultMsgFactory);

            // make sure no fields were dropped in parsing
            Assert.AreEqual(msgStr.Length, msg.ToString().Length);

            // make sure repeating groups are not rearranged
            // 1 level deep
            StringAssert.Contains(String.Join(Message.SOH, new string[] { "55=ABC", "65=CD", "48=securityid", "22=1" }), msg.ToString());
            // 2 levels deep
            StringAssert.Contains(String.Join(Message.SOH, new string[] { "311=underlyingsymbol", "312=WI", "309=underlyingsecurityid", "305=1" }), msg.ToString());
        }
Пример #33
0
 protected virtual void MsgBusinessReject(Message msg, SessionID sid)
 {
     FixReport(msgTypeBsnsRej, msg, 0, msg.ToString());
 }
Пример #34
0
 public void ToApp(QuickFix.Message message, SessionID sessionId)
 {
     AppLogger.Debug(message.ToString());
     Console.WriteLine(string.Format("@toApp:{0}", message.ToString()));
 }
Пример #35
0
 //网关拒绝处理消息
 protected virtual void MsgReject(Message msg, SessionID sid)
 {
     FixReport(msgTypeReject, msg, 0, msg.ToString());
 }
Пример #36
0
 public virtual void ToAdmin(QuickFix.Message message, QuickFix.SessionID session)
 {
     try
     {
         logger.Debug("SND(Admin) --> type[" + message.GetType().ToString() + "] msg[" + message.ToString() + "]");
         //if (message.Header.GetField(QuickFix.Fields.Tags.MsgType) != QuickFix.Fields.MsgType.HEARTBEAT)
         //    this.Crack(message, session);
     }
     catch (Exception ex)
     {
         logger.Error("ToAdmin(): " + ex.Message, ex);
     }
 }
Пример #37
0
 /**
  * Callback chamado logo depois do recebimento bem sucedido de
  * mensagem FIX de controle de sessão.
  *
  */
 public void fromAdmin(QuickFix.Message message, SessionID sessionId)
 {
     logger.Debug("RECV(SES) <-- " + message.ToString());
 }
Пример #38
0
 private void ClientMessageEvent(Message arg1, bool arg2)
 {
     if (InvokeRequired)
     {
         Invoke(new Action<Message, bool>(ClientMessageEvent), arg1, arg2);
         return;
     }
     AddItem(arg1.ToString());
 }
Пример #39
0
 public void ToApp(Message msg, SessionID sessionID)
 {
     Console.WriteLine(sessionID + "------client toApp-------业务逻辑----"
         + msg.ToString());
 }
Пример #40
0
 public void ToStringTest()
 {
     string str1 = "8=FIX.4.2\x01" + "9=55\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01" +
         "52=20000426-12:05:06\x01" + "56=ISLD\x01" + "1=acct123\x01" + "10=123\x01";
     Message msg = new Message();
     try
     {
         msg.FromString(str1, true, null, null, _defaultMsgFactory);
     }
     catch (InvalidMessage e)
     {
         Assert.Fail("Unexpected exception (InvalidMessage): " + e.Message);
     }
     StringField f1 = new StringField(8);
     StringField f2 = new StringField(9);
     StringField f3 = new StringField(35);
     StringField f4 = new StringField(34);
     StringField f5 = new StringField(49);
     StringField f6 = new StringField(52);
     StringField f7 = new StringField(56);
     StringField f8 = new StringField(10);
     StringField f9 = new StringField(1);
     msg.Header.GetField(f1);
     msg.Header.GetField(f2);
     msg.Header.GetField(f3);
     msg.Header.GetField(f4);
     msg.Header.GetField(f5);
     msg.Header.GetField(f6);
     msg.Header.GetField(f7);
     msg.GetField(f9);
     msg.Trailer.GetField(f8);
     Assert.That(f1.Obj, Is.EqualTo("FIX.4.2"));
     Assert.That(f2.Obj, Is.EqualTo("55"));
     Assert.That(f3.Obj, Is.EqualTo("0"));
     Assert.That(f4.Obj, Is.EqualTo("3"));
     Assert.That(f5.Obj, Is.EqualTo("TW"));
     Assert.That(f6.Obj, Is.EqualTo("20000426-12:05:06"));
     Assert.That(f7.Obj, Is.EqualTo("ISLD"));
     Assert.That(f8.Obj, Is.EqualTo("123"));
     Assert.That(f9.Obj, Is.EqualTo("acct123"));
     string raw = msg.ToString();
     Assert.That(raw, Is.EqualTo(str1));
 }
Пример #41
0
        protected bool SendRaw(Message message, int seqNum)
        {
            
            lock (sync_)
            {
                string msgType = message.Header.GetField(Fields.Tags.MsgType);
                if (msgType == Fields.MsgType.HEARTBEAT)
                {
                    _log.Info("Sending heartbeat inside sendraw");
                }

                InitializeHeader(message, seqNum);

                if (Message.IsAdminMsgType(msgType))
                {
                    this.Application.ToAdmin(message, this.SessionID);

                    if (MsgType.LOGON.Equals(msgType) && !state_.ReceivedReset)
                    {
                        Fields.ResetSeqNumFlag resetSeqNumFlag = new QuickFix.Fields.ResetSeqNumFlag(false);
                        if (message.IsSetField(resetSeqNumFlag))
                            message.GetField(resetSeqNumFlag);
                        if (resetSeqNumFlag.getValue())
                        {
                            state_.Reset("ResetSeqNumFlag");
                            message.Header.SetField(new Fields.MsgSeqNum(state_.GetNextSenderMsgSeqNum()));
                        }
                        state_.SentReset = resetSeqNumFlag.Obj;
                    }
                }
                else
                {
                    try
                    {
                        this.Application.ToApp(message, this.SessionID);
                    }
                    catch (DoNotSend)
                    {
                        return false;
                    }
                }

                string messageString = message.ToString();
                if (0 == seqNum)
                    Persist(message, messageString);
                
                if (msgType == Fields.MsgType.HEARTBEAT)
                {
                    _log.Info("about to send that heartbeat for real");
                }

                return Send(messageString, msgType == Fields.MsgType.HEARTBEAT);
            }
        }
Пример #42
0
 /**
  * Callback chamado logo antes do envio de mensagem FIX de aplicação.
  *
  */
 public void toApp(QuickFix.Message message, SessionID sessionId)
 {
     logger.Debug("SEND(APP) --> " + message.ToString());
 }
Пример #43
0
 public void ToApp(QuickFix.Message message, SessionID sessionId)
 {
     DoLog(string.Format("@toApp <{0}>:{1}", sessionId.ToString(), message.ToString()), Fwk.Main.Common.Util.Constants.MessageType.Information);
 }
Пример #44
0
        protected void NextResendRequest(Message resendReq)
        {
            try
            {
                int msgSeqNum = 0;
                if (!(this.IgnorePossDupResendRequests && resendReq.Header.IsSetField(Tags.PossDupFlag)))
                {
                    int begSeqNo = resendReq.GetInt(Fields.Tags.BeginSeqNo);
                    int endSeqNo = resendReq.GetInt(Fields.Tags.EndSeqNo);
                    this.Log.OnEvent("Got resend request from " + begSeqNo + " to " + endSeqNo);

                    if ((endSeqNo == 999999) || (endSeqNo == 0))
                    {
                        endSeqNo = state_.GetNextSenderMsgSeqNum() - 1;
                    }

                    if (!PersistMessages)
                    {
                        endSeqNo++;
                        int next = state_.GetNextSenderMsgSeqNum();
                        if (endSeqNo > next)
                            endSeqNo = next;
                        GenerateSequenceReset(resendReq, begSeqNo, endSeqNo);
                        return;
                    }

                    List<string> messages = new List<string>();
                    state_.Get(begSeqNo, endSeqNo, messages);
                    int current = begSeqNo;
                    int begin = 0;
                    foreach (string msgStr in messages)
                    {
                        Message msg = new Message(msgStr);
                        msgSeqNum = msg.Header.GetInt(Tags.MsgSeqNum);

                        if ((current != msgSeqNum) && begin == 0)
                        {
                            begin = current;
                        }

                        if (IsAdminMessage(msg))
                        {
                            if (begin == 0)
                            {
                                begin = msgSeqNum;
                            }
                        }
                        else
                        {

                            initializeResendFields(msg);
                            if (begin != 0)
                            {
                                GenerateSequenceReset(resendReq, begin, msgSeqNum);
                            }
                            Send(msg.ToString());
                            begin = 0;
                        }
                        current = msgSeqNum + 1;
                    }

                    if (begin != 0)
                    {
                        GenerateSequenceReset(resendReq, begin, msgSeqNum + 1);
                    }

                    if (endSeqNo > msgSeqNum)
                    {
                        endSeqNo = endSeqNo + 1;
                        int next = state_.GetNextSenderMsgSeqNum();
                        if (endSeqNo > next)
                        {
                            endSeqNo = next;
                        }
                        GenerateSequenceReset(resendReq, begSeqNo, endSeqNo);
                    }
                }
                msgSeqNum = resendReq.Header.GetInt(Tags.MsgSeqNum);
                if (!IsTargetTooHigh(msgSeqNum) && !IsTargetTooLow(msgSeqNum))
                {
                    state_.IncrNextTargetMsgSeqNum();
                }

            }
            catch (System.Exception e)
            {
                this.Log.OnEvent("ERROR during resend request " + e.Message);
            }
        }
 /// <summary>
 /// every inbound admin level message will pass through this method, 
 /// such as heartbeats, logons, and logouts. 
 /// </summary>
 /// <param name="message"></param>
 /// <param name="sessionId"></param>
 public void FromAdmin(Message message, SessionID sessionId)
 {
     Log(message.ToString());
 }
Пример #46
0
 public void FromAdmin(QuickFix.Message message, QuickFix.SessionID session)
 {
     try
     {
         logger.Debug("RCV(Admin) <-- type[" + message.GetType().ToString() + "] msg[" + message.ToString() + "]");
     }
     catch (Exception ex)
     {
         logger.Error("FromAdmin(): " + ex.Message, ex);
     }
 }
Пример #47
0
 public void ToAdmin(QuickFix.Message msg, SessionID sessionID)
 {
     Console.WriteLine("ToAdmin - " + msg.ToString() + "@" + sessionID.ToString());
 }
Пример #48
0
 public virtual void ToApp(QuickFix.Message message, QuickFix.SessionID session)
 {
     try
     {
         logger.Debug("SND(App) --> type[" + message.GetType().ToString() + "] msg[" + message.ToString() + "]");
         //this.Crack(message, session);
     }
     catch (Exception ex)
     {
         logger.Error("ToApp(): " + ex.Message, ex);
     }
 }
Пример #49
0
 internal static void Out(Message msg)
 {
     System.Diagnostics.Debug.WriteLine(msg.ToString().Replace((char)0x01, (char)0x20));
 }