示例#1
0
        public async Task TestRescheduleJob_SchedulerListenersCalledOnReschedule()
        {
            const string TriggerName  = "triggerName";
            const string TriggerGroup = "triggerGroup";
            const string JobName      = "jobName";
            const string JobGroup     = "jobGroup";

            NameValueCollection properties = new NameValueCollection();

            properties["quartz.serializer.type"] = TestConstants.DefaultSerializerType;
            ISchedulerFactory sf        = new StdSchedulerFactory(properties);
            IScheduler        scheduler = await sf.GetScheduler();

            DateTime          startTimeUtc = DateTime.UtcNow.AddSeconds(2);
            JobDetailImpl     jobDetail    = new JobDetailImpl(JobName, JobGroup, typeof(NoOpJob));
            SimpleTriggerImpl jobTrigger   = new SimpleTriggerImpl(TriggerName, TriggerGroup, JobName, JobGroup, startTimeUtc, null, 1, TimeSpan.FromMilliseconds(1000));

            ISchedulerListener listener = A.Fake <ISchedulerListener>();

            await scheduler.ScheduleJob(jobDetail, jobTrigger);

            // add listener after scheduled
            scheduler.ListenerManager.AddSchedulerListener(listener);

            // act
            await scheduler.RescheduleJob(new TriggerKey(TriggerName, TriggerGroup), jobTrigger);

            // assert
            // expect unschedule and schedule
            A.CallTo(() => listener.JobUnscheduled(new TriggerKey(TriggerName, TriggerGroup), A <CancellationToken> ._)).MustHaveHappened();
            A.CallTo(() => listener.JobScheduled(jobTrigger, A <CancellationToken> ._)).MustHaveHappened();
        }
示例#2
0
        public void TestRescheduleJob_SchedulerListenersCalledOnReschedule()
        {
            const string TriggerName  = "triggerName";
            const string TriggerGroup = "triggerGroup";
            const string JobName      = "jobName";
            const string JobGroup     = "jobGroup";

            ISchedulerFactory sf           = new StdSchedulerFactory();
            IScheduler        scheduler    = sf.GetScheduler();
            DateTime          startTimeUtc = DateTime.UtcNow.AddSeconds(2);
            JobDetail         jobDetail    = new JobDetail(JobName, JobGroup, typeof(NoOpJob));
            SimpleTrigger     jobTrigger   = new SimpleTrigger(TriggerName, TriggerGroup, JobName, JobGroup, startTimeUtc, null, 1, TimeSpan.FromMilliseconds(1000));

            MockRepository     mockery  = new MockRepository();
            ISchedulerListener listener = (ISchedulerListener)mockery.CreateMock(typeof(ISchedulerListener));

            scheduler.ScheduleJob(jobDetail, jobTrigger);
            // add listener after scheduled
            scheduler.AddSchedulerListener(listener);

            // expect unschedule and schedule
            listener.JobUnscheduled(TriggerName, TriggerGroup);
            listener.JobScheduled(jobTrigger);

            mockery.ReplayAll();

            // act
            scheduler.RescheduleJob(TriggerName, TriggerGroup, jobTrigger);

            // verify
            mockery.VerifyAll();
        }
示例#3
0
 public void AddSchedulerListener(ISchedulerListener schedulerListener)
 {
     lock (schedulerListeners)
     {
         schedulerListeners.Add(schedulerListener);
     }
 }
 public void AddSchedulerListener(ISchedulerListener schedulerListener)
 {
     lock (schedulerListeners)
     {
         schedulerListeners.Add(schedulerListener);
     }
 }
示例#5
0
        public void TestRescheduleJob_SchedulerListenersCalledOnReschedule()
        {
            const string TriggerName  = "triggerName";
            const string TriggerGroup = "triggerGroup";
            const string JobName      = "jobName";
            const string JobGroup     = "jobGroup";

            ISchedulerFactory sf           = new StdSchedulerFactory();
            IScheduler        scheduler    = sf.GetScheduler();
            DateTime          startTimeUtc = DateTime.UtcNow.AddSeconds(2);
            JobDetailImpl     jobDetail    = new JobDetailImpl(JobName, JobGroup, typeof(NoOpJob));
            SimpleTriggerImpl jobTrigger   = new SimpleTriggerImpl(TriggerName, TriggerGroup, JobName, JobGroup, startTimeUtc, null, 1, TimeSpan.FromMilliseconds(1000));

            ISchedulerListener listener = MockRepository.GenerateMock <ISchedulerListener>();

            scheduler.ScheduleJob(jobDetail, jobTrigger);
            // add listener after scheduled
            scheduler.ListenerManager.AddSchedulerListener(listener);

            // act
            scheduler.RescheduleJob(new TriggerKey(TriggerName, TriggerGroup), jobTrigger);

            // assert
            // expect unschedule and schedule
            listener.AssertWasCalled(l => l.JobUnscheduled(new TriggerKey(TriggerName, TriggerGroup)));
            listener.AssertWasCalled(l => l.JobScheduled(jobTrigger));
        }
 public bool RemoveSchedulerListener(ISchedulerListener schedulerListener)
 {
     lock (schedulerListeners)
     {
         return(schedulerListeners.Remove(schedulerListener));
     }
 }
 public QuartzHostedService(ILogger <QuartzHostedService> logger, ISchedulerFactory schedulerFactory, IJobFactory jobFactory, IEnumerable <JobSchedule> jobSchedules, IJobListener jobListener, ISchedulerListener schedulerListener)
 {
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     _schedulerFactory   = schedulerFactory ?? throw new ArgumentNullException(nameof(schedulerFactory));
     _jobFactory         = jobFactory ?? throw new ArgumentNullException(nameof(jobFactory));
     _jobListener        = jobListener ?? throw new ArgumentNullException(nameof(jobListener));
     _schedulerListener  = schedulerListener ?? throw new ArgumentNullException(nameof(schedulerListener));
     _injectJobSchedules = jobSchedules ?? throw new ArgumentNullException(nameof(jobSchedules));
 }
示例#8
0
 public bool RemoveListener(ISchedulerListener listener)
 {
     if (listeners.Contains(listener))
     {
         listeners.Remove(listener);
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public bool RemoveListener(ISchedulerListener listener)
 {
     if (listeners.Contains(listener))
     {
         listeners.Remove(listener);
         return true;
     }
     else
     {
         return false;
     }
 }
示例#10
0
 public bool RemoveSchedulerListener(ISchedulerListener schedulerListener)
 {
     lock (schedulerListeners)
     {
         return schedulerListeners.Remove(schedulerListener);
     }
 }
 public void AddSchedulerListener(ISchedulerListener schedulerListener)
 {
     scheduler.AddSchedulerListener(schedulerListener);
 }
 public bool RemoveSchedulerListener(ISchedulerListener schedulerListener)
 {
     return scheduler.RemoveSchedulerListener(schedulerListener);
 }
示例#13
0
 public SyncAgentScheduler(ISchedulerFactory schedulerFactory, ISchedulerListener schedulerListener, IUnityContainer container)
 {
     _schedulerFactory  = schedulerFactory;
     _schedulerListener = schedulerListener;
     _container         = container;
 }
		/// <summary> 
		/// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />.
		/// </summary>
		public virtual bool RemoveSchedulerListener(ISchedulerListener schedulerListener)
		{
			throw new SchedulerException("Operation not supported for remote schedulers.",
			                             SchedulerException.ErrorUnsupportedFunctionInThisConfiguration);
		}
 public bool RemoveListener(ISchedulerListener listener)
 {
     return(listeners.Remove(listener));
 }
 public JsonSchedulerListener(ISchedulerListener listener)
 {
     name = listener.GetType().FullName;
 }
示例#17
0
 /// <summary>
 /// Register the given <see cref="ISchedulerListener" /> with the
 /// <see cref="IScheduler" />'s list of internal listeners.
 /// </summary>
 /// <param name="schedulerListener"></param>
 public void AddInternalSchedulerListener(ISchedulerListener schedulerListener)
 {
     lock (internalSchedulerListeners)
     {
         internalSchedulerListeners.Add(schedulerListener);
     }
 }
示例#18
0
 public JsonSchedulerListener(ISchedulerListener listener)
 {
     name = listener.GetType().FullName;
 }
示例#19
0
 /// <summary>
 /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />.
 /// </summary>
 public virtual void AddSchedulerListener(ISchedulerListener schedulerListener)
 {
     sched.AddSchedulerListener(schedulerListener);
 }
 public void AddListener(ISchedulerListener listener)
 {
     listeners.Add(listener);
 }
 public bool RemoveListener(ISchedulerListener listener)
 {
     return listeners.Remove(listener);
 }
示例#22
0
 /// <summary>
 /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />.
 /// </summary>
 public virtual bool RemoveSchedulerListener(ISchedulerListener schedulerListener)
 {
     return(sched.RemoveSchedulerListener(schedulerListener));
 }
示例#23
0
 /// <summary>
 /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />.
 /// </summary>
 public virtual bool RemoveSchedulerListener(ISchedulerListener schedulerListener)
 {
     throw new SchedulerException("Operation not supported for remote schedulers.",
                                  SchedulerException.ErrorUnsupportedFunctionInThisConfiguration);
 }
示例#24
0
 /// <summary>
 /// Remove the given <see cref="ISchedulerListener" /> from the
 /// <see cref="IScheduler" />.
 /// </summary>
 /// <returns> 
 /// true if the identifed listener was found in the list, and removed.
 /// </returns>
 public virtual bool RemoveSchedulerListener(ISchedulerListener schedulerListener)
 {
     lock (schedulerListeners)
     {
         return CollectionUtil.Remove(schedulerListeners, schedulerListener);
     }
 }
示例#25
0
 /// <summary>
 /// Remove the given <see cref="ISchedulerListener" /> from the
 /// <see cref="IScheduler" />'s list of internal listeners.
 /// </summary>
 /// <param name="schedulerListener"></param>
 /// <returns>true if the identified listener was found in the list, andremoved.</returns>
 public bool RemoveInternalSchedulerListener(ISchedulerListener schedulerListener)
 {
     lock (internalSchedulerListeners)
     {
         return internalSchedulerListeners.Remove(schedulerListener);
     }
 }
		/// <summary>
		/// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />.
		/// </summary>
		public virtual bool RemoveSchedulerListener(ISchedulerListener schedulerListener)
		{
			return sched.RemoveSchedulerListener(schedulerListener);
		}
		/// <summary>
		/// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />.
		/// </summary>
		public virtual void AddSchedulerListener(ISchedulerListener schedulerListener)
		{
			sched.AddSchedulerListener(schedulerListener);
		}
 public void AddListener(ISchedulerListener listener)
 {
     listeners.Add(listener);
 }