当前位置: 首页>>代码示例>>C#>>正文


C# Event.GetMessages方法代码示例

本文整理汇总了C#中Event.GetMessages方法的典型用法代码示例。如果您正苦于以下问题:C# Event.GetMessages方法的具体用法?C# Event.GetMessages怎么用?C# Event.GetMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Event的用法示例。


在下文中一共展示了Event.GetMessages方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: processEvent

    private void processEvent(Event eventObject, Session session)
    {
      if (GUI_INVOKE_CONTROL != null && GUI_INVOKE_CONTROL.IsDisposed == false && GUI_INVOKE_CONTROL.InvokeRequired && GUI_INVOKE_CONTROL.IsHandleCreated)
      {
        GUI_INVOKE_CONTROL.BeginInvoke(m_processEventHandler, eventObject, session);
        return;
      }

      foreach (Message msg in eventObject.GetMessages())
      {
        if (eventObject.Type == Event.EventType.SUBSCRIPTION_DATA)
        {
          if (msg.MessageType.Equals("PageUpdate"))
          {
            processPageElement(msg.AsElement, msg.CorrelationID.Object.ToString());
          }
          else if (msg.MessageType.Equals("RowUpdate"))
          {
            processRowElement(msg.AsElement, msg.CorrelationID.Object.ToString());
          }
          else if (msg.MessageType.Equals("MarketDataEvents"))
          {
            LiveSecurity sec = LiveSecurityList.Instance.GetSecurity(msg.TopicName, true);
            sec.BeginUpdates();

            foreach (string field in sec.Fields)
            {
              if (msg.HasElement(field) == false)
                continue;

              Element elem = msg.GetElement(field);

              if (elem.IsNull)
                continue;

              if (elem.NumValues > 1)
              {
                Logger.Error(string.Format("Number of elements returned from Bbg for '{0}' for field '{1}' is {2}", msg.TopicName, field, elem.NumValues.ToString()), typeof(Core));
                continue;
              }

              switch (elem.Datatype)
              {
                case Schema.Datatype.BOOL:
                  bool b = msg.GetElementAsBool(elem.Name);
                  sec.SetValue<bool>(elem.Name.ToString(), b);
                  break;
                case Schema.Datatype.DATETIME:
                  DateTime d = msg.GetElementAsDatetime(elem.Name).ToSystemDateTime();
                  sec.SetValue<DateTime>(elem.Name.ToString(), d);
                  break;
                case Schema.Datatype.INT32:
                  int i = msg.GetElementAsInt32(elem.Name);
                  sec.SetValue<int>(elem.Name.ToString(), i);
                  break;
                case Schema.Datatype.STRING:
                  string s = msg.GetElementAsString(elem.Name);
                  sec.SetValue<string>(elem.Name.ToString(), s);
                  break;
                case Schema.Datatype.FLOAT64:
                  {
                    double dd = Convert.ToDouble(msg.GetElementAsFloat64(elem.Name));
                    sec.SetValue<double>(elem.Name.ToString(), dd);
                  }
                  break;
                case Schema.Datatype.FLOAT32:
                  {
                    double dd = Convert.ToDouble(msg.GetElementAsFloat32(elem.Name));
                    sec.SetValue<double>(elem.Name.ToString(), dd);
                  }
                  break;
                default:
                  Console.WriteLine("Need to implement " + elem.Datatype.ToString());
                  break;
              }
            }
            sec.EndUpdates();
          }
          else if (msg.MessageType.Equals("MarketBarUpdate") || msg.MessageType.Equals("MarketBarStart"))
          {
            var corrId = msg.GetCorrelationID(0).Value;

            var objToUpdate = LiveSecurityBarData.GetCached((int)corrId);

            if (objToUpdate == null)
            {
              Logger.Error(string.Format("Could not find an object to update for corrID={0}", corrId), typeof (Core));
              continue;
            }

            if (!msg.HasElement("DATE_TIME"))
            {
              Logger.Error(string.Format("No time element! {0}", msg), typeof (Core));
              continue;
            }

            var time = msg.GetElementAsDatetime("DATE_TIME").ToSystemDateTime();

            foreach (var field in msg.Elements)
            {
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:Core.cs

示例2: ProcessEvent

        private void ProcessEvent(Event evt, List<String> fields)
        {
            Invoke(new Action(() => richTextBox1.AppendText("ProcessEvent(Event, List<String>)\n")));
            const bool excludeNullElements = true;
            foreach (Bloomberglp.Blpapi.Message message in evt.GetMessages())
            {
                string security = message.TopicName;
                Invoke(new Action(() =>
                          richTextBox1.AppendText
                          (string.Format("GOT SECURITY: {0}",
                            security))));
                foreach (var field in fields)
                {
                    //This ignores the extraneous fields in the response
                    if (message.HasElement(field, excludeNullElements)) //be careful, excludeNullElements is false by default
                    {
                        Element elmField = message[field];

                        string retval = "";
                        if (security.Contains("Curncy"))
                        {
                            Invoke(new Action(() =>
                                richTextBox1.AppendText
                                (string.Format("GOT CURNCY FIELD {0}\n",
                                field))));

                            if (field.Equals("LAST_PRICE"))
                            {
                                Invoke(new Action(() =>
                                    richTextBox1.AppendText
                                    ("\nGOT CURNCY LAST_PRICE\n")));
                                retval =
                                    tc.updateCurrencyRate
                                    (security.Substring(0, 3), elmField.GetValueAsFloat64());
                            }
                        }
                        else if (field.Equals("BEST_ASK1"))
                        {
                            retval = tc.updateAsk(security, elmField.GetValueAsFloat64());
                        }
                        else if (field.Equals("BEST_BID1"))
                        {
                            retval = tc.updateBid(security, elmField.GetValueAsFloat64());
                        }
                        else if (field.Equals("BEST_ASK1_SZ"))
                        {
                            retval = tc.updateAskSize(security, elmField.GetValueAsFloat64());
                        }
                        else if (field.Equals("BEST_BID1_SZ"))
                        {
                            retval = tc.updateBidSize(security, elmField.GetValueAsFloat64());
                        }
                        Invoke(new Action(() =>
                            richTextBox1.AppendText
                            (string.Format("{0}",
                            retval))));

                        if (security.Contains("Curncy"))
                        {
                            continue;
                        }

                        Transaction transaction = tc.computeTransaction(security);
                        if (sendTransactions)
                        {
                            Invoke(new Action(() =>
                              richTextBox1.AppendText("\nsendTransactions=true\n")));
                            if (transaction.isFeasible())
                            {
                                Invoke(new Action(() =>
                                    richTextBox1.AppendText("\nFEASIBLE TRANSACTION!\n")));
                                sendTransaction(transaction);
                            }
                            else
                            {
                                Invoke(new Action(() =>
                                    richTextBox1.AppendText("\nno feasible transaction\n")));
                            }
                        }
                        else
                        {
                            Invoke(new Action(() =>
                              richTextBox1.AppendText("\nsendTransactions=false\n")));
                            Invoke(new Action(() =>
                              richTextBox1.AppendText
                              (string.Format
                                ("-\n{0:HH:mm:ss}\nTRANSACTION\n{1}\nELEMENT FIELD (FROM API):\n{2}\n-\n",
                                DateTime.Now,
                                transaction.description,
                                elmField.ToString().Trim()))));
                        }
                    }
                }
            }
            Invoke(new Action(() => richTextBox1.AppendText("\n")));
        }
开发者ID:jjarvitalo,项目名称:reiska,代码行数:96,代码来源:Form1.cs

示例3: dumpEvent

 private void dumpEvent(Event event_)
 {
   Logger.Debug(string.Format("Bbg event: {0}", event_.Type.ToString()), typeof(Core));
   foreach (Message msg in event_.GetMessages())
   {
     Logger.Debug(string.Format("Event msg : {0}", msg.MessageType.ToString()), typeof(Core));
     //msg.Print(Console.Out);
   }
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:9,代码来源:Core.cs

示例4: HandleResponseEvent

        public virtual void HandleResponseEvent(Event objEvent)
        {
            try
            {
                // check for response vs partial response
                Event.EventType t = objEvent.Type;
                // if a partial response the message goes at the end of the queue

                foreach (Message message in objEvent.GetMessages())
                {
                    Element referenceDataResponse = message.AsElement;
                    if (referenceDataResponse.HasElement("responseError"))
                    {
                        Element error = referenceDataResponse.GetElement("responseError");
                        response.ResponseError = new ErrorInfo()
                        {
                            Message = error.GetElementValueByDataType("source"),
                            Category = error.GetElementValueByDataType("category"),
                            Code = error.GetElementValueByDataType("code"),
                            Source = error.GetElementValueByDataType("source"),
                            Subcategory = error.GetElementValueByDataType("subcategory")
                        };
                    }

                    Element securityDataArray = referenceDataResponse.GetElement("securityData");
                    int numItems = securityDataArray.NumValues;

                    for (int i = 0; i < numItems; ++i)
                    {
                        string secsearch = "";
                        Element securityData = securityDataArray.GetValueAsElement(i);
                        String security = securityData.GetElementAsString("security");
                        int sequenceNumber = securityData.GetElementAsInt32("sequenceNumber");

                        // Defined regex to find identifiers in indentifier field coming back form bb
                        RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.RightToLeft;
                        // ticker gold match "^\w+(\s)(\w+)|\w+\s(.)-(\w+)$" matches  "xxxxxxx govt", "xxxx M-Mkt"
                        Regex goldtickerRegex = new Regex(@"^(?<id>\w+)\s\w+$", options);
                        Regex identifierticker = new Regex(@"^/\w+/(?<id>\w+)$", options); // identifier ticker
                        MatchCollection col = null;

                        // try to find the identifier from a goldkey type then try to find the identifier from an identifier type
                        col = goldtickerRegex.Matches(security);
                        if(col.Count == 0)
                            col = identifierticker.Matches(security);
                        // pull out just the identifier value
                        if (col.Count > 0)
                            secsearch = col[0].Groups["id"].Value;

                        // search the security list that was submitted in the request for the matching identifier and get the crid
                        var firstOrDefault = response.OrigRequest.SecurityList.FirstOrDefault(sec => sec.Identifier == secsearch);
                        string crdid = "";
                        // set the crid for the response value
                        if (firstOrDefault != null)
                               crdid = firstOrDefault.CrdId;
                        // create a security object with the information coming back
                        Security newSecurity = new Security
                        {
                            Identifier = security,
                            CrdId = crdid,
                            SequenceNumber = sequenceNumber
                        };

                        // start appending objects to the security as appropriate
                        if (securityData.HasElement("securityError"))
                        {
                            // log error
                            var securityError = securityData.GetElement("securityError");

                            newSecurity.SecurityError = new ErrorInfo()
                            {
                                Message = securityError.GetElementValueByDataType("message"),
                                Category = securityError.GetElementValueByDataType("category"),
                                Code = securityError.GetElementValueByDataType("code"),
                                Source = securityError.GetElementValueByDataType("source"),
                                Subcategory = securityError.GetElementValueByDataType("subcategory")
                            };
                        }
                        if (securityData.HasElement("fieldExceptions"))
                        {
                            var fieldExceptionArray = securityData.GetElement("fieldExceptions");
                            var count =  fieldExceptionArray.NumValues;
                            for (int j = 0; j < count; j++)
                            {
                                var fieldError = fieldExceptionArray.GetValueAsElement(j);
                                var errorinfo = fieldError.GetElement("errorInfo");

                                // if this particular securitydata response element doesn't have it's list initialized
                                if (newSecurity.FieldExceptionList == null)
                                    newSecurity.FieldExceptionList =
                                        new List<FieldException>();

                                newSecurity.FieldExceptionList.Add(
                                    new FieldException
                                    {
                                        FieldId = fieldError.GetElementValueByDataType("fieldId"),
                                        ErrorInfo = new ErrorInfo()
                                        {
                                            Message = errorinfo.GetElementValueByDataType("message"),
                                            Category = errorinfo.GetElementValueByDataType("category"),
//.........这里部分代码省略.........
开发者ID:Rab815,项目名称:BBWebApi,代码行数:101,代码来源:RequestProcessor.cs

示例5: HandleOtherEvent

 public virtual void HandleOtherEvent(Event objEvent)
 {
     //_Logging.Debug("EventType=" + eventObj.Type);
     foreach (Message message in objEvent.GetMessages())
     {
         //_Logging.Debug("correlationID=" + message.CorrelationID);
         //_Logging.Debug("messageType=" + message.MessageType);
         //message.Print(Console.Out);
         if (Event.EventType.SESSION_STATUS == objEvent.Type && message.MessageType.Equals("SessionTerminated"))
         {
             //_Logging.Error("Terminating: " + message.MessageType);
         }
     }
 }
开发者ID:Rab815,项目名称:BBWebApi,代码行数:14,代码来源:RequestProcessor.cs

示例6: handleResponseEvent

        /// <summary>
        /// Filtre la reponse pour les stocker dans des objets de types TITLE
        /// </summary>
        /// <param name="eventObj"></param>
        private static void handleResponseEvent(Event eventObj)
        {
            string marketSector;
            foreach (Message message in eventObj.GetMessages())
            {
                Element ReferenceDataResponse = message.AsElement;
                if (ReferenceDataResponse.HasElement("responseError"))
                {
                    //throw new Exception("responseError " + ReferenceDataResponse.ToString());
                    Console.WriteLine("Mode non connecté");
                    Remplissage_Non_connection();
                }

                Element securityDataArray = ReferenceDataResponse.GetElement("securityData");
                //Console.WriteLine(message.ToString());

                int numItems = securityDataArray.NumValues;
                for (int i = 0; i < numItems; ++i)
                {
                    Element securityData = securityDataArray.GetValueAsElement(i);
                    string security = securityData.GetElementAsString("security");
                    if(!isGetCurve)
                        security = security.Replace("/isin/", "");

                    //int sequenceNumber = securityData.GetElementAsInt32("sequenceNumber");
                    if (securityData.HasElement("securityError"))
                    {
                        Element securityError = securityData.GetElement("securityError");
                        //throw new Exception("securityError : "+security+" invalide");
                    }

                    else
                    {
                        Element fieldData = securityData.GetElement("fieldData");

                        if (isGetCurve)
                        {
                            curve.ParseEquity(fieldData);
                        }

                        else
                        {

                            if (isGetType)
                                marketSector = fieldData.GetElementAsString("MARKET_SECTOR_DES");
                            else
                                marketSector = d_title[security].Item3;

                            switch (marketSector)
                            {
                                case "Equity":
                                    if (isGetType)
                                        RequestEquity(security);
                                    else
                                        ParseEquity(fieldData, security);
                                    break;

                                case "Corp":
                                    if (isGetType)
                                        RequestCorp(security);
                                    else
                                        ParseCorp(fieldData, security);
                                    break;

                                case "Govt":
                                    if (isGetType)
                                        RequestGovt(security);
                                    else
                                        ParseGovt(fieldData, security);
                                    break;

                                case "Index":
                                    if (isGetType)
                                        RequestEquity(security);
                                    else
                                        ParseEquity(fieldData, security);
                                    break;

                                case "Curncy":
                                    if (isGetType)
                                        RequestEquity(security);
                                    else
                                        ParseEquity(fieldData, security);
                                    break;

                                case "Mmkt":
                                    if (isGetType)
                                        RequestEquity(security);
                                    else
                                        ParseEquity(fieldData, security);
                                    break;

                                case "Mtge":
                                    if (isGetType)
                                        RequestEquity(security);
                                    else
//.........这里部分代码省略.........
开发者ID:TigerSCR,项目名称:TigerAppWPF,代码行数:101,代码来源:Connector.cs

示例7: ProcessEvent

        private void ProcessEvent(Event evt, List<String> fields)
        {
            string allVals = tc.getAllValues();
            Invoke(new Action(() =>
                richTextBox1.AppendText
                (string.Format("{0}",
                allVals))));

            Invoke(new Action(() => richTextBox1.AppendText("\n\nGOT NEW MESSAGE --> ProcessEvent(Event, List<String>)\n")));

            const bool excludeNullElements = false;

            foreach (Bloomberglp.Blpapi.Message message in evt.GetMessages())
            {
                /*
                Invoke(new Action(() =>
                    richTextBox1.AppendText
                    (string.Format("MESSAGE: {0}",
                    message.ToString()))));
                    */

                string security = message.TopicName;

                Invoke(new Action(() =>
                          richTextBox1.AppendText
                          (string.Format("GOT SECURITY: {0}",
                            security))));

                string elmFields = "";
                foreach (var field in fields)
                {
                    //This ignores the extraneous fields in the response
                    if (message.HasElement(field, excludeNullElements)) //be careful, excludeNullElements is false by default
                    {
                        Element elmField = message[field];
                        elmFields += security + ": " + elmField.ToString().Trim() + "; ";
                        string retval = "";
                        if (security.Contains("Curncy"))
                        {
                            Invoke(new Action(() =>
                                richTextBox1.AppendText
                                (string.Format("\nGOT CURNCY FIELD {0}\n",
                                field))));

                            if (field.Equals("LAST_PRICE"))
                            {
                                Invoke(new Action(() =>
                                    richTextBox1.AppendText
                                    ("\nGOT CURNCY LAST_PRICE\n")));
                                retval =
                                    tc.updateCurrencyRate
                                    (security.Substring(0, 3), elmField.GetValueAsFloat64());
                            }
                        }
                        else if (field.Equals("BEST_ASK"))
                        {
                            retval = tc.updateAsk(security, elmField.GetValueAsFloat64());
                            if (retval.Equals("NO CURRENCY"))
                            {
                                this.pendingAsk[security] = elmField.GetValueAsFloat64();
                            }
                        }
                        else if (field.Equals("BEST_BID"))
                        {
                            retval = tc.updateBid(security, elmField.GetValueAsFloat64());
                            if (retval.Equals("NO CURRENCY"))
                            {
                                this.pendingBid[security] = elmField.GetValueAsFloat64();
                            }
                        }
                        else if (field.Equals("BEST_ASK1_SZ"))
                        {
                            retval = tc.updateAskSize(security, elmField.GetValueAsFloat64());
                        }
                        else if (field.Equals("BEST_BID1_SZ"))
                        {
                            retval = tc.updateBidSize(security, elmField.GetValueAsFloat64());
                        }
                        if (!retval.Equals(""))
                        {
                            Invoke(new Action(() =>
                                richTextBox1.AppendText
                                (string.Format("\n -> EXECUTED ACTION: {0}",
                                retval))));
                        }

                        if (security.Contains("Curncy"))
                        {
                            continue;
                        }
                    }
                }

                Invoke(new Action(() =>
                    richTextBox1.AppendText
                    (string.Format
                    ("-\n{0:HH:mm:ss}\nELEMENT FIELDS (FROM API):\n{1}\n-\n",
                     DateTime.Now,
                     elmFields.Trim()))));

//.........这里部分代码省略.........
开发者ID:platypu5,项目名称:reiska,代码行数:101,代码来源:Form1.cs


注:本文中的Event.GetMessages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。