public void Start()
        {
            _sched.JobFactory = _jobFactory;
            _sched.Start();
            var JobList = JobRegistrar.GetJobTypes();

            foreach (var jobType in JobList)
            {
                var JobDescriptionAtt = jobType.GetCustomAttributes(typeof(JobDescriptionAttribute), false);

                if (JobDescriptionAtt.Length > 0)
                {
                    string jobDescription = ((JobDescriptionAttribute)(JobDescriptionAtt[0])).JobDescription;
                    string jobCron        = ((JobDescriptionAttribute)(JobDescriptionAtt[0])).JobCron;

                    IJobDetail job = JobBuilder.Create(jobType)
                                     .WithDescription(jobDescription)
                                     .WithIdentity(jobDescription)
                                     .Build();

                    ITrigger trigger = TriggerBuilder.Create()
                                       .WithIdentity(jobDescription, "BankJobGroup")
                                       .WithCronSchedule(jobCron, q => q.InTimeZone(TimeZoneInfo.Local))
                                       .ForJob(job)
                                       .Build();
                    ScheduleJob(job, trigger);
                }
            }
        }
Example #2
0
        public void Run()
        {
            IJobFactory jobFactory = new WindsorJobFactory(Container);

            Container.Register(Component.For <IJobFactory>().Instance(jobFactory).LifeStyle.Transient);

            this.Container.Install(FromAssembly.This());

            JobRegistrar jobRegistrar = new JobRegistrar(this.Container);

            jobRegistrar.RegisterJobs();
        }