public override void Save(IEnumerable <CellExcel> cellInfoList, ParametersDumpInfrastructure infrastructure) { IEnumerable <CellExcel> distinctInfos = cellInfoList.Distinct(p => new { p.ENodebId, p.SectorId, p.Frequency }); IEnumerable <CellExcel> _validInfos = from d in distinctInfos join e in _eNodebRepository.GetAll() on d.ENodebId equals e.ENodebId select d; var updateCells = (from v in _validInfos join c in _repository.GetAll() on new { v.ENodebId, v.SectorId, v.Frequency } equals new { c.ENodebId, c.SectorId, c.Frequency } select new { Info = v, Data = c }).ToList(); infrastructure.CellsUpdated = 0; infrastructure.NeighborPciUpdated = 0; if (_updateExisted) { foreach (var cell in updateCells.Where(x => x.Data.Pci != x.Info.Pci)) { cell.Info.CloneProperties(cell.Data); _repository.Update(cell.Data); infrastructure.CellsUpdated++; } if (_updatePci) { infrastructure.NeighborPciUpdated = SaveLteCellRelationService.UpdateNeighborPci(_validInfos); } } IEnumerable <Cell> insertInfos = _validInfos.Except(updateCells.Select(x => x.Info)).Select(x => { Cell cell = new Cell(); cell.Import(x); return(cell); }).ToList(); _repository.AddCells(insertInfos); infrastructure.CellsInserted = insertInfos.Count(); }
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); }