Example #1
0
        public override void Save(ParametersDumpInfrastructure infrastructure)
        {
            CdmaCell.UpdateFirstFrequency = true;
            List <CdmaCell> validCells = new List <CdmaCell>();

            foreach (CdmaCellExcel info in _validInfos)
            {
                CdmaCell cell = validCells.FirstOrDefault(x =>
                                                          x.BtsId == info.BtsId && x.SectorId == info.SectorId && x.CellType == info.CellType);
                if (cell == null)
                {
                    cell = new CdmaCell();
                    validCells.Add(cell);
                }
                cell.Import(info, true);
            }
            IEnumerable <CdmaCell> updateCells
                = from v in validCells
                  join c in _repository.GetAllList()
                  on new { v.BtsId, v.SectorId, v.CellType }
            equals new { c.BtsId, c.SectorId, c.CellType }
            select v;

            infrastructure.CdmaCellsInserted = 0;
            infrastructure.CdmaCellsUpdated  = 0;
            if (_updateExisted)
            {
                foreach (CdmaCell cell in updateCells)
                {
                    CdmaCell objectCell = _repository.GetAll().FirstOrDefault(
                        x => x.BtsId == cell.BtsId && x.SectorId == cell.SectorId && x.CellType == cell.CellType);
                    if (objectCell == null)
                    {
                        continue;
                    }
                    cell.CloneProperties <CdmaCell>(objectCell);
                    _repository.Update(cell);
                    infrastructure.CdmaCellsUpdated++;
                }
            }
            IEnumerable <CdmaCell>  insertCells = validCells.Except(updateCells, new CdmaCellComperer());
            SaveCdmaCellListService service     = new SimpleSaveCdmaCellListService(
                _repository, insertCells);

            infrastructure.CdmaCellsInserted += insertCells.Count();
            service.Save(infrastructure);
        }
 public override void Save(ParametersDumpInfrastructure infrastructure)
 {
     CdmaCell.UpdateFirstFrequency = true;
     List<CdmaCell> validCells = new List<CdmaCell>();
     foreach (CdmaCellExcel info in _validInfos)
     {
         CdmaCell cell = validCells.FirstOrDefault(x =>
             x.BtsId == info.BtsId && x.SectorId == info.SectorId && x.CellType == info.CellType);
         if (cell == null)
         {
             cell = new CdmaCell();
             validCells.Add(cell);
         }
         cell.Import(info, true);
     }
     IEnumerable<CdmaCell> updateCells
         = from v in validCells
           join c in _repository.GetAllList()
           on new { v.BtsId, v.SectorId, v.CellType }
           equals new { c.BtsId, c.SectorId, c.CellType }
           select v;
     infrastructure.CdmaCellsInserted = 0;
     infrastructure.CdmaCellsUpdated = 0;
     if (_updateExisted)
     {
         foreach (CdmaCell cell in updateCells)
         {
             CdmaCell objectCell = _repository.GetAll().FirstOrDefault(
                 x => x.BtsId == cell.BtsId && x.SectorId == cell.SectorId && x.CellType == cell.CellType);
             if (objectCell == null) continue;
             cell.CloneProperties<CdmaCell>(objectCell);
             _repository.Update(cell);
             infrastructure.CdmaCellsUpdated++;
         }
     }
     IEnumerable<CdmaCell> insertCells = validCells.Except(updateCells, new CdmaCellComperer());
     SaveCdmaCellListService service = new SimpleSaveCdmaCellListService(
         _repository, insertCells);
     infrastructure.CdmaCellsInserted += insertCells.Count();
     service.Save(infrastructure);
 }