public async void Import(IEnumerable <ImportedFileInfo> validFileInfos) { Result = ""; repository = new TRepository(); foreach (ImportedFileInfo file in validFileInfos) { IStatDateImporter importer = GenerateImporter(); ImportedFileInfo fileInfo = file; importer.Date = fileInfo.FilePath.RetrieveFileNameBody().GetDateExtend(); TStat stat = repository.Stats.FirstOrDefault(x => x.StatTime == importer.Date); if (stat == null) { using (StreamReader reader = ReadFile(fileInfo.FilePath)) { int count = await importer.ImportStat(reader, CsvFileDescription.CommaDescription); Result += "\n" + fileInfo.FilePath + "完成导入数量:" + count; } fileInfo.FinishState(); } else { Result += "\n日期:" + importer.Date.ToShortDateString() + "的统计记录已导入!"; fileInfo.UnnecessaryState(); } } FileListGrid.SetDataSource(FileInfoList); }
public override void Import(ImportedFileInfo[] validFileInfos) { string result = ""; SaveLteCellRelationService service = new SaveLteCellRelationService(_repository); foreach (ImportedFileInfo info in validFileInfos) { using (StreamReader reader = ReadFile(info.FilePath)) { IEnumerable<LteCellRelationCsv> csvInfos = CsvContext.Read<LteCellRelationCsv>(reader, CsvFileDescription.CommaDescription).ToList(); service.Save(csvInfos); result += "\n完成导入邻区关系文件:" + info.FilePath; } } MessageBox.Show(result); FileListGrid.SetDataSource(FileInfoList); }
public abstract void Import(ImportedFileInfo[] validFileInfos);