我正在尝试做最简单的事情并将事务应用于该CreatePortal
方法。
如果我正在使用TransactionScope
- 它出于某种未知原因升级为 DTC - 不好。
using (var ts = new TransactionScope())
{
var portalController = new PortalController();
var portalId =
portalController.CreatePortal(
"TESTTESTTEST",
string.Empty,
string.Empty,
"TESTTESTTEST_" + new Random().Next(999999),
UserController.GeneratePassword(),
"TESTTESTTEST_" + new Random().Next(999999) + "@something.com",
string.Empty,
string.Empty,
Globals.ApplicationMapPath + "/Portals/_default/",
"Default Website.template",
"Portals/TESTTEST",
"TESTTESTTEST",
string.Empty,
string.Empty,
false);
ts.Complete();
}
如果我在最后使用DataProvider.Instance().GetTransaction
并执行RollbackTransaction
- 它不会回滚,这意味着事务甚至没有工作。
var t = Data.DataProvider.Instance().GetTransaction();
var portalController = new PortalController();
var portalId =
portalController.CreatePortal(
"TESTTESTTEST",
string.Empty,
string.Empty,
"TESTTESTTEST_" + new Random().Next(999999),
UserController.GeneratePassword(),
"TESTTESTTEST_" + new Random().Next(999999) + "@something.com",
string.Empty,
string.Empty,
Globals.ApplicationMapPath + "/Portals/_default/",
"Default Website.template",
"Portals/TESTTEST",
"TESTTESTTEST",
string.Empty,
string.Empty,
false);
Data.DataProvider.Instance().RollbackTransaction(t);
那么,如何在 DotNetNuke 中使用事务?