/// <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
        }
Example #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) => { };
        }
 public override List<Subscriber> Subscribers(SubscriberService subscriberService)
 {
     return new List<Subscriber> { new Subscriber { Name = _email } };
 }
Example #4
0
 public virtual List<Subscriber> Subscribers(SubscriberService subscriberService)
 {
     return subscriberService.Subscribers(this.Id);
 }