#pragma warning disable CC0091 // Use static method #pragma warning disable CC0038 // You should use expression bodied members whenever possible. bool CheckWindowsService() #pragma warning restore CC0091 // Use static method { #if DEBUG return(true); #else IWindowsServiceManager windowsServiceManager = CustomContainer.Get <IWindowsServiceManager>(); IPopupController popup = CustomContainer.Get <IPopupController>(); ServerServiceConfiguration ssc = new ServerServiceConfiguration(windowsServiceManager, popup); if (ssc.DoesServiceExist()) { if (ssc.IsServiceRunning()) { return(true); } if (ssc.PromptUserToStartService()) { if (ssc.StartService()) { _serverServiceStartedFromStudio = true; return(true); } } } return(false); #endif }
public WindowsServicesControl() : base() { _windowsServiceManager = DependencyManager.WindowsServiceManager; TabTitle = "Windows Services"; InitializeComponent(); }
/* * DELETE THIS METHOD AND LOOSE A VERY IMPORTANT PART OF YOU ;) * * IT IS REQUIRED FOR UPDATES IN RELEASE MODE ;) * REMOVING IT MEANS IT IS NOT POSSIBLE TO BUILD AN INSTALLER ;) */ // ReSharper disable once UnusedMember.Local private bool CheckWindowsService() { IWindowsServiceManager windowsServiceManager = CustomContainer.Get <IWindowsServiceManager>(); IPopupController popup = CustomContainer.Get <IPopupController>(); ServerServiceConfiguration ssc = new ServerServiceConfiguration(windowsServiceManager, popup); if (ssc.DoesServiceExist()) { if (ssc.IsServiceRunning()) { return(true); } if (ssc.PromptUserToStartService()) { if (ssc.StartService()) { _serverServiceStartedFromStudio = true; return(true); } } } return(false); }
private void lstServers_SelectedIndexChanged(object sender, EventArgs e) { grpManageService.Enabled = lstServers.SelectedItems.Count > 0; btnDeleteMachine.Enabled = lstServers.SelectedItems.Count > 0; if (lstServers.SelectedItems.Count > 0) { _selectedMachine = _machines.First(x => x.Name.Equals(lstServers.SelectedItem.ToString())); IWindowsServiceManager windowsServiceManager = null; if (_selectedMachine.IsWmiEnabled) { windowsServiceManager = new WMIWindowServiceManager(); dgvManageServices.DataSource = bsDgvServices; bsDgvServices.DataSource = windowsServiceManager.GetServices(_selectedMachine); var dataGridViewColumn = dgvManageServices.Columns["Machine"]; if (dataGridViewColumn != null) { dataGridViewColumn.Visible = false; } var gridViewColumn = dgvManageServices.Columns["IsSelected"]; if (gridViewColumn != null) { gridViewColumn.Visible = false; } } else { MessageBox.Show("Information", "WMI Not Enabled in the machine"); } } else { bsDgvServices.DataSource = new List <WindowsService>(); } }
public WindowsServicesControl() { _logWriter = DependencyManager.LogWriter; _windowsServiceManager = DependencyManager.WindowsServiceManager; _logWriter.LogInfo("Windows Services initializing."); DataContext = _model; }
private void brnFindService_Click(object sender, EventArgs e) { if (txtService.Text.Trim().Length <= 0) { return; } var selectedMachine = _machines.First(x => x.Name.Equals(lstServers.SelectedItem.ToString())); var services = new frmListServices(selectedMachine, txtService.Text); services.ShowDialog(); foreach (var service in CommonPlace.PickedUpWindowsServices) { if (_selectedMachine.Services.Any(x => x.Name.Equals(service.Name))) { _selectedMachine.Services.Remove(_selectedMachine.Services.First(x => x.Name.Equals(service.Name))); } _selectedMachine.Services.Add(service); } var serviceNameArray = selectedMachine.Services.Select(x => x.Name).ToArray(); selectedMachine.Services.Clear(); for (var i = 0; i < serviceNameArray.Count(); i++) { IWindowsServiceManager windowsServiceManager = null; if (_selectedMachine.IsWmiEnabled) { windowsServiceManager = new WMIWindowServiceManager(); var service = windowsServiceManager.GetService(_selectedMachine, serviceNameArray[i]); if (service != null) { selectedMachine.Services.Add(service); } } else { MessageBox.Show("Information", "WMI Not Enabled in the machine"); } } bsDgvServices.DataSource = selectedMachine.Services; //dgvManageServices.DataSource = bsDgvServices; var dataGridViewColumn = dgvManageServices.Columns["Machine"]; if (dataGridViewColumn != null) { dataGridViewColumn.Visible = false; } var gridViewColumn = dgvManageServices.Columns["IsSelected"]; if (gridViewColumn != null) { gridViewColumn.Visible = false; } dgvManageServices.ResetBindings(); }
public MicroService(IWindowsServiceManager windowsServiceManager, MicroServiceOptions options) { _windowsServiceManager = windowsServiceManager; _options = options; _optionSet = ServiceOptions(); InternalService.OsStarted += Start; InternalService.OsStopped += Stop; ProjectInstaller.InitInstaller(options.DisplayName, options.ServiceName); }
private void frmListServices_Load(object sender, EventArgs e) { if (_machine.IsWmiEnabled) { _windowsServiceManager = new WMIWindowServiceManager(); } else { MessageBox.Show("Information", "WMI Not Enabled in the machine"); return; } lstServers.DataSource = _windowsServiceManager.ListServices(_machine, _serviceNameLike).ToList(); }
public WindowsServicesControl() { _logWriter = DependencyManager.Resolve <ILogWriter>(); _windowsServiceManager = DependencyManager.Resolve <IWindowsServiceManager>(); _logWriter.LogInfo("Windows Services initializing."); DataContext = _model; if (!DesignerProperties.GetIsInDesignMode(this)) { SetRuntimeOptions(); } _logWriter.LogInfo("Windows Services initialized."); }
private void btnFindMachine_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtUsername.Text)) { _machine.UserName = txtUsername.Text; _machine.Password = txtPassword.Text; IWindowsServiceManager windowsServiceManager = null; if (_machine.IsWmiEnabled) { windowsServiceManager = new WMIWindowServiceManager(); } else { MessageBox.Show("WMI Not Enabled in the machine", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } CommonPlace.IsMachineFound = windowsServiceManager.CanTheMachineBeFound(_machine); this.Close(); } else { MessageBox.Show("Username Cannot be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ServerServiceConfiguration(IWindowsServiceManager serviceManager, IPopupController popupController) : this(serviceManager) { PopupController = popupController; }
public ServerServiceConfiguration(IWindowsServiceManager serviceManager) { ServiceManager = serviceManager; }