public string IsStopDispatchHander(out string statusCode, out string errMsg) { statusCode = "0000"; errMsg = ""; if (!ServiceToolEx.IsServiceRunning(dispatchServerName)) { errMsg = dispatchServerName + "服务未运行"; statusCode = "4000"; return(""); } ServiceController service = ServiceToolEx.StopService(dispatchServerName); if (service == null) { errMsg = dispatchServerName + "服务停止失败"; statusCode = "4001"; return(""); } if (!ServiceToolEx.IsServiceRunning(dispatchServerName)) { return(dispatchServerName + "服务已停止"); } else { errMsg = dispatchServerName + "服务停止失败!" + ErrorPolicy; statusCode = "4005"; return(""); } }
// 停止服务 public string IsStopCoreHander(out string statusCode, out string errMsg) { statusCode = "0000"; errMsg = ""; if (!ServiceToolEx.IsServiceRunning(serverName)) { errMsg = serverName + "服务未运行"; statusCode = "4000"; return(""); } ServiceController service = ServiceToolEx.StopService(serverName); if (service == null) { errMsg = serverName + "服务停止失败"; statusCode = "4001"; return(""); } if (ServiceToolEx.IsServiceRunning(serverName)) { errMsg = serverName + "服务停止失败!" + ErrorPolicy; statusCode = "4005"; return(""); } string dispatchInfo = IsStopDispatchHander(out statusCode, out errMsg); return(serverName + "服务已停止;" + dispatchInfo); }
public bool IsDispatchServiceRun() { if (!ServiceToolEx.IsServiceExist(dispatchServerName)) { return(false); } return(ServiceToolEx.IsServiceRunning(dispatchServerName)); }
// 服务是否在运行 public bool IsCoreServiceRun() { if (!ServiceToolEx.IsServiceExist(serverName)) { return(false); } return(ServiceToolEx.IsServiceRunning(serverName)); }
public void RefreshControlState() { Config.ServerIsRuning = false; if (!EnvIsOkay) { this.isInstal.Enabled = false; this.isUnInstal.Enabled = false; this.iStart.Enabled = false; this.isStop.Enabled = false; this.IsRestart.Enabled = false; return; } if (ServiceToolEx.IsServiceExist(Config.envConfigInfo.confProjectInfo.ServerName)) { // 工具栏 this.isInstal.Enabled = false; this.isUnInstal.Enabled = true; this.IsRestart.Enabled = true; // 菜单栏 if (ServiceToolEx.IsServiceRunning(Config.envConfigInfo.confProjectInfo.ServerName)) { this.toolStripStatusLabel4.Text = "正在运行"; this.toolStripStatusLabel4.ForeColor = Color.ForestGreen; this.isStop.Enabled = true; this.iStart.Enabled = false; Config.ServerIsRuning = true; } else { this.toolStripStatusLabel4.Text = "已停止"; this.toolStripStatusLabel4.ForeColor = Color.Red; this.iStart.Enabled = true; this.isStop.Enabled = false; } } else { this.toolStripStatusLabel4.Text = "未注册"; this.isInstal.Enabled = true; this.isUnInstal.Enabled = false; this.iStart.Enabled = false; this.isStop.Enabled = false; this.IsRestart.Enabled = false; } this.textBoxTrace.BackColor = Color.FromArgb(0, 64, 0); this.textBoxTrace.ForeColor = Color.Lime; this.Text = GetTitleText(); this.toolStripStatusProjectName.Text = Config.envConfigInfo.confProjectInfo.ProjectName; }
public string IsRestartDispatchHander(out string statusCode, out string errMsg) { statusCode = "0000"; errMsg = ""; if (!ServiceToolEx.IsServiceExist(dispatchServerName)) { errMsg = dispatchServerName + "服务不存在请先注册"; statusCode = "4000"; return(""); } ServiceController service; if (ServiceToolEx.IsServiceRunning(dispatchServerName)) { service = ServiceToolEx.StopService(dispatchServerName); if (service == null) { service = null; errMsg = dispatchServerName + "服务停止失败"; statusCode = "4001"; return(""); } if (ServiceToolEx.IsServiceRunning(dispatchServerName)) { errMsg = dispatchServerName + "服务停止失败!" + ErrorPolicy; statusCode = "4005"; return(""); } } service = ServiceToolEx.StartService(dispatchServerName, new string[0]); if (service == null) { errMsg = dispatchServerName + "服务启动失败"; statusCode = "4002"; return(""); } if (ServiceToolEx.IsServiceRunning(dispatchServerName)) { return(serverName + "服务已重新启动"); } else { errMsg = dispatchServerName + "服务启动失败!" + ErrorPolicy; statusCode = "4005"; return(""); } }
public string IsStartDispatchHander(out string statusCode, out string errMsg) { statusCode = "0000"; errMsg = ""; if (!ServiceToolEx.IsServiceExist(dispatchServerName)) { errMsg = dispatchServerName + "服务不存在"; statusCode = "4004"; return(""); } string curFilePath = ServiceToolEx.GetWindowsServiceInstallPath(dispatchServerName); if (curFilePath.ToUpper() != new DirectoryInfo(dispatchIotServerPath).Parent.FullName.ToUpper()) { errMsg = dispatchServerName + "服务路径不一致,请先卸载原来路径的服务:" + curFilePath; statusCode = "4007"; return(""); } if (ServiceToolEx.IsServiceRunning(dispatchServerName)) { errMsg = dispatchServerName + "服务已经在运行"; statusCode = "4000"; return(""); } ServiceController service = ServiceToolEx.StartService(dispatchServerName, new string[0]); if (service == null) { errMsg = dispatchServerName + "服务启动失败"; statusCode = "4001"; } if (ServiceToolEx.IsServiceRunning(dispatchServerName)) { return(dispatchServerName + "服务已启动"); } else { errMsg = dispatchServerName + "服务启动失败!" + ErrorPolicy; statusCode = "4005"; return(""); } }