Пример #1
0
        /// <summary>
        /// Called when loaded by Excel.  Connect to the NMS Broker.
        /// </summary>
        /// <param name="callbackObject"></param>
        /// <returns></returns>
        public int ServerStart(Excel.IRTDUpdateEvent callbackObject)
        {
            try
            {
                m_xlRTDUpdate = callbackObject;

                LoadConfiguration();
                log.Info("Starting AIM RTD server");
                if (brokerUrl == null)
                {
                    //brokerUrl = "tcp://localhost:61616";
                    brokerUrl = "tcp://amqpositions:61616";
                }

                client = new NmsClient(callbackObject,
                                       new[]
                {
                    "account", "securityId", "level1TagName", "normOpenPosition"
                }, brokerUrl);
                // The level2-4 tags do not add anything to uniqueness
                // , "level2TagName", "level3TagName", "level4TagName"
                //Thread m_WorkerThread = new Thread(client.NMSReaderLoop);
                //m_WorkerThread.Name = "NMSListener";
                //m_WorkerThread.Start();

                return(1);
            }
            catch (Exception e)
            {
                log.Error("Caught exception during server start", e);
            }
            return(-1);
        }
Пример #2
0
        public NmsClient(Excel.IRTDUpdateEvent xlRTDUpdate, string[] keyBaseFields, string brokerUrl)
        {
            var configurationFileName = System.Reflection.Assembly.GetExecutingAssembly().Location + ".config";

            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(configurationFileName));
            log = log4net.LogManager.GetLogger("SubscriberApp.Logging");

            baseFields     = keyBaseFields;
            m_xlRTDUpdate  = xlRTDUpdate;
            this.brokerUrl = brokerUrl;
            heartBeatTime  = DateTime.Now;

            //log.Info("About to connect to ActiveMQ");
            // Each instance of the Excel RTD creates a new COM instance, since we are using static
            // fields to store the data, we do not need to re-load the data for each instance
            // ensure that we only initialize once
            lock (lockObject)
            {
                positionCache.ClearCaches();
                if (!initialized)
                {
                    InitializeConnection();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Called when loaded by Excel.  Connect to the NMS Broker.
        /// </summary>
        /// <param name="CallbackObject"></param>
        /// <returns></returns>
        public int ServerStart(Excel.IRTDUpdateEvent CallbackObject)
        {
            m_xlRTDUpdate = CallbackObject;

            loadConfiguration();

            if (brokerUrl == null)
            {
                //brokerUrl = "tcp://localhost:61616";
                brokerUrl = "tcp://nysrv61:61616";
            }

            try
            {
                client = new NmsClient(CallbackObject,
                                       new String[]
                {
                    "account", "securityId", "level1TagName"
                }, brokerUrl);
                // The level2-4 tags do not add anything to uniqueness
                // , "level2TagName", "level3TagName", "level4TagName"
                Thread m_WorkerThread = new Thread(client.NMSReaderLoop);
                m_WorkerThread.Name = "NMSListener";
                m_WorkerThread.Start();

                return(1);
            }
            catch (Exception e)
            {
                //log.Error("Caught exception during serverstart", e);
            }
            return(-1);
        }
Пример #4
0
        /// <summary>
        /// 當一個 RTD 被 Excel 建立時,會呼叫 RTD 的這個函式,將該 Excel 的通知物件傳入,以供 RTD 使用,當 RTD 要更新資料時,就需要呼叫它
        /// 我們可以在這個函式建立 RTD 的初始化動作
        /// </summary>
        /// <param key="CallbackObject"> Excel 更新通知物件</param>
        /// <returns> 主動回予 1 表示正常, 0 表示不正常 </returns>
        int Microsoft.Office.Interop.Excel.IRtdServer.ServerStart(Excel.IRTDUpdateEvent CallbackObject)
        {
            try
            {
                lock (fSyncLock)
                {
                    fIsWorking = true;
                    //接入 Excel 更新物件
                    fTargetUpdateEvent = CallbackObject;

                    fUpdateList          = new Dictionary <int, object>();
                    fComm2TopicId        = new Dictionary <string, List <CMoneyTopic> >();
                    f_Data               = new DataProvider();
                    f_Data.Update_Event += new Delegate_Update(UpdateExcel);
                    f_Data.StartWork();
                    ////初始資料提供者,這時資料提供者應該要進行初始化資料的取得
                    //InitDataProvider();

                    //todo :這裡應該要檢查該有的都有了才回傳 1 不然還是要回 0
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("[CmRealTickRtd]無法正常啟動,錯誤訊息:" + ex.Message);
                return(0);
            }

            CMGlobal.ShowErrMsg();

            //MessageBox.Show("[CmRealTickRtd]服務啟動");
            return(1);
        }
Пример #5
0
        /// <summary>
        /// Called when Excel starts the RTD server.
        /// </summary>
        /// <param name="callbackObject">The call back object.</param>
        /// <returns>Status code.</returns>
        int Excel.IRtdServer.ServerStart(Microsoft.Office.Interop.Excel.IRTDUpdateEvent callbackObject)
        {
            // Store the callback object.
            m_callback = callbackObject;

            // Initialise and start the timer.
            m_timer          = new System.Timers.Timer(1000);
            m_timer.Elapsed += TimerElapsed;
            m_timer.Start();
            return(1);
        }
Пример #6
0
        public NmsClient(Excel.IRTDUpdateEvent xlRTDUpdate, String[] keyBaseFields, String brokerUrl)
        {
            baseFields     = keyBaseFields;
            m_xlRTDUpdate  = xlRTDUpdate;
            this.brokerUrl = brokerUrl;
            heartBeatTime  = DateTime.Now;

            //log.Info("About to connect to ActiveMQ");
            // Each instance of the Excel RTD creates a new COM instance, since we are using static
            // fields to store the data, we do not need to re-load the data for each instance
            // ensure that we only initialize once
            lock (lockObject)
            {
                if (!initialized)
                {
                    initializeConnection();
                }
            }
        }
Пример #7
0
 public int ServerStart(XL.IRTDUpdateEvent CallbackObject)
 {
     _timer = new Timer(delegate { CallbackObject.UpdateNotify(); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(3));
     return(1);
 }