Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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
            });
        }
Ejemplo n.º 6
0
        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));
        }