public override void SaveHistory(JobRunner job)
        {
            SaveCount++;

            LastResult = job.LastResult;
            LastRunTime = job.LastRunStartTime;
            LastStatus = job.LastStatus;
        }
        public override void RestoreHistory(JobRunner job)
        {
            RestoreCount++;

            job.LastResult = LastResult;
            job.LastRunStartTime = LastRunTime;
            job.LastStatus = LastStatus;
        }
        public override void RestoreHistory(JobRunner jobRunner)
        {
            var history = _jobHistoryRepository.GetMostRecent(jobRunner.Name);
            if (history == null)
                return;

            jobRunner.LastResult = history.Result;
            jobRunner.LastRunStartTime = history.StartTime;
            jobRunner.LastRunFinishTime = history.FinishTime;
            jobRunner.LastStatus = (JobStatus)history.Status;
        }
예제 #4
0
 /// <summary>
 /// Saves the history to the provider.
 /// </summary>
 /// <param name="jobRunner">The job to save the history on.</param>
 public abstract void SaveHistory(JobRunner jobRunner);
예제 #5
0
 /// <summary>
 /// Restores the latest job history from the provider.
 /// </summary>
 /// <param name="jobRunner">The job to restore the history to.</param>
 public abstract void RestoreHistory(JobRunner jobRunner);
예제 #6
0
        private void AddJobs(IEnumerable<IJobConfiguration> jobs, JobProvider provider)
        {
            if (jobs == null)
                return;

            foreach (var jobConfiguration in jobs) {
                Type jobType = Type.GetType(jobConfiguration.Type, false, true);
                if (jobType == null)
                    throw new ConfigurationErrorsException(
                        String.Format("Could not load type '{0}' for job '{1}'.",
                            jobConfiguration.Type, jobConfiguration.Name));

                JobLockProvider jobLockProvider = _defaultJobLockProvider;

                if (!String.IsNullOrEmpty(jobConfiguration.JobLockProvider)) {
                    // first try getting from provider collection
                    jobLockProvider = _jobLockProviders[jobConfiguration.JobLockProvider];
                    if (jobLockProvider == null) {
                        // next, try loading type
                        Type lockType = Type.GetType(jobConfiguration.JobLockProvider, false, true);
                        if (lockType == null)
                            throw new ConfigurationErrorsException(
                                String.Format("Could not load job lock type '{0}' for job '{1}'.",
                                    jobConfiguration.JobLockProvider, jobConfiguration.Name));

                        jobLockProvider = _dependencyResolver.GetService<JobLockProvider>();
                    }

                    // if not found in provider collection or couldn't create type.
                    if (jobLockProvider == null)
                        throw new ConfigurationErrorsException(
                            String.Format("Could not find job lock provider '{0}' for job '{1}'.", jobConfiguration.JobLockProvider, jobConfiguration.Name));
                }

                JobHistoryProvider jobHistoryProvider = null;
                if (!String.IsNullOrEmpty(jobConfiguration.JobHistoryProvider)) {
                    Type historyType = Type.GetType(jobConfiguration.JobHistoryProvider, false, true);
                    if (historyType == null)
                        throw new ConfigurationErrorsException(
                            String.Format("Could not load job history type '{0}' for job '{1}'.", jobConfiguration.JobHistoryProvider, jobConfiguration.Name));

                    jobHistoryProvider = _dependencyResolver.GetService<JobHistoryProvider>();
                }

                var j = new JobRunner(jobConfiguration, jobType, jobLockProvider, jobHistoryProvider, _dependencyResolver);
                _jobs.Add(j);

                // keep track of jobs for providers so they can be sync'd later
                if (provider == null)
                    continue;

                JobCollection providerJobs;
                if (!_providerJobs.TryGetValue(provider, out providerJobs)) {
                    providerJobs = new JobCollection();
                    _providerJobs.Add(provider, providerJobs);
                }
                providerJobs.Add(j);
            }
        }
        public override void SaveHistory(JobRunner jobRunner)
        {
            var history = new JobHistory {
                Name = jobRunner.Name,
                StartTime = jobRunner.LastRunStartTime,
                FinishTime = jobRunner.LastRunFinishTime,
                Status = (int)jobRunner.LastStatus,
                Result = jobRunner.LastResult
            };

            _jobHistoryRepository.Add(history);
        }