protected void ValidateDatabaseEngine(DatabaseEngineOptions engineOptions, Engine engine) { var direction = engineOptions.IsSource ? "source" : "target"; if (engine == null) { OptionsParser.Usage($"Missing {direction} database engine type"); } var validationErrors = engine.ValidateOptions(engineOptions); if (validationErrors.Length > 0) { var joinedErrors = String.Join(Environment.NewLine, validationErrors); OptionsParser.Usage(joinedErrors); } }
static void Main(string[] args) { var exitCode = 0; var verbose = (args ?? new string[0]).Any(r => String.Equals(r, "-verbose", StringComparison.OrdinalIgnoreCase)); try { ProgramLifetime.Headless = true; ProgramLifetime.InitialiseUnhandledExceptionHandling(); ProgramLifetime.ConfigureSecurityProtocols(); Factory.Register <IApplicationInformation, ApplicationInformation>(); VirtualRadar.SQLiteWrapper.Implementations.Register(Factory.Singleton); VirtualRadar.Headless.Implementations.Register(Factory.Singleton); VirtualRadar.Library.Implementations.Register(Factory.Singleton); VirtualRadar.Database.Implementations.Register(Factory.Singleton); ProgramLifetime.InitialiseManagers(); var appInfo = Factory.Resolve <IApplicationInformation>(); Console.WriteLine($"{appInfo.ApplicationName}, version {appInfo.ShortVersion}, built {appInfo.BuildDate} UTC"); Console.WriteLine(appInfo.Copyright); Console.WriteLine(); LoadDatabasePlugins(); CommandRunner commandRunner = null; var options = OptionsParser.Parse(args); switch (options.Command) { case Command.ApplySchema: commandRunner = new CommandRunner_ApplySchema(); break; case Command.Import: commandRunner = new CommandRunner_Import(); break; default: OptionsParser.Usage("Missing command"); break; } commandRunner.Options = options; if (!commandRunner.Run()) { exitCode = 1; } } catch (Exception ex) { if (!verbose) { Console.WriteLine($"Caught exception: {ex.Message}"); } else { Console.WriteLine($"Caught exception: {ex.ToString()}"); Console.WriteLine(); } try { var log = Factory.ResolveSingleton <ILog>(); log.WriteLine($"Caught exception in BaseStationImport: {ex.ToString()}"); Console.WriteLine("Full details have been recorded in the log"); } catch (Exception iEx) { Console.WriteLine($"The exception could not be logged: {iEx.Message}"); } exitCode = 2; } Environment.Exit(exitCode); }