Example #1
0
        void HandleMigrateDB()
        {
            string           db4oPath     = Path.Combine(Config.baseDirectory, "lib", "cli", "Db4objects.Db4o-8.0");
            string           monoPath     = Path.GetFullPath(Config.LibsDir) + Path.PathSeparator + Path.GetFullPath(db4oPath);
            string           migrationExe = Path.GetFullPath(Path.Combine(Config.LibsDir, "migration", "LongoMatch.exe"));
            ProcessStartInfo startInfo    = new ProcessStartInfo();

            startInfo.CreateNoWindow   = true;
            startInfo.UseShellExecute  = false;
            startInfo.Arguments        = "\"" + migrationExe + "\"";
            startInfo.WorkingDirectory = Path.GetFullPath(Path.Combine(Config.baseDirectory, "bin"));
            if (System.Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                startInfo.FileName = Path.Combine(Config.baseDirectory, "bin", "mono-sgen.exe");
                startInfo.EnvironmentVariables ["MONO_CFG_DIR"] = Path.GetFullPath(
                    Path.Combine(Config.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();
                dbManager.UpdateDatabases();
                dbManager.SetActiveByName(dbManager.ActiveDB.Name);
            }
        }