Exemplo n.º 1
0
        public void Delete(KLineType type, string stockCode, IEnumerable<IStockKLine> kLines)
        {
            ThrowIfTypeNotSupport(type);

            if (type == KLineType.Day)
            {
                string dbFilePath = new Day1KLineFile(stockCode).GetFilePath();
                KLineRepository repository = new KLineRepository(dbFilePath);
                repository.DeleteRange(kLines);
            }
            else
            {
                Year1KLineFile file = null;
                if (type == KLineType.Min1)
                {
                    file = new Min1KLineFile(stockCode);
                }
                else
                {
                    file = new Min5KLineFile(stockCode);
                }
                var packages = file.SplitToPackages(kLines);

                // 插入所有数据
                foreach (var package in packages)
                {
                    // 获取数据文件路径
                    string dbFilePath = file.GetFilePath(package);

                    KLineRepository repository = new KLineRepository(dbFilePath);
                    repository.DeleteRange(package.Items);
                }
            }
        }