Exemple #1
0
        public void Start()
        {
            var fileOptions = _systemConfiguration.GetConfigurationClass(new WatcherOptions());

            Logger.LogFilePath = fileOptions.GetOption <string>("LogFilePath");

            Logger.RecordStatusAsync("The service starts...");
            var serverOptions = _systemConfiguration.GetConfigurationClass(new ServerOptions());

            var        connectionString = (string)serverOptions.GetField("connectionString").GetValue(null);
            DataAccess dataAccess       = new DataAccess(connectionString);

            Logger.DataAccess = dataAccess;

            sourceDirectory = fileOptions.GetOption <string>("SourceDirectory");
            XMLGenerator xmlGenerator    = new XMLGenerator();
            Reporter     reporter        = new Reporter(sourceDirectory, dataAccess, xmlGenerator);
            var          reporterOptions = _systemConfiguration.GetConfigurationClass(new ReporterOptions());
            var          hours           = reporterOptions.GetOption <int>("FrequencyOfReportHours");
            var          minutes         = reporterOptions.GetOption <int>("FrequencyOfReportMinutes");
            var          seconds         = reporterOptions.GetOption <int>("FrequencyOfReportSeconds");

            Logger.RecordStatusAsync("The service started...");
            while (_enabled)
            {
                reporter.CreateNewReportAsync();
                Thread.Sleep(new TimeSpan(hours, minutes, seconds));
            }
        }
Exemple #2
0
 public Reporter(string sourceDirectory, DataAccess dataAccess, XMLGenerator xmlGenerator)
 {
     _sourceDirectory = sourceDirectory;
     _dataAccess      = dataAccess;
     _xmlGenerator    = xmlGenerator;
 }