예제 #1
0
        public async Task <int> SaveCollegeInfo(CollegeInfo info, long userId)
        {
            var item = _repository.GetByName(info.Name);

            if (item == null)
            {
                info.CreatorUserId = userId;
                await _repository.InsertAsync(info);
            }
            else
            {
                item.TownId = info.TownId;
                var areaItem = _repository.GetRegion(item.Id);
                if (areaItem == null)
                {
                    item.CollegeRegion = info.CollegeRegion;
                }
                else
                {
                    areaItem.Area       = info.CollegeRegion.Area;
                    areaItem.Info       = info.CollegeRegion.Info;
                    areaItem.RegionType = info.CollegeRegion.RegionType;
                }
            }
            return(_repository.SaveChanges());
        }
예제 #2
0
 public CollegeStat(ICollegeRepository repository, CollegeInfo info, CollegeYearInfo yearInfo,
                    IInfrastructureRepository infrastructureRepository, IHotSpotENodebRepository eNodebRepository,
                    IHotSpotCellRepository cellRepository, IHotSpotBtsRepository btsRepository,
                    IHotSpotCdmaCellRepository cdmaCellRepository)
 {
     Name = info.Name;
     ExpectedSubscribers = yearInfo?.ExpectedSubscribers ?? 0;
     Area = repository.GetRegion(info.Id)?.Area ?? 0;
     Id   = info.Id;
     UpdateStats(infrastructureRepository);
     TotalLteENodebs =
         eNodebRepository.Count(
             x =>
             x.HotspotName == Name && x.HotspotType == HotspotType.College &&
             x.InfrastructureType == InfrastructureType.ENodeb);
     TotalLteCells =
         cellRepository.Count(
             x =>
             x.HotspotName == Name && x.HotspotType == HotspotType.College &&
             x.InfrastructureType == InfrastructureType.Cell);
     TotalCdmaBts =
         btsRepository.Count(
             x =>
             x.HotspotName == Name && x.HotspotType == HotspotType.College &&
             x.InfrastructureType == InfrastructureType.CdmaBts);
     TotalCdmaCells =
         cdmaCellRepository.Count(
             x =>
             x.HotspotName == Name && x.HotspotType == HotspotType.College &&
             x.InfrastructureType == InfrastructureType.CdmaCell);
 }
 public static IEnumerable<CdmaCell> QueryCollegeCdmaCells(this IInfrastructureRepository repository,
     ICdmaCellRepository cdmaCellRepository, CollegeInfo info)
 {
     IEnumerable<int> ids = repository.InfrastructureInfos.Where(x =>
         x.HotspotName == info.Name && x.InfrastructureType == InfrastructureType.CdmaCell
         ).Select(x => x.InfrastructureId).ToList();
     return ids.Select(cdmaCellRepository.Get).Where(cell => cell != null).ToList();
 }
        public ActionResult DeleteConfirmed(int id)
        {
            CollegeInfo collegeInfo = db.CollegeInfo.Find(id);

            db.CollegeInfo.Remove(collegeInfo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public static IEnumerable<CdmaBts> QueryCollegeBtss(this IInfrastructureRepository repository,
     IBtsRepository btsRepository, CollegeInfo info)
 {
     IEnumerable<int> ids = repository.InfrastructureInfos.Where(x =>
         x.HotspotName == info.Name && x.InfrastructureType == InfrastructureType.CdmaBts
         ).Select(x => x.InfrastructureId).ToList();
     return ids.Select(btsRepository.Get).Where(bts => bts != null).ToList();
 }
예제 #6
0
 public CollegeStat(ICollegeRepository repository, CollegeInfo info, CollegeYearInfo yearInfo,
     IInfrastructureRepository infrastructureRepository)
 {
     CollegeRegion region = repository.GetRegion(info.Id);
     Name = info.Name;
     ExpectedSubscribers = yearInfo?.ExpectedSubscribers ?? 0;
     Area = region?.Area??0;
     Id = info.Id;
     UpdateStats(infrastructureRepository);
 }
 public static IEnumerable<IndoorDistribution> QueryCollegeCdmaDistributions(
     this IInfrastructureRepository repository,
     IIndoorDistributioinRepository indoorRepository, CollegeInfo info)
 {
     IEnumerable<int> ids = repository.InfrastructureInfos.Where(x =>
         x.HotspotName == info.Name && x.InfrastructureType == InfrastructureType.CdmaIndoor
         ).Select(x => x.InfrastructureId).ToList();
     return ids.Select(i => indoorRepository.IndoorDistributions.FirstOrDefault(x => x.Id == i)
         ).Where(distribution => distribution != null).ToList();
 }
예제 #8
0
        public static IEnumerable <IndoorDistribution> QueryCollegeCdmaDistributions(
            this IInfrastructureRepository repository,
            IIndoorDistributioinRepository indoorRepository, CollegeInfo info)
        {
            IEnumerable <int> ids = repository.InfrastructureInfos.Where(x =>
                                                                         x.HotspotName == info.Name && x.InfrastructureType == InfrastructureType.CdmaIndoor
                                                                         ).Select(x => x.InfrastructureId).ToList();

            return(ids.Select(i => indoorRepository.IndoorDistributions.FirstOrDefault(x => x.Id == i)
                              ).Where(distribution => distribution != null).ToList());
        }
예제 #9
0
        public CollegeStat(ICollegeRepository repository, CollegeInfo info,
                           IInfrastructureRepository infrastructureRepository)
        {
            CollegeRegion region = repository.GetRegion(info.Id);

            Name = info.Name;
            ExpectedSubscribers = info.ExpectedSubscribers;
            Area = region.Area;
            Id   = region.AreaId;
            UpdateStats(infrastructureRepository);
        }
예제 #10
0
        public CollegeDto(CollegeInfo info, IEnumerable <Town> towns)
        {
            info.CloneProperties(this);
            Town town = towns.FirstOrDefault(x => x.Id == info.TownId);

            if (town != null)
            {
                CityName     = town.CityName;
                DistrictName = town.DistrictName;
                TownName     = town.TownName;
            }
        }
        public CollegeRegion Get(int id, double area, string message)
        {
            CollegeInfo info = _repository.Get(id);

            if (info == null)
            {
                return(null);
            }
            UpdateRegion(id, area, message, info, RegionType.Polygon);
            _repository.Update(info);
            return(info.CollegeRegion);
        }
예제 #12
0
        public ActionResult CollegeCoverage(int id)
        {
            CollegeInfo info = _repository.Get(id);

            if (info == null)
            {
                return(View(new InfrastructureCoverageViewModel(id)));
            }

            ParametersContainer.UpdateCollegeInfos(this, info);
            FileRecordsRepository.UpdateCoverageInfos(ParametersContainer.QueryENodebs, 0.03);
            return(View(new InfrastructureCoverageViewModel(id, info.Name)));
        }
        public CollegeRegion Get(int id, double x1, double y1, double x2, double y2, double area)
        {
            CollegeInfo info = _repository.Get(id);

            if (info == null)
            {
                return(null);
            }
            string message = x1 + ";" + y1 + ";" + x2 + ";" + y2;

            UpdateRegion(id, area, message, info, RegionType.Rectangle);
            _repository.Update(info);
            return(info.CollegeRegion);
        }
        // GET: CollegeInfoes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CollegeInfo collegeInfo = db.CollegeInfo.Find(id);

            if (collegeInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(collegeInfo));
        }
예제 #15
0
 public static void UpdateCollegeInfos(ICollegeController controller, CollegeInfo info)
 {
     QueryENodebs = controller.InfrastructureRepository.QueryCollegeENodebs(
         controller.ENodebRepository, info);
     QueryCells = controller.InfrastructureRepository.QueryCollegeCells(
         controller.CellRepository, info);
     QueryBtss = controller.InfrastructureRepository.QueryCollegeBtss(
         controller.BtsRepository, info);
     QueryCdmaCells = controller.InfrastructureRepository.QueryCollegeCdmaCells(
         controller.CdmaCellRepository, info);
     QueryLteDistributions = controller.InfrastructureRepository.QueryCollegeLteDistributions(
         controller.IndoorDistributioinRepository, info);
     QueryCdmaDistributions = controller.InfrastructureRepository.QueryCollegeCdmaDistributions(
         controller.IndoorDistributioinRepository, info);
 }
        public CollegeRegion Get(int id, double centerX, double centerY, double radius)
        {
            CollegeInfo info = _repository.Get(id);

            if (info == null)
            {
                return(null);
            }
            double area    = Math.PI * radius * radius;
            string message = centerX + ";" + centerY + ";" + radius;

            UpdateRegion(id, area, message, info, RegionType.Circle);
            _repository.Update(info);
            return(info.CollegeRegion);
        }
 public ActionResult Create(CollegeInfoshow collegeInfo)
 {
     if (ModelState.IsValid)
     {
         var model = new CollegeInfo
         {
             Title  = collegeInfo.Title,
             Number = collegeInfo.Number,
             Info   = collegeInfo.Info
         };
         db.CollegeInfo.Add(model);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(collegeInfo));
 }
예제 #18
0
        public ActionResult CollegeCells(int id)
        {
            CollegeInfo info = _repository.Get(id);

            if (info == null)
            {
                return(View(new InfrastructureInfoViewModel(id)));
            }

            ParametersContainer.UpdateCollegeInfos(this, info);

            return(View(new InfrastructureInfoViewModel(id, info.Name)
            {
                StartDate = DateTime.Today.AddDays(-7),
                EndDate = DateTime.Today
            }));
        }
예제 #19
0
        public ActionResult CollegeDetails(int id)
        {
            CollegeInfo        info  = _repository.Get(id);
            IEnumerable <Town> towns = _townRepository.GetAllList();
            CollegeDto         dto   = (info == null)
                ? new CollegeDto()
                : new CollegeDto(info, towns);
            CollegeEditViewModel viewModel = new CollegeEditViewModel
            {
                CollegeDto = dto
            };

            viewModel.Initialize(towns, new Town
            {
                CityName     = dto.CityName,
                DistrictName = dto.DistrictName,
                TownName     = dto.TownName
            });
            return(View(viewModel));
        }
예제 #20
0
        public List <CollegeInfo> GetAllCollegeInfo() //获取学院信息的方法
        {
            CollegeInfo        co;
            List <CollegeInfo> list = new List <CollegeInfo>();
            string             sql  = "select * from CollegeInfo";

            using (SqlDataReader sdr = DBHelpers.GetAllInfo(sql))
            {
                while (sdr.Read())
                {
                    co           = new CollegeInfo();
                    co.CollegeID = int.Parse(sdr["CollegeID"].ToString());
                    //co.CollegeSimple = sdr["CollegeSimple"].ToString();
                    co.CollegeName = sdr["CollegeName"].ToString();
                    list.Add(co);
                }
            }

            return(list);
        }
        private void UpdateRegion(int id, double area, string message, CollegeInfo info, RegionType type)
        {
            CollegeRegion region = _repository.GetRegion(id);

            if (region == null)
            {
                info.CollegeRegion = new CollegeRegion
                {
                    Area       = area,
                    Info       = message,
                    RegionType = type
                };
            }
            else
            {
                region.Area       = area;
                region.Info       = message;
                region.RegionType = type;
            }
        }
        // GET: CollegeInfoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CollegeInfo model  = db.CollegeInfo.Find(id);
            var         models = new CollegeInfoshow
            {
                ID     = model.ID,
                Info   = model.Info,
                Number = model.Number,
                Title  = model.Title
            };

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
예제 #23
0
        public ActionResult CollgeEdit(CollegeEditViewModel viewModel)
        {
            Town town = _townRepository.GetAll().FirstOrDefault(x =>
                                                                x.CityName == viewModel.CollegeDto.CityName &&
                                                                x.DistrictName == viewModel.CollegeDto.DistrictName &&
                                                                x.TownName == viewModel.CollegeDto.TownName);
            int townId = town == null ? -1 : town.Id;

            CollegeInfo info = viewModel.CollegeDto.Id == -1
                ? new CollegeInfo()
                : _repository.Get(viewModel.CollegeDto.Id);

            if (info == null)
            {
                TempData["error"] = "该校园不存在。无法修改!";
                return(RedirectToAction("List"));
            }
            int    oldTownId = info.TownId;
            string oldName   = info.Name;

            viewModel.CollegeDto.CloneProperties(info);
            info.TownId = townId;
            if (viewModel.CollegeDto.Id == -1)
            {
                _repository.Insert(info);
                TempData["success"] = "新增校园" + info.Name + "信息成功!";
            }
            else
            {
                info.TownId         = oldTownId;
                info.Name           = oldName;
                TempData["success"] = "修改校园" + info.Name + "信息成功!";
                _repository.Update(info);
            }
            return(RedirectToAction("List"));
        }
예제 #24
0
 public async Task <int> Post(CollegeInfo info)
 {
     return(await _service.SaveCollegeInfo(info, User.Identity.Name.GetHashCode()));
 }
 public static IEnumerable<ENodeb> QueryCollegeENodebs(this IInfrastructureRepository repository,
     IENodebRepository eNodebRepository, CollegeInfo info)
 {
     IEnumerable<int> ids = repository.InfrastructureInfos.Where(x =>
         x.HotspotName == info.Name && x.InfrastructureType == InfrastructureType.ENodeb
         ).Select(x => x.InfrastructureId).ToList();
     return ids.Select(i => eNodebRepository.GetAll().FirstOrDefault(x => x.Id == i)
         ).Where(eNodeb => eNodeb != null).ToList();
 }
예제 #26
0
 public static void UpdateCollegeInfos(ICollegeController controller, CollegeInfo info)
 {
     QueryENodebs = controller.InfrastructureRepository.QueryCollegeENodebs(
         controller.ENodebRepository, info);
     QueryCells = controller.InfrastructureRepository.QueryCollegeCells(
         controller.CellRepository, info);
     QueryBtss = controller.InfrastructureRepository.QueryCollegeBtss(
         controller.BtsRepository, info);
     QueryCdmaCells = controller.InfrastructureRepository.QueryCollegeCdmaCells(
         controller.CdmaCellRepository, info);
     QueryLteDistributions = controller.InfrastructureRepository.QueryCollegeLteDistributions(
         controller.IndoorDistributioinRepository, info);
     QueryCdmaDistributions = controller.InfrastructureRepository.QueryCollegeCdmaDistributions(
         controller.IndoorDistributioinRepository, info);
 }
예제 #27
0
        private void CreateInfo(StringBuilder jsBuilder, CollegeInfo info)
        {
            if (info.schoolName == null)
            {
                info.schoolName = "学校很懒,什么也没有留下……";
            }
            jsBuilder.Append("$('#schoolName').text('" + info.schoolName + "');");

            if (info.englishName == null)
            {
                info.englishName = "School is lazy, left nothing...";
            }
            jsBuilder.Append("$('#englishName').text('" + info.englishName + "');");

            if (info.extSchNo == null)
            {
                info.extSchNo = "??";
            }
            jsBuilder.Append("$('#extSchNo').text('" + info.extSchNo + "');");

            if (info.campus == null)
            {
                info.campus = "未知";
            }
            else
            {
                info.campus = AlreadyKnownThings.Campus[info.campus];
            }
            jsBuilder.Append("$('#Icampus').text('" + info.campus + "');");

            if (info.division == null)
            {
                info.division = "未知";
            }
            else
            {
                info.division = AlreadyKnownThings.Division[info.division];
            }
            jsBuilder.Append("$('#Idivision').text('" + info.division + "');");

            if (info.staff == null)
            {
                info.staff = new Staff {
                    name = "未设置"
                }
            }
            ;
            jsBuilder.Append("$('#staff').text('" + info.staff.name + "');");

            if (info.telephone == null)
            {
                info.telephone = "学校很懒,什么也没有留下……";
            }
            jsBuilder.Append("$('#telephone').text('" + info.telephone + "');");

            if (info.website == null)
            {
                info.website = "学校很懒,什么也没有留下……";
            }
            jsBuilder.Append("$('#website').text('" + info.website + "');");

            if (info.introduction == null)
            {
                info.introduction = "学校很懒,什么也没有留下……";
            }
            jsBuilder.Append("$('#introduction').text('" + info.introduction + "');");
        }
        public IHttpActionResult Get(int id)
        {
            CollegeInfo info = _repository.Get(id);

            return(info == null ? (IHttpActionResult)BadRequest("College Id Not Found!") : Ok(info));
        }
        public IHttpActionResult Get(string name)
        {
            CollegeInfo info = _repository.FirstOrDefault(x => x.Name == name);

            return(info == null ? (IHttpActionResult)BadRequest("College Name Not Found!") : Ok(info));
        }
예제 #30
0
        public static IEnumerable <ENodeb> QueryCollegeENodebs(this IInfrastructureRepository repository,
                                                               IENodebRepository eNodebRepository, CollegeInfo info)
        {
            IEnumerable <int> ids = repository.InfrastructureInfos.Where(x =>
                                                                         x.HotspotName == info.Name && x.InfrastructureType == InfrastructureType.ENodeb
                                                                         ).Select(x => x.InfrastructureId).ToList();

            return(ids.Select(i => eNodebRepository.GetAll().FirstOrDefault(x => x.Id == i)
                              ).Where(eNodeb => eNodeb != null).ToList());
        }
예제 #31
0
        public static IEnumerable <CdmaBts> QueryCollegeBtss(this IInfrastructureRepository repository,
                                                             IBtsRepository btsRepository, CollegeInfo info)
        {
            IEnumerable <int> ids = repository.InfrastructureInfos.Where(x =>
                                                                         x.HotspotName == info.Name && x.InfrastructureType == InfrastructureType.CdmaBts
                                                                         ).Select(x => x.InfrastructureId).ToList();

            return(ids.Select(btsRepository.Get).Where(bts => bts != null).ToList());
        }
예제 #32
0
        public static IEnumerable <CdmaCell> QueryCollegeCdmaCells(this IInfrastructureRepository repository,
                                                                   ICdmaCellRepository cdmaCellRepository, CollegeInfo info)
        {
            IEnumerable <int> ids = repository.InfrastructureInfos.Where(x =>
                                                                         x.HotspotName == info.Name && x.InfrastructureType == InfrastructureType.CdmaCell
                                                                         ).Select(x => x.InfrastructureId).ToList();

            return(ids.Select(cdmaCellRepository.Get).Where(cell => cell != null).ToList());
        }