public DbRootAddress PublishToSession(DbSession destSession) { // Refresh the transaction log with a cleared 'no base root' version. // This operation sets up the transaction log appropriately so that the // 'commit' process of future transactions will understand that this // version is not an iteration of previous versions. WriteClearedTransactionLog(); // The database client, NetworkClient dbClient = session.Client; // Flush the transaction to the network DataAddress toPublish = dbClient.FlushTransaction(transaction); try { DataAddress published = dbClient.Commit(destSession.PathName, toPublish); // Return the root in the destionation session, return(new DbRootAddress(destSession, published)); } catch (CommitFaultException e) { // This shouldn't be thrown, throw new ApplicationException("Unexpected Commit Fault", e); } }
public DbRootAddress Commit() { CheckValid(); try { // Update transaction information on the tables that were modified during // this transaction. lock (tableMap) { foreach (KeyValuePair <string, DbTable> pair in tableMap) { string tableName = pair.Key; DbTable table = pair.Value; if (table.Modified) { // Log this modification, // If there was a structural change to the table we log as a TS // event if (table.HasStructuralChanges) { log.Add("TS" + tableName); } // Otherwise we log as a TM event (rows or columns were deleted). else { log.Add("TM" + tableName); } // Write out the table log table.PrepareForCommit(); } } } // Process the transaction log and write it out to a DataFile for the // path function processor to handle, // If there are changes to commit, if (log.Count > 0) { // Refresh the transaction log with the entries stored in 'log' RefreshTransactionLog(); // The database client, NetworkClient dbClient = session.Client; // Flush the transaction to the network DataAddress proposal = dbClient.FlushTransaction(transaction); // Perform the commit operation, return(new DbRootAddress(session, dbClient.Commit(session.PathName, proposal))); } else { // No changes, so return base root return(new DbRootAddress(session, baseRoot)); } } // Make sure transaction is invalidated finally { // Invalidate this transaction Invalidate(); } }