コード例 #1
0
        /// <summary>
        /// Public constructor for service. Here is where we start our file watcher and launch
        /// our periodic logging.
        /// </summary>
        public SimpleLogParserService(bool asMonitor = false)
        {
            _asMonitor = asMonitor;

            string connectionString = ConfigurationManager.ConnectionStrings["SimpleLogParserDataSource"].ConnectionString;
            // set up our log parser
            var metricService = new MetricService(connectionString);
            var settingsService = new PluginSettingsService(connectionString);
            var subscriberService = new SubscriberService(connectionString);
            var directory = new PluginDirectory();

            _service = new StatefulParser(metricService, settingsService, directory, subscriberService, OnAlert);

            string path = ConfigurationManager.AppSettings["WatchDirectory"];
            bool includeSubdirectories = false;

            try { includeSubdirectories = bool.Parse(ConfigurationManager.AppSettings["IncludeSubdirectories"]); }
            catch { }

            _queue = new FileSystemQueue(path, connectionString, includeSubdirectories);

            int intervalMinutes = int.Parse(ConfigurationManager.AppSettings["IntervalMinutes"] ?? "30");

            // if we want active monitoring we need to start the watcher
            if (asMonitor)
                _queue.Start();

            _timer = new Timer(FrequencyIntervalMilliseconds * intervalMinutes) { AutoReset = true };
            _timer.Elapsed += (sender, eventArgs) => this.SynchronizedMain();

            this.SynchronizedMain(); // call the timer callback right away to start
        }
コード例 #2
0
        public StatefulParser(
            MetricService metricService, 
            PluginSettingsService pluginSettingsService, 
            PluginDirectory pluginDirectory,
            SubscriberService subscriberService,
            Action<IParserPlugin, string, List<Subscriber>, Dictionary<string, string>> onAlert = null)
        {
            _metricService = metricService;
            _pluginSettingsService = pluginSettingsService;
            _pluginDirectory = pluginDirectory;
            _subscriberService = subscriberService;
            OnAlert = onAlert;

            if (null == OnAlert)
                OnAlert = (p, m, s, d) => { };
        }
コード例 #3
0
        public StatefulParser(
            MetricService metricService,
            PluginSettingsService pluginSettingsService,
            PluginDirectory pluginDirectory,
            SubscriberService subscriberService,
            Action <IParserPlugin, string, List <Subscriber>, Dictionary <string, string> > onAlert = null)
        {
            _metricService         = metricService;
            _pluginSettingsService = pluginSettingsService;
            _pluginDirectory       = pluginDirectory;
            _subscriberService     = subscriberService;
            OnAlert = onAlert;

            if (null == OnAlert)
            {
                OnAlert = (p, m, s, d) => { }
            }
            ;
        }
コード例 #4
0
 /// <summary>
 /// Initialize the plugin with settings from the database. This is called once.
 /// </summary>
 /// <param name="settings"></param>
 public virtual void Initialize(PluginSettings settings, MetricService metricService)
 {
     this.Settings = settings;
     this.MetricService = metricService;
 }
コード例 #5
0
 /// <summary>
 /// Initialize the plugin with settings from the database. This is called once.
 /// </summary>
 /// <param name="settings"></param>
 public virtual void Initialize(PluginSettings settings, MetricService metricService)
 {
     this.Settings      = settings;
     this.MetricService = metricService;
 }