Esempio n. 1
0
        private static void RunMigrations()
        {
            try
            {
                var connectionString       = ConfigurationManager.ConnectionStrings["DbConnection"].ConnectionString;
                var migrationRunnerBuilder = new ServiceProviderBuilder(connectionString, Assembly.GetAssembly(typeof(Migration1CreateLockingTable)));
                var serviceProvider        = migrationRunnerBuilder.BuildMigrationRunner();


                // Put the database update into a scope to ensure
                // that all resources will be disposed.
                using (var scope = serviceProvider.CreateScope())
                {
                    // Instantiate the runner
                    var migrationRunner = scope.ServiceProvider.GetRequiredService <IMigrationRunner>();

                    // Execute the migrations
                    migrationRunner.MigrateUp();
                }
            }
            catch (Exception ex)
            {
                ConsoleUtilities.WriteLineWithColor($"Exception:  {ex.Message}", ConsoleColor.Red);
            }
        }
Esempio n. 2
0
        private static void RunUntilCancelKeyPress()
        {
            Console.WriteLine();
            Console.WriteLine("Press 'P' to pause.");
            Console.WriteLine("Press 'R' to resume.");

            Console.CancelKeyPress += OnCancelKeyPress;
            do
            {
                var consoleKey = Console.ReadKey().Key;
                switch (consoleKey)
                {
                case ConsoleKey.P:
                    try
                    {
                        _consumer.Pause().Inline();
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtilities.WriteLineWithColor($"Exception:  {ex.Message}", ConsoleColor.Red);
                    }
                    break;

                case ConsoleKey.R:
                    try
                    {
                        _consumer.Resume().Inline();
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtilities.WriteLineWithColor($"Exception:  {ex.Message}", ConsoleColor.Red);
                    }

                    break;
                }
            }while (!_ending);
        }