Esempio n. 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);
            }
        }
Esempio n. 2
0
        public static void InvokeFromGui(Action proc)
        {
            IAsyncResult res = proc.BeginInvoke(null, null);

            Async.WaitFor(res);
            proc.EndInvoke(res);
        }
Esempio n. 3
0
        private static void Open(IPhysicalConnection conn)
        {
            IAsyncResult res = conn.BeginOpen(null);

            Async.WaitFor(res);
            conn.EndOpen(res);
        }
Esempio n. 4
0
        public static void Close(IPhysicalConnection conn)
        {
            IAsyncResult res = conn.BeginClose(null);

            Async.WaitFor(res);
            conn.EndClose(res);
        }
Esempio n. 5
0
 private void Disconnected(IAsyncResult async)
 {
     try
     {
         if (async != null)
         {
             Async.WaitFor(async);
         }
         //Properties["connected"] = "";
         DispatchChangedProperties();
         RealNode.CollapseNode();
         if (async != null)
         {
             m_conn.EndClose(async);
         }
     }
     catch (Exception e)
     {
         Errors.Report(e);
     }
     m_connecting = false;
     OnDisconnect();
     CallRefresh();
     //ProcessRegister.RemoveBackgroundTask("s_disconnect");
 }
Esempio n. 6
0
        public static void SafeReconnect(IPhysicalConnection conn)
        {
            IAsyncResult res = conn.BeginInvoke((Action)conn.Reconnect, null);

            Async.WaitFor(res);
            conn.EndInvoke(res);
        }
Esempio n. 7
0
        //public static List<NameWithSchema> InvokeLoadFullTableNames(this IPhysicalConnection conn, string dbname)
        //{
        //    DatabaseStructureMembers dbmem = new DatabaseStructureMembers { TableList = true };
        //    IDatabaseStructure dbs = conn.InvokeLoadStructure(dbname, dbmem);
        //    return dbs.GetTableNames();
        //}

        public static IDatabaseStructure InvokeLoadStructure(this IPhysicalConnection conn, string dbname, DatabaseStructureMembers members, IProgressInfo progress)
        {
            IAsyncResult async = conn.BeginInvoke(
                (Func <IDatabaseStructure>) delegate() { return(conn.Dialect.AnalyseDatabase(conn, dbname, members, progress)); },
                null);

            Async.WaitFor(async);
            return((IDatabaseStructure)conn.EndInvoke(async));
        }
Esempio n. 8
0
        //public static List<IVirtualFolder> GetFolderSet(this ITreeNode node, string dbsubfolder)
        //{
        //    ITreeNode seldb = node.GetDatabaseNode();
        //    if (seldb == null) return null;

        //    string dbname = node.GetDatabaseName();
        //    IPhysicalConnection conn = MainWindowExtension.SelectedConnection;
        //    if (conn != null && conn.SystemConnection != null)
        //    {
        //        DXDriver driver = PhysicalConnectionExtension.GetDXDriver(conn);
        //        IVirtualFolder local = new FileSystemFolder(seldb.GetPrivateSubFolder(dbsubfolder));
        //        List<IVirtualFolder> res = new List<IVirtualFolder>();
        //        res.Add(local);
        //        if (driver != null)
        //        {
        //            IVirtualFolder onserver = driver.GetFolder(dbsubfolder, dbname);
        //            res.Add(onserver);
        //        }
        //        return res;
        //    }
        //    return null;
        //}

        public static ITreeNode[] GetChildrenNow(this ITreeNode node)
        {
            if (!node.PreparedChildren)
            {
                IAsyncResult async = node.BeginLoadChildren(null);
                Async.WaitFor(async);
                node.EndLoadChildren(async);
            }
            return(node.GetChildren());
        }
Esempio n. 9
0
        public static void Invoke4 <T1, T2, T3, T4>(this IInvoker conn, Action <T1, T2, T3, T4> func, T1 p1, T2 p2, T3 p3, T4 p4)
        {
            if (conn.IsInInvokerThread)
            {
                func(p1, p2, p3, p4); return;
            }
            IAsyncResult res = conn.BeginInvoke((Action) delegate() { func(p1, p2, p3, p4); }, null, null);

            Async.WaitFor(res);
            conn.EndInvoke(res);
        }
Esempio n. 10
0
        public static void Invoke1 <T1>(this IInvoker conn, Action <T1> func, T1 p1)
        {
            if (conn.IsInInvokerThread)
            {
                func(p1); return;
            }
            IAsyncResult res = conn.BeginInvoke((Action) delegate() { func(p1); }, null, null);

            Async.WaitFor(res);
            conn.EndInvoke(res);
        }
Esempio n. 11
0
        public static void Invoke(this IInvoker conn, Action func)
        {
            if (conn.IsInInvokerThread)
            {
                func(); return;
            }
            IAsyncResult res = conn.BeginInvoke(func, null, null);

            Async.WaitFor(res);
            conn.EndInvoke(res);
        }
Esempio n. 12
0
        public static R InvokeR4 <R, T1, T2, T3, T4>(this IInvoker conn, Func <T1, T2, T3, T4, R> func, T1 p1, T2 p2, T3 p3, T4 p4)
        {
            if (conn.IsInInvokerThread)
            {
                return(func(p1, p2, p3, p4));
            }
            IAsyncResult res = conn.BeginInvoke((Func <R>) delegate() { return(func(p1, p2, p3, p4)); }, null, null);

            Async.WaitFor(res);
            return((R)conn.EndInvoke(res));
        }
Esempio n. 13
0
        public static R InvokeR1 <R, T1>(this IInvoker conn, Func <T1, R> func, T1 p1)
        {
            if (conn.IsInInvokerThread)
            {
                return(func(p1));
            }
            IAsyncResult res = conn.BeginInvoke((Func <R>) delegate() { return(func(p1)); }, null, null);

            Async.WaitFor(res);
            return((R)conn.EndInvoke(res));
        }
Esempio n. 14
0
        public static ITableStructure InvokeLoadStructure(this ITableSource table, TableStructureMembers members)
        {
            IPhysicalConnection conn = table.Connection;

            if (conn == null)
            {
                return(table.LoadTableStructure(members));
            }
            IAsyncResult async = conn.BeginInvoke((Func <TableStructureMembers, ITableStructure>)table.LoadTableStructure, null, members);

            Async.WaitFor(async);
            return((ITableStructure)conn.EndInvoke(async));
        }
Esempio n. 15
0
        public static IDatabaseStructure InvokeLoadStructure(this IDatabaseSource db, DatabaseStructureMembers members, IProgressInfo progress)
        {
            if (db.Connection == null)
            {
                return(db.LoadDatabaseStructure(members, progress));
            }
            IAsyncResult async = db.Connection.BeginInvoke(
                (Func <IDatabaseStructure>) delegate() { return(db.LoadDatabaseStructure(members, progress)); },
                null);

            Async.WaitFor(async);
            return((IDatabaseStructure)db.Connection.EndInvoke(async));
        }
Esempio n. 16
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++;
                }
            }
        }