private void SaveMigration()
        {
            MigrationOptions.Collections.Clear();
            for (int i = 0; i < CollectionChk.Items.Count; i++)
            {
                if (CollectionChk.GetItemChecked(i))
                {
                    MigrationOptions.Collections.Add(CollectionChk.Items[i].ToString());
                }
            }
            if (ValidateInputes())
            {
                //Save Migration File

                if (string.IsNullOrEmpty(MigrationOptions.Id))
                {
                    MigrationOptions.GenerateId();
                    Session.Migrators.Add(MigrationOptions);
                }
                else
                {
                    var _MigrationOptions = Session.Migrators.FirstOrDefault(x => x.Id == MigrationOptions.Id);
                    _MigrationOptions = MigrationOptions;
                }

                Session.SaveMigrators();
            }
        }
        private void CollectionChk_SelectedIndexChanged(object sender, EventArgs e)
        {
            int i        = CollectionChk.SelectedIndex;
            var chkState = CollectionChk.GetItemChecked(i) ? CheckState.Unchecked : CheckState.Checked;

            CollectionChk.SetItemCheckState(i, chkState);
        }
        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 ChkAll_CheckedChanged(object sender, EventArgs e)
 {
     for (int i = 0; i < CollectionChk.Items.Count; i++)
     {
         if (CollectionChk.GetItemChecked(i) != ChkAll.Checked)
         {
             CollectionChk.SetItemCheckState(i, ChkAll.Checked ? CheckState.Checked : CheckState.Unchecked);
         }
     }
 }
Esempio n. 5
0
        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");
                }

            }
        }