void Import_Start() { Import_InitializeVariables(); try { string line = string.Empty; while (line != null) { if (stopProcess) { processCompletionType = ProcessEndType.Cancelled; break; } try { line = Import_GetLine(); if (line == null) { break; } if (line.Length == 0) { continue; } Import_ProcessLine(line); } catch (Exception ex) { line = string.Empty; _lastError = ex; _lastErrorSql = _sbImport.ToString(); if (!string.IsNullOrEmpty(ImportInfo.ErrorLogFile)) { File.AppendAllText(ImportInfo.ErrorLogFile, ex.Message + Environment.NewLine + Environment.NewLine + _lastErrorSql + Environment.NewLine + Environment.NewLine); } _sbImport = new StringBuilder(); GC.Collect(); if (!ImportInfo.IgnoreSqlError) { StopAllProcess(); throw; } } } } finally { ReportEndProcess(); } }
void Export_InitializeVariables() { if (Command == null) { throw new Exception("SQLiteCommand is not initialized. Object not set to an instance of an object."); } if (Command.Connection == null) { throw new Exception("SQLiteCommand.Connection is not initialized. Object not set to an instance of an object."); } if (Command.Connection.State != System.Data.ConnectionState.Open) { throw new Exception("SQLiteCommand.Connection is not opened."); } timeStart = DateTime.Now; stopProcess = false; processCompletionType = ProcessEndType.UnknownStatus; currentProcess = ProcessType.Export; _lastError = null; timerReport.Interval = ExportInfo.IntervalForProgressReport; GetSHA512HashFromPassword(ExportInfo.EncryptionPassword); _database = new SQLiteDatabase(Command, ExportInfo.GetTotalRowsBeforeExport); _currentTableName = ""; _totalRowsInCurrentTable = 0; _totalRowsInAllTables = _database.TotalRows; _currentRowIndexInCurrentTable = 0; _currentRowIndexInAllTable = 0; _totalTables = 0; _currentTableIndex = 0; }
void Import_InitializeVariables() { if (Command == null) { throw new Exception("SQLiteCommand is not initialized. Object not set to an instance of an object."); } if (Command.Connection == null) { throw new Exception("SQLiteCommand.Connection is not initialized. Object not set to an instance of an object."); } if (Command.Connection.State != System.Data.ConnectionState.Open) { throw new Exception("SQLiteCommand.Connection is not opened."); } stopProcess = false; GetSHA512HashFromPassword(ImportInfo.EncryptionPassword); _lastError = null; timeStart = DateTime.Now; _currentBytes = 0L; currentProcess = ProcessType.Import; processCompletionType = ProcessEndType.Complete; if (ImportProgressChanged != null) { timerReport.Start(); } }
void ExportStart() { try { Export_InitializeVariables(); int stage = 1; while (stage < 9) { if (stopProcess) { break; } switch (stage) { case 1: Export_BasicInfo(); break; case 2: Export_DocumentHeader(); break; case 3: Export_TableRows(); break; case 4: Export_Views(); break; case 5: Export_Triggers(); break; case 6: Export_Sequencies(); break; case 7: Export_Indexes(); break; case 8: Export_DocumentFooter(); break; default: break; } textWriter.Flush(); stage += 1; } if (stopProcess) { processCompletionType = ProcessEndType.Cancelled; } else { processCompletionType = ProcessEndType.Complete; } } catch (Exception ex) { _lastError = ex; processCompletionType = ProcessEndType.Error; StopAllProcess(); throw; } ReportEndProcess(); }
void Export_InitializeVariables() { if (Command == null) { throw new Exception("MySqlCommand is not initialized. Object not set to an instance of an object."); } if (Command.Connection == null) { throw new Exception("MySqlCommand.Connection is not initialized. Object not set to an instance of an object."); } if (Command.Connection.State != System.Data.ConnectionState.Open) { throw new Exception("MySqlCommand.Connection is not opened."); } if (ExportInfo.BlobExportMode == BlobDataExportMode.BinaryChar && !ExportInfo.BlobExportModeForBinaryStringAllow) { throw new Exception("[ExportInfo.BlobExportMode = BlobDataExportMode.BinaryString] is still under development. Please join the discussion at https://github.com/MySqlBackupNET/MySqlBackup.Net/issues (Title: Help requires. Unable to export BLOB in Char Format)"); } timeStart = DateTime.Now; stopProcess = false; processCompletionType = ProcessEndType.UnknownStatus; currentProcess = ProcessType.Export; _lastError = null; timerReport.Interval = ExportInfo.IntervalForProgressReport; //GetSHA512HashFromPassword(ExportInfo.EncryptionPassword); _database.GetDatabaseInfo(Command, ExportInfo.GetTotalRowsMode); _server.GetServerInfo(Command); _currentTableName = string.Empty; _totalRowsInCurrentTable = 0L; _totalRowsInAllTables = Export_GetTablesToBeExported() .Sum(pair => _database.Tables[pair.Key].TotalRows); _currentRowIndexInCurrentTable = 0; _currentRowIndexInAllTable = 0; _totalTables = 0; _currentTableIndex = 0; }
void Import_Start() { Import_InitializeVariables(); string line = ""; while (line != null) { if (stopProcess) { processCompletionType = ProcessEndType.Cancelled; break; } try { line = Import_GetLine(); Import_ProcessLine(line); } catch (Exception ex) { line = ""; _lastError = ex; if (ImportInfo.IgnoreSqlError) { if (!string.IsNullOrEmpty(ImportInfo.ErrorLogFile)) { File.AppendAllText(ImportInfo.ErrorLogFile, Environment.NewLine + Environment.NewLine + ex.ToString()); } } else { StopAllProcess(); throw; } } } ReportEndProcess(); }
private void Import_InitializeVariables() { if (Command == null) { throw new Exception("MySqlCommand is not initialized. Object not set to an instance of an object."); } if (Command.Connection == null) { throw new Exception( "MySqlCommand.Connection is not initialized. Object not set to an instance of an object."); } if (Command.Connection.State != ConnectionState.Open) { throw new Exception("MySqlCommand.Connection is not opened."); } _stopProcess = false; GetSha512HashFromPassword(ImportInfo.EncryptionPassword); LastError = null; _timeStart = DateTime.Now; _currentBytes = 0L; _sbImport = new StringBuilder(); _mySqlScript = new MySqlScript(Command.Connection); _currentProcess = ProcessType.Import; _processCompletionType = ProcessEndType.Complete; _delimiter = ";"; if (ImportProgressChanged != null) { _timerReport.Start(); } if (ImportInfo.TargetDatabase.Length > 0) { Import_CreateNewDatabase(); } }
private void Export_InitializeVariables() { if (Command == null) { throw new Exception("MySqlCommand is not initialized. Object not set to an instance of an object."); } if (Command.Connection == null) { throw new Exception( "MySqlCommand.Connection is not initialized. Object not set to an instance of an object."); } if (Command.Connection.State != ConnectionState.Open) { throw new Exception("MySqlCommand.Connection is not opened."); } _timeStart = DateTime.Now; _stopProcess = false; _processCompletionType = ProcessEndType.UnknownStatus; _currentProcess = ProcessType.Export; LastError = null; _timerReport.Interval = ExportInfo.IntervalForProgressReport; GetSha512HashFromPassword(ExportInfo.EncryptionPassword); Database.GetDatabaseInfo(Command, ExportInfo.GetTotalRowsBeforeExport); Server.GetServerInfo(Command); _currentTableName = ""; _totalRowsInCurrentTable = 0; _totalRowsInAllTables = Database.TotalRows; _currentRowIndexInCurrentTable = 0; _currentRowIndexInAllTable = 0; _totalTables = 0; _currentTableIndex = 0; }
void Import_InitializeVariables() { if (Command == null) { throw new Exception("MySqlCommand is not initialized. Object not set to an instance of an object."); } if (Command.Connection == null) { throw new Exception("MySqlCommand.Connection is not initialized. Object not set to an instance of an object."); } if (Command.Connection.State != System.Data.ConnectionState.Open) { throw new Exception("MySqlCommand.Connection is not opened."); } //_createViewDetected = false; //_dicImportRoutines = new Dictionary<string, bool>(); stopProcess = false; //GetSHA512HashFromPassword(ImportInfo.EncryptionPassword); _lastError = null; timeStart = DateTime.Now; _currentBytes = 0L; _sbImport = new StringBuilder(); _mySqlScript = new MySqlScript(Command.Connection); currentProcess = ProcessType.Import; processCompletionType = ProcessEndType.Complete; _delimiter = ";"; _lastErrorSql = string.Empty; if (ImportProgressChanged != null) { timerReport.Start(); } }
void ExportStart() { try { Export_InitializeVariables(); int stage = 1; while (stage < 11) { if (stopProcess) { break; } switch (stage) { case 1: Export_BasicInfo(); break; case 2: Export_CreateDatabase(); break; case 3: Export_DocumentHeader(); break; case 4: Export_TableRows(); break; case 5: Export_Functions(); break; case 6: Export_Procedures(); break; case 7: Export_Events(); break; case 8: Export_Views(); break; case 9: Export_Triggers(); break; case 10: Export_DocumentFooter(); break; default: break; } textWriter.Flush(); stage = stage + 1; } if (stopProcess) { processCompletionType = ProcessEndType.Cancelled; } else { processCompletionType = ProcessEndType.Complete; } } catch (Exception ex) { _lastError = ex; StopAllProcess(); throw; } finally { ReportEndProcess(); } }
void Import_Start() { Import_InitializeVariables(); string line = ""; while (line != null) { if (stopProcess) { processCompletionType = ProcessEndType.Cancelled; break; } try { line = Import_GetLine(); Import_ProcessLine(line); } catch (Exception ex) { _lastError = ex; if (ImportInfo.IgnoreSqlError) { if (!string.IsNullOrEmpty(ImportInfo.ErrorLogFile)) { File.AppendAllText(ImportInfo.ErrorLogFile, Environment.NewLine + Environment.NewLine + ex.ToString()); } } else { StopAllProcess(); throw; } } } ReportEndProcess(); }
void ImportFromTextReaderStream(TextReader tr, FileInfo fileInfo) { Import_InitializeVariables(); if (fileInfo != null) _totalBytes = fileInfo.Length; else _totalBytes = 0L; textReader = tr; string line = ""; while (line != null) { if (stopProcess) { processCompletionType = ProcessEndType.Cancelled; break; } try { line = Import_GetLine(); Import_ProcessLine(line); } catch (Exception ex) { _lastError = ex; if (ImportInfo.IgnoreSqlError) { if (!string.IsNullOrEmpty(ImportInfo.ErrorLogFile)) { File.AppendAllText(ImportInfo.ErrorLogFile, Environment.NewLine + Environment.NewLine + ex.ToString()); } } else { StopAllProcess(); throw; } } } ReportEndProcess(); }
void ExportStart() { try { Export_InitializeVariables(); int stage = 1; while (stage < 11) { if (stopProcess) break; switch (stage) { case 1: Export_BasicInfo(); break; case 2: Export_CreateDatabase(); break; case 3: Export_DocumentHeader(); break; case 4: Export_TableRows(); break; case 5: Export_Functions(); break; case 6: Export_Procedures(); break; case 7: Export_Events(); break; case 8: Export_Views(); break; case 9: Export_Triggers(); break; case 10: Export_DocumentFooter(); break; default: break; } textWriter.Flush(); stage = stage + 1; } if (stopProcess) processCompletionType = ProcessEndType.Cancelled; else processCompletionType = ProcessEndType.Complete; } catch (Exception ex) { _lastError = ex; StopAllProcess(); throw; } ReportEndProcess(); }
void Import_InitializeVariables() { if (Command == null) { throw new Exception("MySqlCommand is not initialized. Object not set to an instance of an object."); } if (Command.Connection == null) { throw new Exception("MySqlCommand.Connection is not initialized. Object not set to an instance of an object."); } if (Command.Connection.State != System.Data.ConnectionState.Open) { throw new Exception("MySqlCommand.Connection is not opened."); } stopProcess = false; GetSHA512HashFromPassword(ImportInfo.EncryptionPassword); _lastError = null; timeStart = DateTime.Now; _currentBytes = 0L; _sbImport = new StringBuilder(); _mySqlScript = new MySqlScript(Command.Connection); currentProcess = ProcessType.Import; processCompletionType = ProcessEndType.Complete; _delimiter = ";"; if (ImportProgressChanged != null) timerReport.Start(); if (ImportInfo.TargetDatabase.Length > 0) { Import_CreateNewDatabase(); } }
void Import_Start() { Import_InitializeVariables(); string line = ""; int lineCount = 0; var statement = new StringBuilder(); while (line != null) { if (stopProcess) { processCompletionType = ProcessEndType.Cancelled; break; } try { line = Import_GetLine(); if (!Import_IsEmptyLine(line)) { statement.AppendLine(line); if (line.Trim().EndsWith(";")) { Command.CommandText = statement.ToString(); Command.ExecuteNonQuery(); statement = new StringBuilder(); } } if (lineCount > 5000) { lineCount = 0; GC.Collect(); } else { lineCount += 1; } } catch (Exception ex) { line = ""; _lastError = ex; if (ImportInfo.IgnoreSqlError) { if (!string.IsNullOrEmpty(ImportInfo.ErrorLogFile)) { File.AppendAllText(ImportInfo.ErrorLogFile, Environment.NewLine + Environment.NewLine + ex.ToString()); } } else { StopAllProcess(); throw; } } } ReportEndProcess(); }
void Import_InitializeVariables() { GetSHA512HashFromPassword(ImportInfo.EncryptionPassword); _lastError = null; timeStart = DateTime.Now; _currentBytes = 0L; _sbImport = new StringBuilder(); _mySqlScript = new MySqlScript(Command.Connection); currentProcess = ProcessType.Import; processCompletionType = ProcessEndType.Complete; _delimiter = ";"; if (ImportProgressChanged != null) timerReport.Start(); if (ImportInfo.TargetDatabase.Length > 0) { Import_CreateNewDatabase(); } // Modifying max_allowed_packet for this connection. try { Command.CommandText = "SET GLOBAL max_allowed_packet=1024*1024*1024;"; // 1GB. Maximum length of single query allow by MySQL Command.ExecuteNonQuery(); } catch { // Purposely do nothing. // MySqlException will raise if user do not has the privilege to modify max_allowed_packet for this connection. } }
void Export_InitializeVariables() { if (Command == null) { throw new Exception("MySqlCommand is not initialized. Object not set to an instance of an object."); } if (Command.Connection == null) { throw new Exception("MySqlCommand.Connection is not initialized. Object not set to an instance of an object."); } if (Command.Connection.State != System.Data.ConnectionState.Open) { throw new Exception("MySqlCommand.Connection is not opened."); } timeStart = DateTime.Now; stopProcess = false; processCompletionType = ProcessEndType.UnknownStatus; currentProcess = ProcessType.Export; _lastError = null; timerReport.Interval = ExportInfo.IntervalForProgressReport; GetSHA512HashFromPassword(ExportInfo.EncryptionPassword); _database.GetDatabaseInfo(Command, ExportInfo.GetTotalRowsBeforeExport); _server.GetServerInfo(Command); _currentTableName = ""; _totalRowsInCurrentTable = 0; _totalRowsInAllTables = _database.TotalRows; _currentRowIndexInCurrentTable = 0; _currentRowIndexInAllTable = 0; _totalTables = 0; _currentTableIndex = 0; }
void Export_InitializeVariables() { timeStart = DateTime.Now; processCompletionType = ProcessEndType.UnknownStatus; currentProcess = ProcessType.Export; _lastError = null; timerReport.Interval = ExportInfo.IntervalForProgressReport; GetSHA512HashFromPassword(ExportInfo.EncryptionPassword); _database.GetDatabaseInfo(Command, ExportInfo.GetTotalRowsBeforeExport); _server.GetServerInfo(Command); _currentTableName = ""; _totalRowsInCurrentTable = 0; _totalRowsInAllTables = _database.TotalRows; _currentRowIndexInCurrentTable = 0; _currentRowIndexInAllTable = 0; _totalTables = 0; _currentTableIndex = 0; try { Command.CommandText = "SET GLOBAL max_allowed_packet=1024*1024*1024;"; // 1GB. Maximum length of single query allow by MySQL Command.ExecuteNonQuery(); } catch { // Purposely do nothing. // MySqlException will raise if user do not has the privilege to modify max_allowed_packet for this connection. } }