Example #1
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Application started -  Esc to quit");

            var sessionFactory = NHibernateFactory.AssembleSessionFactory(DATABASE_FILE);
            ILog consoleLogger = new ConsoleLogger {VerbosityLevel = 2};
            ILog databaseLogger = new Logger(new LogEntryDatabaseRepository(sessionFactory)) {VerbosityLevel = 1};
            ILog log = new CompositeLogger(consoleLogger, databaseLogger);

            var iocContainer = new IocContainerForScheduler();
            iocContainer.BindToConstant(sessionFactory);
            var taskDirectory = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName;

            var taskScheduler = new Scheduler(iocContainer, taskDirectory, new FileUtilities(), new TimerWithTimestamp(0, 10000), new TimerWithTimestamp(0, 2000), log);
            taskScheduler.Start();

            try
            {
                while (System.Console.ReadKey().Key != ConsoleKey.Escape) { }
            }
            catch (Exception e)
            {
                log.WriteEntry(new LogEntry(e.Source, e.Message, DateTime.Now));
            }
        }
Example #2
0
 public Scheduler(
     IocContainerForScheduler iocContainer, 
     string taskDirectory, 
     IFileUtilities fileUtility, 
     ITimerWithTimestamp taskConfigurationTimer, 
     ITimerWithTimestamp dispatchTimer, 
     ILog logger)
 {
     taskNameToTypeMappings = new Dictionary<string, Type>();
     TaskMetaDatas = new List<TaskMetaData>();
     this.logger = logger;
     this.iocContainer = iocContainer;
     this.taskDirectory = taskDirectory;
     this.fileUtility = fileUtility;
     this.taskConfigurationTimer = taskConfigurationTimer;
     this.taskConfigurationTimer.Elapsed += (o, e) => GatherTaskConfigurations();
     this.dispatchTimer = dispatchTimer;
     this.dispatchTimer.Elapsed += (o, timerElapsedEventArgs) => DispatchTasks(timerElapsedEventArgs.Time);
 }
 public void Setup()
 {
     container = new IocContainerForScheduler();
 }
Example #4
0
        private void RunTasks()
        {
            var sessionFactory = NHibernateFactory.AssembleSessionFactory(DatabaseFile);
            var logger = new Logger(new LogEntryDatabaseRepository(sessionFactory)) { VerbosityLevel = 1 };
            var iocContaier = new IocContainerForScheduler();
            iocContaier.BindToConstant(sessionFactory);
            var taskDirectory = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName;

            var taskScheduler = new Scheduler(iocContaier, taskDirectory, new FileUtilities(), new TimerWithTimestamp(0, 10000), new TimerWithTimestamp(0, 2000), logger);
            taskScheduler.Start();
        }