예제 #1
0
        public void DragDrop_CopyTable(AppObject appobj)
        {
            //var tobj = appobj as TableAppObject;
            //if (tobj == null) return;
            var              conn    = this.FindDatabaseConnection();
            ITableSource     tsource = appobj.TableSource;
            TableStructure   tbl     = new TableStructure(tsource.InvokeLoadStructure(TableStructureMembers.AllNoRefs));
            TableCopyOptions opts;
            bool             copydata;
            string           newname = CopyTableForm.Run(tsource, conn, out copydata, out opts);

            if (newname == null)
            {
                return;
            }
            List <NameWithSchema> names = new List <NameWithSchema>(conn.InvokeLoadFullTableNames());

            if (ArrayTool.Contains(names, new NameWithSchema(newname)))
            {
                StdDialog.ShowError(Texts.Get("s_table_allready_exists"));
                return;
            }
            tbl.FullName = new NameWithSchema(newname);
            if (conn.Dialect != null)
            {
                conn.Dialect.MigrateTable(tbl, conn.Dialect.CreateMigrationProfile(), null);
            }
            tbl.RemoveConstraints <IForeignKey>();
            PrimaryKey pk = (PrimaryKey)TableStructureExtension.FindConstraint <IPrimaryKey>(tbl);

            if (pk != null && pk.Name != null && pk.Name.ToUpper().StartsWith("PK_"))
            {
                pk.Name = "PK_" + tbl.Name;
            }
            try
            {
                ITableSource dst = conn.CreateTable(tbl);
                if (copydata)
                {
                    BulkCopyJob.Create(tsource.GetDataStoreAndClone(), dst.GetDataStoreAndClone(), new IdentityTransform(tbl), opts, null).StartProcess();
                }
            }
            catch (Exception e)
            {
                Errors.Report(e);
            }
        }
예제 #2
0
 private Job CreateJob()
 {
     return(BulkCopyJob.Create(m_source, m_target, columnMapFrame1.GetTransform(), tableCopyOptionsFrame1.GetOptions(), null));
 }