Exemple #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));
            }
        }