static void Main(string[] args) { var kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); logger = kernel.Get <ILog>(); logger.Info("-----------------------------------"); logger.Info("Запуск сервиса"); oreader = kernel.Get <IO2SOPCReader>(); creader = kernel.Get <IO2SConfigReader>(); sender = kernel.Get <IO2SSQLSender>(); IList <O2SOPCTag> tags = oreader.ReadData(); if (creader.SQLSendDataEnabled) { sender.SendData(tags); } logger.DeleteOldLogs(creader); Timer tm = new Timer(Worker, null, 0, creader.ReadInterval); //Timer tmlogs = new Timer(LogWorker, null, 0, creader.ReadInterval); Console.ReadKey(); logger.Info("-----------------------------------"); logger.Info("Остановка сервиса"); }
protected override void OnStart(string[] args) { var kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); logger = kernel.Get <ILog>(); logger.Info("-----------------------------------"); logger.Info("Запуск сервиса"); creader = kernel.Get <IO2SConfigReader>(); oreader = kernel.Get <IO2SOPCReader>(); sqlsender = kernel.Get <IO2SSQLSender>(); timer = new System.Timers.Timer(); timer.Interval = creader.ReadInterval; timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer); timer.Start(); timerLogs = new System.Timers.Timer(); timerLogs.Interval = 3600000 * 12; // Раз в 12 часов timerLogs.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimerLogs); timerLogs.Start(); }