Esempio n. 1
0
        private static void testStaticInfo_Index()
        {
            string securityFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"C:\Users\limeng\Desktop\indexinfo_20140731.xml");
            string fileContent  = File.ReadAllText(securityFile, Encoding.UTF8);

            CodeTimer.CodeTimer.Initialize();
            QuotV5.StaticInfo.IndexInfoParser parser = new QuotV5.StaticInfo.IndexInfoParser();
            securities = parser.Parse(fileContent);
            //CodeTimer.CodeTimer.Time("ParseIndex", 10, () => { var ss = parser.Parse(fileContent); });
        }
        protected override void OnScanData()
        {
            string filePath = GetFileFullPath();

            if (File.Exists(filePath))
            {
                try
                {
                    if (!FileModifyTimeChanged(filePath))
                    {
                        this.logHelper.LogDebugMsg("文件最后修改时间无变化,FilePath={0}", filePath);
                        return;
                    }
                    string fileContent = ReadAllText(filePath, encoding);

                    if (fileContent == this.lastScanFileContent)
                    {
                        return;
                    }

                    List <QuotV5.StaticInfo.IndexInfo> securityInfos = parser.Parse(fileContent);

                    RaiseStaticInfoReadEvent(securityInfos);

                    this.lastScanFileContent = fileContent;
                }
                catch (Exception ex)
                {
                    this.logHelper.LogErrMsg(ex, "读取并解析静态信息文件异常,FilePath={0}", filePath);
                }
            }
            else
            {
                this.logHelper.LogInfoMsg("文件不存在:{0}", filePath);
            }
        }