public void WillExecuteAtServerInitialization()
        {
            var scheduleFactory  = new StdSchedulerFactory();
            var getJobCalled     = false;
            var mockedJobService = new Mock <IJobService>();

            mockedJobService
            .Setup(x => x.Get())
            .Callback(() => getJobCalled = true)
            .Returns(new List <Job>()
            {
                new Job()
                {
                    Configuration = new SimpleConfig()
                }
            });
            var updateJob = new UpdateInMemoryQuartzJob(new IConfigurableJob[] { new SimpleJob(mockedJobService.Object), }, mockedJobService.Object, scheduleFactory);

            var mockedFactory = new Mock <IJobFactory>(MockBehavior.Default);

            mockedFactory
            .Setup(x => x.NewJob(It.IsAny <TriggerFiredBundle>(), It.IsAny <IScheduler>()))
            .Returns(updateJob);

            var server = new QuartzServer(mockedFactory.Object, new GlobalJobListener(), scheduleFactory, new [] { updateJob });

            server.Initialize();

            getJobCalled.Should().BeTrue();
        }
Example #2
0
        static void Main(string[] args)
        {
            var exiteCode = HostFactory.Run(x =>
            {
                x.Service <IQuartzServer>(s =>
                {
                    s.ConstructUsing(name =>
                    {
                        QuartzServer server = new QuartzServer();
                        server.Initialize();
                        return(server);
                    });
                    s.WhenStarted(server => server.Start());
                    s.WhenPaused(server => server.Pause());
                    s.WhenContinued(server => server.Resume());
                    s.WhenStopped(server => server.Stop());
                });

                x.RunAsLocalSystem();

                x.SetDescription("Quartz.Net Server");
                x.SetDisplayName("Quartz.Net Server");
                x.SetServiceName("Quartz.NetServer");
            });
        }
Example #3
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();
            _log.DebugFormat("Program was started");
            var server = new QuartzServer();

            server.Initialize();
            var implementedJobs = new JobProvider().GetImplementedJobsTypes();

            SetScheduledJobs(server, implementedJobs);
        }
 /// <summary>
 /// Main.
 /// </summary>
 public static void Main()
 {
     HostFactory.Run(x =>
     {
         x.RunAsLocalSystem();
         x.SetDescription(Configuration.ServiceDescription);
         x.SetDisplayName(Configuration.ServiceDisplayName);
         x.SetServiceName(Configuration.ServiceName);
         x.Service(factory =>
         {
             QuartzServer server = new QuartzServer();
             server.Initialize();
             return(server);
         });
     });
 }
Example #5
0
        public static void Run()
        {
            HostFactory.Run(x =>
            {
                x.RunAsLocalSystem();

                x.SetDescription(UtilHelper.GetAppSetting("ZcbListening_ServiceName"));
                x.SetDisplayName(UtilHelper.GetAppSetting("ZcbListening_ServiceDisplayName"));
                x.SetServiceName(UtilHelper.GetAppSetting("ZcbListening_ServiceDescription"));

                x.Service(factory =>
                {
                    var server = new QuartzServer();
                    server.Initialize();

                    return(server);
                });
            });
        }
        public void WillScheduleJob()
        {
            var getJobCalled    = false;
            var schedulerCalled = false;
            var scheduleFactory = new Mock <ISchedulerFactory>();
            var scheduler       = new StdSchedulerFactory().GetScheduler();

            scheduleFactory.Setup(x => x.GetScheduler(It.IsAny <CancellationToken>()))
            .Callback(() => schedulerCalled = true)
            .Returns(scheduler);

            var mockedJobService = new Mock <IJobService>();

            mockedJobService
            .Setup(x => x.Get())
            .Callback(() => getJobCalled = true)
            .Returns(new List <Job>()
            {
                new Job()
                {
                    Configuration = new SimpleConfig(), LastUpdated = DateTime.Now, Name = "test", TriggerCronSyntax = "*/4 * * * * ?"
                }
            });
            var updateJob = new UpdateInMemoryQuartzJob(
                new IConfigurableJob[] { new SimpleJob(mockedJobService.Object), },
                mockedJobService.Object, scheduleFactory.Object);

            var mockedFactory = new Mock <IJobFactory>(MockBehavior.Default);

            mockedFactory
            .Setup(x => x.NewJob(It.IsAny <TriggerFiredBundle>(), It.IsAny <IScheduler>()))
            .Returns(updateJob);

            var server = new QuartzServer(mockedFactory.Object, new GlobalJobListener(), scheduleFactory.Object, new[] { updateJob });

            server.Initialize();

            getJobCalled.Should().BeTrue();
            schedulerCalled.Should().BeTrue();
        }
        /// <summary>
        /// Main.
        /// </summary>
        public static void Main(string[] args)
        {
            // change from service account's dir to more logical one
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

            // TODO: Add DI config
            // TODO: Add Logger Config

            HostFactory.Run(x => {
                x.RunAsLocalSystem();

                x.SetDescription(Configuration.ServiceDescription);
                x.SetDisplayName(Configuration.ServiceDisplayName);
                x.SetServiceName(Configuration.ServiceName);

                x.Service(factory => {
                    QuartzServer server = QuartzServerFactory.CreateServer();
                    server.Initialize().GetAwaiter().GetResult();
                    return(server);
                });
            });
        }
Example #8
0
        /// <summary>
        /// Main.
        /// </summary>
        public static void Main()
        {
            //Install-Package Common.Logging.Log4Net1213 -Version 3.0.0
            //Install-Package log4net
            HostFactory.Run(x =>
            {
                x.RunAsLocalSystem();

                x.SetDescription(Configuration.ServiceDescription);
                x.SetDisplayName(Configuration.ServiceDisplayName);
                x.SetServiceName(Configuration.ServiceName);

                x.Service(factory =>
                {
                    Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

                    QuartzServer server = new QuartzServer();
                    server.Initialize();
                    return(server);
                });
            });
        }