/// <summary>
        /// 检索工作线程,更新订阅列表
        /// </summary>
        private void CheckSubscribeUpdate()
        {
            //获取发生改变的工作实例列表
            List <String> ToChangeList = (from item in Workers where item.Value.bSubscribeChange == true select item.Key).ToList();

            foreach (String g in ToChangeList)
            {
                //遍历其中订阅的股票期货信息,剔除其中不匹配内容
                List <String> _newSubscribeMarketList = Workers[g].GetSubscribeList();
                List <String> _oldSubscribeMarketList = (from item in MarketSubscribeList where item.Value.Contains(g) select item.Key).ToList();

                List <String> _ExistAndDoNotChange = (from item in _newSubscribeMarketList where _oldSubscribeMarketList.Contains(item) select item).ToList();
                List <String> _ToAdd    = (from item in _newSubscribeMarketList where !(_ExistAndDoNotChange.Contains(item)) select item).ToList();
                List <String> _ToDelete = (from item in _oldSubscribeMarketList where !(_ExistAndDoNotChange.Contains(item)) select item).ToList();

                for (int i = 0; i < _ToAdd.Count; i++)
                {
                    if (MarketSubscribeList.Keys.Contains(_ToAdd[i]))
                    {
                        MarketSubscribeList[_ToAdd[i]].Add(g);
                    }
                    else
                    {
                        MarketSubscribeList.Add(_ToAdd[i], new List <String>()
                        {
                            g
                        });
                    }
                }

                for (int i = 0; i < _ToDelete.Count; i++)
                {
                    MarketSubscribeList[_ToDelete[i]].Remove(g);
                }
            }

            if (ToChangeList.Count != 0)
            {
                MapMarketStratgy.SetMapSS(MarketSubscribeList);
            }
        }
示例#2
0
        /// <summary>
        /// 更新本地行情订阅列表
        /// </summary>
        private void updateNewSubscribeList()
        {
            if (MapMarketStratgy.bSubscribeListChangeLabel)
            {
                subscribeList = MapMarketStratgy.GetMapSS();

                Dictionary <String, List <String> > dic = MapMarketStratgy.GetMapMS();
                bool mark = true;
                while (mark)
                {
                    try
                    {
                        foreach (KeyValuePair <String, List <String> > pair in dic)
                        {
                            if (!subscribeList.Keys.Contains(pair.Key))
                            {
                                subscribeList.Add(pair.Key, new List <string>());
                            }
                            foreach (String module in pair.Value)
                            {
                                if (!subscribeList[pair.Key].Contains(module))
                                {
                                    subscribeList[pair.Key].Add(module);
                                }
                            }
                        }

                        mark = false;
                    }
                    catch (Exception ex)
                    {
                        GlobalErrorLog.LogInstance.LogEvent(ex.ToString());
                    }
                }

                MapMarketStratgy.bSubscribeListChangeLabel = false;
            }
        }