public virtual Object StopTask(RCM_Cmd rc) { var tid = rc.Val("tid", ""); var res = Util.NewDict(); if (String.IsNullOrWhiteSpace(tid)) { res["code"] = -1; res["err"] = "DTM_C the tid is requied"; return res; } try { Process proc = null; if (this.Tasks.TryGetValue(tid, out proc)) { proc.Kill(); res["code"] = 0; } else { res["code"] = -3; res["err"] = String.Format("DTM_C stop task fail with runner is not found by id({0})", tid); } } catch (Exception e) { res["code"] = -2; res["err"] = String.Format("DTM_C stop task fail with {0}", e.Message); } return res; }
public virtual Object WaitTask(RCM_Cmd rc) { var tid = rc.Val("tid", ""); var res = Util.NewDict(); if (String.IsNullOrWhiteSpace(tid)) { res["code"] = -1; res["err"] = "DTM_C the tid is requied"; return res; } try { Process proc = null; if (this.Tasks.TryGetValue(tid, out proc)) { proc.WaitForExit(); } res["code"] = 0; } catch (Exception e) { res["code"] = -2; res["err"] = String.Format("DTM_C wait task fail with {0}", e.Message); } return res; }
public virtual Object StartTask(RCM_Cmd rc) { var tid = rc.Val("tid", ""); var cmds = rc.Val("cmds", ""); var res = Util.NewDict(); if (String.IsNullOrWhiteSpace(tid) || String.IsNullOrWhiteSpace(cmds)) { res["code"] = -1; res["err"] = "DTM_C the tid/cmds is requied"; return res; } try { this.RunCmd(tid, cmds); res["code"] = 0; res["tid"] = tid; } catch (Exception e) { res["code"] = -2; res["err"] = String.Format("DTM_C start command fail with {0}", e.Message); L.E(e, "DTM_C start command(\n{0}\n) fail with error {1}", cmds, e.Message); } return res; }