Example #1
0
        public void SetBindings(ITabularDataStore source, ITabularDataStore target)
        {
            Async.SafeOpen(source.Connection);
            Async.SafeOpen(target.Connection);
            //lbsource.Enabled = false;
            //lbtarget.Enabled = false;
            lbsource.Items.Clear();
            lbtarget.Rows.Clear();
            //lbtarget.Items.Clear();
            Errors.Assert(source.AvailableRowFormat);
            //Async.CreateInvokeCallback(m_invoker, GotRowFormat));
            m_source = source;
            m_target = target;
            //lbsource.Enabled = true;
            //lbtarget.Enabled = true;

            try
            {
                IAsyncResult async = m_source.BeginGetRowFormat(null);
                Async.WaitFor(async);
                m_srcformat = m_source.EndGetRowFormat(async);
            }
            catch (Exception err)
            {
                throw new BulkCopyInputError("DAE-00184", err);
            }

            foreach (IColumnStructure col in m_srcformat.Columns)
            {
                lbsource.Items.Add(col.ColumnName);
                lbtarget.Rows.Add(col.ColumnName, new GenericTransform.ColumnColExprType().ToString(), col.ColumnName);
                //lbtarget.Items.Add(col.ColumnName);
            }
        }
Example #2
0
 public BulkCopyJobCommand(ITabularDataStore source, ITabularDataStore target, IRowTransform rowTransform, TableCopyOptions copyOpts)
 {
     m_source      = source;
     m_target      = target;
     m_transform   = rowTransform;
     m_copyOptions = copyOpts;
 }
Example #3
0
 public override void LoadFromXml(XmlElement xml)
 {
     base.LoadFromXml(xml);
     m_source       = (ITabularDataStore)TabularDataStoreAddonType.Instance.LoadAddon(xml.FindElement("Source"));
     m_target       = (ITabularDataStore)TabularDataStoreAddonType.Instance.LoadAddon(xml.FindElement("Target"));
     m_transformXml = xml.FindElement("Transform");
     m_copyOptions  = new TableCopyOptions();
     m_copyOptions.LoadFromXml(xml.FindElement("CopyOptions"));
 }
Example #4
0
        public DataStoreFileContent(XmlElement xml)
        {
            var ds = xml.FindElement("DataStore");

            this.LoadPropertiesCore(xml);
            if (ds != null)
            {
                DataStore = (ITabularDataStore)TabularDataStoreAddonType.Instance.LoadAddon(ds);
            }
        }
Example #5
0
        public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts)
        {
            var tdst = m_db.GetTable(table.FullName);
            ITabularDataStore dstds = tdst.GetDataStoreAndReuse();

            dstds.CopyOptions  = opts;
            dstds.ProgressInfo = ProgressInfo;
            IAsyncResult async = dstds.BeginWrite(null, queue);

            dstds.EndWrite(async);
        }
Example #6
0
 public void SetDataStore(ITabularDataStore value)
 {
     if (FixedMode)
     {
         propertyFrame1.SelectedObject = value;
     }
     else
     {
         addonSelectFrame1.SelectObject(value);
     }
     UpdateMode();
 }
Example #7
0
 private void PrepareSource()
 {
     if (m_showSource)
     {
         m_source = source.DataStore;
         Async.SafeOpen(m_source.Connection);
     }
     if (m_source != null && !m_sourceCacheCleared)
     {
         m_source.ClearCaches();
         m_sourceCacheCleared = true;
     }
 }
Example #8
0
 private void InitColumnMap()
 {
     PrepareSource();
     if (m_showTarget)
     {
         m_target = target.DataStore;
         Async.SafeOpen(m_target.Connection);
     }
     if (m_target != null)
     {
         m_target.ClearCaches();
     }
     columnMapFrame1.SetBindings(m_source, m_target);
 }
Example #9
0
        public BulkCopyWizard(ITabularDataStore source, ITabularDataStore target)
        {
            InitializeComponent();
            m_source = source;
            m_target = target;

            bool isConfig = false;

            if (m_source != null)
            {
                m_source.Mode = TabularDataStoreMode.Read;
                if (!m_source.ConfigurationNeeded)
                {
                    wizard1.Pages.Remove(wpsource);
                    m_showSource = false;
                }
                else
                {
                    isConfig = true;
                    this.source.SetDataStore(m_source);
                }
            }

            if (m_target != null)
            {
                m_target.Mode = TabularDataStoreMode.Write;
                if (!m_target.ConfigurationNeeded)
                {
                    wizard1.Pages.Remove(wptarget);
                    m_showTarget = false;
                }
                else
                {
                    isConfig = true;
                }
                if (m_target != null)
                {
                    this.target.SetDataStore(m_target);
                }
            }
            if (!isConfig && m_source != null && m_target != null)
            {
                InitColumnMap();
            }
            wizard1.PageIndex = 0;
        }
Example #10
0
 public void SetBindings(ITabularDataStore source, ITabularDataStore target)
 {
     if (m_frmvar != null)
     {
         ((UserControl)m_frmvar).Dispose();
     }
     if (target.AvailableRowFormat)
     {
         ColumnMapFrame_FixedTarget frmvar = new ColumnMapFrame_FixedTarget();
         panel1.Controls.Add(frmvar);
         frmvar.Dock = DockStyle.Fill;
         m_frmvar    = frmvar;
         frmvar.SetBindings(source, target);
     }
     else
     {
         ColumnMapFrame_VarTarget frmvar = new ColumnMapFrame_VarTarget();
         panel1.Controls.Add(frmvar);
         frmvar.Dock = DockStyle.Fill;
         m_frmvar    = frmvar;
         frmvar.SetBindings(source, target);
     }
     Translating.TranslateControl(this);
 }
Example #11
0
 public static Job Create(ITabularDataStore source, ITabularDataStore target, IRowTransform rowTransform, TableCopyOptions copyOpts, JobProperties jobProps)
 {
     return(Job.FromCommand(new BulkCopyJobCommand(source, target, rowTransform, copyOpts), jobProps));
 }
Example #12
0
 public override void LoadFromXml(System.Xml.XmlElement xml)
 {
     base.LoadFromXml(xml);
     DataStore = (ITabularDataStore)TabularDataStoreAddonType.Instance.LoadAddon(xml.FindElement("DataStore"));
 }
Example #13
0
 void res_ChangedSelectedObject(object sender, EventArgs e)
 {
     DataStore = (ITabularDataStore)((AddonSelectFrame)sender).SelectedObject;
 }
Example #14
0
        public static void Run(ITabularDataStore source, ITabularDataStore target)
        {
            BulkCopyWizard wizard = new BulkCopyWizard(source, target);

            wizard.ShowDialogEx();
        }
Example #15
0
        public void SetBindings(ITabularDataStore source, ITabularDataStore target)
        {
            using (WaitContext wc = new WaitContext())
            {
                Async.SafeOpen(source.Connection);
                Async.SafeOpen(target.Connection);
                try
                {
                    IAsyncResult res1 = source.BeginGetRowFormat(null);
                    Async.WaitFor(res1);
                    m_source = source.EndGetRowFormat(res1);
                }
                catch (Exception err)
                {
                    throw new BulkCopyInputError("DAE-00181", err);
                }

                if (m_source.Columns.Count == 0)
                {
                    throw new ExpectedError("DAE-00182 " + Texts.Get("s_no_columns_detected_in_imported_source"));
                }

                IAsyncResult res2 = target.BeginGetRowFormat(null);
                Async.WaitFor(res2);
                m_target = target.EndGetRowFormat(res2);

                int acty     = labValue.Top + labValue.Height + 10;
                int colindex = 0;
                foreach (IColumnStructure col in m_target.Columns)
                {
                    Label lab = new Label();
                    Controls.Add(lab);
                    lab.Left = labTarget.Left;
                    lab.Top  = acty;
                    lab.Text = col.ColumnName + " :";

                    CheckBox skip = new CheckBox();
                    Controls.Add(skip);
                    skip.Top   = acty;
                    skip.Width = 30;
                    skip.Left  = labSkip.Left;
                    m_checks.Add(skip);
                    skip.Tag             = colindex;
                    skip.CheckedChanged += new EventHandler(skip_CheckedChanged);

                    ComboBox type = new ComboBox();
                    Controls.Add(type);
                    type.Left          = labType.Left;
                    type.Top           = acty;
                    type.DropDownStyle = ComboBoxStyle.DropDownList;
                    GenericTransform.GetColExprTypes(type.Items);
                    type.SelectedIndex = 0;
                    type.Tag           = colindex;
                    m_typeCombos.Add(type);

                    ComboBox sel = new ComboBox();
                    Controls.Add(sel);
                    sel.Left            = labValue.Left;
                    sel.Top             = acty;
                    sel.DropDownStyle   = ComboBoxStyle.DropDown;
                    sel.DropDownClosed += new EventHandler(sel_DropDownClosed);
                    sel.Tag             = colindex;
                    foreach (IColumnStructure srccol in m_source.Columns)
                    {
                        sel.Items.Add(srccol.ColumnName);
                    }
                    sel.SelectedIndex = sel.Items.IndexOf(col.ColumnName);
                    if (sel.SelectedIndex < 0)
                    {
                        if (col.ColumnOrder < sel.Items.Count)
                        {
                            sel.SelectedIndex = col.ColumnOrder;
                        }
                        else
                        {
                            sel.SelectedIndex = 0;
                        }
                    }
                    m_combos.Add(sel);

                    acty += Math.Max(sel.Height, lab.Height) * 5 / 4;
                    colindex++;
                }
            }
        }
Example #16
0
        public static void CopyDatabase(IDatabaseSource src, IDatabaseWriter dst, IProgressInfo progress, DatabaseCopyOptions copyOpts)
        {
            IDatabaseWriter dst2 = null;

            for (; ;)
            {
                dst2 = dst.GetRedirectedWriter();
                if (dst2 == null)
                {
                    break;
                }
                dst = dst2;
            }
            dst.SetSourceInfo(new DatabaseWriterSourceInfo
            {
                Dialect = src.Dialect,
                //CopyMode = copyOpts.Mode,
                SchemaMode = copyOpts.SchemaMode,
            });
            try
            {
                dst.ProgressInfo = progress;

                Async.SafeOpen(src.Connection);
                dst.OpenConnection();

                if (dst.DirectCopy(src))
                {
                    dst.RunDirectCopy(src, copyOpts);
                }
                else
                {
                    copyOpts.CopyMembers.IgnoreSystemObjects = true;
                    IDatabaseStructure tmpDb    = src.InvokeLoadStructure(copyOpts.CopyMembers, progress);
                    DatabaseStructure  sourceDb = new DatabaseStructure(tmpDb);
                    //sourceDb.AutoFillRefs();
                    DatabaseStructure targetDb = sourceDb.GetMappedDatabase(copyOpts, dst.Dialect);
                    if (dst.Dialect != null)
                    {
                        dst.Dialect.MigrateDatabase(targetDb, copyOpts.MigrationProfile, progress);
                    }

                    if (copyOpts.CopyStructure)
                    {
                        dst.WriteStructureBeforeData(targetDb);
                    }

                    bool copydata = copyOpts.DataMode != DbCopyDataMode.None && src.TableCaps.DataStoreForReading && dst.WriterCaps.AcceptData;
                    if (copydata)
                    {
                        dst.BeforeFillData();

                        foreach (var tbl in sourceDb.Tables.SortedByKey <ITableStructure, int>(tbl => copyOpts.DataCopyTables.IndexOf(tbl.FullName)))
                        {
                            if (!copyOpts.CopyTableData(tbl.FullName))
                            {
                                continue;
                            }
                            Logging.Debug("Copying table {0}", tbl);
                            if (progress != null)
                            {
                                progress.SetCurWork(String.Format("{0} {1}", Texts.Get("s_copying_table"), tbl));
                            }
                            GenericDataQueue queue = new GenericDataQueue(tbl, tbl, new IdentityTransform(tbl));
                            queue.ProgressInfo = progress;
                            if (dst.WriterCaps.ExecuteSql)
                            {
                                var ada = new RecordToDbAdapter(tbl, tbl, dst.Dialect, new DataFormatSettings());
                                ada.ProgressInfo = progress;
                                queue.AddOutputAdapter(ada);
                            }
                            ITableSource      tsrc           = src.GetTable(tbl.FullName);
                            ITabularDataStore srcds          = tsrc.GetDataStoreAndReuse();
                            IAsyncResult      async_src      = srcds.BeginRead(null, queue);
                            ITableStructure   newTableStruct = (ITableStructure)targetDb.FindByGroupId(tbl.GroupId);
                            dst.FillTable(newTableStruct, queue, copyOpts.TableOptions);
                            srcds.EndRead(async_src);
                        }
                        dst.AfterFillData();
                    }
                    if (copyOpts.CopyStructure)
                    {
                        dst.WriteStructureAfterData(targetDb);
                    }
                }
            }
            catch (Exception)
            {
                dst.ProcessFailed();
                throw;
            }
            finally
            {
                Async.SafeClose(src.Connection);
                dst.CloseConnection();
            }
        }