Exemplo n.º 1
0
        public List <EntityComputer> GetScheduleComputers(int scheduleId, string type)
        {
            var groups = new List <EntityGroup>();

            if (type.Equals("wakeup"))
            {
                groups = _uow.GroupRepository.Get(x => x.WakeupScheduleId == scheduleId);
            }
            else if (type.Equals("shutdown"))
            {
                groups = _uow.GroupRepository.Get(x => x.ShutdownScheduleId == scheduleId);
            }
            else
            {
                return(new List <EntityComputer>());
            }

            var groupService = new ServiceGroup();
            var computers    = new List <EntityComputer>();

            foreach (var group in groups)
            {
                computers.AddRange(groupService.GetGroupMembers(group.Id));
            }

            return(computers.GroupBy(x => x.Id).Select(y => y.First()).ToList());
        }
Exemplo n.º 2
0
        public DtoActionResult InsertOrUpdate(EntityActiveGroupPolicy activeGroupPolicy)
        {
            var actionResult = new DtoActionResult();
            var p            = new ServiceGroup().GetActiveGroupPolicy(activeGroupPolicy.GroupId);

            if (p == null)
            {
                //insert
                _uow.ActiveGroupPoliciesRepository.Insert(activeGroupPolicy);
                _uow.Save();
                actionResult.Success = true;
                actionResult.Id      = activeGroupPolicy.Id;
            }
            else
            {
                //update
                activeGroupPolicy.Id = p.Id;
                _uow.ActiveGroupPoliciesRepository.Update(activeGroupPolicy, activeGroupPolicy.Id);
                _uow.Save();
                actionResult.Success = true;
                actionResult.Id      = activeGroupPolicy.Id;
            }

            return(actionResult);
        }
Exemplo n.º 3
0
        public DtoActionResult Delete(int imageId)
        {
            var u = GetImage(imageId);

            if (u == null)
            {
                return new DtoActionResult {
                           ErrorMessage = "Image Not Found", Id = 0
                }
            }
            ;

            if (u.Protected)
            {
                return(new DtoActionResult {
                    ErrorMessage = "This Image Is Protected And Cannot Be Deleted", Id = u.Id
                });
            }

            _uow.ImageRepository.Delete(imageId);
            _uow.Save();
            var actionResult = new DtoActionResult();

            actionResult.Success = true;
            actionResult.Id      = u.Id;

            //Check if image name is empty or null, return if so or something will be deleted that shouldn't be
            if (string.IsNullOrEmpty(u.Name))
            {
                return(actionResult);
            }

            var computers       = _uow.ComputerRepository.Get(x => x.ImageId == imageId);
            var computerService = new ServiceComputer();

            foreach (var computer in computers)
            {
                computer.ImageId        = -1;
                computer.ImageProfileId = -1;
                computerService.UpdateComputer(computer);
            }

            var groups       = _uow.GroupRepository.Get(x => x.ImageId == imageId);
            var groupService = new ServiceGroup();

            foreach (var group in groups)
            {
                group.ImageId        = -1;
                group.ImageProfileId = -1;
                groupService.UpdateGroup(group);
            }

            var delDirectoryResult = new FilesystemServices().DeleteImageFolders(u.Name);

            return(actionResult);
        }
Exemplo n.º 4
0
        public DtoActionResult Delete(int imageProfileId)
        {
            var u = GetImageProfile(imageProfileId);

            if (u == null)
            {
                return new DtoActionResult {
                           ErrorMessage = "ImageProfile Not Found", Id = 0
                }
            }
            ;
            _uow.ImageProfileRepository.Delete(imageProfileId);
            _uow.Save();

            var computers       = _uow.ComputerRepository.Get(x => x.ImageProfileId == imageProfileId);
            var computerService = new ServiceComputer();

            foreach (var computer in computers)
            {
                computer.ImageProfileId = -1;

                computerService.UpdateComputer(computer);
            }

            var groups       = _uow.GroupRepository.Get(x => x.ImageProfileId == imageProfileId);
            var groupService = new ServiceGroup();

            foreach (var group in groups)
            {
                group.ImageProfileId = -1;
                groupService.UpdateGroup(group);
            }

            var actionResult = new DtoActionResult();

            actionResult.Success = true;
            actionResult.Id      = u.Id;
            return(actionResult);
        }