private static void RestoreCurrentProject(FwRestoreProjectSettings restoreSettings,
Form dialogOwner)
{
// When we get here we can safely do the backup of the project because we either
// have no cache (and no other process has this project open), or we are the
// process that has this project open. (FWR-3344)
if (restoreSettings.Settings.BackupOfExistingProjectRequested &&
!BackupProjectForRestore(restoreSettings, Cache, dialogOwner))
{
return;
}
ExecuteWithAppsShutDown(restoreSettings.FwAppCommandLineAbbrev, () =>
{
bool retry;
do
{
retry = false;
try
{
var restoreService = new ProjectRestoreService(restoreSettings.Settings, s_ui, FwDirectoryFinder.ConverterConsoleExe, FwDirectoryFinder.DbExe);
Logger.WriteEvent("Restoring from " + restoreSettings.Settings.Backup.File);
if (RestoreProjectDlg.HandleRestoreFileErrors(null, ResourceHelper.GetResourceString("ksRestoreFailed"),
restoreSettings.Settings.Backup.File, () => DoRestore(restoreService)))
{
s_LinkDirChangedTo = restoreService.LinkDirChangedTo;
return s_projectId ??
new ProjectId(ClientServerServices.Current.Local.IdForLocalProject(restoreSettings.Settings.ProjectName), null);
}
}
catch (CannotConvertException e)
{
MessageBoxUtils.Show(e.Message, ResourceHelper.GetResourceString("ksRestoreFailed"));
}
catch (MissingOldFwException e)
{
using (var dlg = new MissingOldFieldWorksDlg(restoreSettings.Settings,
e.HaveOldFieldWorks, e.HaveFwSqlServer))
{
retry = (dlg.ShowDialog() == DialogResult.Retry);
}
}
catch (FailedFwRestoreException e)
{
MessageBoxUtils.Show(Properties.Resources.ksRestoringOldFwBackupFailed, Properties.Resources.ksFailed);
}
}
while (retry);
return null;
});
}