Inheritance: CouchDesignDocument
Esempio n. 1
0
        /// <summary>
        /// Handles the Click event of the addDesignToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void addDesignToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_contextNode == null)
            {
                return;
            }

            if (HasOnlyDummyNode(_contextNode))
            {
                _contextNode.Nodes.Clear();
            }

            using (var dialog = new dlgName("Design name", "New Design"))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var design = new GenericDesignDocument(dialog.EnteredName,
                                                       ((CouchDatabase)_contextNode.Tag));

                var designNode = CreateDesignNode(design, _contextNode);
                designNode.EnsureVisible();
            }
        }
Esempio n. 2
0
        private void LoadDesign(GenericDesignDocument designDoc, TreeNode parent)
        {
            var viewsNode = CreateViewsNode(parent);

            foreach (var view in designDoc.Definitions)
            {
                TreeNode node = CreateViewNode(viewsNode, view);
                CreateGenericFunctionNode("map", node, "map");
                if (!String.IsNullOrEmpty(view.Reduce))
                {
                    CreateGenericFunctionNode("reduce", node, "reduce");
                }
            }

            var ftiNode = CreateIndicesNode(parent);

            foreach (var index in designDoc.LuceneDefinitions)
            {
                CreateGenericFunctionNode("fti", ftiNode, index.Name);
            }

            var showsNode = CreateShowsNode(parent);

            foreach (var show in designDoc.Shows)
            {
                CreateGenericFunctionNode("show", showsNode, show.Name);
            }

            var listsNode = CreateListsNode(parent);

            foreach (var list in designDoc.Lists)
            {
                CreateGenericFunctionNode("list", listsNode, list.Name);
            }
        }
Esempio n. 3
0
        private void importViewsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CouchDatabase targetDb = (CouchDatabase)_contextNode.Tag;

            if (folderBrowserDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            foreach (var file in Directory.GetFiles(folderBrowserDialog1.SelectedPath))
            {
                using (var reader = new StreamReader(File.OpenRead(file)))
                {
                    var design = new GenericDesignDocument();
                    design.ReadJson((JObject)JToken.ReadFrom(new JsonTextReader(reader)));

                    // need to make sure to overwrite the target
                    if (targetDb.HasDocument(design.Id))
                    {
                        design.Rev = targetDb.GetDocument(design.Id).Rev;
                    }
                    else
                    {
                        design.Rev = null;
                    }

                    design.Owner = targetDb;
                    design.Synch();
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a design node.
        /// </summary>
        /// <param name="design">The design.</param>
        /// <param name="parent">The parent.</param>
        /// <returns></returns>
        private TreeNode CreateDesignNode(GenericDesignDocument design, TreeNode parent)
        {
            var node = parent.Nodes.Add(design.Id);

            node.Nodes.Add(String.Empty);
            node.Tag                = design;
            node.ImageIndex         = 1;
            node.SelectedImageIndex = 1;

            return(node);
        }