I am able to to a Backup and monitor the progress, but can't seem to get the progress for the restore. Any advice here?
Thanks in advance.
Dump and Restore Progress
-
- Devart Team
- Posts: 2420
- Joined: Wed 02 Nov 2011 09:44
There is the Progress event in MySqlDump. Almost all properties of MySqlDumpProgressEventArgs work with backup. But you can receive such information for Restoring by using MySqlScript. Our MySqlDump.Restore() uses MySqlScript for restoring. It takes MySqlDump.DumpText and Execute a MySqlScript. All this is performed inside the Restore function.
You can use MySqlScript and get access to the MySqlScript.Progress event.
Create MySqlDump:
Backuping into D:\mydump.txt file
Restoring from D:\mydump.txt file via MySqlScript
Event handler
For more information about the MySqlScript Progress event please refer to http://www.devart.com/dotconnect/mysql/ ... ss_EV.html
You can use MySqlScript and get access to the MySqlScript.Progress event.
Create MySqlDump:
Code: Select all
MySqlDump dump = new MySqlDump(conn);
conn.Open();
Code: Select all
dump.Backup("D:\mydump.txt");
Code: Select all
FileInfo file = new FileInfo("D:\mydump.txt");
MySqlScript script = new MySqlScript();
script.Connection = conn;
script.ScriptText = file.OpenText().ReadToEnd();
script.Progress+= new Devart.Common.ScriptProgressEventHandler(onProgress);
IDataReader reader;
while (script.ExecuteNext(out reader))
{
reader.Close();
}
Code: Select all
static void onProgress(object sender, Devart.Common.ScriptProgressEventArgs e)
{
//percentage of the operation completion
Console.WriteLine((100*e.Offset)/((MySqlScript)sender).ScriptText.Length);
//Console.WriteLine(e.Text); //Executed script text
}