public static void CommitTransaction() { lock (_lock) { if (Transaction != null) { _timer.Dispose(); _timer = null; if (ManagementUnit.CommitRequested) { try { ManagementUnit.ServerManager.CommitChanges(); } catch { AbortTransaction(); throw; } } Transaction = null; ManagementUnit.Dispose(); ManagementUnit = null; } } }
private async Task ProceedNoTransaction(HttpContext context) { using (var mu = new MgmtUnit()) { context.SetManagementUnit(mu); try { await _next(context); } finally { context.SetManagementUnit(null); } } }
public static void AbortTransaction() { lock (_lock) { if (_timer != null) { _timer.Dispose(); _timer = null; } Transaction = null; if (ManagementUnit != null) { ManagementUnit.Dispose(); ManagementUnit = null; } } }
public static Transaction BeginTransaction() { lock (_lock) { if (Transaction == null) { var transaction = new Transaction(); transaction.ExpiresOn = transaction.CreatedOn.AddMilliseconds(TRANSACTION_IDLE_TIMEOUT); _timer = new Timer(TimeoutCallback, null, TRANSACTION_IDLE_TIMEOUT, Timeout.Infinite); ManagementUnit = new MgmtUnit(); Transaction = transaction; } } return(Transaction); }
public async Task Invoke(HttpContext context) { bool webServerTargetted = context.Request.Path.StartsWithSegments(WEBSERVER_PATH); // Don't inject management unit if one already exists or the request isn't targetting the webserver if (context.GetManagementUnit() != null || !webServerTargetted) { await _next(context); } else { using (var mu = new MgmtUnit()) { context.SetManagementUnit(mu); await _next(context); context.SetManagementUnit(null); } } }