public bool DumpSingleCellExcel(CdmaCellExcel info) { var cell = _cellRepository.GetBySectorIdAndCellType(info.BtsId, info.SectorId, info.CellType); if (cell == null) { cell = Mapper.Map<CdmaCellExcel, CdmaCell>(info); cell.Import(info); _cellRepository.SaveChanges(); return _cellRepository.Insert(cell) != null; } cell.Import(info); cell.IsInUse = true; _cellRepository.Update(cell); _cellRepository.SaveChanges(); return true; }
public bool Post(CdmaCellExcel info) { return _service.DumpSingleCellExcel(info); }
public void Import(CdmaCellExcel cellExcelInfo) { var currentFrequency = (short)cellExcelInfo.Frequency; if (!currentFrequency.IsCdmaFrequency()) return; if (HasFrequency(currentFrequency)) return; AntennaGain = cellExcelInfo.AntennaGain; if (Frequency1 == -1) { Frequency1 = AddFrequency(currentFrequency); } else if (Frequency2 == -1) { Frequency2 = AddFrequency(currentFrequency); } else if (Frequency3 == -1) { Frequency3 = AddFrequency(currentFrequency); } else if (Frequency4 == -1) { Frequency4 = AddFrequency(currentFrequency); } else if (Frequency5 == -1) { Frequency5 = AddFrequency(currentFrequency); } }
public static CdmaCell ConstructItem(CdmaCellExcel cellExcelInfo) { var cell = Mapper.Map<CdmaCellExcel, CdmaCell>(cellExcelInfo); cell.Frequency1 = cell.AddFrequency((short)cellExcelInfo.Frequency); return cell; }
public void TestFormCdmaCellExcelToCdmaCell2() { var info = new CdmaCellExcel { BtsId = 12333, SectorId = 3, Frequency = 283, IsIndoor = "是" }; var item = info.MapTo<CdmaCell>(); Assert.AreEqual(item.BtsId, 12333); Assert.AreEqual(item.SectorId, 3); Assert.AreEqual(item.Frequency, 0); Assert.IsFalse(item.IsOutdoor); }
public void Test_Import_UpdateThirdFrequency( int btsId, byte sectorId, int cellId, short frequency, string cellType, double antennaGain, short overallFrequency) { var cell = new CdmaCell { BtsId = 1, SectorId = 2, CellId = 3, Frequency = 3, CellType = "DO", AntennaGain = 12.8, Frequency1 = 37, Frequency2 = 78 }; var cellExcelInfo = new CdmaCellExcel { BtsId = btsId, SectorId = sectorId, CellId = cellId, Frequency = frequency, CellType = cellType, AntennaGain = antennaGain }; cell.Import(cellExcelInfo); Assert.AreEqual(cell.BtsId, 1, "btsId"); Assert.AreEqual(cell.SectorId, 2); Assert.AreEqual(cell.CellId, 3); Assert.AreEqual(cell.CellType, "DO"); Assert.AreEqual(cell.Frequency, overallFrequency, "frequency"); Assert.AreEqual(cell.Frequency1, 37); Assert.AreEqual(cell.Frequency2, 78); Assert.AreEqual(cell.Frequency3, frequency == 37 || frequency == 78 || !frequency.IsCdmaFrequency() ? -1 : frequency); Assert.AreEqual(cell.AntennaGain, frequency == 37 || frequency == 78 || !frequency.IsCdmaFrequency() ? 12.8 : antennaGain); }
public void Test_Import_UpdateFirstFrequency( int btsId, byte sectorId, int cellId, short frequency, string cellType, double antennaGain, short overallFrequency) { var cell = new CdmaCell { BtsId = 1, SectorId = 2, CellId = 3, Frequency = 0, CellType = "DO", AntennaGain = 12.8, Frequency1 = -1 }; var cellExcelInfo = new CdmaCellExcel { BtsId = btsId, SectorId = sectorId, CellId = cellId, Frequency = frequency, CellType = cellType, AntennaGain = antennaGain }; cell.Import(cellExcelInfo); Assert.AreEqual(cell.BtsId, 1, "btsId"); Assert.AreEqual(cell.SectorId, 2); Assert.AreEqual(cell.CellId, 3); Assert.AreEqual(cell.CellType, "DO"); Assert.AreEqual(cell.Frequency, overallFrequency, "frequency"); Assert.AreEqual(cell.Frequency1, overallFrequency == 0 ? -1 : frequency, "frequency1"); Assert.AreEqual(cell.AntennaGain, overallFrequency != 0 ? antennaGain : 12.8); Assert.AreEqual(cell.HasFrequency(frequency), overallFrequency != 0); }
public void Test_NewCell(int btsId, byte sectorId, int cellId, short frequency, string cellType, int overallFrequency, bool updateFrequency) { var cellExcelInfo = new CdmaCellExcel { BtsId = btsId, SectorId = sectorId, CellId = cellId, Frequency = frequency, CellType = cellType, AntennaGain = 12.8 }; var cell = CdmaCell.ConstructItem(cellExcelInfo); Assert.IsNotNull(cell); Assert.AreEqual(cell.BtsId, btsId); Assert.AreEqual(cell.SectorId, sectorId); Assert.AreEqual(cell.CellId, cellId); Assert.AreEqual(cell.CellType, cellType); Assert.AreEqual(cell.AntennaGain, 12.8); Assert.AreEqual(cell.Frequency, overallFrequency, "Wrong overall frequency"); Assert.AreEqual(cell.Frequency2, -1); Assert.AreEqual(cell.Frequency3, -1); Assert.AreEqual(cell.Frequency4, -1); Assert.AreEqual(cell.Frequency5, -1); if (updateFrequency) { Assert.AreEqual(cell.Frequency1, frequency); Assert.IsTrue(cell.HasFrequency(frequency)); } else { Assert.AreEqual(cell.Frequency1, -1); Assert.IsFalse(cell.HasFrequency(frequency)); } }