public IActionResult RunWithParams(PowerShellParam psParam) { var jobServices = new JobServices(_scriptRepository, _scriptIO); jobServices.LaunchScriptWithParams(User.Identity.Name, psParam); return(RedirectToAction("Details", new { id = psParam.Id })); }
// GET: PowerShell/RunWithParams/1 public IActionResult RunWithParams(int id) { var script = _scriptRepository.GetScriptById(id); if (script == null) { return(NotFound()); } if (script.Category != null && !UserHasAccessToCategory(script.Category.Id)) { return(RedirectToAction("Index")); } var scriptParams = _scriptIO.ScriptParams(script.Name); if (scriptParams == null) { return(NotFound()); } var psParams = new PowerShellParam() { Id = id, PSparams = scriptParams }; return(PartialView(psParams)); }
public void Post([FromBody] PowerShellParam id) { var jobServices = new JobServices(_scriptRepository, _scriptIO); var script = _scriptRepository.GetScriptById(id.Id); if (script == null || script.Category == null || !this.UserHasAccessToCategory(script.Category.Id)) { Unauthorized(); } jobServices.LaunchScriptWithParams(User.Identity.Name, id); }
public void LaunchScriptWithParams(string name, PowerShellParam psParam) { //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 <IJobServices>(x => x.Run(script.Name, psParam.PSparams))), Status = Status.Started }; _scriptRepository.InsertJob(newJob); _scriptRepository.Save(); }
// GET: PowerShell/RunWithParams/1 public IActionResult RunWithParams(int id) { var script = _scriptRepository.GetScriptById(id); if (script == null) { return(NotFound()); } var scriptParams = _scriptIO.ScriptParams(script.Name); if (scriptParams == null) { return(NotFound()); } var psParams = new PowerShellParam() { Id = id, PSparams = scriptParams }; return(PartialView(psParams)); }