示例#1
0
        protected void OnlineMessage(IMessage message)
        {
            // We need to build a list of updates, this can then be used by the
            // RTD server interface to only send back topics that have changed.
            DateTime now = DateTime.Now;

            ITextMessage textMessage = message as ITextMessage;
            IDictionary  record      = ExtractPositionRecord(textMessage.Text);

            record.Add("receiveTime", now.ToString());

            // For each record build the cacheKey - the key would be configured
            string key = BuildPositionKey(record);

            // store each value
            string messageType = (string)record["messageType"];

            if ("BatchPosition".Equals(messageType))
            {
                PositionCache.addBatchCacheItem(key, record);
                lastUpdateTime = now;
                RegisterChange(key, record);
            }
            else if ("OnlinePosition".Equals(messageType))
            {
                PositionCache.addOnlineCacheItem(key, record);
                lastUpdateTime = now;
                RegisterChange(key, record);
            }
            else if ("HeartBeat".Equals(messageType))
            {
                heartBeatTime = DateTime.Now;
                RegisterGenericChange("heartBeat", heartBeatTime.ToString());
            }
            else if ("Command".Equals(messageType) && record["purgeRecordType"] != null)
            {
                PositionCache.clearCaches();
                lastUpdateTime = now;
                return;
            }
            else
            {
                return;
            }

            if (m_xlRTDUpdate != null)
            {
                m_xlRTDUpdate.UpdateNotify();
            }
        }
示例#2
0
        public String lookupValue(String key, String fieldName)
        {
            // provide away to findout the brokerUrl/batchCount/onlineCount
            if (fieldName == "brokerUrl")
            {
                return(brokerUrl);
            }
            else if (fieldName == "securityCount")
            {
                IDictionary book       = new Hashtable();
                string      startsWith = key.Split('-')[0];
                PositionCache.findAllOnlineFieldValues(startsWith, new String[] { "securityId", "level1TagName" }, book);
                PositionCache.findAllBatchFieldValues(startsWith, new String[] { "securityId", "level1TagName" }, book);

                return("" + book.Count);
            }

            else if (fieldName == "batchCount")
            {
                return("" + PositionCache.countBatchCacheItems(key.Split('-')[0]));
            }
            else if (fieldName == "onlineCount")
            {
                return("" + PositionCache.countOnlineCacheItems(key.Split('-')[0]));
            }
            else if (fieldName == "lastUpdateTime")
            {
                return(lastUpdateTime.ToString());
            }
            else if (fieldName == "heartBeat")
            {
                return((heartBeatTime == null) ? "" : heartBeatTime.ToString());
            }
            // We don't know what cache this item is in, check the online first, then batch
            String value = PositionCache.lookupOnlineCacheValue(key, fieldName);

            if (value == null)
            {
                value = PositionCache.lookupBatchCacheValue(key, fieldName);
            }

            if (value != null)
            {
                return(value);
            }

            return("N/A");
        }
示例#3
0
        /// <summary>
        /// Get all the securities for a book/account.
        /// </summary>
        /// <param name="startsWith"></param>
        /// <param name="updateFlag">used to force a refresh on an event</param>
        /// <returns></returns>
        public Object AIM_AllSecurities(String startsWith, Object updateFlag)
        {
            // Build a unique list of all securities
            IDictionary book = new Hashtable();

            PositionCache.findAllOnlineFieldValues(startsWith, new String[] { "securityId", "level1TagName" }, book);
            PositionCache.findAllBatchFieldValues(startsWith, new String[] { "securityId", "level1TagName" }, book);

            Object[,] cellValues = new Object[book.Count, 2];
            int i = 0;

            foreach (DictionaryEntry entry in book)
            {
                String[] columnValues = (String[])entry.Value;
                cellValues[i, 0] = columnValues[0];
                cellValues[i, 1] = columnValues[1];
                i++;
            }
            return(cellValues);
        }
示例#4
0
        protected void StartupMessageLoad(IMessage message)
        {
            // We need to build a list of updates, this can then be used by the
            // RTD server interface to only send back topics that have changed.
            DateTime now = DateTime.Now;

            lastUpdateTime = now;
            if (startUpTime == null)
            {
                startUpTime = now;
            }

            startupCount++;

            ITextMessage textMessage = message as ITextMessage;
            IDictionary  record      = ExtractPositionRecord(textMessage.Text);

            record.Add("receiveTime", now.ToString());

            // For each record build the cacheKey - the key would be configured
            string key = BuildPositionKey(record);

            // store each value
            string messageType = (string)record["messageType"];

            if ("BatchPosition".Equals(messageType))
            {
                PositionCache.addBatchCacheItem(key, record);
                RegisterChange(key, record);
            }
            else if ("OnlinePosition".Equals(messageType))
            {
                PositionCache.addOnlineCacheItem(key, record);
                RegisterChange(key, record);
            }
            else if ("Command".Equals(messageType))
            {
                if (record.Contains("purgeRecordType") && record["purgeRecordType"] != null)
                {
                    PositionCache.clearCaches();
                    return;
                }
                else if (record.Contains("endOfMessages") && record["endOfMessages"] != null)
                {
                    RegisterGenericChange("brokerUrl", brokerUrl);
                    // Ensure we update on the last message
                    if (m_xlRTDUpdate != null)
                    {
                        m_xlRTDUpdate.UpdateNotify();
                    }

                    // The queue is complete, disconnect.
                    if (batchConsumer != null)
                    {
                        //batchConsumer.Close(); // free up some resources
                    }
                    return;
                }
                else
                {
                    return;     // unknown record type
                }
            }
            else
            {
                return;     // unknown command
            }

            //We update at the end too
            if (m_xlRTDUpdate != null)
            {
                m_xlRTDUpdate.UpdateNotify();
            }
        }