protected override void Upload() { logger.Trace("Writing grouped XE data"); int numRows, originalRows; using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConnectionString; conn.Open(); DataTable groupedData = null; lock (EventsTable) { originalRows = EventsTable.Rows.Count; groupedData = GroupBy(); EventsTable.Rows.Clear(); } if (!TargetTableCreated) { CreateTargetTable(groupedData); } DataTableTSQLAdapter adapter = new DataTableTSQLAdapter(groupedData, conn) { DestinationTableName = Smart.Format(TableName, Tokens) }; numRows = adapter.MergeToServer(_outputColumns); originalRows = groupedData.Rows.Count; } logger.Info(String.Format("{0} rows aggregated, {1} rows written", originalRows, numRows)); }
protected override void CreateTargetTable(DataTable data) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConnectionString; conn.Open(); DataTableTSQLAdapter adapter = new DataTableTSQLAdapter(data, conn) { DestinationTableName = Smart.Format(TableName, Tokens) }; if (!adapter.CheckTableExists()) { adapter.CreateFromDataTable(); } } }