| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Text;
- using System.ConsoleApp;
- using System.ConsoleApp.Commands;
- using Keln.Progress;
- namespace Keln.Commands.Service {
-
- public class ServiceState : BaseCommand {
- [ConsoleCommand("servicestate")]
- [ConsoleCommand("ss")]
- public static bool execute(string line, string cmd, NameValueCollection arguments) {
- switch(arguments["general"].ToLower().Trim()) {
- case "deviceemotion":
- case "de":
- writeProcessInfo("deviceemotion");
- break;
- case "speech":
- case "say":
- writeProcessInfo("speech");
- break;
- case "sozoti":
- case "sozi":
- writeProcessInfo("sozoti");
- break;
- case "sambale":
- case "learning":
- writeProcessInfo("sambale");
- break;
- case "intensi":
- case "intent":
- writeProcessInfo("intensi");
- break;
- case "gregorcalendus":
- case "gregor":
- case "calender":
- case "calendus":
- writeProcessInfo("gregor");
- break;
- case "":
- case "?":
- BeginWrite();
- WriteLine(new NameValueCollection() {
- { "deviceemotion", "" },
- { "speech", "" },
- { "sozoti", "" },
- { "sambale", "" },
- { "intensi", "" },
- { "gregorcalendus", "" }
- });
- EndWrite();
- break;
- }
- return false;
- }
- protected static void writeProcessInfo(ProcessInfo pi) {
- BeginWrite();
- WriteLine( new NameValueCollection() {
- { "Name", pi.ProcessName },
- { "ExitCode", pi.ExitCode.ToString() },
- { "State", pi.State.ToString() },
- { "StartTime", pi.StartTime.ToString("dddd, dd MMMM yyyy HH:mm:ss") },
- { "Total Processor Time", pi.TotalProcessorTime.ToString("dddd, dd MMMM yyyy HH:mm:ss") },
- { "User Processor Time", pi.UserProcessorTime.ToString("dddd, dd MMMM yyyy HH:mm:ss") },
- { "Peak Paged Memory Size", pi.PeakPagedMemorySize64.ToString("N") },
- { "Paged Memory Size", pi.PagedMemorySize64.ToString("N") },
- { "Paged System Memory Size", pi.PagedSystemMemorySize64.ToString("N") },
-
- { "V-Memory Size", pi.VirtualMemorySize64.ToString("N") },
- { "Peak V-Memory Size", pi.PeakVirtualMemorySize64.ToString("N") },
- { "Private Memory Size", pi.PrivateMemorySize64.ToString("N") }
- });
- EndWrite();
- }
- protected static void writeProcessInfo(string pi) {
- BeginWrite();
- if(Program.processes.ContainsKey(pi)) {
- writeProcessInfo(Program.processes[pi]);
- } else {
- WriteLine("Process not found: '" + pi + "'");
- WriteLine("Processes in list: ");
- foreach(string key in Program.processes.Keys) {
- Write("> ", ConsoleColor.Blue);
- WriteLine(key);
- }
- }
- EndWrite();
- }
- }
- }
|