示例#1
0
 private void AddDbs(TreeNode tnn,Data.Connect c)
 {
     //throw new NotImplementedException();
     foreach (MongoDB.Driver.MongoDatabase mdb in c.Databases)
     {
         TreeNode tn = new TreeNode();
         Data.MTag mt = new Data.MTag();
         mt.tag = mdb;
         mt.Type = Data.Data.DbCludes.Database;
         tn.Text = mdb.Name;
         tn.Tag = mt;
         tn.ImageIndex = 1;
         tn.SelectedImageIndex = 1;
         AddDBNode(tn);
         tnn.Nodes.Add(tn);
     }
 }
示例#2
0
 private void MakeUsers(TreeNode treeNode, MongoDB.Driver.MongoDatabase mongoDatabase, bool bRefresh)
 {
     //throw new NotImplementedException();
     if (bRefresh) treeNode.Nodes.Clear();
     if (treeNode.Nodes.Count <= 0)
     {
         Log("db.system.users.find()");
         foreach (MongoDB.Driver.MongoUser mu in mongoDatabase.FindAllUsers())
         {
             Data.MTag mt = new Data.MTag(Data.Data.DbCludes.user);
             mt.tag = mu;
             TreeNode tn = new TreeNode(mu.Username);
             tn.ImageIndex = (int)Data.Data.DbCludes.user;
             tn.SelectedImageIndex = (int)Data.Data.DbCludes.user;
             tn.Tag = mt;
             treeNode.Nodes.Add(tn);
         }
         treeNode.ExpandAll();
     }
 }
示例#3
0
 private void MakeCollections(TreeNode treeNode, MongoDB.Driver.MongoDatabase mongoDatabase,bool bRefresh)
 {
     //throw new NotImplementedException();
     if (bRefresh) treeNode.Nodes.Clear();
     if (treeNode.Nodes.Count <= 0)
     {
         foreach (string s in mongoDatabase.GetCollectionNames())
         {
             if (s.IndexOf("system") == 0) // system belong to Db,not Collections!
                 continue;
             TreeNode tn = new TreeNode(s);
             tn.ImageIndex = (int)Data.Data.DbCludes.table;
             tn.SelectedImageIndex = (int)Data.Data.DbCludes.table;
             Data.MTag mt = new Data.MTag(Data.Data.DbCludes.table);
             mt.tag = mongoDatabase.GetCollection(s);
             tn.Tag = mt;
             AddIndexes(tn);
             treeNode.Nodes.Add(tn);
         }
         treeNode.ExpandAll();
     }
 }
示例#4
0
        private void MakeJs(TreeNode treeNode, MongoDB.Driver.MongoDatabase mongoDatabase,bool bRefresh)
        {
            //throw new NotImplementedException();
            if (bRefresh) treeNode.Nodes.Clear();
            if (treeNode.Nodes.Count <= 0)
            {
                Log("db."+mongoDatabase.Name+".system.js.find()");
                foreach (MongoDB.Bson.BsonDocument bd in mongoDatabase.GetCollection(Data.Data.sysStore).FindAll())
                {
                    Data.JSStore js =new Data.JSStore();
                    foreach (MongoDB.Bson.BsonElement be in bd.Elements)
                    {
                        if (be.Name == "_id")
                            js.Name = be.Value.ToString();
                        else
                            js.Value = be.Value.ToString();//.Substring(19, be.Value.ToString().Length - 20);
                    }

                    Data.MTag mt = new Data.MTag(Data.Data.DbCludes.jsstore);
                    mt.tag = js;
                    TreeNode tn = new TreeNode(js.Name);
                    tn.ImageIndex = (int)Data.Data.DbCludes.jsstore;
                    tn.SelectedImageIndex = (int)Data.Data.DbCludes.jsstore;
                    tn.Tag = mt;
                    treeNode.Nodes.Add(tn);
                }
                treeNode.ExpandAll();
            }
        }
示例#5
0
        private bool LocalConnect(TreeNode tn)
        {
            //default connect local
            Data.Connect c = new Data.Connect();

            if (c.Connected())
            {
                Log("Mongo.exe");
                Data.MTag mt = new Data.MTag();
                mt.Type = (int)Data.Data.DbCludes.DatabaseConnect;
                mt.tag = c;
                tn.Tag = mt;
                tn.Text = c.Name;

                AddDbs(tn,c);
                Log("show dbs");
                return true;
            }
            return false;
        }