Пример #1
0
        private static void testStaticInfo_Security()
        {
            string securityFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Samples/securities_20140703.xml");
            string fileContent  = File.ReadAllText(securityFile, Encoding.UTF8);

            CodeTimer.CodeTimer.Initialize();
            QuotV5.StaticInfo.SecurityInfoParser parser = new QuotV5.StaticInfo.SecurityInfoParser();
            var securities = parser.Parse(fileContent);

            var sec150167 = securities.FirstOrDefault(s => s.CommonInfo.SecurityID == "150167");

            CodeTimer.CodeTimer.Time("ParseSecurity", 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.SecurityInfoBase> 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);
            }
        }