Skip to content

Commit

Permalink
Display final row count for each table
Browse files Browse the repository at this point in the history
Addresses #12.
  • Loading branch information
Andrew Brobston committed Nov 20, 2017
1 parent 8dfb1db commit d6ba621
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions soddi/Loaders/BulkCopyTask.cs
Expand Up @@ -137,8 +137,8 @@ public void Process()
}

_bc.RowsInserted += (s, e) =>
{
_count += _bc.NotifyAfter;
{
_count = e.Count;
e.Abort = OnRowsInserted(CopyEventType.Active);
if (e.Abort)
{
Expand Down
11 changes: 11 additions & 0 deletions soddi/Loaders/MsSql/MsSqlBulkInserter.cs
Expand Up @@ -89,6 +89,17 @@ public override void WriteToServer(IDataReader reader)
try
{
_inner.WriteToServer(reader);
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
using (var command = connection.CreateCommand())
{
command.CommandType = CommandType.Text;
command.CommandText = $"SELECT COUNT_BIG(*) FROM {DestinationTableName}";
var rowCount = (long) command.ExecuteScalar();
OnRowsInserted(new BulkCopyEventArgs {Count = rowCount, Type = CopyEventType.Complete});
}
}
}
finally
{
Expand Down
1 change: 1 addition & 0 deletions soddi/Loaders/MySql/MySqlBulkInserter.cs
Expand Up @@ -131,6 +131,7 @@ public override void WriteToServer(IDataReader reader)
dbTrans.Commit();
}
}
OnRowsInserted(new BulkCopyEventArgs {Count = totalRecords, Type = CopyEventType.Complete});
}
}
}
Expand Down
1 change: 1 addition & 0 deletions soddi/Loaders/SQLite/SQLiteBulkInserter.cs
Expand Up @@ -130,6 +130,7 @@ public override void WriteToServer(IDataReader reader)
dbTrans.Commit();
}
}
OnRowsInserted(new BulkCopyEventArgs {Count = totalRecords, Type = CopyEventType.Complete});
}
}
}
Expand Down

0 comments on commit d6ba621

Please sign in to comment.