public void LaunchScriptWithParams(string name, PowerShellParam psParam) { var jobServices = new JobServices(_scriptRepository); //ToDo: Add Logic to Return True / False if successful var script = _scriptRepository.GetScriptById(psParam.Id); var newJob = new Job() { UserName = name, ScriptId = script.Id, Date = DateTime.Now, JobId = Int32.Parse(BackgroundJob.Enqueue(() => jobServices.Run(script.Name, psParam.PSparams))), Status = Status.Started }; _scriptRepository.InsertJob(newJob); _scriptRepository.Save(); }
public ActionResult RunWithParams(PowerShellParam psParam) { var jobServices = new JobServices(_scriptRepository); jobServices.LaunchScriptWithParams(User.Identity.Name, psParam); return RedirectToAction("Details", new { id = psParam.Id }); }
//Get PowerShell/RunWithParams/1 public ActionResult RunWithParams(int id) { var script = _scriptRepository.GetScriptById(id); if (script == null) return HttpNotFound(); var scriptParams = ScriptIO.ScriptParams(script.Name); if (scriptParams == null) return HttpNotFound(); var psParams = new PowerShellParam() { Id = id, PSparams = scriptParams }; return PartialView(psParams); }