void HandleMigrateDB(MigrateDBEvent e)
{
string db4oPath = Path.Combine (App.Current.baseDirectory, "lib", "cli", "Db4objects.Db4o-8.0");
string monoPath = Path.GetFullPath (App.Current.LibsDir) + Path.PathSeparator + Path.GetFullPath (db4oPath);
string migrationExe = Path.GetFullPath (Path.Combine (App.Current.LibsDir, "migration", "LongoMatch.exe"));
ProcessStartInfo startInfo = new ProcessStartInfo ();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = "\"" + migrationExe + "\"";
startInfo.WorkingDirectory = Path.GetFullPath (Path.Combine (App.Current.baseDirectory, "bin"));
if (System.Environment.OSVersion.Platform == PlatformID.Win32NT) {
startInfo.FileName = Path.Combine (App.Current.baseDirectory, "bin", "mono-sgen.exe");
startInfo.EnvironmentVariables ["MONO_CFG_DIR"] = Path.GetFullPath (
Path.Combine (App.Current.baseDirectory, "etc"));
} else {
startInfo.FileName = "mono-sgen";
}
if (startInfo.EnvironmentVariables.ContainsKey ("MONO_PATH")) {
startInfo.EnvironmentVariables ["MONO_PATH"] += Path.PathSeparator + monoPath;
} else {
startInfo.EnvironmentVariables.Add ("MONO_PATH", monoPath);
}
Log.Information (String.Format ("Launching migration tool {0} {1}",
startInfo.FileName,
startInfo.EnvironmentVariables ["MONO_PATH"]));
using (Process exeProcess = Process.Start (startInfo)) {
exeProcess.WaitForExit ();
App.Current.DatabaseManager.UpdateDatabases ();
App.Current.DatabaseManager.SetActiveByName (App.Current.DatabaseManager.ActiveDB.Info.Name);
}
}