Exemple #1
0
        private void ExportToList(FileInfo file_input, FileInfo file_output)
        {
            Stream _stream = new MemoryStream();
            // 加载文件,支持7z解压
            var fileStream = file_input.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            {
                try
                {
                    using (var zip = new SevenZipExtractor(fileStream))
                    {
                        // 只解压了第0个,如果有多个也只解压第一个
                        zip.ExtractFile(0, _stream);
                        _stream.Seek(0, SeekOrigin.Begin);
                    }
                }
                catch
                {
                    _stream = fileStream;
                    _stream.Seek(0, SeekOrigin.Begin);
                }
            }

            PbTickCodec codec = new PbTickCodec();

            QuantBox.Data.Serializer.PbTickSerializer Serializer = new QuantBox.Data.Serializer.PbTickSerializer();
            List <PbTickView> list = Serializer.Read2View(_stream);

            ListToCSV(list, file_output);
        }
        private void ExportToList(FileInfo file_input, FileInfo file_output, bool toCsv, bool toKdb, bool saveQuote)
        {
            // 都没选,跳过
            if (toCsv || toKdb)
            {
            }
            else
            {
                return;
            }

            Stream _stream = new MemoryStream();
            // 加载文件,支持7z解压
            var fileStream = file_input.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            {
                try
                {
                    using (var zip = new SevenZipExtractor(fileStream))
                    {
                        // 只解压了第0个,如果有多个也只解压第一个
                        zip.ExtractFile(0, _stream);
                        _stream.Seek(0, SeekOrigin.Begin);
                    }
                }
                catch
                {
                    _stream = fileStream;
                    _stream.Seek(0, SeekOrigin.Begin);
                }
            }

            PbTickCodec codec = new PbTickCodec();

            QuantBox.Data.Serializer.PbTickSerializer Serializer = new QuantBox.Data.Serializer.PbTickSerializer();
            List <PbTickView> list = Serializer.Read2View(_stream);

            if (toCsv)
            {
                ListToCSV(list, file_output);
            }
            // 得加入kdb+支持
            if (toKdb)
            {
                ListToKdb(list, saveQuote);
            }
        }
Exemple #3
0
        public List <QuantBox.Data.Serializer.V2.PbTickView> ReadOneFile(FileInfo file)
        {
            Stream _stream    = new MemoryStream();
            var    fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            {
                try
                {
                    using (var zip = new SevenZipExtractor(fileStream))
                    {
                        zip.ExtractFile(0, _stream);
                        _stream.Seek(0, SeekOrigin.Begin);
                    }
                }
                catch (Exception ex)
                {
                    _stream = fileStream;
                    _stream.Seek(0, SeekOrigin.Begin);
                }
            }
            return(Serializer.Read2View(_stream));
        }
Exemple #4
0
        private void ExportToList(FileInfo file_input,FileInfo file_output)
        {
            Stream _stream = new MemoryStream();
            // 加载文件,支持7z解压
            var fileStream = file_input.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            {
                try
                {
                    using (var zip = new SevenZipExtractor(fileStream))
                    {
                        // 只解压了第0个,如果有多个也只解压第一个
                        zip.ExtractFile(0, _stream);
                        _stream.Seek(0, SeekOrigin.Begin);
                    }
                }
                catch
                {
                    _stream = fileStream;
                    _stream.Seek(0, SeekOrigin.Begin);
                }
            }

            PbTickCodec codec = new PbTickCodec();
            QuantBox.Data.Serializer.PbTickSerializer Serializer = new QuantBox.Data.Serializer.PbTickSerializer();
            List<PbTickView> list = Serializer.Read2View(_stream);
            ListToCSV(list, file_output);
        }