Exemple #1
0
        private void stopHost(HostViewModel hvm)
        {
            if (Settings.Default.HostsBeingStartedOnLastTime == null)
            {
                Settings.Default.HostsBeingStartedOnLastTime = new StringCollection();
            }
            if (Settings.Default.HostsBeingStartedOnLastTime.Contains(hvm.Name))
            {
                Settings.Default.HostsBeingStartedOnLastTime.Remove(hvm.Name);
                Settings.Default.Save();
            }

            var hosts = _hostsManager.DependentHosts(hvm, true).Select(vm => vm.Model);

            foreach (var host in hosts.Reverse().Where(h => h.Link.Status != ELinkStatus.Stopped))
            {
                host.Link.Stop();
                host.Link.WaitForStop(2);
            }

            if (hvm.Model.Link.Status != ELinkStatus.Stopped)
            {
                hvm.Model.Link.Stop();
                hvm.Model.Link.WaitForStop(2);
            }
        }
Exemple #2
0
 private static void startHostAndParentHosts(HostViewModel viewmodel, List <Host> depList)
 {
     foreach (var h1 in depList)
     {
         if (h1.Link.Status == ELinkStatus.Starting)
         {
             h1.Link.Stop();
             if (!h1.Link.WaitForStop())
             {
                 MessageBox.Show(
                     string.Format(
                         Resources.PuttyLink_WaitForStopTimedOut,
                         h1.Info.Name),
                     Util.AssemblyTitle, MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
                 return;
             }
         }
         if (h1.Link.Status == ELinkStatus.Stopped)
         {
             h1.Link.AsyncStart();
             if (!h1.Link.WaitForStart())
             {
                 MessageBox.Show(
                     string.Format(
                         Resources.PuttyLink_WaitForStartTimedOut,
                         h1.Info.Name),
                     Util.AssemblyTitle, MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
                 return;
             }
         }
     }
     viewmodel.Model.Link.AsyncStart();
 }
Exemple #3
0
        public ActionResult Create(HostViewModel hvm)
        {
            if (ModelState.IsValid)
            {
                var host = new Host
                {
                    HostName        = hvm.HostName,
                    IpAddress       = hvm.IpAddress,
                    CPU             = hvm.CPU,
                    DiskSpace       = hvm.DiskSpace,
                    RAM             = hvm.RAM,
                    OperatingSystem = hvm.OperatingSystem,
                    Hypervisor      = hvm.Hypervisors,
                    Date            = hvm.Date
                };

                _host.Add(host);
                _host.SaveChanges();
                TempData["Success"] = "Added Successfully!";

                return(RedirectToAction("Index"));
            }

            else
            {
                return(View(hvm));
            }
        }
Exemple #4
0
        private void fillFiltersTree()
        {
            foreach (var node in treeViewFilter.Nodes[0].Nodes.Cast <TreeNode>().ToArray())
            {
                node.Remove();
            }
            imageListStates.Images.Clear();
            imageListStates.Images.Add(@"Root", Resources.Servers);
            treeViewFilter.Nodes[0].ImageKey         = @"Root";
            treeViewFilter.Nodes[0].SelectedImageKey = @"Root";
            var statuses = Enum.GetValues(typeof(ELinkStatus)).Cast <ELinkStatus>().
                           GroupBy(HostViewModel.GetStatusText).ToArray();

            foreach (var status in statuses)
            {
                imageListStates.Images.Add(status.Key, HostViewModel.GetStatusIcon(status.First()));
            }
            var nodes = statuses.Select(g => new TreeNode(g.Key, imageListStates.Images.IndexOfKey(g.Key),
                                                          imageListStates.Images.IndexOfKey(g.Key))
            {
                Tag = g.ToArray()
            }).ToArray();

            treeViewFilter.Nodes[0].Nodes.AddRange(nodes);
            treeViewFilter.ExpandAll();
            treeViewFilter.SelectedNode = treeViewFilter.Nodes[0];
        }
Exemple #5
0
        private void editHost(HostViewModel host)
        {
            if (host.Model.Link.Status != ELinkStatus.Stopped)
            {
                return;
            }

            var hd = new HostDialog(HostDialog.EMode.EditHost, _hostsManager.HostInfoList)
            {
                Host = host.Model.Info
            };
            var res = hd.ShowDialog(this);

            if (res == DialogResult.Cancel)
            {
                return;
            }

            var dependentHosts =
                _hostsManager.Hosts.Cast <ObjectView <HostViewModel> >().Select(ov => ov.Object).
                Where(m => m.Model.Info.DependsOn == host.Model.Info);

            foreach (var index in dependentHosts.Select(dependentHost => _bindingSource.IndexOf(dependentHost)))
            {
                _bindingSource.ResetItem(index);
            }

            updateHost(host);
            Modified = true;
        }
Exemple #6
0
        public ActionResult Index(string Name)
        {
            var host = HostManager.Current.GetHost(Name);

            if (host == null)
            {
                return(RedirectToRoute(new { Action = "Index", Controller = "Home" }));
            }

            IEnumerable <SelectListItem> availableNetworkDropDownList = host.AvailableNetworks.Select(x => new SelectListItem {
                Text = x.SSID, Value = x.MAC, Selected = x.MAC == host.SelectedNetwork.MAC
            });
            IEnumerable <SelectListItem> availableTargetHostDropDownList = host.AvailableTargetHosts.Select(x => new SelectListItem {
                Text = x.MAC, Value = x.MAC, Selected = x == host.SelectedTargetHost
            });

            var model = new HostViewModel
            {
                Name = host.Name,
                AvailableNetworkDropDownList     = availableNetworkDropDownList ?? Enumerable.Empty <SelectListItem>(),
                AvailableTargetHostsDropDownList = availableTargetHostDropDownList ?? Enumerable.Empty <SelectListItem>(),
                SelectedNetwork    = host.SelectedNetwork ?? nullSelectedNetwork,
                SelectedTargetHost = host.SelectedTargetHost ?? nullSelectedTargetHost
            };

            return(View(model));
        }
        public bool RemoveHost(HostViewModel hvm)
        {
            bool success = Hosts.Remove(hvm);

            RaiseAllPropertiesChanged();
            return(success);
        }
            public void ChangesTriggerPropertyChanged()
            {
                //arrange
                var vm = new HostViewModel();

                //act/assert
                vm.ShouldNotifyOn(s => s.SearchText).When(s => s.SearchText = "Some new Value");
            }
Exemple #9
0
        public void should_throw_exception_navigate_back()
        {
            var vm = new HostViewModel();

            vm.NavigateInternal("main", new object(), Direction.Forward);
            Assert.ThrowsException <ArgumentOutOfRangeException>(
                () => vm.NavigateInternal("main", new object(), Direction.Back, 2));
        }
Exemple #10
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            var window = new HostView();
            var vm     = new HostViewModel();

            window.DataContext = vm;
            window.Show();
        }
Exemple #11
0
        public void should_go_back()
        {
            var    viewModel = new HostViewModel();
            object vm        = new object();

            viewModel.NavigateTo("main", vm);
            viewModel.NavigateTo("main", new object());
            viewModel.GoBack("main");
        }
            public void SetterSetsAndGetterGets()
            {
                //arrange
                var vm = new HostViewModel {
                    SearchText = "Setter Works"
                };

                //act/assert
                Assert.Equal("Setter Works", vm.SearchText);
            }
        public RecordEditorWindow(Record record)
        {
            InitializeComponent();
            ResizeMode            = ResizeMode.NoResize;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            this.Record      = record;
            Host             = new HostViewModel(record.Host.DeepClone());
            Settings         = new XraySettingsViewModel(record.Settings.DeepClone());
            this.DataContext = this;
        }
Exemple #14
0
        private void DataGridHosts_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            HostViewModel model = DataGridHosts.SelectedItem as HostViewModel;

            if (model != null)
            {
                SynchronizationTool.SelectedId = model.HostModel.ElementId;
                SynchronizationTool.ToolAction = ToolAction.ShowItem;
                SynchronizationTool.TheEvent.Raise();
            }
        }
            public void SetsSearchTextToSearchWhenSearchTextIsEmpty()
            {
                //arrange
                var vm = new HostViewModel {
                    SearchText = string.Empty
                };

                //act
                vm.SearchLostFocus(null);

                //assert
                Assert.Equal("Search", vm.SearchText);
            }
            public void SetsSearchTextToEmptyString()
            {
                //arrange
                var vm = new HostViewModel {
                    SearchText = "Some Value"
                };

                //act
                vm.SearchGotFocus(null);

                //assert
                Assert.Equal(string.Empty, vm.SearchText);
            }
            public void DoesntModifySearchTextIfSearchTextIsntEmpty()
            {
                //arrange
                var vm = new HostViewModel {
                    SearchText = "Some String"
                };

                //act
                vm.SearchLostFocus(null);

                //assert
                Assert.Equal("Some String", vm.SearchText);
            }
Exemple #18
0
        public void should_trigger_property_changed()
        {
            var vm = new HostViewModel();

            vm.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName != nameof(vm.Children))
                {
                    Assert.Fail("Property changed should be Children");
                }
            };
            vm.NavigateInternal("main", new object(), Direction.Forward);
        }
 public void CreateViewModel()
 {
     OpeningViewModels = new List <OpeningViewModel>();
     HostViewModels    = new List <HostViewModel>();
     foreach (OpeningModel opm in ComparedOpenings)
     {
         OpeningViewModel viewModel = new OpeningViewModel(opm);
         OpeningViewModels.Add(viewModel);
     }
     foreach (HostModel hm in ComparedHosts)
     {
         HostViewModel hostViewModel = new HostViewModel(hm);
         HostViewModels.Add(hostViewModel);
     }
 }
Exemple #20
0
        void s_LostFocus(object sender, RoutedEventArgs e)
        {
            string new_host = (sender as TextBox).Text;

            if (new_host == org_host)
            {
                return;
            }

            HostViewModel vm = this.DataContext as HostViewModel;

            // delete org host
            vm.Del(org_host);
            // add new host
            vm.Add(new_host);
        }
Exemple #21
0
        public ViewResult HostDetails(int ListID, int HostID)
        {
            HostViewModel ViewModel = new HostViewModel()
            {
                Listings = DBContext.Listings.Include(l => l.Address).Where(l => l.HostID == HostID).ToList(),
                User     = DBContext.Users.Include(u => u.Address).FirstOrDefault(u => u.UserID == HostID),
                ListID   = ListID
            };

            if (HttpContext.Session.GetInt32("LoggedIn") != null)
            {
                ViewModel.LoggedIn = (int)HttpContext.Session.GetInt32("LoggedIn");
            }

            return(View(ViewModel));
        }
        private void AddHost(Host host = null)
        {
            for (int i = 0; i < Hosts.Count; i++)
            {
                if (Hosts[i].IsNew)
                {
                    return;
                }
            }

            host = host ?? new Host();
            Debug.WriteLine("adding host " + host);
            HostViewModel hvm = new HostViewModel(host, this);

            hvm.IsNew = hvm.IsInEditMode = true;
            Hosts.Add(hvm);
            RaiseAllPropertiesChanged();
        }
Exemple #23
0
        // GET: Jonghor
        public ActionResult Index()
        {
            if (Session["Status"] != null && Session["Status"].ToString() == "Owner")
            {
                HostViewModel hostView = new HostViewModel();
                hostView.SetDorm(Session["Username"].ToString());
                return(View("Host_Homepage", hostView));
            }

            else if (Session["Status"] != null && Session["Status"].ToString() == "User")
            {
                return(RedirectToAction("Index", "User"));
            }
            else
            {
                return(View("Homepage"));
            }
        }
Exemple #24
0
        public ActionResult Edit(HostViewModel hvm)
        {
            var host = new Host
            {
                HostName        = hvm.HostName,
                IpAddress       = hvm.IpAddress,
                CPU             = hvm.CPU,
                DiskSpace       = hvm.DiskSpace,
                RAM             = hvm.RAM,
                OperatingSystem = hvm.OperatingSystem,
                Hypervisor      = hvm.Hypervisors,
                Date            = hvm.Date
            };

            if (TryUpdateModel(host))
            {
                _host.Edit(host);
                _host.SaveChanges();
                TempData["Success"] = "Edited Successfully!";
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Exemple #25
0
        private void editHost(HostViewModel host)
        {
            var oldName = host.Name;
            var hd      = new HostDialog(HostDialog.EMode.EditHost, _hostsManager.HostInfoList)
            {
                Host = host.Model.Info
            };
            var res = hd.ShowDialog(this);

            if (res == DialogResult.Cancel)
            {
                return;
            }

            if (Settings.Default.HostsBeingStartedOnLastTime?.Contains(oldName) == true)
            {
                Settings.Default.HostsBeingStartedOnLastTime.Remove(oldName);
                Settings.Default.Save();
            }
            if (host.Model.Link.Status != ELinkStatus.Stopped)
            {
                stopHost(host);
            }

            var dependentHosts =
                _hostsManager.Hosts.Cast <ObjectView <HostViewModel> >().Select(ov => ov.Object).
                Where(m => m.Model.Info.DependsOn == host.Model.Info);

            foreach (var index in dependentHosts.Select(dependentHost => _bindingSource.IndexOf(dependentHost)))
            {
                _bindingSource.ResetItem(index);
            }

            updateHost(host);
            Modified = true;
        }
        public void SelectItemCommand_HostViewModel()
        {
            var mockA = new Mock <IConnctionService>();

            mockA.Setup(x => x.SelectHost(It.IsAny <Host>()));
            //Doods.Framework.Repository.Std.Tables.Host


            LocalAutoMock = AutoMock.GetLoose(cfg => cfg.RegisterMock(mockA));
            SetMockContainer();
            var obj = new HostManagerPageViewModel();

            Assert.IsNotNull(obj);
            Assert.IsNotNull(obj.Title);
            Assert.IsNotNull(obj.ItemsView);
            Assert.IsNotNull(obj.SelectItemCommand);

            var vm = new HostViewModel(new Host());

            Assert.IsTrue(obj.SelectItemCommand.CanExecute(vm));
            obj.SelectItemCommand.Execute(vm);

            mockA.Verify(x => x.SelectHost(It.IsAny <Host>()), Times.Once());
        }
Exemple #27
0
 private void updateHost(HostViewModel host)
 {
     var index2 = _bindingSource.IndexOf(host);
     _bindingSource.ResetItem(index2);
 }
Exemple #28
0
 private static void startHostAndParentHosts(HostViewModel viewmodel, List<Host> depList)
 {
     foreach (var h1 in depList)
     {
         if (h1.Link.Status == ELinkStatus.Starting)
         {
             h1.Link.Stop();
             if (!h1.Link.WaitForStop())
             {
                 MessageBox.Show(
                     string.Format(
                         Resources.PuttyLink_WaitForStopTimedOut,
                         h1.Info.Name),
                     Util.AssemblyTitle, MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
                 return;
             }
         }
         if (h1.Link.Status == ELinkStatus.Stopped)
         {
             h1.Link.AsyncStart();
             if (!h1.Link.WaitForStart())
             {
                 MessageBox.Show(
                     string.Format(
                         Resources.PuttyLink_WaitForStartTimedOut,
                         h1.Info.Name),
                     Util.AssemblyTitle, MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
                 return;
             }
         }
     }
     viewmodel.Model.Link.AsyncStart();
 }
Exemple #29
0
        private void editHost(HostViewModel host)
        {
            if (host.Model.Link.Status != ELinkStatus.Stopped)
                return;

            var hd = new HostDialog(HostDialog.EMode.EditHost, _hostsManager.HostInfoList) {Host = host.Model.Info};
            var res = hd.ShowDialog(this);
            if (res == DialogResult.Cancel)
            {
                return;
            }

            var dependentHosts =
                _hostsManager.Hosts.Cast<ObjectView<HostViewModel>>().Select(ov => ov.Object).
                Where(m => m.Model.Info.DependsOn == host.Model.Info);
            foreach (var index in dependentHosts.Select(dependentHost => _bindingSource.IndexOf(dependentHost)))
            {
                _bindingSource.ResetItem(index);
            }

            updateHost(host);
            Modified = true;
        }
Exemple #30
0
 /// <inheritdoc/>
 public IUiServiceBroker Create(PageViewModel page, HostViewModel host)
 {
     return(new STAMvvmServiceBroker(page, host, Application.Current.Dispatcher.Invoke));
 }
 public TheConstructor()
 {
     vm = new HostViewModel();
 }
 /// <summary>
 /// Inicializa una nueva instancia de la clase
 /// <see cref="STAMvvmServiceBroker"/>.
 /// </summary>
 /// <param name="guest">Página cliente del servicio de UI.</param>
 /// <param name="host">
 /// Host de la página cliente del servicio de UI.
 /// </param>
 /// <param name="uiInvoker">
 /// Delegado que permite ejecutar llamadas en el hilo de UI.
 /// </param>
 public STAMvvmServiceBroker(PageViewModel guest, HostViewModel host, Action <Action> uiInvoker) : base(guest, host)
 {
     _uiInvoker = uiInvoker;
 }
Exemple #33
0
        private void updateHost(HostViewModel host)
        {
            var index2 = _bindingSource.IndexOf(host);

            _bindingSource.ResetItem(index2);
        }