public static ActionResult RemoveDatabase(Session session, UpdateDetectionVariables updateDetectionVariables) { try { DatabaseSetupInfo databaseSetupInfo = DatabaseSetupInfo.CreateFromFeature(session, updateDetectionVariables.DatabaseFeatureName); DropDatabaseForm dropDatabaseForm = new DropDatabaseForm() { SetupInfo = databaseSetupInfo, Text = "Drop database objects", QuestionText = "Should the database objects be removed?", NoText = "No, keep the database objects", YesText = "Yes, drop the database objects" }; if (BaseForm.ShowAsDialog(dropDatabaseForm, session.InstallerWindowWrapper()) == DialogResult.Yes) { var ddl = updateDetectionVariables.SubstituteDDL(Properties.Resources.drp_tbl); if (updateDetectionVariables.TriggersEnabled) { ddl += updateDetectionVariables.SubstituteDDL(Properties.Resources.drp_trg); } if (!string.IsNullOrEmpty(updateDetectionVariables.ExtraDatabaseDropDDL)) { ddl += updateDetectionVariables.ExtraDatabaseDropDDL; } DatabaseCustomAction.ExecuteDDL(ddl, databaseSetupInfo); DatabaseCustomAction.DropDatabaseUser(databaseSetupInfo); } return(ActionResult.Success); } catch (Exception ex) { session.ShowErrorMessage(ex); throw ex; } }
public static ActionResult RollbackDatabase(Session session, UpdateDetectionVariables updateDetectionVariables) { try { DatabaseSetupInfo databaseSetupInfo = DatabaseSetupInfo.CreateFromFeature(session, updateDetectionVariables.DatabaseFeatureName); var ddl = updateDetectionVariables.SubstituteDDL(Properties.Resources.drp_tbl); if (updateDetectionVariables.TriggersEnabled) { ddl += updateDetectionVariables.SubstituteDDL(Properties.Resources.drp_trg); } if (!string.IsNullOrEmpty(updateDetectionVariables.ExtraDatabaseDropDDL)) { ddl += updateDetectionVariables.ExtraDatabaseDropDDL; } DatabaseCustomAction.ExecuteDDL(ddl, databaseSetupInfo); DatabaseCustomAction.DropDatabaseUser(databaseSetupInfo); return(ActionResult.Success); } catch (Exception ex) { session.ShowErrorMessage(ex); throw ex; } }