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 MoreSQLOptions_Load(object sender, EventArgs e) { SqlDumpDto settings = ConfigurationManager.getInstance().mysqlDumpConfigInstance.getSettings(); //general cbAddComments.Checked = settings.includeComments; cbForeignKey.Checked = settings.disableForeignKeyChecks; if (settings.singleTransaction || settings.lockTables) { cbEnableDataPreservation.Checked = true; if (settings.singleTransaction) { rbSingleTransaction.Checked = true; } else { rbLockTables.Checked = true; } } else { cbEnableDataPreservation.Checked = false; } disableOrEnableRadioButtons(cbEnableDataPreservation.Checked); cbNoAutocommit.Checked = settings.noAutocommit; tbCustomComment.Text = settings.addCustomCommentInHeader; cbIncreasedComp.Checked = settings.moreCompatible; string[] charsets = { "utf8", "armscii8", "ascii", "cp850", "cp852", "cp866", "cp1250", "cp1251", "cp1256", "cp1257", "dec8", "geostd8", "greek", "hebrew", "hp8", "Index", "keybcs2", "koi8r", "koi8u", "latin1", "latin2", "latin5", "latin7", "macce", "macroman", "swe7" }; cmbCharacterSet.DataSource = charsets; cmbCharacterSet.SelectedItem = settings.characterSet; cbXml.Checked = settings.xml; //structure cbAddDropDatabase.Checked = settings.addDropDatabase; cbAddCreateDatabase.Checked = settings.createDatabase; cbAddDropTable.Checked = settings.addDropTable; cbAddLocks.Checked = settings.addLocks; cbAddDateComment.Checked = settings.addInfoComments; cbEncloseBackquotes.Checked = settings.encloseWithBackquotes; //data cbUseCompleteInserts.Checked = settings.completeInsertStatements; cbUseExtendedInserts.Checked = settings.extendedInsertStatements; cbUseIgnoreInserts.Checked = settings.useIgnoreInserts; cbUseHexadecimal.Checked = settings.useHexadecimal; nudMaxLength.Value = settings.maximumLengthOfQuery; nudMaxPacketSize.Value = settings.maximumPacketLength; string[] exportTypes = { "INSERT", "REPLACE" }; cmbExportType.DataSource = exportTypes; cmbExportType.SelectedIndex = settings.exportType; }
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); } }
private SqlDumpConfig initializeConfig(bool skipRecursion = false) { try { this.mySqlDumpDto = JsonConvert.DeserializeObject <SqlDumpDto>(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)); } }
private void bSave_Click(object sender, EventArgs e) { SqlDumpDto settings = ConfigurationManager.getInstance().mysqlDumpConfigInstance.getSettings(); //general settings.includeComments = cbAddComments.Checked; settings.disableForeignKeyChecks = cbForeignKey.Checked; if (cbEnableDataPreservation.Checked) { settings.singleTransaction = rbSingleTransaction.Checked; settings.lockTables = rbLockTables.Checked; } else { settings.singleTransaction = false; settings.lockTables = false; } settings.noAutocommit = cbNoAutocommit.Checked; settings.addCustomCommentInHeader = tbCustomComment.Text; settings.moreCompatible = cbIncreasedComp.Checked; settings.characterSet = (string)cmbCharacterSet.SelectedItem; settings.xml = cbXml.Checked; //structure settings.addDropDatabase = cbAddDropDatabase.Checked; settings.createDatabase = cbAddCreateDatabase.Checked; settings.addDropTable = cbAddDropTable.Checked; settings.addLocks = cbAddLocks.Checked; settings.addInfoComments = cbAddDateComment.Checked; settings.encloseWithBackquotes = cbEncloseBackquotes.Checked; //data settings.completeInsertStatements = cbUseCompleteInserts.Checked; settings.extendedInsertStatements = cbUseExtendedInserts.Checked; settings.useIgnoreInserts = cbUseIgnoreInserts.Checked; settings.useHexadecimal = cbUseHexadecimal.Checked; settings.maximumLengthOfQuery = (int)nudMaxLength.Value; settings.maximumPacketLength = (int)nudMaxPacketSize.Value; settings.exportType = cmbExportType.SelectedIndex; ConfigurationManager.getInstance().mysqlDumpConfigInstance.setSettings(settings); ConfigurationManager.getInstance().mysqlDumpConfigInstance.saveConfig(); this.Close(); }
public void setSettings(SqlDumpDto settings) { this.mySqlDumpDto = settings; }
private SqlDumpConfig() { this.mySqlDumpDto = new SqlDumpDto(); }
/// <summary> /// /// </summary> /// <param name="line"></param> /// <param name="createschema"></param> private void handleLineOutput(string line, SqlDumpDto dto) //ekana ta boolean global gia na min ta pernaei sinexws parametrika { if (!String.IsNullOrEmpty(line)) { if (dto.encloseWithBackquotes && line.ToUpper().StartsWith("USE")) { currentDatabase = line.Split('`', '`')[1]; } else if (line.ToUpper().StartsWith("USE")) { currentDatabase = line.Replace("USE", "").Trim(); } string insertStartsWith = ""; if (dto.exportType == 1 && dto.useIgnoreInserts == true) { insertStartsWith = "REPLACE IGNORE INTO"; } else if (dto.exportType == 1) { insertStartsWith = "REPLACE INTO"; } else if (dto.useIgnoreInserts) { insertStartsWith = "INSERT IGNORE INTO"; } else { insertStartsWith = "INSERT INTO"; } if (!dto.xml) { if (dto.includeCreateSchema) { if (line.StartsWith("CREATE TABLE")) { string tablename = ""; if (!dto.encloseWithBackquotes) { int Pos1 = line.IndexOf("TABLE") + 5; int Pos2 = line.IndexOf("("); tablename = line.Substring(Pos1, Pos2 - Pos1).Trim(); } else { tablename = line.Split('`', '`')[1]; } int rowcount = 1; try { rowcount = getDbTableRowsCount(tablename, currentDatabase); } catch (Exception ex) { } onTableStartDump(tablename); onTableRowCount(rowcount); } } else if (line.Contains(insertStartsWith)) { string tablename = ""; if (!dto.encloseWithBackquotes) { int Pos1 = line.IndexOf("INTO") + 4; tablename = line.Substring(Pos1, line.IndexOf("(") - Pos1).Trim(); } else { tablename = line.Split('`', '`')[1]; } if (tablename != tempTableName) { tempTableName = tablename; int rowcount = 1; try { rowcount = getDbTableRowsCount(tablename, currentDatabase); } catch (Exception ex) { } //fire event onTableStartDump(tablename); onTableRowCount(rowcount); } } } } }