Пример #1
0
        /// <summary>
        /// 读取文件
        /// </summary>
        /// <param name="strDir">目录</param>
        /// <param name="mgr"></param>
        /// <param name="futurelist"></param>
        /// <param name="blive"></param>
        /// <returns></returns>
        public static bool Read(
            string strDir,
            FutureManager mgr,
            List <string> futurelist,
            bool blive)
        {
            try
            {
                mgr.Clear();

                string strIndexFile = strDir + "\\" + IndexFile;
                if (File.Exists(strIndexFile))
                {
                    ReadRefIndex(strIndexFile, mgr);
                }

                string strFile = strDir + "\\" + FileName;
                if (!File.Exists(strFile))
                {
                    return(false);
                }

                XmlDocument doc = new XmlDocument();
                doc.Load(strFile);

                foreach (XmlNode node in doc.DocumentElement.ChildNodes)
                {
                    XmlElement tagNode = node as XmlElement;
                    if (tagNode == null)
                    {
                        continue;
                    }

                    if (tagNode.Name != ExchangeTag)
                    {
                        continue;
                    }

                    Exchange exchange = new Exchange();
                    FutureExchangeXml.Get(tagNode, exchange, mgr, futurelist, blive);
                    if (exchange.ExchangeID != "")
                    {
                        mgr.AddExchange(exchange);
                    }
                }

                //Check(mgr);

                return(true);
            }
            catch (Exception ex)
            {
                ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
                logger.Error("读取期货品种失败", ex);
                mgr.Clear();
            }

            return(false);
        }