예제 #1
0
        private void toolStripDataExport_Click(object sender, EventArgs e)
        {
            if (lstCollection.SelectedItems.Count < 1)
            {
                return;
            }

            var frmdataExp = new DataExport(SelectedDB.GetCollection(lstCollection.SelectedItems[0].Text), false);

            frmdataExp.ShowDialog(this);
        }
예제 #2
0
        private void DeleteDocMenuData_Click(object sender, EventArgs e)
        {
            var model = Utils.GetRootBindableDoc(treeListViewData);

            if (lstCollection.SelectedItems.Count > 0)
            {
                SelectedDB.GetCollection(SelectedCollection).Remove(new QueryDocument(model.BsonParent.ToBsonDocument()));

                lstCollection_ItemSelectionChanged(lstCollection,
                                                   new ListViewItemSelectionChangedEventArgs(
                                                       lstCollection.SelectedItems[0], 0, true));
            }
        }
예제 #3
0
        private void lstCollection_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            if (!e.IsSelected)
            {
                return;
            }

            try
            {
                this.SelectedCollection = lstCollection.SelectedItems[0].Text;

                this.treeListViewData.CanExpandGetter = delegate(object x)
                {
                    /*
                     * var doc = (BsonDocumentBindable)x;
                     * if (doc.BsonElements == null)
                     *  return false;
                     * return doc.BsonElements.Count() > 0;
                     */

                    /*****old logic -- only bson document
                     * var doc = (BsonDocumentBindable)x;
                     * if (doc.BsonParent == null)
                     *  return false;
                     * if (!doc.BsonParent.IsBsonDocument)
                     *  return false;
                     *
                     * BsonDocument docVal = (BsonDocument)doc.BsonParent;//.ToBsonDocument();
                     * return docVal.Elements.Count() > 0;
                     */
                    var doc = (BsonDocumentBindable)x;
                    if ((doc.BsonParent != null) && (doc.BsonParent.IsBsonDocument || doc.BsonParent.IsBsonArray))
                    {
                        if (doc.BsonParent.IsBsonDocument)
                        {
                            return(((BsonDocument)doc.BsonParent).Elements.Count() > 0);
                        }
                        if (doc.BsonParent.IsBsonArray)
                        {
                            return(((BsonArray)doc.BsonParent).Count > 0);
                        }
                    }
                    return(false);

                    /*
                     * var doc = (BsonDocumentBindable)x;
                     * if (doc.BsonParent == null)
                     *  return false;
                     *
                     * if (doc.BsonParent.IsBsonDocument)
                     * {
                     *  BsonDocument docVal = (BsonDocument)doc.BsonParent;
                     *  return docVal.Elements.Count() > 0;
                     * }
                     * else if (doc.BsonParent.IsBsonArray)
                     * {
                     *  BsonArray docVal = (BsonArray)doc.BsonParent;
                     *  return docVal.Count > 0;
                     * }
                     * else
                     * {
                     *  return false;
                     * }*/
                };
                this.treeListViewData.ChildrenGetter = delegate(object x)
                {
                    return
                        (Utils.GetBindableDocsFromElements(
                             (BsonDocumentBindable)x));
                };

                this.treeListViewData.Roots = Utils.GetBindableDocsFromCollection(SelectedDB,
                                                                                  lstCollection.SelectedItems[0].Text);

                tabControl1.TabPages[2].Text = "Data (" + lstCollection.SelectedItems[0].Text + ")";

                //Showing collection property
                MongoCollection collection = SelectedDB.GetCollection(lstCollection.SelectedItems[0].Text);
                propCollection.SelectedObject = Utils.GetCollectionProperty(collection);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }