private void ServiceCommand(ServiceCommandType commandType) { Console.WriteLine(String.Format("ServiceCommand: {0}", commandType.ToString())); LogWriter.WriteLogEntry(String.Format("ServiceCommand: {0}", commandType.ToString())); if (commandType == ServiceCommandType.Start) { StartService(); } else if (commandType == ServiceCommandType.Stop) { StopService(); } else if (commandType == ServiceCommandType.Restart) { StopService(); StartService(); } }
protected virtual void ExecuteServiceCommand(MdxQueryArgs query_args, ServiceCommandType actionType) { if (query_args != null) { IsWaiting = true; LogManager.LogInformation(this, this.Name + " - Service command: " + actionType.ToString()); OlapDataLoader.LoadData(query_args, actionType); } }
private void ServiceCommand(string serviceName, ServiceCommandType commandType) { Console.WriteLine(String.Format("ServiceCommand: {0}, CommandType: {1}", serviceName, commandType.ToString())); if (Utilities.IsInstalledWindowsService(serviceName)) { ServiceController service = new ServiceController(serviceName); ServiceControllerStatus stat = ServiceControllerStatus.Running; try { stat = service.Status; } catch (Exception ex) { LogWriter.WriteLogEntry(ex); } if (commandType == ServiceCommandType.Stop) { if (stat != ServiceControllerStatus.Stopped) { try { if (service.CanStop) { service.Stop(); } } catch (Exception ex) { LogWriter.WriteLogEntry(ex); } } } else if (commandType == ServiceCommandType.Start) { if (stat != ServiceControllerStatus.Running) { try { service.Start(); } catch (Exception ex) { LogWriter.WriteLogEntry(ex); } } } } }