Пример #1
0
        private void cloneViewsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CouchDatabase sourceDb = (CouchDatabase)_contextNode.Tag;

            using (var dialog = new dlgName("Specify Target", "Target Server/database"))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var dbParts  = dialog.EnteredName.Replace("//", "").Split('/');
                var svr      = CreateServer(dbParts[0].Split(':'));
                var targetDb = svr.GetDatabase(dbParts[1]);

                foreach (var view in sourceDb.QueryAllDocuments().StartKey("_design").EndKey("_designZZZZZZZZZZZZZZZZZ").GetResult().RowDocuments())
                {
                    var design = sourceDb.GetDocument <GenericDesignDocument>(view.Key);

                    // 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();
                }
            }
        }
Пример #2
0
        private void extractViewsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CouchDatabase sourceDb = (CouchDatabase)_contextNode.Tag;

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

            foreach (var view in sourceDb.QueryAllDocuments().StartKey("_design").EndKey("_designZZZZZZZZZZZZZZZZZ").GetResult().RowDocuments())
            {
                var design = sourceDb.GetDocument <GenericDesignDocument>(view.Key);

                using (var streamWriter = new StreamWriter(File.OpenWrite(Path.Combine(folderBrowserDialog1.SelectedPath, design.Id.Substring(8) + ".js"))))
                {
                    var writer = new JsonTextWriter(streamWriter);
                    writer.Indentation = 1;
                    writer.IndentChar  = '\t';
                    writer.Formatting  = Formatting.Indented;
                    writer.WriteStartObject();
                    design.WriteJson(writer);
                    writer.WriteEndObject();
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Loads the database into the treeview, under the given parent.
 /// </summary>
 /// <param name="couchDatabase">The couch database.</param>
 /// <param name="parent">The parent.</param>
 private void LoadDatabase(CouchDatabase couchDatabase, TreeNode parent)
 {
     foreach (var view in couchDatabase.QueryAllDocuments().StartKey("_design").EndKey("_design0").GetResult().RowDocuments())
     {
         var design = couchDatabase.GetDocument <GenericDesignDocument>(view.Key);
         design.Owner = couchDatabase;
         CreateDesignNode(design, parent);
     }
 }
Пример #4
0
 /// <summary>
 /// Loads the database into the treeview, under the given parent.
 /// </summary>
 /// <param name="couchDatabase">The couch database.</param>
 /// <param name="parent">The parent.</param>
 private void LoadDatabase(CouchDatabase couchDatabase, TreeNode parent)
 {
     try
     {
         foreach (var view in couchDatabase.QueryAllDocuments().StartKey("_design").EndKey("_design0").GetResult().RowDocuments())
         {
             var design = couchDatabase.GetDocument <GenericDesignDocument>(view.Key);
             design.Owner = couchDatabase;
             CreateDesignNode(design, parent);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Error Loading Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }