public void OnPerforming(PerformingContext filterContext) { var jobServices = new JobServices(); var scriptName = filterContext.BackgroundJob.Job.Args[0].ToString(); // TODO: test var scriptName = filterContext.BackgroundJob.Job.Method.Name; jobServices.UpdateJob(filterContext.BackgroundJob.Id, Status.Running, null, scriptName); }
public void OnStateElection(ElectStateContext context) { var jobServices = new JobServices(); if (context.CandidateState is FailedState failedState) { jobServices.UpdateJob(context.BackgroundJob.Id, Status.Failed, failedState.Exception.Message); } }
public void OnStateElection(ElectStateContext context) { var jobService = new JobServices(); var failedState = context.CandidateState as FailedState; if (failedState != null) { jobService.UpdateJob(context.BackgroundJob.Id, Status.Failed, failedState.Exception.Message); } }
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 CancelJobConfirmed(Job job) { var jobServices = new JobServices(_scriptRepository); //Get Recurring and Original Job Info var recurringJob = _scriptRepository.GetJobById(job.Id); BackgroundJob.Delete(recurringJob.JobId.ToString()); if (recurringJob.JobType == JobType.Recurring) { var originalJob = _scriptRepository.GetJobById(recurringJob.RecurringId); BackgroundJob.Delete(originalJob.JobId.ToString()); jobServices.UpdateJobStatus(recurringJob, Status.Cancelled); } RecurringJob.RemoveIfExists(recurringJob.RecurringId.ToString()); jobServices.UpdateJobStatus(recurringJob, Status.Cancelled); return RedirectToAction("Details", new { id = recurringJob.ScriptId }); }
public void OnPerformed(PerformedContext filterContext) { var jobServices = new JobServices(); jobServices.UpdateJob(filterContext.BackgroundJob.Id, Status.Completed); }
public void OnPerforming(PerformingContext filterContext) { var jobService = new JobServices(); var scriptName = filterContext.BackgroundJob.Job.Args[0].ToString(); jobService.UpdateJob(filterContext.BackgroundJob.Id, Status.Running, null, scriptName); }
public void OnPerformed(PerformedContext filterContext) { var jobService = new JobServices(); jobService.UpdateJob(filterContext.BackgroundJob.Id, Status.Completed); }
public ActionResult Schedule(PowerShellSchedule schedule) { var jobServices = new JobServices(_scriptRepository); var psMetadata = _scriptRepository.GetScriptById(schedule.Id); if (psMetadata == null) return HttpNotFound(); jobServices.Schedule(psMetadata, schedule, User.Identity.Name); return RedirectToAction("Details", new { id = schedule.Id }); }
public ActionResult RunWithParams(PowerShellParam psParam) { var jobServices = new JobServices(_scriptRepository); jobServices.LaunchScriptWithParams(User.Identity.Name, psParam); return RedirectToAction("Details", new { id = psParam.Id }); }
//Job ActionResults // GET: PowerShell/Run/1 public ActionResult Run(int id) { var jobServices = new JobServices(_scriptRepository); var script = _scriptRepository.GetScriptById(id); jobServices.LaunchScript(User.Identity.Name, script); return RedirectToAction("Details", new { id }); }