Example #1
0
        protected BaseScheduler(SchedulerSettings settings, JobMetadata metadataManager, IJobDetailService jobDetailService)
        {
            JobDetailService = jobDetailService;
            Metadata         = metadataManager;

            Init(settings);
        }
Example #2
0
        private void InitBasicSettings(SchedulerSettings settings)
        {
            if (settings.StartEngineImmediately)
            {
                Start();
            }

            InstanceId   = settings.InstanceId;
            InstanceName = settings.InstanceName;
        }
Example #3
0
        private void Init(SchedulerSettings settings)
        {
            if (settings != null)
            {
                WireEventHandlers(settings);
                SetupJobsDirectory(settings);

                InitBasicSettings(settings);
            }
        }
Example #4
0
        private void SetupJobsDirectory(SchedulerSettings settings)
        {
            if (!string.IsNullOrEmpty(settings.JobsDirectory))
            {
                JobsDirectory = settings.JobsDirectory;

                if (!Directory.Exists(JobsDirectory))
                {
                    Directory.CreateDirectory(JobsDirectory);
                }

                if (settings.EnableJobsDirectoryTracking)
                {
                    JobsDirectoryWatcher = new FileSystemWatcher(JobsDirectory, "*.dll");

                    JobsDirectoryWatcher.Changed += OnJobsDirectoryChanged;
                    JobsDirectoryWatcher.Created += OnJobsDirectoryChanged;
                    JobsDirectoryWatcher.Deleted += OnJobsDirectoryChanged;

                    JobsDirectoryWatcher.IncludeSubdirectories = true;
                    JobsDirectoryWatcher.EnableRaisingEvents   = true;
                }
            }
        }
Example #5
0
        private void WireEventHandlers(SchedulerSettings settings)
        {
            if (settings.EngineStarted != null)
            {
                EngineStarted += settings.EngineStarted;
            }

            if (settings.EnginePaused != null)
            {
                EnginePaused += settings.EnginePaused;
            }

            if (settings.EngineTerminated != null)
            {
                EngineTerminated += settings.EngineTerminated;
            }

            if (settings.JobsDiscovered != null)
            {
                JobsDiscovered += settings.JobsDiscovered;
            }

            if (settings.JobScheduled != null)
            {
                JobScheduled += settings.JobScheduled;
            }

            if (settings.JobUnscheduled != null)
            {
                JobUnscheduled += settings.JobUnscheduled;
            }

            if (settings.JobPaused != null)
            {
                JobPaused += settings.JobPaused;
            }

            if (settings.JobResumed != null)
            {
                JobResumed += settings.JobResumed;
            }

            if (settings.JobTriggered != null)
            {
                JobTriggered += settings.JobTriggered;
            }

            if (settings.BeforeJobExecution != null)
            {
                BeforeJobExecution += settings.BeforeJobExecution;
            }

            if (settings.AfterJobExecution != null)
            {
                AfterJobExecution += settings.AfterJobExecution;
            }

            if (settings.JobExecutionSucceeded != null)
            {
                JobExecutionSucceeded += settings.JobExecutionSucceeded;
            }

            if (settings.JobExecutionFailed != null)
            {
                JobExecutionFailed += settings.JobExecutionFailed;
            }

            if (settings.JobExecutionSkipped != null)
            {
                JobExecutionSkipped += settings.JobExecutionSkipped;
            }
        }