Ejemplo n.º 1
0
 public override void Cancel(string jobId)
 {
     base.Cancel(jobId);
     if (!this.Repository.GetJobs().Any())
     {
         CrossJobs.StopJobService();
     }
 }
Ejemplo n.º 2
0
        protected virtual async Task <JobRunResult> RunJob(JobInfo job, string batchName, CancellationToken cancelToken)
        {
            this.JobStarted?.Invoke(this, job);
            var result = default(JobRunResult);
            var cancel = false;

            try
            {
                this.LogJob(JobState.Start, job, "manual");
                var service = CrossJobs.ResolveJob(job);

                await service
                .Run(job, cancelToken)
                .ConfigureAwait(false);

                if (!job.Repeat)
                {
                    this.Cancel(job.Name);
                    cancel = true;
                }
                this.LogJob(JobState.Finish, job, "manual");
                result = new JobRunResult(job, null);
            }
            catch (Exception ex)
            {
                this.LogJob(JobState.Error, job, "manual", ex);
                result = new JobRunResult(job, ex);
            }
            finally
            {
                if (!cancel)
                {
                    job.LastRunUtc = DateTime.UtcNow;
                    this.Repository.Persist(job, true);
                }
            }
            this.JobFinished?.Invoke(this, result);
            return(result);
        }
Ejemplo n.º 3
0
 public override void CancelAll()
 {
     base.CancelAll();
     CrossJobs.StopJobService();
 }
Ejemplo n.º 4
0
        public override async Task Schedule(JobInfo jobInfo)
        {
            await base.Schedule(jobInfo);

            CrossJobs.StartJobService();
        }