protected virtual void Dispose(bool disposing) { if (!disposing) { return; } if (!IsDisposed && IsInTranx) { Rollback(); } Locator = null; IsDisposed = true; }
public TransactionManager(SchedulerDatabaseConnection dbConnection) { _databaseConnection = dbConnection; _runningTransactions = 0; Locator = new RepositoryLocator(_databaseConnection); }
private void AuditAction <TResult>(Func <RepositoryLocator, TResult> command, Exception raisedException, TResult actionResult) where TResult : class//TODO: Not sure about DTOResponse, IDtoResponseWrapper { //TODO: Resolving of caller method name might be optimized!!! (Just found quick solution and implemented it) StackTrace stackTrace = new StackTrace(false); if (stackTrace.FrameCount < 3) { return; } String methodName = stackTrace.GetFrame(3).GetMethod().Name; RepositoryLocator locator = this.Locator; FieldInfo[] additionalParamsInfo = command.Target.GetType().GetFields(); if (additionalParamsInfo.Length == 0) { return; } FieldInfo targetType = null; foreach (FieldInfo item in additionalParamsInfo) { if (item.GetValue(command.Target) != null) { //TODO: Not sure about ServiceBase now. //if (item.GetValue(command.Target).GetType().IsSubclassOf(typeof(ServiceBase))) targetType = item; } } if (targetType != null) { //TODO: Not sure about ServiceBase. //ServiceBase service = targetType.GetValue(command.Target) as ServiceBase; //// ServiceBase service = additionalParamsInfo[0].GetValue(command.Target) as ServiceBase; //if (service == null) return; object[] additionalParams = new object[additionalParamsInfo.Length - 1]; for (int i = 1; i < additionalParamsInfo.Length; i++) { additionalParams[i - 1] = additionalParamsInfo[i].GetValue(command.Target); } if (raisedException != null) { if (raisedException.GetType().Name != "SchedulerException") { //TODO: uncomment next 3 lines once audit Repo is added. // locator.AuditRepository.CreateUnhandledException( //new UnhandledExceptionEntry(Container.RequestContext.UserName, raisedException.Message, // raisedException.StackTrace, DateTime.Now, methodName)); // locator.AuditRepository.Create(new AuditEntry(null, // string.Format("Attempt to call \"{2}\" failed with message {0}:'{1}'", raisedException.GetType().Name, raisedException.Message, methodName))); } } else { //TODO: uncomment this block when AuditEntry is added. //List<AuditEntry> actionDescription = service.GetCommandDescription(methodName, raisedException, // locator, // actionResult, additionalParams); //if (actionDescription != null) //{ // foreach (AuditEntry auditEntry in actionDescription) // { // if (auditEntry != null) // { // locator.AuditRepository.Create(auditEntry); // } // } //} } } }