public void GetServices(BO.Host host) { host.Services = new List <BO.Service>(); try { ImpersonateUser iu = new ImpersonateUser(); if (!(string.IsNullOrEmpty(host.Username) || string.IsNullOrEmpty(host.Password))) { iu.Impersonate(host.Domain, host.Username, AES.DecryptString(host.Password)); } System.ServiceProcess.ServiceController[] sc = System.ServiceProcess.ServiceController.GetServices(host.Value); foreach (var s in sc) { host.Services.Add(new BO.Service { Name = s.DisplayName, Value = s.ServiceName, Status = s.Status }); } iu.Undo(); } catch (Exception) { //OnLog(new BO.LogEventArgs(string.Format("Failed to Connect to Server: {0} [{1}]\r\n", host.Name, host.Value ))); } }
void MenuItem_Host_Edit(object sender, RoutedEventArgs e) { WndAddServer editHost = new WndAddServer(); BO.Host host = (BO.Host)lbxHosts.SelectedItem; editHost.Host = host; editHost.ShowDialog(); if (editHost.isValid) { Hosts.Profile[ActiveServers.Name][Hosts.Profile[ActiveServers.Name].IndexOf((BO.Host)lbxHosts.SelectedItem)] = editHost.Host; } lbxHosts.Items.Refresh(); editHost.Reset(); editHost.Close(); }
public void Reset() { this.Host = new BO.Host(); tbxPassword.Password = Password = string.Empty; }