Exemplo n.º 1
0
        public async Task OnGetAsync()
        {
            var user = _applicationDbContext.Users
                       .Include(u => u.UserManagerUsers)
                       .FirstOrDefault(u => u.UserName == HttpContext.User.Identity.Name);

            Dashboard = new DashboardModel();

            var managers = _applicationDbContext.Managers
                           .Include(m => m.Users)
                           .ToList();

            if (managers != null)
            {
                // Fill the MapNodes to the Map component
                Dashboard.MapNodes = managers.Select(m => new MapNode(m.Name, $"{m.IP}/{m.Port}", m.Latitude, m.Longitude)).ToList();

                // Get all the Inactive RSUs for the DownRSU component
                foreach (var manager in managers)
                {
                    var managerUser = user.UserManagerUsers.FirstOrDefault(umu => umu.ManagerUserManagerId == manager.Id)?.ManagerUser;
                    if (managerUser != null)
                    {
                        var rsus = await _rsuService.GetAsync(managerUser);

                        if (rsus != null)
                        {
                            Dashboard.DownRSUs.AddRange(rsus.Where(r => r.Active == false));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public async Task OnGetAsync(int?managerId)
        {
            var user = _applicationDbContext.Users
                       .Include(u => u.UserManagerUsers)
                       .FirstOrDefault(u => u.UserName == HttpContext.User.Identity.Name);

            RSUs = new List <RSU>();

            if (managerId.HasValue)
            {
                var manager = _applicationDbContext.Managers
                              .Include(m => m.Users)
                              .FirstOrDefault(m => m.Id == managerId);
                if (manager == null)
                {
                    NotFound($"No manager with id: {managerId}");
                }

                var managerUser = user.UserManagerUsers.FirstOrDefault(umu => umu.ManagerUserManagerId == manager.Id)?.ManagerUser;

                if (managerUser == null)
                {
                    NotFound($"There's no Manager User assigned to this User, with {manager.Name} Manager");
                }

                var rsus = await _rsuService.GetAsync(managerUser);

                if (rsus != null)
                {
                    RSUs = rsus.ToList();
                }
            }
            else
            {
                var managers = _applicationDbContext.Managers
                               .Include(m => m.Users)
                               .ToList();
                if (managers == null)
                {
                    NotFound("There are no managers");
                }

                foreach (var manager in managers)
                {
                    var managerUser = user.UserManagerUsers.FirstOrDefault(umu => umu.ManagerUserManagerId == manager.Id)?.ManagerUser;
                    if (managerUser != null)
                    {
                        var rsus = await _rsuService.GetAsync(managerUser);

                        if (rsus != null)
                        {
                            RSUs.AddRange(rsus);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync(int?id, int?managerId)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            var user = _applicationDbContext.Users
                       .Include(u => u.UserManagerUsers)
                       .FirstOrDefault(u => u.UserName == HttpContext.User.Identity.Name);

            if (user == null)
            {
                // TODO finish
            }

            if (!managerId.HasValue)
            {
                return(NotFound());
            }

            var manager = _applicationDbContext.Managers
                          .Include(m => m.Users)
                          .FirstOrDefault(m => m.Id == managerId.Value);

            if (manager == null)
            {
                return(NotFound());
            }

            var managerUser = user.UserManagerUsers.FirstOrDefault(umu => umu.ManagerUserManagerId == managerId)?.ManagerUser;

            if (managerUser == null)
            {
                NotFound($"There's no Manager User assigned to this User, with {RSU.Manager.Name} Manager");
            }

            RSU = await _rsuService.GetAsync(managerUser, id.Value);

            if (RSU == null)
            {
                return(NotFound());
            }

            return(Page());
        }
Exemplo n.º 4
0
        private async Task LoadRSUData(int managerId, int rsuId)
        {
            RSUDetail = new RSUDetail();

            var user = await _applicationDbContext.Users
                       .Include(u => u.UserManagerUsers)
                       .FirstOrDefaultAsync(u => u.UserName == HttpContext.User.Identity.Name);

            var manager = await _applicationDbContext.Managers
                          .Include(m => m.Users)
                          .FirstOrDefaultAsync(m => m.Id == managerId);

            if (manager == null)
            {
                NotFound($"No manager with id: {managerId}");
            }
            var manageruser = user.UserManagerUsers.FirstOrDefault(umu => umu.ManagerUserManagerId == manager.Id)?.ManagerUser;

            RSUDetail.Rsu = await _rsuService.GetAsync(manageruser, rsuId);

            if (RSUDetail.Rsu != null)
            {
                object temp = SetData(manageruser, rsuId, "0.1.15628.4.1.8.8");
                if (temp != null)
                {
                    RSUDetail.Elevation = ((double)(int)temp) / 1000000;
                    temp = SetData(manageruser, rsuId, "0.1.15628.4.1.8.9");
                }
                if (temp != null)
                {
                    RSUDetail.FrequencyDefault = (int)temp;
                    temp = SetData(manageruser, rsuId, "0.1.15628.4.1.8.10");
                }
                if (temp != null)
                {
                    RSUDetail.FrequencySecondary = (int)temp;
                    temp = SetData(manageruser, rsuId, "0.1.15628.4.1.8.13");
                }
                if (temp != null)
                {
                    RSUDetail.BandwidthDefault = (int)temp;
                    temp = SetData(manageruser, rsuId, "0.1.15628.4.1.8.14");
                }
                if (temp != null)
                {
                    RSUDetail.BandwidthSecondary = (int)temp;
                    temp = SetData(manageruser, rsuId, "0.1.15628.4.1.9.15");
                }
                if (temp != null)
                {
                    RSUDetail.Cam = StringToBool((string)temp);
                    temp          = SetData(manageruser, rsuId, "0.1.15628.4.1.9.16");
                }
                if (temp != null)
                {
                    RSUDetail.Denm = StringToBool((string)temp);
                    temp           = SetData(manageruser, rsuId, "0.1.15628.4.1.9.20");
                }
                if (temp != null)
                {
                    RSUDetail.Ldm = StringToBool((string)temp);
                }
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnGetAsync(int?managerId, int?rsuId)
        {
            var user = _applicationDbContext.Users
                       .Include(u => u.UserManagerUsers)
                       .FirstOrDefault(u => u.UserName == HttpContext.User.Identity.Name);

            TrapLogs = new List <TrapLogViewModel>();

            if (managerId.HasValue)
            {
                var manager = _applicationDbContext.Managers
                              .Include(m => m.Users)
                              .FirstOrDefault(m => m.Id == managerId);
                if (manager == null)
                {
                    return(NotFound($"There are no manager with id: {managerId}"));
                }
                if (manager.Users == null || manager.Users.Count == 0)
                {
                    return(NotFound($"There are no user for manager {managerId}"));
                }

                Manager = manager;

                var managerUser = user.UserManagerUsers.FirstOrDefault(umu => umu.ManagerUserManagerId == manager.Id)?.ManagerUser;

                if (managerUser == null)
                {
                    return(NotFound($"There's no Manager User assigned to this User, with {manager.Name} Manager"));
                }

                IEnumerable <TrapLog> trapLogs;
                List <RSU>            rsus = new List <RSU>();
                if (rsuId.HasValue)
                {
                    trapLogs = await _TrapLogService.GetAsync(managerUser, rsuId.Value);

                    if (trapLogs != null)
                    {
                        var rsu = await _rsuService.GetAsync(managerUser, rsuId.Value);

                        rsus.Add(rsu);
                    }
                }
                else
                {
                    trapLogs = await _TrapLogService.GetAsync(managerUser);

                    if (trapLogs != null)
                    {
                        rsus.AddRange(await _rsuService.GetAsync(managerUser));
                    }
                }

                if (trapLogs != null)
                {
                    TrapLogs = trapLogs.Select(tl => new TrapLogViewModel(rsus.FirstOrDefault(r => r.Id == tl.SourceRsuId), tl)).ToList();
                }
            }

            return(Page());
        }