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. var now = DateTime.Now; var textMessage = message as ITextMessage; if (textMessage == null) { return; } var record = ExtractPositionRecord(textMessage.Text); record.Add("receiveTime", now.ToString()); // For each record build the cacheKey - the key would be configured var key = BuildPositionKey(record); // store each value var 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; // Force a recalc of the spreadsheet RegisterGenericChange("heartBeat", DateTime.Now.ToString()); } else { return; } if (m_xlRTDUpdate != null) { m_xlRTDUpdate.UpdateNotify(); } }
/// <summary> /// The timer was elapsed. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The event arguments.</param> void TimerElapsed(object sender, System.Timers.ElapsedEventArgs e) { // Stop the timer and notify Excel there is new data. if (m_callback != null) { m_timer.Stop(); m_callback.UpdateNotify(); } }
// Handler for the timer events - we use this to update the data. private void TimerEventHandler(object sender, ElapsedEventArgs e) { // Update the data. Random random = new Random(); foreach (StockData dataItem in dataCollection) { dataItem.Update(random); } // Tell Excel we have updated data available. xlUpdateEvent.UpdateNotify(); }
public void UpdateExcel(IRTD_DataProvider IRTD_Data) { lock (fSyncLock) { if (fIsWorking == false) { return; } if (fComm2TopicId != null) { foreach (string id in IRTD_Data.GetChangedComms()) { foreach (CMoneyTopic topic in fComm2TopicId[id]) { fUpdateList[topic.TopicID] = IRTD_Data.GetRTCommProperty(id, topic.PropertyName); } } } fTargetUpdateEvent.UpdateNotify(); } }
public int ServerStart(XL.IRTDUpdateEvent CallbackObject) { _timer = new Timer(delegate { CallbackObject.UpdateNotify(); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(3)); return(1); }