示例#1
0
 private void CopyMembers(DestinationTable old)
 {
     this.dataset      = old.dataset;
     this.databaseName = old.databaseName;
     this.schemaName   = old.schemaName;
     this.tableName    = old.tableName;
     this.options      = old.options;
 }
示例#2
0
 protected void ReadTable(DataFileBase source, DestinationTable destination)
 {
     // Import the file by wrapping it into a dummy command
     using (var cmd = new FileCommand(source))
     {
         ImportTable(cmd, destination);
     }
 }
示例#3
0
        protected void ImportTable(IDbCommand cmd, DestinationTable destination)
        {
            var guid = Guid.NewGuid();
            var ccmd = new CancelableDbCommand(cmd);

            RegisterCancelable(guid, ccmd);

            ccmd.ExecuteReader(dr =>
            {
                // TODO: Add multiple results logic

                // TODO: Add table naming logic here, maybe...
                var table = destination.GetTable();

                table.Initialize(dr.GetSchemaTable(), destination.Options);
                ExecuteBulkCopy(dr, table);
            });

            UnregisterCancelable(guid);
        }
示例#4
0
        /// <summary>
        /// Copies resultset from the output temporary table to the destination database (MYDB)
        /// </summary>
        public void CopyResultset()
        {
            switch (Query.ExecutionMode)
            {
                case ExecutionMode.SingleServer:
                    // Do nothing as execute writes results directly into destination table
                    break;
                case ExecutionMode.Graywulf:
                    {
                        var source = GetOutputSourceQuery();

                        var destination = new DestinationTable(Query.Destination)
                        {
                            // Change destination to Append, output table has already been created,
                            // partitions only append to it
                            Options = TableInitializationOptions.Append
                        };

                        DumpSqlCommand(source.Query);

                        // Create bulk copy task and execute it
                        var tc = CreateTableCopyTask(source, destination, false);

                        var guid = Guid.NewGuid();
                        RegisterCancelable(guid, tc);

                        tc.Execute();

                        UnregisterCancelable(guid);
                    }
                    break;
                default:
                    throw new NotImplementedException();
            }
        }
示例#5
0
        /// <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);
        }
示例#6
0
 private void InitializeMembers()
 {
     this.source = null;
     this.destination = null;
 }
示例#7
0
 private void CopyMembers(CopyTable old)
 {
     this.source = old.source;
     this.destination = old.destination;
 }
 private void CopyMembers(ImportTableArchive old)
 {
     this.destination = old.destination;
 }
示例#9
0
 protected void ReadTable(DataFileBase source, DestinationTable destination)
 {
     // Import the file by wrapping it into a dummy command
     using (var cmd = new FileCommand(source))
     {
         ImportTable(cmd, destination);
     }
 }
示例#10
0
        private DestinationTable CreateDestination(string schemaName, string tableName)
        {
            GetUniqueTableName(schemaName, ref tableName);

            var destination = new DestinationTable(
                MyDBDataset,
                MyDBDataset.DatabaseName,
                schemaName,
                tableName,
                Graywulf.Schema.TableInitializationOptions.Create);

            return destination;
        }
示例#11
0
 public DestinationTable(DestinationTable old)
 {
     CopyMembers(old);
 }
示例#12
0
 private void CopyMembers(DestinationTable old)
 {
     this.dataset = old.dataset;
     this.databaseName = old.databaseName;
     this.schemaName = old.schemaName;
     this.tableName = old.tableName;
     this.options = old.options;
 }
示例#13
0
 public DestinationTable(DestinationTable old)
 {
     CopyMembers(old);
 }
示例#14
0
 private void CopyMembers(ImportTableArchive old)
 {
     this.destination = old.destination;
 }
示例#15
0
 private void InitializeMembers()
 {
     this.source      = null;
     this.destination = null;
 }
示例#16
0
 private void CopyMembers(CopyTable old)
 {
     this.source      = old.source;
     this.destination = old.destination;
 }
示例#17
0
        protected void ImportTable(IDbCommand cmd, DestinationTable destination)
        {
            var guid = Guid.NewGuid();
            var ccmd = new CancelableDbCommand(cmd);
            RegisterCancelable(guid, ccmd);

            ccmd.ExecuteReader(dr =>
            {
                // TODO: Add multiple results logic

                // TODO: Add table naming logic here, maybe...
                var table = destination.GetTable();

                table.Initialize(dr.GetSchemaTable(), destination.Options);
                ExecuteBulkCopy(dr, table);
            });

            UnregisterCancelable(guid);
        }