public override void PerformXMLActions() { try { var mongoDB = new MongoDBAcess(DatabaseName); if (RemovedKey == "ALL") { mongoDB.RemoveAllKVFromCollection(TableName); } else { // Remove record PK from any Index File RemoveFromIndexFiles(mongoDB); // Remove record PK from FK value RemoveFromFKIndexFiles(mongoDB); // Remove record from UQ file RemoveFromUQIndexFiles(mongoDB); // Remove record from main table collection mongoDB.RemoveKVFromCollection(TableName, RemovedKey); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public override void PerformXMLActions() { try { var xmlDocument = XDocument.Load(Application.StartupPath + "\\SGBDCatalog.xml"); XElement[] databasesNodes = xmlDocument.Element("Databases").Descendants("Database").ToArray(); XElement givenDB = Array.Find(databasesNodes, elem => elem.Attribute("databaseName").Value.Equals(DBName)); XElement[] databasesTables = givenDB.Descendants("Table").ToArray(); XElement deletedXMLTag = Array.Find(databasesTables, elem => elem.Attribute("tableName").Value.Equals(TableName)); // Delete the records from the table, stored in the MongoDB collection new DeleteRowsQuery(DBName, TableName, "ALL").Execute(); // Delete unique key collections from MongoDB XElement[] uniqueKeysNodes = deletedXMLTag.Descendants("UniqueKeys").Descendants("UniqueKeyColumn").ToArray(); foreach (var uniqueKey in uniqueKeysNodes) { MongoDB.RemoveAllKVFromCollection(uniqueKey.Attribute("fileName").Value); } // Delete index file collections from MongoDB XElement[] indexNodes = deletedXMLTag.Descendants("IndexFiles").Descendants("IndexFile").ToArray(); foreach (var index in indexNodes) { MongoDB.RemoveAllKVFromCollection(index.Attribute("indexName").Value); } // Delete foreign key file collection from MongoDB XElement[] foreignKeysNodes = deletedXMLTag.Descendants("ForeignKeys").Descendants("ForeignKey").ToArray(); foreach (var foreignKey in foreignKeysNodes) { MongoDB.RemoveAllKVFromCollection(foreignKey.Attribute("fileName").Value); } // Delete the XML content for the table deletedXMLTag.Remove(); xmlDocument.Save(Application.StartupPath + "\\SGBDCatalog.xml"); } catch (Exception ex) { throw new Exception(ex.Message); } }