>>> public class MiddlewareMain : MiddlewareBase >>> { >>> private delegate String InvokeMethod(Dictionary<String, String> parameters); >>> private Dictionary<String, InvokeMethod> invokeMethods; >>> private Sales _sales; >>> private Data _data; >>> private Retail _retail; >>> private Bookings _bookings; >>> private Validation _validation; >>> private Boolean _bShouldRollback = false; >>> private Boolean _bShouldRollbackGlobalInvoke = false; >>> >>>... >>>>>>
>>> public abstract class UnitTestBase >>> { >>> public static IniFile iniFile, systemIniFile; >>> public static MiddlewareMain middlewareMain; >>> public static Boolean isClassInitialized = false;>>
> /// <summary> > /// Main Invoke method > /// </summary> > /// <param name="input"></param> > /// <returns></returns> > public String Invoke(String input) > { > this.CurrentRequest = new Request(); > this.CurrentRequest.InvokeString = input; // Save invoke string > Logging.Log(2, "Invoke called with " + input); > this.CurrentRequest.InvokeStartTime = DateTime.Now; > > this.data.CurrentRequest = this.CurrentRequest; > this.sales.CurrentRequest = this.CurrentRequest; > this.bookings.CurrentRequest = this.CurrentRequest; > this.validation.CurrentRequest = this.CurrentRequest; > this.retail.CurrentRequest = this.CurrentRequest; > > Dictionary<String, String> parameters = new Dictionary<String, String>(StringComparer.OrdinalIgnoreCase); > > try > { > parameters.PopulateFromSQML(input); > } > > catch (Exception ex) > { > String error = ex.ToString(); > Logging.Log(error, 1); > this.CurrentRequest.LastError = new ErrorState(100, error); > } > > if (this.CurrentRequest.LastError ==null && !parameters.ContainsKey("func")) > { > this.CurrentRequest.LastError = new ErrorState(100, "Parameter 'func' not specified"); > } > > if (this.CurrentRequest.LastError == null && !invokeMethods.ContainsKey(parameters["func"])) > { > this.CurrentRequest.LastError = new ErrorState(100, String.Format("Function '{0}' is not available", parameters["func"])); > } > > if (this.CurrentRequest.LastError != null) > { > return this.CurrentRequest.FormatError(); > } > String cReturnValue = ""; > > // If the <TestOnly> tag was passed in the Invoke call, roll back the entire Invoke call once it completes (see below) > if (parameters.ContainsKey("testonly")) > database.rollbackGlobalInvoke = true; > > try > { > if (database.rollbackGlobalInvoke) > { > using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) > { > database.globalTransaction = true; > if (database.sqlConnection != null && database.sqlConnection.State == ConnectionState.Open) > database.sqlConnection.EnlistTransaction(Transaction.Current); > cReturnValue = invokeMethods[parameters["func"]](parameters); > database.globalTransaction = false; > // Do not call Complete(), so the entire Invoke call will be automatically rolled back. > // scope.Complete(); > } > } > else > cReturnValue = invokeMethods[parameters["func"]](parameters); > } > > catch (SiriusException ex) > { > Logging.LogFormat(1,"Sirius Exception Caught: {0}", ex.Message); > this.CurrentRequest.LastError = new ErrorState((Int16)ex.statusCode, ex.Message); > // Lookup error codes for the status returned if necessary. > cReturnValue = this.CurrentRequest.FormatError(); > } > > catch (Exception ex) > { > String error = ex.ToString(); > Logging.Log(error, 1); > this.CurrentRequest.LastError = new ErrorState(100, error); > cReturnValue = this.CurrentRequest.FormatError(); > } > > this.CurrentRequest.InvokeEndTime = DateTime.Now; > Logging.Log(2, "Invoke took " + this.CurrentRequest.InvokeDuration.ToString()); > this.CurrentRequest.Dispose(); > return cReturnValue; > } > }I see the Request class implements IDisposable so it's presumably accessing unmanaged resources - and the above code doesn't guarantee that Dispose() is called. Might just be possible that it's holding something open that the compiler needs. IAC you should wrap it in a using block.