Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var slackNotificationService = new SlackNotificationService();

            HostFactory.Run(c =>
            {
                c.ScheduleQuartzJobAsService(q =>
                                             q.WithJob(() =>
                                                       JobBuilder.Create <DriveSpaceMonitoringService>().Build())
                                             .AddTrigger(() =>
                                                         TriggerBuilder.Create()
                                                         .WithSimpleSchedule(builder => builder
                                                                             .WithIntervalInSeconds(10)
                                                                             .RepeatForever())
                                                         .Build())
                                             );
            });

            //HostFactory.Run(x =>
            //{
            //    x.Service<MyService>(s =>
            //    {
            //        s.WhenStarted(service => service.OnStart());
            //        s.WhenStopped(service => service.OnStop());
            //        s.ConstructUsing(() => new MyService());

            //        s.ScheduleQuartzJob(q =>
            //            q.WithJob(() =>
            //                JobBuilder.Create<DriveSpaceMonitoringService>().Build())
            //                .AddTrigger(() => TriggerBuilder.Create()
            //                    .WithSimpleSchedule(b => b
            //                        .WithIntervalInSeconds(10)
            //                        .RepeatForever())
            //                    .Build()));
            //    });

            //    x.RunAsLocalSystem()
            //        .DependsOnEventLog()
            //        .StartAutomatically()
            //        .EnableServiceRecovery(rc => rc.RestartService(1));

            //    x.SetServiceName("My Topshelf Service");
            //    x.SetDisplayName("My Topshelf Service");
            //    x.SetDescription("My Topshelf Service's description");
            //});
        }
Exemplo n.º 2
0
 public DriveSpaceMonitoringService(SlackNotificationService slackNotificationService)
 {
     this.slackNotificationService = slackNotificationService;
 }
Exemplo n.º 3
0
 public DriveSpaceMonitoringService()
 {
     Console.WriteLine(String.Format("[{0}] Drive Monitoring Job started", DateTime.Now));
     slackNotificationService = new SlackNotificationService();
 }