示例#1
0
        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;
        }
示例#2
0
        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 Start()
        {
            sb = new StringBuilder();
            sb.AppendLine("<html><head><style>h1 { line-height:160%; font-size: 20pt; } h2 { line-height:160%; font-size: 14pt; } body { font-family: \"Segoe UI\", Arial; line-height: 150%; } table { border: 1px solid #5C5C5C; border-collapse: collapse; } td { font-size: 10pt; padding: 4px; border: 1px solid #5C5C5C; } .code { font-family: \"Courier New\"; font-size: 10pt; line-height:110%; } </style></head>");
            sb.AppendLine("<body>");

            using (MySqlConnection conn = new MySqlConnection(Program.ConnectionString))
            {
                try
                {
                    conn.Open();


                    cmd = new MySqlCommand();
                    cmd.Connection = conn;

                    myDatabase = new MySqlDatabase();
                    myDatabase.GetDatabaseInfo(cmd, true);
                    myServer = new MySqlServer();
                    myServer.GetServerInfo(cmd);

                    int stage = 1;

                    while (stage < 13)
                    {
                        try
                        {
                            switch (stage)
                            {
                                case 1: LoadDatabase(); break;
                                case 2: LoadUser(); break;
                                case 3: LoadGlobalPrivilege(); break;
                                case 4: LoadViewPrivilege(); break;
                                case 5: LoadFunctionPrivilege(); break;
                                case 6: LoadVariables(); break;
                                case 7: LoadTables(); break;
                                case 8: LoadFunctions(); break;
                                case 9: LoadProcedures(); break;
                                case 10: LoadTriggers(); break;
                                case 11: LoadViews(); break;
                                case 12: LoadEvents(); break;
                                default: break;
                            }
                        }
                        catch (Exception ex)
                        {
                            WriteError(ex.Message);
                        }

                        stage += 1;
                    }

                    conn.Close();

                }
                catch (Exception exCon)
                {
                    WriteError(exCon.Message);
                }
            }

            sb.Append("</body>");
            sb.Append("</html>");
        }