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 backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { MongoGeneralLogic.ImportFromJson(server, TxtDbName.Text, SelectedFiles, ChkDropIfExist.Checked); }