private IExportTable GetTableExportTask(string path, bool remote) { var source = new SourceTableQuery() { Dataset = new Jhu.Graywulf.Schema.SqlServer.SqlServerDataset(Jhu.Graywulf.Test.Constants.TestDatasetName, Jhu.Graywulf.Test.AppSettings.IOTestConnectionString), Query = "SELECT * FROM SampleData" }; var destination = new DelimitedTextDataFile() { Uri = Util.UriConverter.FromFilePath(path) }; IExportTable te = null; if (remote) { te = RemoteServiceHelper.CreateObject <IExportTable>(Test.Constants.Localhost); } else { te = new ExportTable(); } te.Source = source; te.Destination = destination; return(te); }
private IExportTable GetTableExportTask(string path, bool remote) { var source = new SourceTableQuery() { Dataset = new Jhu.Graywulf.Schema.SqlServer.SqlServerDataset(Jhu.Graywulf.Test.Constants.TestDatasetName, Jhu.Graywulf.Test.AppSettings.IOTestConnectionString), Query = "SELECT * FROM SampleData" }; var destination = new DelimitedTextDataFile() { Uri = Util.UriConverter.FromFilePath(path) }; IExportTable te = null; if (remote) { te = RemoteServiceHelper.CreateObject<IExportTable>(Test.Constants.Localhost); } else { te = new ExportTable(); } te.Source = source; te.Destination = destination; return te; }
protected void WriteTable(SourceTableQuery source, DataFileBase destination) { // Create command that reads the table using (var cmd = source.CreateCommand()) { using (var cn = source.OpenConnection()) { using (var tn = cn.BeginTransaction(IsolationLevel.ReadUncommitted)) { cmd.Connection = cn; cmd.Transaction = tn; cmd.CommandTimeout = Timeout; WriteTable(cmd, destination); } } } }
private ICopyTable GetTableCopy(string tableName, bool remote) { ICopyTable q = null; if (remote) { q = RemoteServiceHelper.CreateObject <ICopyTable>(Test.Constants.Localhost); } else { q = new CopyTable(); } var ds = new Jhu.Graywulf.Schema.SqlServer.SqlServerDataset(Jhu.Graywulf.Test.Constants.TestDatasetName, Jhu.Graywulf.Test.AppSettings.IOTestConnectionString) { IsMutable = true }; var source = new SourceTableQuery() { Dataset = ds, Query = "SELECT 1 AS one, 2 AS two, 3 AS three" }; q.Source = new SourceTableQuery[] { source }; var destination = new Jhu.Graywulf.Schema.Table() { Dataset = ds, SchemaName = "dbo", TableName = tableName }; q.Destination = new Schema.Table[] { destination }; q.Options = TableInitializationOptions.Create; return(q); }
private ICopyTable GetTableCopy(string tableName, bool remote) { ICopyTable q = null; if (remote) { q = RemoteServiceHelper.CreateObject<ICopyTable>(Test.Constants.Localhost); } else { q = new CopyTable(); } var ds = new Jhu.Graywulf.Schema.SqlServer.SqlServerDataset(Jhu.Graywulf.Test.Constants.TestDatasetName, Jhu.Graywulf.Test.AppSettings.IOTestConnectionString) { IsMutable = true }; var source = new SourceTableQuery() { Dataset = ds, Query = "SELECT 1 AS one, 2 AS two, 3 AS three" }; q.Source = new SourceTableQuery[] { source }; var destination = new Jhu.Graywulf.Schema.Table() { Dataset = ds, SchemaName = "dbo", TableName = tableName }; q.Destination = new Schema.Table[] { destination }; q.Options = TableInitializationOptions.Create; return q; }
private void CopyMembers(CopyTable old) { this.source = old.source; this.destination = old.destination; }
private void InitializeMembers() { this.source = null; this.destination = null; }
/// <summary> /// Copies a table from a remote data source by creating and /// executing a table copy task. /// </summary> /// <param name="table"></param> /// <param name="source"></param> public void CopyRemoteTable(TableReference table, SourceTableQuery source) { // Create a target table name var temptable = GetTemporaryTable(GetEscapedUniqueName(table)); TemporaryTables.TryAdd(table.UniqueName, temptable); var dest = new DestinationTable(temptable) { Options = TableInitializationOptions.Drop | TableInitializationOptions.Create }; var tc = CreateTableCopyTask(source, dest, false); var guid = Guid.NewGuid(); RegisterCancelable(guid, tc); tc.Execute(); UnregisterCancelable(guid); }
public IExportTableArchive GetInitializedTableExportTask() { // Determine server name from connection string // This is required, because bulk copy can go into databases that are only known // by their connection string // Get server name from data source name (requires trimming the sql server instance name) string host = ((Jhu.Graywulf.Schema.SqlServer.SqlServerDataset)sources[0].Dataset).Host; var ss = new SourceTableQuery[sources.Length]; for (int i = 0; i < sources.Length; i++) { ss[i] = new SourceTableQuery() { Dataset = sources[i].Dataset, Query = String.Format("SELECT t.* FROM [{0}].[{1}] AS t", sources[i].SchemaName, sources[i].ObjectName) }; } // Create bulk operation var te = RemoteServiceHelper.CreateObject<IExportTableArchive>(host); te.Sources = ss; te.Destinations = destinations; te.Uri = uri; te.FileFormatFactoryType = fileFormatFactoryType; te.StreamFactoryType = streamFactoryType; te.Timeout = timeout; return te; }
private void CopyMembers(SourceTableQuery old) { this.dataset = Util.DeepCloner.CloneObject(old.dataset); this.query = old.query; }
public SourceTableQuery(SourceTableQuery old) { CopyMembers(old); }
private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, QueryPartitionBase querypartition, TableReference remotetable, SourceTableQuery source) { RegisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition); querypartition.CopyRemoteTable(remotetable, source); UnregisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition); }