Esempio n. 1
0
        public static void Deal(string content)
        {
            bool success = JsonUtil.ParseStruct <OperationStruct>(content, out OperationStruct os);

            if (success)
            {
                switch (os.type)
                {
                case OperationType.Add:
                    OperationClerk.AddProcess(os.pathName);
                    break;

                case OperationType.Remove:
                    OperationClerk.RemoveProcess(os.pathName);
                    break;

                case OperationType.Start:
                    OperationClerk.StartProcess(os.pathName, os.args);
                    break;

                case OperationType.Stop:
                    OperationClerk.StopProcess(os.pathName);
                    break;

                default:
                    LogClerk.Warn("Invalid OperationType.");
                    break;
                }
            }
        }
Esempio n. 2
0
        private static void OnProcessExit(object sender, EventArgs e)
        {
            Process       ps       = sender as Process;
            string        pathName = ps.StartInfo.FileName;
            ProcessStruct pst      = Processes[pathName];

            pst.isRunning       = false;
            Processes[pathName] = pst;
            OperationClerk.OnProcessStopped(pathName, FPName[pathName]);
            LogClerk.Info($"Process {FPName[pathName]} exited");
        }
Esempio n. 3
0
        public static void Deal(string content)
        {
            bool success = JsonUtil.ParseStruct <NurseryStruct>(content, out NurseryStruct ns);

            if (success)
            {
                switch (ns.type)
                {
                case NurseryType.Setting:
                    DealWithConfig(ns.content);
                    break;

                case NurseryType.Operation:
                    OperationClerk.Deal(ns.content);
                    break;

                default:
                    LogClerk.Warn($"Invalid nursery type. {content}");
                    break;
                }
            }
        }