예제 #1
0
파일: Program.cs 프로젝트: mobile32/ZTP
        static void Main(string[] args)
        {
            var options = new SchedulerOptions
            {
                Url           = ConfigurationManager.AppSettings["Url"],
                InputFile     = ConfigurationManager.AppSettings["InputFile"],
                LoggingFolder = ConfigurationManager.AppSettings["LoggingFolder"],
            };

            var container = AutofacContainer.Configure(options.LoggingFolder);

            GlobalConfiguration.Configuration.UseAutofacActivator(container);
            var _logger = container.Resolve <Interfaces.ILogger>();

            HostFactory.Run(c =>
            {
                c.UseAutofacContainer(container);
                c.Service <Scheduler>(callback: s =>
                {
                    s.ConstructUsingAutofacContainer();
                    s.WhenStarted((service, control) => {
                        _logger.Information("Service started...");
                        return(service.Start(options));
                    });
                    s.WhenStopped((service, control) => service.Stop());
                });
                c.SetDisplayName("MailSchedulerService");
                c.SetDescription("dupa123");
                c.StartAutomatically();
                c.RunAsLocalService();
            });
        }
예제 #2
0
 public bool Start(SchedulerOptions options)
 {
     try
     {
         _service.Init(options.InputFile);
         webApp = WebApp.Start <Startup>(options.Url);
         //processmailqueue
         return(true);
     }
     catch (Exception ex)
     {
         _logger.Error($"Topshelf starting occured errors:{ex.ToString()}");
         return(false);
     }
 }
예제 #3
0
파일: Scheduler.cs 프로젝트: mobile32/ZTP
 public bool Start(SchedulerOptions options)
 {
     try
     {
         _service.Init(options.InputFile);
         webApp = WebApp.Start <Startup>(options.Url);
         RecurringJob.AddOrUpdate(
             () => _service.ProcessMailQueue(),
             Cron.Minutely()
             );
         return(true);
     }
     catch (Exception ex)
     {
         _logger.Error($"Topshelf starting occured errors:{ex.ToString()}");
         return(false);
     }
 }