예제 #1
0
        public RECMService()
        {
            InitializeComponent();

            var settings = TimedREConnectionMonitor.LoadSettingsFromConfig();

            loggingEnabled = settings[MonitorSettings.LoggingEnabled].ToLower() == "true";

            if (loggingEnabled)
            {
                if (!System.Diagnostics.EventLog.SourceExists(settings[MonitorSettings.LogSource]))
                {
                    System.Diagnostics.EventLog.CreateEventSource(settings[MonitorSettings.LogSource], settings[MonitorSettings.LogName]);
                }

                recmEventLog.Source = settings[MonitorSettings.LogSource];
                recmEventLog.Log    = settings[MonitorSettings.LogName];
            }
        }
예제 #2
0
        protected override void OnStart(string[] args)
        {
            try
            {
                monitor = new TimedREConnectionMonitor(recmEventLog, true);
                monitor.FreedConnection          += new REConnectionMonitor.FreedConnectionEvent(monitor_FreedConnection);
                monitor.SkippedFreeingConnection += new REConnectionMonitor.SkippedFreeingConnectionEvent(monitor_SkippedFreeingConnection);
                monitorThread = new System.Threading.Thread(new System.Threading.ThreadStart(monitor.StartMonitor));
                monitorThread.Start();

                var settingDisplay = new String(monitor.Settings.Select(a => string.Format("{0}: {1}\n", Enum.GetName(a.Key.GetType(), a.Key), a.Value)).SelectMany(a => a).ToArray());
                Log("RECM Service has started\n\nSettings\n---------\n" + settingDisplay, EventLogEntryType.Information);

                base.OnStart(args);
            }
            catch (Exception err)
            {
                Log(err);
                this.Stop();
            }
        }