private void Destroy(DiscoveredTable tbl, params IDeleteable[] deletablesInOrderOfDeletion) { tbl.Drop(); foreach (IDeleteable deleteable in deletablesInOrderOfDeletion) { deleteable.DeleteInDatabase(); } }
private void ConfirmTableDeletion(DiscoveredTable expectTable) { if (expectTable.Exists()) { var confirm = MessageBox.Show(String.Format("A table named {0} has been created as part of this import. Do you want to keep it?", expectTable.GetFullyQualifiedName()), "Confirm", MessageBoxButtons.YesNo); if (confirm == DialogResult.No) { expectTable.Drop(); } } }
public void TestBasicDataTableAnonymiser3(DatabaseType type) { DiscoveredDatabase database = GetCleanedServer(type); //Create a names table that will go into the database var dt = new DataTable(); dt.Columns.Add("Name"); dt.Rows.Add(new[] { "Thomas" }); dt.Rows.Add(new[] { "Wallace" }); dt.Rows.Add(new[] { "Frank" }); DiscoveredTable table = database.CreateTable("ForbiddenNames", dt); TableInfo tableInfo; Import(table, out tableInfo, out _); //Create the test dataset chunk that will be anonymised var dtStories = new DataTable(); dtStories.Columns.Add("Story"); dtStories.Rows.Add(new[] { "Thomas went to school regularly" }); dtStories.Rows.Add(new[] { "It seems like Wallace went less regularly" }); dtStories.Rows.Add(new[] { "Mr Smitty was the teacher" }); //Create the anonymiser var a = new BasicDataTableAnonymiser3(); //Tell it about the database table a.NamesTable = tableInfo; //run the anonymisation var resultTable = a.ProcessPipelineData(dtStories, new ThrowImmediatelyDataLoadEventListener(), new GracefulCancellationToken()); //check the results Assert.AreEqual(resultTable.Rows.Count, 3); Assert.AreEqual("REDACTED went to school regularly", resultTable.Rows[0][0]); Assert.AreEqual("It seems like REDACTED went less regularly", resultTable.Rows[1][0]); Assert.AreEqual("Mr Smitty was the teacher", resultTable.Rows[2][0]); //finally drop the database table table.Drop(); }
public DatabaseDestination(IsIdentifiableAbstractOptions options, string reportName) : base(options) { var targetDatabase = new DiscoveredServer(options.DestinationConnectionString, options.DestinationDatabaseType).GetCurrentDatabase(); if (!targetDatabase.Exists()) { throw new Exception("Destination database did not exist"); } _tbl = targetDatabase.ExpectTable(reportName); if (_tbl.Exists()) { _tbl.Drop(); } _reportName = reportName; }
public void DropTable() { //don't try to cleanup if there was Assert.Inconclusive because the server was inaccessible if (_database == null) { return; } if (!_table.Exists()) { return; } string problemsDroppingTrigger, thingsThatWorkedDroppingTrigger; GetImplementer().DropTrigger(out problemsDroppingTrigger, out thingsThatWorkedDroppingTrigger); if (_archiveTable.Exists()) { _archiveTable.Drop(); } _table.Drop(); }