public ActionResult Index(int page = 1)
        {
            ViewBag.Message = TempData[MESSAGE_KEY];
            if (TempData.ContainsKey(MESSAGE_KEY))
            {
                ModelState.AddModelError("", ((String)TempData[MESSAGE_KEY]));
            }

            ViewBag.Pagination = new Pagination {
                CurrentPage = page, TotalCount = userRepository.Count()
            };

            List <int> areaIds = CurrentAvailableAreas.Select(area => area.Id).ToList();
            IEnumerable <IndexUser> indexUsers = userRepository
                                                 .FindAll(user => areaIds.Contains(user.AreaId),
                                                          new PagingOptions <User>(page, Pagination.DefaultPageSize, "UserName"))
                                                 .Select(user =>
                                                         new IndexUser
            {
                Id       = user.Id,
                UserName = user.UserName,
                Email    = user.Email,
                Phone    = user.Phone,
                AreaName = areaRepository.Get(user.AreaId) != null ? areaRepository.Get(user.AreaId).Name : ""
            });

            return(View(indexUsers));
        }
Beispiel #2
0
        public ActionResult TableMode(int page = 1)
        {
            ViewBag.Pagination = new Pagination {
                TotalCount = deviceRepository.Count(), CurrentPage = page
            };
            List <int> areaIds = CurrentAvailableAreas.Select(area => area.Id).ToList();
            IEnumerable <DeviceModel> devices = deviceRepository.
                                                FindAll(device => areaIds.Contains(device.AreaId),
                                                        new PagingOptions <Device>(page, Pagination.DefaultPageSize, "Name"))
                                                .Select(device =>
                                                        new DeviceModel
            {
                Id              = device.Id,
                Name            = device.Name,
                Description     = device.Description,
                IMEI            = device.IMEI,
                SimNumber       = device.SimNumber,
                AreaName        = areaRepository.Get(device.AreaId).Name,
                Battery         = device.Battery,
                DataDttm        = device.DataDttm,
                PowerMode       = device.PowerMode,
                TransportPlanId = device.TransportPlanId,
                TransportPlan   = device.TransportPlan
            });

            return(View(devices));
        }
 private IOrderedEnumerable <SelectListItem> GetAreaSelectItems()
 {
     return(CurrentAvailableAreas.Select(
                area => new SelectListItem {
         Text = area.Name, Value = area.Id.ToString()
     })
            .OrderBy(item => item.Text));
 }
 public ActionResult Index()
 {
     ViewBag.areaId      = CurrentAreaId;
     ViewBag.AreaCount   = CurrentAvailableAreas.Count;
     ViewBag.DeviceCount =
         devRepository.FindDevicesInAreas(CurrentAvailableAreas.Select(area => area.Id).ToList()).Count();
     ViewBag.UserCount = userRepository.FindUsersInAreas(CurrentAvailableAreas.Select(area => area.Id)).Count();
     ViewBag.PlanCount = transportPlanRepository.Count();
     return(View());
 }
Beispiel #5
0
        public ActionResult Index(int page = 1)
        {
            ViewBag.Pagination = new Pagination {
                TotalCount = transportPlanRepository.Count(), CurrentPage = page
            };
            List <int> areaIds = CurrentAvailableAreas.Select(area => area.Id).ToList();
            IEnumerable <TransportPlan> plans = transportPlanRepository.GetAll(new PagingOptions <TransportPlan>(page, Pagination.DefaultPageSize, "Name"));

            return(View(plans));
        }
Beispiel #6
0
        public ActionResult Index(int page = 1)
        {
            ViewBag.Message = TempData[MESSAGE_KEY];
            if (TempData.ContainsKey(MESSAGE_KEY))
            {
                ModelState.AddModelError("", ((String)TempData[MESSAGE_KEY]));
            }

            List <int> areaIds = CurrentAvailableAreas.Select(area => area.Id).ToList();
            IEnumerable <AreaModel> areaModels = areaRepository
                                                 .FindAll(area => areaIds.Contains(area.Id), new PagingOptions <Area>(page, Pagination.DefaultPageSize, "Name"))
                                                 .Select(AreaToViewModel);

            ViewBag.Pagination = new Pagination {
                CurrentPage = page, TotalCount = areaModels.Count()
            };
            return(View(areaModels));
        }
Beispiel #7
0
        public ActionResult Tempmode12chs(int page = 1)
        {
            string deviceType = "12路温度仪";

            ViewBag.Pagination = new Pagination {
                TotalCount = deviceRepository.Count(), CurrentPage = page
            };
            List <int> areaIds = CurrentAvailableAreas.Select(area => area.Id).ToList();
            IEnumerable <DeviceModel> devices = deviceRepository.
                                                FindAll(device => areaIds.Contains(device.AreaId) && (device.DeviceMeta == null ? true : device.DeviceMeta.DeviceType == deviceType),
                                                        new PagingOptions <Device>(page, Pagination.DefaultPageSize, "Name"))
                                                .Select(device =>
                                                        new DeviceModel
            {
                Id              = device.Id,
                Name            = device.Name,
                Description     = device.Description,
                IMEI            = device.IMEI,
                SimNumber       = device.SimNumber,
                AreaName        = areaRepository.Get(device.AreaId).Name,
                Battery         = device.Battery,
                DataDttm        = device.DataDttm,
                PowerMode       = device.PowerMode,
                TransportPlanId = device.TransportPlanId,
                TransportPlan   = device.TransportPlan
            });

            DeviceMeta metaData = deviceMetaRepository.Find(p => p.DeviceType == deviceType);

            if (metaData == null || string.IsNullOrEmpty(metaData.MetaContent))
            {
                return(this.HttpNotFound());
            }

            string[] chnInfos = metaData.MetaContent.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            var val = chnInfos.Select(p => new DeviceUnitMode {
                Ch   = p.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0],
                Unit = deviceUnitRepository.Get(Convert.ToInt32(p.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[1]))
            });

            ViewBag.chInfos = val;
            return(View(devices));
        }
Beispiel #8
0
 public ActionResult Create()
 {
     ViewBag.Areas = CurrentAvailableAreas.Select(areaToSelectItem).OrderBy(item => item.Text);
     return(View());
 }
Beispiel #9
0
 private IOrderedEnumerable <SelectListItem> GetCurrentSelectableAreaItems()
 {
     return(CurrentAvailableAreas.Select(areaToSelectItem).OrderBy(item => item.Text));
 }