/// <summary>显示状态</summary> protected void ShowStatus() { Consoles.WriteLine("*************************************************", ConsoleColor.Red); var service = Instance; var name = service.ServiceName; Console.Write("服务:"); Consoles.WriteLine(name != service.DisplayName ? $"{service.DisplayName}({name})" : $"{name}", ConsoleColor.Red); Console.Write("描述:"); Consoles.WriteLine(service.Description, ConsoleColor.Red); Console.Write("状态:"); string status; switch (WinServer.IsInstalled(service.ServiceName)) { case null: status = "未知"; break; case false: status = "未安装"; break; default: switch (WinServer.IsRunning(service.ServiceName)) { case null: status = "未知"; break; case false: status = "未启动"; break; default: status = "运行中"; break; } break; } Consoles.WriteLine(status, ConsoleColor.Green); Consoles.WriteLine("*************************************************", ConsoleColor.Red); }
/// <inheritdoc /> protected override void ReceiveShowTaskList() { var sum = _taskList.Sum(o => o.Tasks.Length); var index = 0; foreach (var task in _taskList) { Consoles.WriteLine($"{ConvertShow(task)}", ConsoleColor.Yellow); foreach (var taskEntity in task.Tasks) { Console.Write($"\t{(index++).PadLeft(sum.ToString().Length)}:"); Consoles.WriteLine(taskEntity.Caption, ConsoleColor.Green); } Console.WriteLine(); } }
/// <summary>显示菜单</summary> protected void ShowMenu() { var sp = new StrPlus(); sp.AppendLine(new string('*', 50)); sp.AppendLine("1 显示状态"); if (WinServer.IsInstalled(ServiceName) == true) { if (WinServer.IsRunning(ServiceName) == true) { sp.AppendLine("3 停止服务 -stop"); } else { sp.AppendLine("2 卸载服务 -u"); sp.AppendLine("3 启动服务 -start"); } } else { sp.AppendLine("2 安装服务 -i"); } if (_isTimingService) { sp.AppendLine("4 单步调试 -step"); } sp.AppendLine("5 循环调试 -run"); if (_isTimingService) { sp.AppendLine("6 任务列表 -show"); } sp.AppendLine("0 退出"); sp.AppendLine(new string('*', 50)); Consoles.WriteLine(sp.ToString(), ConsoleColor.Yellow); }
/// <summary>服务启动事件</summary> protected override void OnStart(string[] args) { _isAutoStartServer = true; Consoles.WriteLine("服务启动", ConsoleColor.Red); Start(args); }