public override void Process(DeleteSchemaExpression expression) { this.ExecuteCodeBlockUntilNoExeception(() => { if (!SchemaExists(expression.SchemaName)) { return; } var stopwatch = new StopWatch(); Logger.LogSay($"Dropping Postgres schema '{expression.SchemaName}'..."); stopwatch.Time(() => Process(ExtendedGeneratorField.Generate(expression))); Logger.LogSay($"Dropped Postgres schema '{expression.SchemaName}'..."); Logger.LogElapsedTime(stopwatch.ElapsedTime()); Process(new DeleteUserExpression(expression)); PostgresDatabaseCreator.DropDatabase( DbMigrationConfig, () => { stopwatch.Start(); Logger.LogSay($"Dropping Postgres database '{DbMigrationConfig.DatabaseName.ToLower()}'..."); }, sql => { stopwatch.Stop(); Logger.LogSql(sql); Logger.LogSay($"Dropped Postgres database '{DbMigrationConfig.DatabaseName.ToLower()}'..."); Logger.LogElapsedTime(stopwatch.ElapsedTime()); }); }, ex => Logger.LogError(ex, $"Dropping Postgres schema(user) '{expression.SchemaName}' failed with exception :-(")); }
public override void Process(DeleteSchemaExpression expression) { this.ExecuteCodeBlockUntilNoExeception(() => { if (!SchemaExists(expression.SchemaName)) { return; } var stopwatch = new StopWatch(); Logger.LogHeader("Drop Oracle schema(user)"); Logger.LogSay($"Dropping Oracle schema(user) '{expression.SchemaName}'..."); stopwatch.Time(() => Process(ExtendedGenerator.Generate(expression))); Logger.LogSay($"Dropped Oracle schema(user) '{expression.SchemaName}'..."); Logger.LogElapsedTime(stopwatch.ElapsedTime()); RunCustomAction(() => CustomMigrationProcessor?.ProcessAfter(new DropSchemaWithPrefixExpression { SchemaName = expression.SchemaName, SchemaPrefixId = SchemaPrefix, SchemaPrefixUniqueId = SchemaPrefixUniqueId })); }, ex => Logger.LogError(ex, $"Dropping Oracle schema(user) '{expression.SchemaName}' failed with exception :-(")); }
public ExtendedPostgresProcessor(IDbMigrationConfig dbMigrationConfig, PostgresQuoter quoter, PostgresDbFactory factory, PostgresGenerator generator, ILogger <ExtendedPostgresProcessor> logger, IOptionsSnapshot <ProcessorOptions> options, IConnectionStringAccessor connectionStringAccessor, IExtendedMigrationGenerator <ExtendedPostgresGenerator> extendedGenerator) : base(factory, generator, logger, options, connectionStringAccessor) { ExtendedGeneratorField = extendedGenerator; DbMigrationConfig = dbMigrationConfig; if (dbMigrationConfig.ProcessorId == ProcessorIds.PostgresProcessorId) { var stopWatch = new StopWatch(); PostgresDatabaseCreator.CreateDatabase( dbMigrationConfig, () => { Logger.LogSay($"Creating Postgres database '{dbMigrationConfig.DatabaseName.ToLower()}'..."); stopWatch.Start(); }, sql => { stopWatch.Stop(); Logger.LogSql(sql); Logger.LogSay($"Created Postgres database '{dbMigrationConfig.DatabaseName.ToLower()}'..."); Logger.LogElapsedTime(stopWatch.ElapsedTime()); }); } this.SetPrivateFieldValue <PostgresProcessor>("_quoter", quoter); }
public void CanGetTheElapsedTime() { var watch = new StopWatch(); StopWatch.TimeNow = () => new DateTime(2009, 9, 6, 15, 53, 0, 0); watch.Start(); StopWatch.TimeNow = () => new DateTime(2009, 9, 6, 15, 53, 0, 5); watch.Stop(); watch.ElapsedTime().Milliseconds.ShouldBe(5); }
private void Process(DeleteUserExpression expression) { if (!Exists(ExtendedGeneratorField.GenerateUserExistsSql(expression.SchemaName))) { return; } var stopwatch = new StopWatch(); Logger.LogSay($"Dropping Postgres user/role '{expression.SchemaName}'..."); stopwatch.Time(() => Process(ExtendedGeneratorField.Generate(expression))); Logger.LogSay($"Dropping Postgres user/role '{expression.SchemaName}'..."); Logger.LogElapsedTime(stopwatch.ElapsedTime()); }
private static void QueryData() { Console.Write("Type the Sticker Number: "); var stickerNumber = Console.ReadLine(); var source = string.Empty; Sticker sticker; var cache = _serviceProvider.GetRequiredService <IDistributedCache>(); var cachedSticker = cache.GetString($"Sticker:{stickerNumber}"); var stopWatch = new StopWatch(); stopWatch.Start(); if (!string.IsNullOrWhiteSpace(cachedSticker)) { sticker = JsonConvert.DeserializeObject <Sticker>(cachedSticker); source = "Redis Cache"; } else { using (var context = new StickersContext(Configuration.GetConnectionString("DataStore"))){ sticker = context.Stickers.FirstOrDefault(x => x.Number == int.Parse(stickerNumber)); } if (sticker != null) { cache.SetString($"Sticker:{stickerNumber}", JsonConvert.SerializeObject(sticker)); source = "SQL Database"; } } stopWatch.Stop(); if (sticker != null) { PrintBreakLine(); Console.WriteLine("Found the following sticker:"); PrintBreakLine(); Console.WriteLine($"Number: {sticker.Number}"); Console.WriteLine($"Player: {sticker.PlayerName}"); Console.WriteLine($"Country: {sticker.Country}"); PrintImportantInfo($"Source: {source}"); PrintImportantInfo($"Execution time: {stopWatch.ElapsedTime().Milliseconds}ms"); PrintBreakLine(); } }
public override void Process(DeleteSchemaExpression expression) { this.ExecuteCodeBlockUntilNoExeception(() => { if (!SchemaExists(expression.SchemaName)) { return; } var stopwatch = new StopWatch(); Logger.LogSay($"Dropping Oracle schema(user) '{expression.SchemaName}'..."); stopwatch.Time(() => Process(ExtendedGenerator.Generate(expression))); Logger.LogSay($"Dropped Oracle schema(user) '{expression.SchemaName}'..."); Logger.LogElapsedTime(stopwatch.ElapsedTime()); }, ex => Logger.LogError(ex, $"Dropping Oracle schema(user) '{expression.SchemaName}' failed with exception :-(")); }