private void KillAllSubProcesses() { foreach (var entry in RunningBackups) { entry.Value.Kill(); } RunningBackups.Clear(); foreach (var entry in RunningRestores) { entry.Value.Kill(); } RunningRestores.Clear(); }
private void OnControlPlanKill(object sender, ServerCommandEventArgs e) { string planType = e.Command.GetArgumentValue <string>("planType"); Int32 planId = e.Command.GetArgumentValue <Int32>("planId"); Process processToBeKilled = null; bool isBackup = planType.Equals(PlanTypeEnum.BACKUP.ToString().ToLowerInvariant()); bool isRestore = planType.Equals(PlanTypeEnum.RESTORE.ToString().ToLowerInvariant()); if (isBackup) { RunningBackups.TryGetValue(planId, out processToBeKilled); } else if (isRestore) { RunningRestores.TryGetValue(planId, out processToBeKilled); } if (processToBeKilled == null) { string msg = Commands.ReportError(0, "{0} plan #{1} is not running", planType.ToTitleCase(), planId); Handler.Send(e.Context, msg); return; } processToBeKilled.Kill(); if (isBackup) { RunningBackups.Remove(planId); } else if (isRestore) { RunningRestores.Remove(planId); } }