private void bSave_Click(object sender, EventArgs e)
        {
            SqlDumpDto  mysqlSettings = ConfigurationManager.getInstance().getMySqlDumpSettings();
            CompressDto compSettings  = ConfigurationManager.getInstance().getCompressSettings();

            if (cbEncryptHeader.Checked)
            {
                if (cmbFileFormat.SelectedIndex != 0)
                {
                    MessageBox.Show("Header encryption only works with .7z file format. Switch to .7z format or disable header encryption.",
                                    "Header Encryption", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (cbEnableComp.Checked && cbEnablePasswordEncryption.Checked)
            {
                if (tbPass.Text != tbConfirmPass.Text)
                {
                    MessageBox.Show("The two passwords do not match.",
                                    "Passowrd Fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                compSettings.password = tbPass.Text;
            }

            //folder locations
            mysqlSettings.tempSavePath = tbTempFolder.Text;
            //log folder path not implemented yet

            //SQL dump options
            mysqlSettings.includeCreateSchema        = cbCreateSchema.Checked;
            mysqlSettings.includeData                = cbDumpData.Checked;
            mysqlSettings.dumpEvents                 = cbEvents.Checked;
            mysqlSettings.dumpTriggers               = cbTriggers.Checked;
            mysqlSettings.addCreateProcedureFunction = cbProcsFuncs.Checked;
            //single file selection not implemented yet

            //compression options
            compSettings.enableCompression = cbEnableComp.Checked;
            compSettings.fileType          = cmbFileFormat.SelectedIndex;
            compSettings.compressionLevel  = cmbCompressionLevel.SelectedIndex;
            compSettings.useMultithreading = cbUseMultithreading.Checked;

            //encryption
            compSettings.enablePasswordEncryption = cbEnablePasswordEncryption.Checked;
            compSettings.encryptHeader            = cbEncryptHeader.Checked;

            ConfigurationManager.getInstance().mysqlDumpConfigInstance.setSettings(mysqlSettings);
            ConfigurationManager.getInstance().compressConfigInstance.setSettings(compSettings);
            ConfigurationManager.getInstance().mysqlDumpConfigInstance.saveConfig();
            ConfigurationManager.getInstance().compressConfigInstance.saveConfig();
            this.Close();
        }
        private void setupFormComponents()
        {
            SqlDumpDto  mysqlSettings = ConfigurationManager.getInstance().getMySqlDumpSettings();
            CompressDto compSettings  = ConfigurationManager.getInstance().getCompressSettings();

            //Folder Options
            tbTempFolder.Text = mysqlSettings.tempSavePath;
            tbLogFolder.Text  = ""; //not implemented yet

            //SQL Dump Options
            cbCreateSchema.Checked = mysqlSettings.includeCreateSchema;
            cbDumpData.Checked     = mysqlSettings.includeData;
            cbEvents.Checked       = mysqlSettings.dumpEvents;
            cbTriggers.Checked     = mysqlSettings.dumpTriggers;
            cbProcsFuncs.Checked   = mysqlSettings.addCreateProcedureFunction;
            cbSingleFile.Checked   = true; //not implemented yet

            //Compression settings
            cbEnableComp.Checked = compSettings.enableCompression;
            /// 0 - -t7z : file.7z
            /// 1 - -tgzip : file.gzip
            /// 2 - -tzip : file.zip
            /// 3 - -tbzip2 : file.bzip2
            /// 4 - -ttar : file.tar (UNIX and LINUX)
            /// 5 - -tiso : file.iso
            /// 6 - -tudf : file.udf
            cmbFileFormat.DataSource    = new string[] { ".7z", ".gzip", ".zip", ".bzip2", ".tar", ".iso", ".udf" };
            cmbFileFormat.SelectedIndex = compSettings.fileType;
            /// 0 - -mx1 : Low compression faster proccess
            /// 1 - -mx3 : Fast compression mode
            /// 2 - -mx5 : Normal compression mode
            /// 3 - -mx7 : Maximum compression mode
            /// 4 - -mx9 : Ultra compression mode
            cmbCompressionLevel.DataSource     = new string[] { "Fastest", "Fast", "Normal", "Maximum", "Ultra" };
            cmbCompressionLevel.SelectedIndex  = compSettings.compressionLevel;
            cbUseMultithreading.Checked        = compSettings.useMultithreading;
            cbEnablePasswordEncryption.Checked = compSettings.enablePasswordEncryption;
            cbEncryptHeader.Checked            = compSettings.encryptHeader;
            tbPass.Text        = compSettings.password;
            tbConfirmPass.Text = compSettings.password;
            if (!cbEnableComp.Checked)
            {
                disableORenableCompression(false);
            }
            if (!cbEnablePasswordEncryption.Checked)
            {
                disableORenableEnryption(false);
            }
        }
Example #3
0
 private CompressConfig initializeConfig(bool skipRecursion = false)
 {
     try
     {
         this.compressDto = JsonConvert.DeserializeObject <CompressDto>(File.ReadAllText(jsonFilePath));
         return(this);
     }
     catch (Exception ex)
     {
         if (skipRecursion)
         {
             throw new Exception("Somthing went wrong initializing config file options.:" + ex.Message);
         }
         return(this.resetToDefaults(true));
     }
 }
Example #4
0
 public void setSettings(CompressDto settings)
 {
     this.compressDto = settings;
 }
Example #5
0
 private CompressConfig()
 {
     this.compressDto = new CompressDto();
 }