/// <summary> /// Handles the Click event of the btnRestore control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnRestore_Click(object sender, EventArgs e) { string filePath = ViewState["FilePath"].ToString(); Page.MaintainScrollPositionOnPostBack = false; try { if (File.Exists(filePath)) { IBackupFile bak = new BackupFile(filePath); bak.IncludeMembershipData = chkImportMembership.Checked; bak.IncludeGalleryData = chkImportGalleryData.Checked; bak.Import(); UserController.LogOffUser(); ClientMessage = new ClientMessageOptions { Title = "Restore Complete", Message = Resources.GalleryServerPro.Admin_Backup_Restore_Db_Successfully_Restored_Msg, Style = MessageStyle.Success, AutoCloseDelay = 0 }; } else { ClientMessage = new ClientMessageOptions { Title = "Restore Aborted", Message = Resources.GalleryServerPro.Admin_Backup_Restore_Cannot_Restore_File_File_Not_Found_Msg, Style = MessageStyle.Error }; } } catch (Exception ex) { LogError(ex); ClientMessage = new ClientMessageOptions { Title = "Restore Aborted", Message = String.Concat(Resources.GalleryServerPro.Admin_Backup_Restore_Cannot_Restore_File_Label, ex.Message), Style = MessageStyle.Error }; } finally { DeletePreviouslyUploadedFile(); ConfigureBackupFileInfo(null); HelperFunctions.PurgeCache(); bool adviseUserToManuallyRestartApp = false; try { // Recycle the app to force the providers to re-initialize. This will query the application ID from the database, which // may have changed during the restore. If any errors occur, advise the user to manually restart the app. Utils.ForceAppRecycle(); } catch (IOException) { adviseUserToManuallyRestartApp = true; } catch (UnauthorizedAccessException) { adviseUserToManuallyRestartApp = true; } catch (PlatformNotSupportedException) { adviseUserToManuallyRestartApp = true; } if (adviseUserToManuallyRestartApp) { ClientMessage = new ClientMessageOptions { Title = "Restore Complete", Message = Resources.GalleryServerPro.Admin_Backup_Restore_Db_Successfully_Restored_AppNotRecycled_Msg, Style = MessageStyle.Info }; } } }