public void loginAccount(Guid accountId) { SequentialTransactionManager sequentialTransactionManager = new SequentialTransactionManager(); sequentialTransactionManager.EnlistmentNotificationCollection.Add(new LoginTransactionTask()); sequentialTransactionManager.setContextValue(accountId); sequentialTransactionManager.setContextValue(DateTime.Now); //sequentialTransactionManager.setContextValue("accountId", accountId); //sequentialTransactionManager.setContextValue("loginDateTime", DateTime.Now); using (TransactionScope transactionScope = new TransactionScope()) { sequentialTransactionManager.enlistVolatile(); transactionScope.Complete(); } }
public static void setContextValue <T>(this SequentialTransactionManager sequentialTransactionManager, T value) { sequentialTransactionManager.setContextValue(value.GetType().FullName, value); }