// Parse command line arguments and return true if values are valid. // Otherwise log errors and return false. public bool ValidArgumentValues(Options opts) { try { if (opts.using_test_data) { // Set up array of source ids to reflect // those in the test data set. opts.source_ids = _test_repo.ObtainTestSourceIDs(); return(true); // Should always be able to run } else { if (opts.source_ids.Count() == 0) { throw new ArgumentException("No source id provided"); } foreach (int source_id in opts.source_ids) { if (!_mon_repo.SourceIdPresent(source_id)) { throw new ArgumentException("Source argument " + source_id.ToString() + " does not correspond to a known source"); } } return(true); // Got this far - the program can run! } } catch (Exception e) { _logger.Error(e.Message); _logger.Error(e.StackTrace); _logger.Information("Harvester application aborted"); _logger_helper.Logheader("Closing Log"); return(false); } }
public int Run(Options opts) { try { _logger_helper.Logheader("STARTING IMPORTER"); _logger_helper.LogCommandLineParameters(opts); if (!opts.using_test_data) { // Simply import the data for each listed source. foreach (int source_id in opts.source_ids) { ImportData(source_id, opts.rebuild_ad_tables, false); } } else { // first recreate the ADcomposite tables. _test_repo.SetUpADCompositeTables(); // Go through and import each test source. foreach (int source_id in opts.source_ids) { _logger_helper.Logheader("BEGINNING " + source_id.ToString() + " first test pass"); ImportData(source_id, true, true); _logger_helper.Logheader("ENDING " + source_id.ToString() + " first test pass"); } // make scripted changes to the ad tables to // create diffs between them _test_repo.ApplyScriptedADChanges(); // Go through each test source again, // this time keeping the ad tables. foreach (int source_id in opts.source_ids) { _logger_helper.Logheader("BEGINNING " + source_id.ToString() + " second test pass"); ImportData(source_id, false, true); _logger_helper.Logheader("ENDING " + source_id.ToString() + " second test pass"); } // construct a log detailing differences between the // expacted and actual (composite ad) values. _test_repo.ConstructDiffReport(); } _logger_helper.Logheader("Closing Log"); return(0); } catch (Exception e) { _logger.Error(e.Message); _logger.Error(e.StackTrace); _logger_helper.Logheader("Closing Log"); return(-1); } }