private void AutoRunScheduleJob(List <ScheduledJob> existingScheduledJobs, ScheduledJobDefinition job) { var(scheduledJob, message) = FindScheduledJob(existingScheduledJobs, job); var existingJob = scheduledJob; var extraInfoMessage = message; if (existingJob != null) { _scheduledJobExecutor.StartAsync(existingJob, new JobExecutionOptions { RunSynchronously = true, Trigger = ScheduledJobTrigger.User }); Logger.Debug($"Ran {existingJob.Name} ({existingJob.ID})."); _resultLog.AppendLine($"Ran {existingJob.Name} ({existingJob.ID}).<br />"); } else { Logger.Warning($"Could not find scheduled job with {extraInfoMessage}"); _resultLog.AppendLine($"Could not find scheduled job with {extraInfoMessage}<br />"); } }
public ActionResult RunIndexJob() { var indexJob = _scheduledJobRepository.List().FirstOrDefault(job => job.Name == Constants.IndexEPiServerContentDisplayName); if (indexJob != null) { _scheduledJobExecutor.StartAsync(indexJob); } return(RedirectToAction("Index")); }
public void JobStartManually <T>() where T : ScheduledJobBase { var job = _scheduledJobRepo.Get("Execute", typeof(T).FullName, typeof(T).Assembly.GetName().Name); if (!job.IsRunning) { IScheduledJobExecutor exec = ServiceLocator.Current.GetInstance <IScheduledJobExecutor>(); exec.StartAsync(job); Thread.Sleep(500); } }
public void VGJobStartManually() { var job = _scheduledJobRepo.Get("Execute", "N1990.Episerver.Cms.Audit.Business.VisitorGroupAudit", "N1990.Episerver.Cms.Audit"); if (!job.IsRunning) { IScheduledJobExecutor exec = ServiceLocator.Current.GetInstance <IScheduledJobExecutor>(); exec.StartAsync(job); Thread.Sleep(500); } }
private static void RunIndexJob(IScheduledJobExecutor scheduledJobExecutor, IScheduledJobRepository scheduledJobRepository, Guid jobId) { var job = scheduledJobRepository.Get(jobId); if (job == null) { return; } scheduledJobExecutor.StartAsync(job, new JobExecutionOptions { Trigger = ScheduledJobTrigger.User }); }
public RestResult Post(string id) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } var job = _repository.GetById(int.Parse(id)); if (job == null) { return(Rest(null)); } var jobInstance = job.InstanceId != Guid.Empty ? _repository.Get(job.InstanceId) : _repository.Create(job); _executor.StartAsync(jobInstance, new JobExecutionOptions { Trigger = ScheduledJobTrigger.User }); return(Rest(null)); }