private void btnRunChecks_Click(object sender, EventArgs e) { IRunner runner; try { var command = CommandGetter(CommandLineActivity.check); runner = _factory.CreateRunner(Activator, command); } catch (Exception ex) { ragChecks.Fatal(ex); return; } CurrentRunner = runner; btnRunChecks.Enabled = false; //reset the visualisations ragChecks.Reset(); checksUI1.Clear(); //ensure the checks are visible over the load loadProgressUI1.Visible = false; checksUI1.Visible = true; //create a to memory that passes the events to checksui since that's the only one that can respond to proposed fixes var toMemory = new ToMemoryCheckNotifier(checksUI1); Task.Factory.StartNew(() => Check(runner, toMemory)).ContinueWith( t => { //once Thread completes do this on the main UI Thread //find the worst check state var worst = toMemory.GetWorst(); //update the rag smiley to reflect whether it has passed ragChecks.OnCheckPerformed(new CheckEventArgs("Checks resulted in " + worst, worst)); //update the bit flag ChecksPassed = worst <= CheckResult.Warning; //enable other buttons now based on the new state SetButtonStates(); }, TaskScheduler.FromCurrentSynchronizationContext()); _runningTask = null; ChecksPassed = true; }
private static int Run(RDMPCommandLineOptions opts) { ImplementationManager.Load <MicrosoftSQLImplementation>(); ImplementationManager.Load <MySqlImplementation>(); ImplementationManager.Load <OracleImplementation>(); ImplementationManager.Load <PostgreSqlImplementation>(); PopulateConnectionStringsFromYamlIfMissing(opts); var listener = new NLogIDataLoadEventListener(false); var checker = new NLogICheckNotifier(true, false); var factory = new RunnerFactory(); opts.DoStartup(GetEnvironmentInfo(), opts.LogStartup ? (ICheckNotifier)checker: new IgnoreAllErrorsCheckNotifier()); //if user wants to run checking chances are they don't want checks to fail becasue of errors logged during startup (MEF shows lots of errors!) if (opts.LogStartup && opts.Command == CommandLineActivity.check) { checker.Worst = LogLevel.Info; } var runner = opts is ConsoleGuiOptions g ? new ConsoleGuiRunner(g): factory.CreateRunner(opts); int runExitCode = runner.Run(opts.GetRepositoryLocator(), listener, checker, new GracefulCancellationToken()); if (opts.Command == CommandLineActivity.check) { checker.OnCheckPerformed(checker.Worst <= LogLevel.Warn ? new CheckEventArgs("Checks Passed", CheckResult.Success) : new CheckEventArgs("Checks Failed", CheckResult.Fail)); } if (runExitCode != 0) { return(runExitCode); } //or if either listener reports error if (listener.Worst >= LogLevel.Error || checker.Worst >= LogLevel.Error) { return(-1); } if (opts.FailOnWarnings && (listener.Worst >= LogLevel.Warn || checker.Worst >= LogLevel.Warn)) { return(1); } return(0); }
private static int Run(RDMPCommandLineOptions opts) { opts.PopulateConnectionStringsFromYamlIfMissing(); // where RDMP objects are stored var repositoryLocator = opts.GetRepositoryLocator(); if (!CheckRepo(repositoryLocator)) { return(REPO_ERROR); } var listener = new NLogIDataLoadEventListener(false); var checker = new NLogICheckNotifier(true, false); var factory = new RunnerFactory(); opts.DoStartup(GetEnvironmentInfo(), opts.LogStartup ? (ICheckNotifier)checker: new IgnoreAllErrorsCheckNotifier()); //if user wants to run checking chances are they don't want checks to fail becasue of errors logged during startup (MEF shows lots of errors!) if (opts.LogStartup && opts.Command == CommandLineActivity.check) { checker.Worst = LogLevel.Info; } var runner = opts is ConsoleGuiOptions g ? new ConsoleGuiRunner(g): factory.CreateRunner(new ThrowImmediatelyActivator(repositoryLocator, checker), opts); // Let's not worry about global errors during the CreateRunner process // These are mainly UI/GUI and unrelated to the actual process to run if (checker.Worst > LogLevel.Warn) { checker.Worst = LogLevel.Warn; } int runExitCode = runner.Run(repositoryLocator, listener, checker, new GracefulCancellationToken()); if (opts.Command == CommandLineActivity.check) { checker.OnCheckPerformed(checker.Worst <= LogLevel.Warn ? new CheckEventArgs("Checks Passed", CheckResult.Success) : new CheckEventArgs("Checks Failed", CheckResult.Fail)); } if (runExitCode != 0) { return(runExitCode); } //or if either listener reports error if (listener.Worst >= LogLevel.Error || checker.Worst >= LogLevel.Error) { return(-1); } if (opts.FailOnWarnings && (listener.Worst >= LogLevel.Warn || checker.Worst >= LogLevel.Warn)) { return(1); } return(0); }