void Migrate() { MigrationOptions.Collections.Clear(); for (int i = 0; i < CollectionChk.Items.Count; i++) { if (CollectionChk.GetItemChecked(i)) { MigrationOptions.Collections.Add(CollectionChk.Items[i].ToString()); } } if (!MigrationOptions.Collections.Any()) { MessageBox.Show("Please Select Collections To Be Migrated"); return; } string log = ""; var exportPath = MongoGeneralLogic.ExportToJson(MigrationOptions.SourceServer.ConnectionString, MigrationOptions.SourceDb, "", MigrationOptions.Collections, true, false, out log, true); MongoGeneralLogic.ImportFromJson(MigrationOptions.DestinationServer, MigrationOptions.DestinationDb, Directory.GetFiles(exportPath).ToList(), true); try { Directory.Delete(exportPath, true); MessageBox.Show("Migration DONE"); } catch { MessageBox.Show("Migration ERROR"); } }
private void BtnExport_Click(object sender, EventArgs e) { string log = ""; var Collections = new List<string>(); for (int i = 0; i < CollectionChk.Items.Count; i++) { if (CollectionChk.GetItemChecked(i)) { Collections.Add(CollectionChk.Items[i].ToString()); } } //TODO Check Save Path if (RdJson.Checked) { if (!string.IsNullOrEmpty(txtSavePath.Text)) { MongoGeneralLogic.ExportToJson(server.ConnectionString, DbName, txtSavePath.Text, Collections, ChkFormatJson.Checked, ChkArray.Checked, out log); log = string.IsNullOrEmpty(log) ? "Done" : ""; MessageBox.Show(log); Close(); } } else if (RdAnotherDb.Checked) { var exportTodbFrm = new ExportToDbFrm(server.ConnectionString, DbName, Collections); if (exportTodbFrm.ShowDialog() == DialogResult.OK) { log = string.IsNullOrEmpty(log) ? "Done" : ""; MessageBox.Show(log); Close(); } else { MessageBox.Show("Please Select Save Location"); } } else if (RdBackUpFile.Checked) { if (!string.IsNullOrEmpty(TxtMdtFilePath.Text)) { MongoGeneralLogic.ExportToDump(server, DbName, TxtMdtFilePath.Text, Collections, out log); log = string.IsNullOrEmpty(log) ? "Done" : ""; MessageBox.Show(log); Close(); } else { MessageBox.Show("Please Select Save Path"); } } }