Exemple #1
0
        void NewConnection(MDTServer server = null)
        {
            var c = new ConnectionsFrm();

            if (server != null || c.ShowDialog() == DialogResult.OK)
            {
                var            CurrentConnection = server ?? Session.CurrentConnections.Last();
                var            ConnectionDb      = MongoGeneralLogic.GetServerDataBases(CurrentConnection);
                string         ConnectionName    = !string.IsNullOrEmpty(CurrentConnection.ConnectionAlias) ? CurrentConnection.ConnectionAlias : CurrentConnection.Server;
                ServerTreeNode connectionNode    = new ServerTreeNode()
                {
                    Text                   = ConnectionName,
                    ImageIndex             = 0,
                    ServerConnectionString = CurrentConnection.ConnectionString,
                    Server                 = CurrentConnection,
                    ContextMenuStrip       = ServerContextMenu,
                };
                foreach (var db in ConnectionDb)
                {
                    var dbTreeNode = new DbTreeNode()
                    {
                        Text                   = db,
                        Name                   = "Db_" + db,
                        ImageIndex             = 1,
                        ContextMenuStrip       = DbContextMenu,
                        DbName                 = db,
                        Server                 = CurrentConnection,
                        ServerConnectionString = CurrentConnection.ConnectionString
                    };
                    dbTreeNode.Nodes.Add("");

                    connectionNode.Nodes.Add(dbTreeNode);
                }
                ConnectionTree.Nodes.Add(connectionNode);
                connectionNode.Expand();
            }
        }
 private void ConnectionsGrid_SelectionChanged(object sender, EventArgs e)
 {
     ConnectionTree.Nodes.Clear();
     if (ConnectionsGrid.SelectedRows.Count > 0)
     {
         int    SelectedIndex     = ConnectionsGrid.Rows.IndexOf(ConnectionsGrid.SelectedRows[0]);
         var    CurrentConnection = Session.Settings.Servers[SelectedIndex];
         var    ConnectionDb      = MongoGeneralLogic.GetServerDataBases(CurrentConnection);
         string ConnectionName    = !string.IsNullOrEmpty(CurrentConnection.ConnectionAlias) ? CurrentConnection.ConnectionAlias : CurrentConnection.Server;
         TargetConnection = CurrentConnection.ConnectionString;
         foreach (var db in ConnectionDb)
         {
             var dbTreeNode = new DbTreeNode()
             {
                 Text = db,
                 Name = "Db_" + db,
                 //ImageIndex = 1,
                 DbName = db,
                 ServerConnectionString = CurrentConnection.ConnectionString
             };
             ConnectionTree.Nodes.Add(dbTreeNode);
         }
     }
 }