private static void QuickCheck() { try { ServiceController serviceController = new ServiceController(WebSettings.GetServiceName(), WebSettings.GetServiceLocation()); serviceController.ExecuteCommand((int)ServiceCustomCommand.StartCheck); } catch (Exception ex) { new ExceptionLogger().HandleException(ex); } }
private static void StartService() { try { ServiceController serviceController = new ServiceController(WebSettings.GetServiceName(), WebSettings.GetServiceLocation()); if (serviceController.Status == ServiceControllerStatus.Stopped) { serviceController.Start(); } } catch (Exception ex) { new ExceptionLogger().HandleException(ex); } }
/// <summary> /// Gets service status /// </summary> /// <returns>service status string</returns> public static string GetServiceStatus() { try { ServiceController serviceController = new ServiceController(WebSettings.GetServiceName(), WebSettings.GetServiceLocation()); switch (serviceController.Status) { case ServiceControllerStatus.Running: return(ConstExpressions.SERVICE_STATUS_STARTED); case ServiceControllerStatus.Stopped: return(ConstExpressions.SERVICE_STATUS_STOPPED); default: return(ConstExpressions.SERVICE_STATUS_PAUSED); } } catch (Exception ex) { return(((ex.InnerException != null) ? ex.InnerException.Message + ". " : "") + ex.Message); } }