Пример #1
0
 protected override void OnStop()
 {
     _timer.Stop();
     _timer.Dispose();
     _logAggregator = null;
     eventLog.WriteEntry("Service has stopped");
 }
Пример #2
0
        protected override void OnStart(string[] args)
        {
            string clientSideAggregatedLogsPath = System.Configuration.ConfigurationSettings.AppSettings["clientSideAggregatedLogsPath"];
            string serverSideAggregatedLogsPath = System.Configuration.ConfigurationSettings.AppSettings["serverSideAggregatedLogsPath"];
            int    maxNoClientSideFiles         = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["maxNoClientSideFiles"]);
            int    timerInterval = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["timerInterval"]) * 60 * 1000;

            _logAggregator = new OxigenIIAdvertising.DataAggregators.LogAggregator(clientSideAggregatedLogsPath,
                                                                                   serverSideAggregatedLogsPath, maxNoClientSideFiles, eventLog);

            _timer           = new Timer();
            _timer.Interval  = timerInterval;
            _timer.AutoReset = false;
            _timer.Elapsed  += new ElapsedEventHandler(timer_Elapsed);

            _timer.Start();

            eventLog.WriteEntry("Service has started");
        }