Esempio n. 1
0
        /// <summary>
        /// Called whenever Excel requests a new RTD topic from the RealTimeData server.
        /// </summary>
        /// <param name="TopicID"></param>
        /// <param name="Strings"></param>
        /// <param name="GetNewValues"></param>
        /// <returns></returns>
        public object ConnectData(int TopicID, ref Array Strings, ref bool GetNewValues)
        {
            try
            {
                string queuename       = "defaultExcelAddInQueue";
                string destinationName = "ExcelAddIn-" + queuename;
                if (Strings.Length > 0)
                {
                    queuename = (string)Strings.GetValue(0);
                }
                // Error message if the queue does not exist
                QueueQueryResult result = (QueueQueryResult)_session.QueueQuery(queuename).Result;
                if (result.GetQueue() == null)
                {
                    System.Windows.Forms.MessageBox.Show("Error: \n queue " + queuename + " does not exist");
                    return("error");
                }

                QpidListener listener;
                _topicMessages.Add(TopicID, null);
                _topicQueueName.Add(TopicID, queuename);
                if (_queueListener.ContainsKey(queuename))
                {
                    listener = _queueListener[queuename];
                    listener.addTopic(TopicID);
                }
                else
                {
                    listener = new QpidListener(this);
                    listener.addTopic(TopicID);
                    _queueListener.Add(queuename, listener);
                    _session.AttachMessageListener(listener, destinationName);
                    _session.MessageSubscribe(queuename, destinationName, MessageAcceptMode.EXPLICIT,
                                              MessageAcquireMode.PRE_ACQUIRED, null, 0, null);
                    // issue credits
                    _session.MessageSetFlowMode(destinationName, MessageFlowMode.WINDOW);
                    _session.MessageFlow(destinationName, MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
                    _session.MessageFlow(destinationName, MessageCreditUnit.MESSAGE, 1000);
                    _session.Sync();
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Error: \n" + e.StackTrace);
                return("error");
            }
            return("waiting");
        }
Esempio n. 2
0
 /// <summary>
 /// Called whenever Excel requests a new RTD topic from the RealTimeData server.
 /// </summary>
 /// <param name="TopicID"></param>
 /// <param name="Strings"></param>
 /// <param name="GetNewValues"></param>
 /// <returns></returns>
 public object ConnectData(int TopicID, ref Array Strings, ref bool GetNewValues)
 {
     try
     {
         string queuename = "defaultExcelAddInQueue";
         string destinationName = "ExcelAddIn-" + queuename;
         if( Strings.Length > 0 )
         {
             queuename = (string) Strings.GetValue(0);
         }
         // Error message if the queue does not exist
         QueueQueryResult result = (QueueQueryResult)_session.QueueQuery(queuename).Result;
         if( result.GetQueue() == null )
         {
             System.Windows.Forms.MessageBox.Show("Error: \n queue " + queuename + " does not exist");
             return "error";  
         }
   
         QpidListener listener;
         _topicMessages.Add(TopicID, null);
         _topicQueueName.Add(TopicID, queuename);
         if (_queueListener.ContainsKey(queuename))
         {
             listener = _queueListener[queuename];
             listener.addTopic(TopicID);
         }
         else
         {
             listener = new QpidListener(this);
             listener.addTopic(TopicID);
             _queueListener.Add(queuename, listener);
             _session.AttachMessageListener(listener, destinationName);
             _session.MessageSubscribe(queuename, destinationName, MessageAcceptMode.EXPLICIT,
                                       MessageAcquireMode.PRE_ACQUIRED, null, 0, null);
             // issue credits     
             _session.MessageSetFlowMode(destinationName, MessageFlowMode.WINDOW);
             _session.MessageFlow(destinationName, MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
             _session.MessageFlow(destinationName, MessageCreditUnit.MESSAGE, 1000);
             _session.Sync();
         }                
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show("Error: \n" + e.StackTrace);
         return "error";
     }
     return "waiting";
 }