Esempio n. 1
0
        private void OnBeforeExpand(object o, System.Windows.Forms.TreeViewCancelEventArgs e)
        {
            if (DoubleClicked)
            {
                e.Cancel      = true;
                DoubleClicked = false;
                e.Node.Collapse();
            }
            else
            {
                DatabaseNode dbn = e.Node as DatabaseNode;
                if (dbn != null)
                {
                    if (dbn.Nodes.Count == 1)
                    {
                        HiddenNode hn = dbn.Nodes[0] as HiddenNode;
                        if (hn != null)
                        {
                            dbn.Nodes.Clear();

                            // build tables
                            TablesNode TableRoot = new TablesNode("Tables");

                            Collection <TableInfo> tables = DatabaseCtrl.GetTables(dbn.DbInfo);

                            foreach (TableInfo tbl in tables)
                            {
                                TableNode tNode = new TableNode(tbl);
                                foreach (ColumnInfo column in tbl.Columns)
                                {
                                    ColumnNode cNode = new ColumnNode(column.ColumnName);
                                    tNode.Nodes.Add(cNode);
                                }
                                TableRoot.Nodes.Add(tNode);
                            }

                            dbn.Nodes.Add(TableRoot);

                            // build views
                            TableRoot = new TablesNode("Views");

                            Collection <ViewInfo> views = DatabaseCtrl.GetViews(dbn.DbInfo);

                            foreach (ViewInfo view in views)
                            {
                                ViewNode vNode = new ViewNode(view.ViewName);
                                foreach (ColumnInfo column in view.Columns)
                                {
                                    ColumnNode cNode = new ColumnNode(column.ColumnName);
                                    vNode.Nodes.Add(cNode);
                                }
                                TableRoot.Nodes.Add(vNode);
                            }

                            dbn.Nodes.Add(TableRoot);
                        }
                    }
                }
            }
        }
 private void cmbDatabase_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbServer.Items.Count > 0 && cmbServer.Text != string.Empty)
     {
         DatabaseInfo db = cmbDatabase.SelectedItem as DatabaseInfo;
         _tables = DatabaseCtrl.GetTables(db);
         lstAllTables.Items.Clear();
         lstSelectedTables.Items.Clear();
         if (_tables != null)
         {
             foreach (TableInfo table in _tables)
             {
                 lstAllTables.Items.Add(table);
             }
         }
     }
 }
        private void LoadTaskConfig()
        {
            if (!String.IsNullOrEmpty(_dbserver.ServerName))
            {
                for (int ix = 0; ix < cmbServer.Items.Count; ix++)
                {
                    if (cmbServer.Items[ix].ToString() == _dbserver.ServerName)
                    {
                        cmbServer.SelectedIndex = ix;
                    }
                }
            }
            //else if (cmbServer.Items.Count > 0)
            //    cmbServer.SelectedIndex = 0;

            if (!String.IsNullOrEmpty(_dbserver.DatabaseName))
            {
                for (int ix = 0; ix < cmbDatabase.Items.Count; ix++)
                {
                    if (cmbDatabase.Items[ix].ToString() == _dbserver.DatabaseName)
                    {
                        cmbDatabase.SelectedIndex = ix;
                    }
                }
            }
            // else if (cmbDatabase.Items.Count > 0)
            //     cmbDatabase.SelectedIndex = 0;


            //load config info
            TaskInfo taskitem = ConfigCtrl.GetTask(_taskid, _taskname);

            if (taskitem == null)
            {
                MessageBox.Show("Fail to read task config file!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Template
            if (!String.IsNullOrEmpty(taskitem.Template))
            {
                for (int ix = 0; ix < cmbTemplate.Items.Count; ix++)
                {
                    if (cmbTemplate.Items[ix].ToString() == taskitem.Template)
                    {
                        cmbTemplate.SelectedIndex = ix;
                    }
                }
            }
            else if (cmbTemplate.Items.Count > 0)
            {
                cmbTemplate.SelectedIndex = 0;
            }

            //Modules
            if (cmbTemplate.SelectedIndex >= 0)
            {
                selectorModule.AllSelectedItems = taskitem.Modules;
            }

            //tables
            if (cmbServer.SelectedIndex >= 0 && cmbDatabase.SelectedIndex >= 0)
            {
                _tables = DatabaseCtrl.GetTables(taskitem.DatabaseServer);

                lstAllTables.Items.Clear();
                lstSelectedTables.Items.Clear();

                if (_tables != null)
                {
                    lstAllTables.Items.Clear();
                    bool isAdded;
                    foreach (TableInfo table in _tables)
                    {
                        isAdded = false;
                        if (taskitem.Tables != null)
                        {
                            foreach (TableInfo selecteditem in taskitem.Tables)
                            {
                                if (selecteditem.TableName == table.TableName)
                                {
                                    lstSelectedTables.Items.Add(table);
                                    isAdded = true;
                                    break;
                                }
                            }
                        }

                        if (!isAdded)
                        {
                            lstAllTables.Items.Add(table);
                        }
                    }
                }
            }

            txtNameSpacePrefix.Text   = taskitem.NameSpacePrefix;
            txtNameSpaceSuffix.Text   = taskitem.NameSpaceSuffix;
            chkWriteLogToFile.Checked = taskitem.WriteLogToFile;
        }