public CentralService(PDFGenerator pdfGenerator, AppDataFileWatcher appDataFileWatcher)
        {
            _pdfGenerator  = pdfGenerator;
            _fileProcessor = new FileProcessor(_pdfGenerator);
            appDataFileWatcher.Start();

            var timer = new Timer();

            timer.Elapsed += OnTimedSaveDocumentEvent;
            timer.Elapsed += OnTimedEvent;
            timer.Interval = 1000;
            timer.Enabled  = true;
        }
Exemple #2
0
        public static void Configure()
        {
            var pdfGenerator       = new PDFGenerator(Configuration.PDFFileName);
            var appDataFileWatcher = new AppDataFileWatcher(AppDomain.CurrentDomain.BaseDirectory);

            HostFactory.Run(configure =>
            {
                configure.Service <CentralService>(service =>
                {
                    service.ConstructUsing(s => new CentralService(pdfGenerator, appDataFileWatcher));
                    service.WhenStarted(s => s.Start());
                    service.WhenStopped(s => s.Stop());
                });

                configure.RunAsLocalSystem();
                configure.SetServiceName(Configuration.ServiceName);
                configure.SetDisplayName(Configuration.DisplayName);
                configure.SetDescription(Configuration.Description);
            });
        }