You are viewing a plain text version of this content. The canonical link for it is here.
Posted to stonehenge-commits@incubator.apache.org by be...@apache.org on 2009/07/22 03:40:45 UTC

svn commit: r796609 [1/2] - in /incubator/stonehenge/trunk/stocktrader/dotnet: business_service/BusinessServiceConfigurationSettings/ business_service/BusinessServiceConsole/ business_service/BusinessServiceImplementation/ business_service/OrderProcess...

Author: bendewey
Date: Wed Jul 22 03:40:44 2009
New Revision: 796609

URL: http://svn.apache.org/viewvc?rev=796609&view=rev
Log:
STONEHENGE-83, thanks Avantika, this version is much better.

Modified:
    incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConfigurationSettings/Settings.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/App.config
    incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/Program.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeServiceFacadeWcf.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/common/DALSQLServer/Config.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/common/OrderProcessorServiceConfigurationSettings/Settings.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/common/ServiceConfigurationSettings/Settings.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.csproj
    incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/App.config
    incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/Program.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/order_processor/OrderProcessorConsoleServiceHost/App.config
    incubator/stonehenge/trunk/stocktrader/dotnet/order_processor/OrderProcessorConsoleServiceHost/Program.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/order_processor/OrderProcessorImplementation/OrderProcessorService.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/BusinessServiceClient/BSLClient.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/Trade/Configuration.aspx
    incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/Trade/Configuration.aspx.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/Trade/ConfigurationAdd.aspx.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/Trade/ConfigurationAdvanced.aspx
    incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/Trade/ConfigurationAdvanced.aspx.cs
    incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/Trade/Web.config

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConfigurationSettings/Settings.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConfigurationSettings/Settings.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConfigurationSettings/Settings.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConfigurationSettings/Settings.cs Wed Jul 22 03:40:44 2009
@@ -74,14 +74,8 @@
         //            YET UPDATABLE ACROSS DISTRIBUTED HOST INSTANCES VIA THE CONFIG MANAGEMENT SYSTEM (CONFIGWEB).  YOU WILL USE CONFIGWEB TO ADD
         //            REPOSITORY CONFIGURATION KEYS TO MAP THE REPOSITORY SETTING TO A CUSTOM (APP-SPECIFIC) FIELD NAME IN THE SETTINGS CLASS, AS
         //            WELL AS UPDATE SETTINGS ON LIVE CLUSTERED SYSTEMS WITHOUT APP RESTARTS.
-        public static string EVENT_LOG;
+
         public static string CS_DOTNET_ENDPOINT_CONFIG_HTTP;
-        //public static string OPS_DOTNET_ENDPOINT_CONFIG_HTTP;
-        //public static string OPS_DOTNET_ENDPOINT_CONFIG_WSHTTP;
-        //public static string OPS_PHP_ENDPOINT_CONFIG_HTTP;
-        //public static string OPS_PHP_ENDPOINT_CONFIG_WSHTTP;
-        //public static string OPS_WSAS_ENDPOINT_CONFIG_HTTP;
-        //public static string OPS_WSAS_ENDPOINT_CONFIG_WSHTTP;
         public static string DBServer; 
         public static string Database; 
         public static string UserID; 
@@ -117,7 +111,6 @@
         {
 
             Settings.CS_DOTNET_ENDPOINT_CONFIG_HTTP = ConfigurationManager.AppSettings.Get("CS_DOTNET_ENDPOINT_CONFIG_HTTP");
-            Settings.EVENT_LOG = ConfigurationManager.AppSettings.Get("EVENT_LOG");
             Settings.MinDBConnections = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MinDBConnections"));
             Settings.MaxDBConnections = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MaxDBConnections"));
             Settings.TRADEDB_SQL_CONN_STRING = ConfigurationManager.AppSettings.Get("TRADEDB_SQL_CONN_STRING");

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/App.config
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/App.config?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/App.config (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/App.config Wed Jul 22 03:40:44 2009
@@ -27,7 +27,11 @@
 <configuration>
   <!---THIS IS A CONFIG SERVICE CUSTOM CONFIG SECTION USED TO SPECIFIY individual ServiceEndpoint Identities, when desired-->
   <appSettings>
+    
+    <!--Possible values for logger mode: CONSOLE, EVENT_VIEWER-->
+    <add key="LOGGER_MODE" value="CONSOLE"/>
     <add key="EVENT_LOG" value="Trade Business Services" />
+    <add key="LOGGING_ENABLED" value="ON"/>
 
     <add key="BSL_VALID_USERID" value="bsloperationuser"/>
     <add key="BSL_VALID_PASSWORD" value="yyy"/>
@@ -52,6 +56,7 @@
     <add key="JAVA_OPSSEC" value="OpsClient_WSAS_WsHttpBinding_MSec" />
     <add key="ClientSettingsProvider.ServiceUri" value="" />
     <add key="BS_LABEL" value="DOTNET_BS"/>
+
   </appSettings>
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/Program.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/Program.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/Program.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceConsole/Program.cs Wed Jul 22 03:40:44 2009
@@ -126,7 +126,10 @@
             public void Dispose()
             {
                 if (serviceHost != null)
+                {
+                    serviceHost.Abort();
                     serviceHost.Close();
+                }
             }
         }
 
@@ -142,17 +145,27 @@
             {
                 using (var serviceHost = new BusinessServiceConsoleHost())
                 {
-                    serviceHost.start();
-
-                    //Test to see what the database specifies as the Order Processing Mode
-                    var configClient = new ConfigServiceClient();
-                    var bsRequest = new BSConfigRequest();
-                    bsRequest.BSName = Trade.BusinessServiceConfigurationSettings.Settings.BS_LABEL;
-                    var bsConfig = configClient.GetBSConfig(bsRequest);
-
-                    Console.WriteLine(" ORDER_PROCESSING_MODE is currently = {0}\n", bsConfig.OPSName);
-
-                    Console.WriteLine(" {0} is started\n", Console.Title);
+                    try
+                    {
+                        serviceHost.start();
+
+                        //Test to see what the database specifies as the Order Processing Mode
+                        var configClient = new ConfigServiceClient();
+                        var bsRequest = new BSConfigRequest();
+                        bsRequest.BSName = Trade.BusinessServiceConfigurationSettings.Settings.BS_LABEL;
+                        var bsConfig = configClient.GetBSConfig(bsRequest);
+
+                        if (bsConfig == null)
+                            throw new Exception("No DB Entry for " + Trade.BusinessServiceConfigurationSettings.Settings.BS_LABEL + ". Run SetupActions.sln to set up the database correctly");
+
+                        Console.WriteLine(" ORDER_PROCESSING_MODE is currently = {0}\n", bsConfig.OPSName);
+
+                        Console.WriteLine(" {0} is started\n", Console.Title);
+                    }
+                    catch (Exception ex)
+                    {
+                        StockTraderUtility.Logger.WriteException(ex);
+                    }
 
                     Console.WriteLine("Press Enter to quit or Ctrl+R to restart");
 

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs Wed Jul 22 03:40:44 2009
@@ -70,7 +70,7 @@
     {
         private IOrder dalOrder;
         private ICustomer dalCustomer;
-        private IMarketSummary dalMarketSummary; 
+        private IMarketSummary dalMarketSummary;
         
         //The following are the core functional service method implementations that
         //provide for the business functions/back-end processing of the application.
@@ -113,65 +113,70 @@
         /// <param name="password">Password for authentication</param>
         public AccountDataModel login(string userid, string password) 
         {
-            Console.WriteLine("Logging in for " + userid);
+            StockTraderUtility.Logger.WriteDebugMessage("Logging in for " + userid);
 
-            // Get Config
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
-
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
-
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create(SQLHelper.GetAssemblyNameFromDBName(bsConfig.DBName));
-            
-            //As feature of the StockTrader DAL, you will see dal.Open, dal.BeginTransaction, dal.CommitTransaction,
-            //dal.AbortTransaction and dal.Close methods being invoked in the BSL. The pattern  within this BSL is:
-            //a) Create an instance of the DAL; 
-            //b) Open the DAL; 
-            //c) Start a transaction only if necessary (more than one update/insert/delete involved);
-            //d) You get to pick ADO.NET transaction or System.Transactions or ServicedComponent, it will work with
-            //   all of the above; StockTrader lets you choose ADO.NET txs or System.Transactions via config.
-            //e) Close the DAL. This releases the DAL's internal connection back to the connection pool.
-
-            //The implementation "hides" the type of database being used from the BSL, so this BSL will work
-            //with any type of database you create a DAL for, with no changes in the BSL whatsoever. 
-            
-            //System.Transactions and SQL Server 2005 and Oracle databases work together
-            //with a new feature called "lightweight transactions"; which means you do not *need* to have the
-            //same performance penalty you got with Serviced Components for always invoking the tx as a full
-            //two-phase operation with DTC logging unless necessary.  For now, only SQL Server 2005 and Oracle databases support this feature which
-            //will automatically keep a transaction as a local database transaction and auto-promote to a distributed tx if needed.
-            //If operating against a single connection to SQL 2005 or Oracle, will not promote to a DTC-coordinated tx; and hence be much faster.
-            //On other databases, System.Transactions (and Serviced Components) *always* invoke the DTC, even when
-            //on a single connection to a single database.  So our StockTrader DAL is designed to:
-
-            // 1.  Hide DB implementation from BSL so we maintain clean separation of BSL from DAL.
-            // 2.  Let you freely call into the DAL from BSL methods as many times as you want *without*
-            //     creating new separate DB connections; which would invoke the DTC even on SQL Server 2005.
-            // 3.  As a by-product, it also helps you use ADO.NET transactions without worrying about
-            //     passing DB connections/transaction objects between tiers; maintaining cleaner separation
-            //     of BSL from DAL.  If using ADO.NET txs; you can accomplish DB-implementation isolation also with
-            //     the Provider Factories introduced with ADO.NET 2.0/.NET 2.0: see for details:
+            try
+            {
+                // Get Config
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
+
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create(SQLHelper.GetAssemblyNameFromDBName(bsConfig.DBName));
+
+                //As feature of the StockTrader DAL, you will see dal.Open, dal.BeginTransaction, dal.CommitTransaction,
+                //dal.AbortTransaction and dal.Close methods being invoked in the BSL. The pattern  within this BSL is:
+                //a) Create an instance of the DAL; 
+                //b) Open the DAL; 
+                //c) Start a transaction only if necessary (more than one update/insert/delete involved);
+                //d) You get to pick ADO.NET transaction or System.Transactions or ServicedComponent, it will work with
+                //   all of the above; StockTrader lets you choose ADO.NET txs or System.Transactions via config.
+                //e) Close the DAL. This releases the DAL's internal connection back to the connection pool.
+
+                //The implementation "hides" the type of database being used from the BSL, so this BSL will work
+                //with any type of database you create a DAL for, with no changes in the BSL whatsoever. 
+
+                //System.Transactions and SQL Server 2005 and Oracle databases work together
+                //with a new feature called "lightweight transactions"; which means you do not *need* to have the
+                //same performance penalty you got with Serviced Components for always invoking the tx as a full
+                //two-phase operation with DTC logging unless necessary.  For now, only SQL Server 2005 and Oracle databases support this feature which
+                //will automatically keep a transaction as a local database transaction and auto-promote to a distributed tx if needed.
+                //If operating against a single connection to SQL 2005 or Oracle, will not promote to a DTC-coordinated tx; and hence be much faster.
+                //On other databases, System.Transactions (and Serviced Components) *always* invoke the DTC, even when
+                //on a single connection to a single database.  So our StockTrader DAL is designed to:
+
+                // 1.  Hide DB implementation from BSL so we maintain clean separation of BSL from DAL.
+                // 2.  Let you freely call into the DAL from BSL methods as many times as you want *without*
+                //     creating new separate DB connections; which would invoke the DTC even on SQL Server 2005.
+                // 3.  As a by-product, it also helps you use ADO.NET transactions without worrying about
+                //     passing DB connections/transaction objects between tiers; maintaining cleaner separation
+                //     of BSL from DAL.  If using ADO.NET txs; you can accomplish DB-implementation isolation also with
+                //     the Provider Factories introduced with ADO.NET 2.0/.NET 2.0: see for details:
+
+                //             http://msdn2.microsoft.com/en-us/library/ms379620(VS.80).aspx
 
-            //             http://msdn2.microsoft.com/en-us/library/ms379620(VS.80).aspx
 
 
-            
-            //Note Open() is not really necessary, since the DAL will open a new connection automatically 
-            //if it's internal connection is not already open.  It's also free to open up more connections, if desired.
-            //We use Open() to stick with a consistent pattern in this application, since the Close() method IS
-            //important.  Look for this pattern in all BSL methods below; with a transaction scope defined
-            //only for operations that actually require a transaction per line (c) above.
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString);
-            try
-            {
-                Console.WriteLine("Leaving login for " + userid);
+                //Note Open() is not really necessary, since the DAL will open a new connection automatically 
+                //if it's internal connection is not already open.  It's also free to open up more connections, if desired.
+                //We use Open() to stick with a consistent pattern in this application, since the Close() method IS
+                //important.  Look for this pattern in all BSL methods below; with a transaction scope defined
+                //only for operations that actually require a transaction per line (c) above.
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString);
+                StockTraderUtility.Logger.WriteDebugMessage("Leaving login for " + userid);
                 return dalCustomer.login(userid, password);
             }
+            catch (Exception ex)
+            {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.login Error: " + ex.ToString());
+                throw;
+            }
             finally
             {
                 //Always close the DAL, this releases its primary DB connection.
@@ -185,30 +190,33 @@
         /// <param name="userID">User id to logout.</param>
         public void logout(string userID)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString);;
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString); ;
             
-            try
-            {
+   
                 dalCustomer.logOutUser(userID);
-                Console.WriteLine("Logging out for " + userID);
+                StockTraderUtility.Logger.WriteDebugMessage("Logging out for " + userID);
                 return;
             }
-            catch 
+            catch (Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.logout Error: " + ex.ToString());
                 throw;
             }
+
             finally
             {
                 dalCustomer.Close();
@@ -221,28 +229,30 @@
         /// <param name="userID">User id to retrieve data for.</param>
         public AccountDataModel getAccountData(string userID)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString);;
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString); ;
 
-            try
-            {
                 return dalCustomer.getCustomerByUserID(userID);
             }
-            catch 
+            catch (Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.getAccountData Error: " + ex.ToString());
                 throw;
             }
+
             finally
             {
                 dalCustomer.Close();
@@ -255,28 +265,30 @@
         /// <param name="userID">User id to retrieve data for.</param>
         public AccountProfileDataModel getAccountProfileData(string userID)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString); ;
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString); ;
 
-            try
-            {
                 return dalCustomer.getAccountProfileData(userID);
             }
-            catch 
+            catch (Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.getAccountProfileData Error: " + ex.ToString());
                 throw;
             }
+
             finally
             {
                 dalCustomer.Close();
@@ -289,26 +301,26 @@
         /// <param name="userID">User id to retrieve data for.</param>
         public List<OrderDataModel> getOrders(string userID)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
-
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString);;
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            try
-            {
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString); ;
                 return dalCustomer.getOrders(userID, false, Settings.MAX_QUERY_TOP_ORDERS,Settings.MAX_QUERY_ORDERS);
             }
-            catch 
+            catch(Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.getOrders Error: " + ex.ToString());
                 throw;
             }
             finally
@@ -323,26 +335,26 @@
         /// <param name="userID">User id to retrieve data for.</param>
         public List<OrderDataModel> getTopOrders(string userID)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
-
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString);;
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            try
-            {
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString); 
                 return dalCustomer.getOrders(userID, true, Settings.MAX_QUERY_TOP_ORDERS,Settings.MAX_QUERY_ORDERS);
             }
-            catch
+            catch(Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.getTopOrders Error: " + ex.ToString());
                 throw;
             }
             finally
@@ -357,26 +369,26 @@
         /// <param name="userID">User id to retrieve data for.</param>
         public List<OrderDataModel> getClosedOrders(string userID)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
-
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString);;
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            try
-            {
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString); ;
                 return dalCustomer.getClosedOrders(userID);
             }
-            catch 
+            catch (Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.getClosedOrders Error: " + ex.ToString());
                 throw;
             }
             finally
@@ -392,26 +404,26 @@
         /// <param name="userID">User id to retrieve data for.</param>
         public List<HoldingDataModel> getHoldings(string userID)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
-
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString);;
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            try
-            {
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString); ;
                 return dalCustomer.getHoldings(userID);
             }
-            catch 
+            catch(Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.getHoldings Error: " + ex.ToString());
                 throw;
             }
             finally
@@ -427,28 +439,29 @@
         /// <param name="holdingID">Holding id to retrieve data for.</param>
         public HoldingDataModel getHolding(string userID, int holdingID)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
-
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString);;
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            try
-            {
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString); ;
                 return dalCustomer.getHolding(userID, holdingID);
             }
-            catch
+            catch (Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.getHolding Error: " + ex.ToString());
                 throw;
             }
+
             finally
             {
                 dalCustomer.Close();
@@ -467,51 +480,52 @@
         /// <param name="openBalance">Open balance as specified by user. </param>
         public AccountDataModel register(string userID, string password, string fullname, string address, string email, string creditcard, decimal openBalance)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
-
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
 
-            //Switch is two let you configure which transaction model you want to benchmark/test.
-            switch (Settings.TRANSACTION_MODEL)
-            {
-                case (StockTraderUtility.TRANSACTION_MODEL_SYSTEMDOTTRANSACTION_TRANSACTION):
-                    {
-                         System.Transactions.TransactionOptions txOps = new TransactionOptions();
-                         txOps.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
-                         txOps.Timeout = TimeSpan.FromSeconds(15);
-                         //Start our System.Transactions tx with the options set above.  System.Transactions
-                         //will handle rollbacks automatically if there is an exception; note the 
-                         //difference between the System.Transaction case and the ADO.NET transaction case;
-                         //and where the dal.Open() happens (which opens a 'hidden' DB connection in DAL).  
-                         //System.Transactions will automatically enlist ANY connection
-                         //opened within the tx scope in the transaction for you.  Since it supports distributed
-                         //tx's; it frees you quite a bit, with the caveat of the overhead of doing a distributed
-                         //tx when you do not need one.  Hence: lightweight System.Transactions with SQL Server 2005 and Oracle;
-                         //and our DAL designed to take advantage of this important feature (auto-promote to DTC
-                         //only if needed). ADO.NET txs always require an already-open connection before starting a tx.
-                         using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required, txOps))
-                         {
+                //Switch is two let you configure which transaction model you want to benchmark/test.
+                switch (Settings.TRANSACTION_MODEL)
+                {
+                    case (StockTraderUtility.TRANSACTION_MODEL_SYSTEMDOTTRANSACTION_TRANSACTION):
+                        {
+                            System.Transactions.TransactionOptions txOps = new TransactionOptions();
+                            txOps.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
+                            txOps.Timeout = TimeSpan.FromSeconds(15);
+                            //Start our System.Transactions tx with the options set above.  System.Transactions
+                            //will handle rollbacks automatically if there is an exception; note the 
+                            //difference between the System.Transaction case and the ADO.NET transaction case;
+                            //and where the dal.Open() happens (which opens a 'hidden' DB connection in DAL).  
+                            //System.Transactions will automatically enlist ANY connection
+                            //opened within the tx scope in the transaction for you.  Since it supports distributed
+                            //tx's; it frees you quite a bit, with the caveat of the overhead of doing a distributed
+                            //tx when you do not need one.  Hence: lightweight System.Transactions with SQL Server 2005 and Oracle;
+                            //and our DAL designed to take advantage of this important feature (auto-promote to DTC
+                            //only if needed). ADO.NET txs always require an already-open connection before starting a tx.
+                            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required, txOps))
+                            {
                                 //Now open the connection, after entering tx scope.
-                                dalCustomer.Open(connectionString);;
+                                dalCustomer.Open(connectionString); ;
                                 try
                                 {
                                     AccountDataModel newCustomer = addNewRegisteredUser(userID, password, fullname, address, email, creditcard, openBalance);
                                     //Scope complete, commit work.
                                     tx.Complete();
-                                    Console.WriteLine("New user has been registered with userid: " + userID);
+                                    StockTraderUtility.Logger.WriteDebugMessage("New user has been registered with userid: " + userID);
                                     return newCustomer;
                                 }
-                                catch 
+                                catch
                                 {
                                     //no rollback needed, infrastructure will never commit without
                                     //scope.Complete() and immediately issue rollback on and unhandled
@@ -520,15 +534,15 @@
                                 }
                                 finally
                                 {
-                                    dalCustomer.Close(); 
+                                    dalCustomer.Close();
                                 }
-                         }
-                    }
+                            }
+                        }
 
-                case (StockTraderUtility.TRANSACTION_MODEL_ADONET_TRANSACTION):
-                    {
+                    case (StockTraderUtility.TRANSACTION_MODEL_ADONET_TRANSACTION):
+                        {
                             //ADO.NET TX case:  First you need to open the connecton.
-                            dalCustomer.Open(connectionString);;
+                            dalCustomer.Open(connectionString); ;
 
                             //Now you start TX 
                             dalCustomer.BeginADOTransaction();
@@ -537,10 +551,10 @@
                                 AccountDataModel newCustomer = addNewRegisteredUser(userID, password, fullname, address, email, creditcard, openBalance);
                                 //done, commit.
                                 dalCustomer.CommitADOTransaction();
-                                Console.WriteLine("New user has been registered with userid: " + userID);
+                                StockTraderUtility.Logger.WriteDebugMessage("New user has been registered with userid: " + userID);
                                 return newCustomer;
                             }
-                            catch 
+                            catch
                             {
                                 //explicit rollback needed.
                                 dalCustomer.RollBackTransaction();
@@ -553,9 +567,16 @@
                                 //but for a generic DB backend as far as the BSL is concerned.
                                 dalCustomer.Close();
                             }
-                    }
+                        }
+                }
+                throw new Exception(Settings.ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING + ": " + StockTraderUtility.EXCEPTION_MESSAGE_INVALID_TXMMODEL_CONFIG + " Repository ConfigKey table.");
+            }
+            catch (Exception ex)
+            {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.register Error: " + ex.ToString());
+                throw;
             }
-            throw new Exception(Settings.ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING + ": " + StockTraderUtility.EXCEPTION_MESSAGE_INVALID_TXMMODEL_CONFIG + " Repository ConfigKey table.");
+
         }
 
         /// <summary>
@@ -594,29 +615,31 @@
         /// <param name="profileData">Profile data model class with updated info.</param>
         public AccountProfileDataModel updateAccountProfile(AccountProfileDataModel profileData)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalCustomer = Trade.DALFactory.Customer.Create("Trade.DALSQLServer");
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalCustomer.Open(connectionString);;
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalCustomer.Open(connectionString); 
 
-            try
-            {
-                Console.WriteLine("Account profile updated for " + profileData.userID);
+                StockTraderUtility.Logger.WriteDebugMessage("Account profile updated for " + profileData.userID);
                 return dalCustomer.update(profileData);
             }
-            catch 
+            catch (Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.updateAccountProfile Error: " + ex.ToString());
                 throw;
             }
+
             finally
             {
                 dalCustomer.Close();
@@ -628,28 +651,30 @@
         /// </summary>
         public MarketSummaryDataModelWS getMarketSummary()
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
-
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalMarketSummary = Trade.DALFactory.MarketSummary.Create("Trade.DALSQLServer");
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalMarketSummary.Open(connectionString);;
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalMarketSummary = Trade.DALFactory.MarketSummary.Create("Trade.DALSQLServer");
 
-            try
-            {
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalMarketSummary.Open(connectionString); ;
+            
                 return dalMarketSummary.getMarketSummaryData();
             }
-            catch 
+            catch (Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.getMarketSummary Error: " + ex.ToString());
                 throw;
             }
+
             finally
             {
                 dalMarketSummary.Close();
@@ -662,28 +687,30 @@
         /// <param name="symbol">Symbol to get data for.</param>
         public QuoteDataModel getQuote(string symbol)
         {
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
-
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+            try
+            {
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalMarketSummary = Trade.DALFactory.MarketSummary.Create("Trade.DALSQLServer");
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
-            dalMarketSummary.Open(connectionString);;
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalMarketSummary = Trade.DALFactory.MarketSummary.Create("Trade.DALSQLServer");
 
-            try
-            {
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                dalMarketSummary.Open(connectionString); ;
+            
                 return dalMarketSummary.getQuote(symbol);
             }
-            catch
+            catch (Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.getQuote Error: " + ex.ToString());
                 throw;
             }
+
             finally
             {
                 dalMarketSummary.Close();
@@ -746,41 +773,99 @@
         /// <param name="quantity">Shares to buy.</param>
         public OrderDataModel placeOrder(string orderType, string userID, int holdingID, string symbol, double quantity)
         {
-            OrderDataModel order = null;
-            HoldingDataModel holding = new HoldingDataModel();
+            try
+            {
+                OrderDataModel order = null;
+                HoldingDataModel holding = new HoldingDataModel();
 
-            var configClient = new ConfigServiceClient();
-            var bsRequest = new BSConfigRequest();
-            bsRequest.BSName = Settings.BS_LABEL;
-            var bsConfig = configClient.GetBSConfig(bsRequest);
+                var configClient = new ConfigServiceClient();
+                var bsRequest = new BSConfigRequest();
+                bsRequest.BSName = Settings.BS_LABEL;
+                var bsConfig = configClient.GetBSConfig(bsRequest);
 
-            if (bsConfig == null)
-                throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
+                if (bsConfig == null)
+                    throw new Exception(string.Format(StockTraderUtility.EXCEPTION_MESSAGE_BAD_CONFIG, bsRequest.BSName));
 
-            //Create instance of a DAL, which could be designed for any type of DB backend.
-            dalOrder = Trade.DALFactory.Order.Create("Trade.DALSQLServer");
-            var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
+                //Create instance of a DAL, which could be designed for any type of DB backend.
+                dalOrder = Trade.DALFactory.Order.Create("Trade.DALSQLServer");
+                var connectionString = SQLHelper.GenerateSqlServerConnectionString(bsConfig.DBHostName, bsConfig.DBPort);
 
 
-            switch (Settings.TRANSACTION_MODEL)
-            {
-                case (StockTraderUtility.TRANSACTION_MODEL_SYSTEMDOTTRANSACTION_TRANSACTION):
-                    {
-                        System.Transactions.TransactionOptions txOps = new TransactionOptions();
-                        txOps.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
-                        txOps.Timeout = TimeSpan.FromSeconds(Settings.SYSTEMDOTTRANSACTION_TIMEOUT);
-                        //Start our System.Transactions tx with the options set above.
-                        using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required, txOps))
+                switch (Settings.TRANSACTION_MODEL)
+                {
+                    case (StockTraderUtility.TRANSACTION_MODEL_SYSTEMDOTTRANSACTION_TRANSACTION):
+                        {
+                            System.Transactions.TransactionOptions txOps = new TransactionOptions();
+                            txOps.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
+                            txOps.Timeout = TimeSpan.FromSeconds(Settings.SYSTEMDOTTRANSACTION_TIMEOUT);
+                            //Start our System.Transactions tx with the options set above.
+                            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required, txOps))
+                            {
+                                dalOrder.Open(connectionString);
+                                try
+                                {
+                                    //Business Step 1:  create the order header.
+                                    order = createOrder(orderType, userID, holdingID, symbol, quantity, ref holding);
+
+                                    //Business Step 2:  Sets up the interface with the 
+                                    //async WCF Order Processing Service via a service-to-service call
+                                    //distributed/remote.
+
+                                    //Fire up our async client;  we follow the same model here as with the
+                                    //StockTrader Web App in that we do not talk 'directly' to the generated proxy
+                                    //for the service; rather we channel all calls through a single 
+                                    //class that then talks to the service proxy.  This will aid in more
+                                    //easily knowing where communication and proxy logic sits; and make changes to services
+                                    //you might want to interface with vs. littering proxy calls throughout the
+                                    //business tier itself.
+
+                                    //Here, replaced the Settings.orderMode with the database configuration stuff
+                                    //Settings.orderMode has become bsConfig.ops
+
+                                    //This method clears the cache so that the configuration changes are recognized
+                                    //without restarts
+                                    TradeServiceWcf.Initialize();
+
+                                    //This creates a new client with the orderMode specified using the config info
+                                    //from the database. Specifically, the row containing "DOTNET_BS" in the table
+                                    //BSTOOPS
+                                    TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(bsConfig.OPSName);
+
+                                    asyncclient.processOrderASync(order);
+
+                                    tx.Complete();
+                                    StockTraderUtility.Logger.WriteDebugMessage("Order placed of type " + orderType + " for the user " + userID + " in the quantity of " + quantity);
+                                    return order;
+                                }
+
+                                catch
+                                {
+                                    //If per chance you are doing step-through debugging through here and are getting a
+                                    // "TRANSACTION HAS ABORTED" exception and do not know why,
+                                    //it's quite likely you are hitting the 15-second timeout we set in
+                                    //ConfigurationSettings for the System.Transaction options so its just doing what we told it to. 
+                                    //Simply adjust timeout higher, recompile if you need to.
+                                    throw;
+                                }
+                                finally
+                                {
+                                    dalOrder.Close();
+                                }
+                            }
+                        }
+
+                    //Repeat for ADO.NET transactions config option case. 
+                    case (StockTraderUtility.TRANSACTION_MODEL_ADONET_TRANSACTION):
                         {
                             dalOrder.Open(connectionString);
+                            dalOrder.BeginADOTransaction();
                             try
                             {
                                 //Business Step 1:  create the order header.
                                 order = createOrder(orderType, userID, holdingID, symbol, quantity, ref holding);
 
-                                //Business Step 2:  Sets up the interface with the 
-                                //async WCF Order Processing Service via a service-to-service call
-                                //distributed/remote.
+                                //Business Step 2:  Sets up an interface with the 
+                                //async WCF Order Processing Service via a service-to-service call.
 
                                 //Fire up our async client;  we follow the same model here as with the
                                 //StockTrader Web App in that we do not talk 'directly' to the generated proxy
@@ -789,33 +874,15 @@
                                 //easily knowing where communication and proxy logic sits; and make changes to services
                                 //you might want to interface with vs. littering proxy calls throughout the
                                 //business tier itself.
-
-                                //Here, replaced the Settings.orderMode with the database configuration stuff
-                                //Settings.orderMode has become bsConfig.ops
-
-                                //This method clears the cache so that the configuration changes are recognized
-                                //without restarts
-                                TradeServiceWcf.Initialize();
-
-                                //This creates a new client with the orderMode specified using the config info
-                                //from the database. Specifically, the row containing "DOTNET_BS" in the table
-                                //BSTOOPS
-                                TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(bsConfig.OPSName);
-                                
+                                TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(bsConfig.OPS);
                                 asyncclient.processOrderASync(order);
+                                dalOrder.CommitADOTransaction();
 
-                                tx.Complete();
-                                Console.WriteLine("Order placed of type " + orderType + " for the user " + userID + " in the quantity of " + quantity);
                                 return order;
                             }
-
                             catch
                             {
-                                //If per chance you are doing step-through debugging through here and are getting a
-                                // "TRANSACTION HAS ABORTED" exception and do not know why,
-                                //it's quite likely you are hitting the 15-second timeout we set in
-                                //ConfigurationSettings for the System.Transaction options so its just doing what we told it to. 
-                                //Simply adjust timeout higher, recompile if you need to.
+                                dalOrder.RollBackTransaction();
                                 throw;
                             }
                             finally
@@ -823,46 +890,15 @@
                                 dalOrder.Close();
                             }
                         }
-                    }
-               
-                //Repeat for ADO.NET transactions config option case. 
-                case (StockTraderUtility.TRANSACTION_MODEL_ADONET_TRANSACTION):
-                    {
-                        dalOrder.Open(connectionString);
-                        dalOrder.BeginADOTransaction();
-                        try
-                        {
-                            //Business Step 1:  create the order header.
-                            order = createOrder(orderType, userID, holdingID, symbol, quantity, ref holding);
-
-                            //Business Step 2:  Sets up an interface with the 
-                            //async WCF Order Processing Service via a service-to-service call.
-
-                            //Fire up our async client;  we follow the same model here as with the
-                            //StockTrader Web App in that we do not talk 'directly' to the generated proxy
-                            //for the service; rather we channel all calls through a single 
-                            //class that then talks to the service proxy.  This will aid in more
-                            //easily knowing where communication and proxy logic sits; and make changes to services
-                            //you might want to interface with vs. littering proxy calls throughout the
-                            //business tier itself.
-                            TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(bsConfig.OPS);
-                            asyncclient.processOrderASync(order);
-                            dalOrder.CommitADOTransaction();
+                }
+                throw new Exception(Settings.ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING + ": " + StockTraderUtility.EXCEPTION_MESSAGE_INVALID_TXMMODEL_CONFIG + " Repository ConfigKey table.");
+            }
+            catch (Exception ex)
+            {
 
-                            return order;
-                        }
-                        catch
-                        {
-                            dalOrder.RollBackTransaction();
-                            throw;
-                        }
-                        finally
-                        {
-                            dalOrder.Close();
-                        }
-                    }
+                StockTraderUtility.Logger.WriteException(ex); 
+                throw;
             }
-            throw new Exception(Settings.ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING + ": " + StockTraderUtility.EXCEPTION_MESSAGE_INVALID_TXMMODEL_CONFIG + " Repository ConfigKey table.");
         }
 
         
@@ -981,14 +1017,16 @@
                 order.holdingID = holdingid;
                 dalOrder.closeOrder(order);
 
-                Console.WriteLine("Order has been processed synchronously");
+                StockTraderUtility.Logger.WriteDebugMessage("Order has been processed synchronously");
 
                 return;
             }
-            catch 
+            catch (Exception ex)
             {
+                StockTraderUtility.Logger.WriteErrorMessage("TradeService.processOrderSync Error: " + ex.ToString());
                 throw;
             }
+
         }
 
         /// <summary>

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeServiceFacadeWcf.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeServiceFacadeWcf.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeServiceFacadeWcf.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeServiceFacadeWcf.cs Wed Jul 22 03:40:44 2009
@@ -60,7 +60,7 @@
         {
             loginCount++;
             if (Settings.DISPLAY_WEBSERVICE_LOGINS && (loginCount % Settings.LOGIN_ITERATIONSTO_DISPLAY == 0))
-                StockTraderUtility.writeConsoleMessage("Login request # " + loginCount.ToString() + " received. Login is for user id: " + userid + "\n",EventLogEntryType.Information,false, Settings.EVENT_LOG);
+                StockTraderUtility.Logger.WriteDebugMessage("Login request # " + loginCount.ToString() + " received. Login is for user id: " + userid + "\n");
             TradeService service = new TradeService();
             return service.login(InputText(userid, StockTraderUtility.USERID_MAX_LENGTH), InputText(password, StockTraderUtility.PASSWORD_MAX_LENGTH));             
         }

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs Wed Jul 22 03:40:44 2009
@@ -77,7 +77,7 @@
             }
             catch
             {
-                throw new Exception("Order Mode not recognized");
+                StockTraderUtility.Logger.WriteErrorMessage("TradeOrderServiceAsyncClient Initialization Error: BAD CONFIG");
             }
         }
 
@@ -146,7 +146,7 @@
                 string innerException = null;
                 if (e.InnerException != null)
                     innerException = e.InnerException.ToString();
-                StockTraderUtility.writeErrorConsoleMessage(e.ToString() + "\nInner Exception: " + innerException,EventLogEntryType.Error,true,Settings.EVENT_LOG);
+                StockTraderUtility.Logger.WriteErrorMessage(e.ToString() + "\nInner Exception: " + innerException);
                 this.Channel = null;
                 throw;
             }

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/common/DALSQLServer/Config.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/common/DALSQLServer/Config.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/common/DALSQLServer/Config.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/common/DALSQLServer/Config.cs Wed Jul 22 03:40:44 2009
@@ -120,9 +120,9 @@
         private const string SQL_FIND_SERVICE = @"SET NOCOUNT ON; SELECT SERVICENAME, URL, SEC FROM dbo.SERVICE WHERE SERVICENAME = @ServiceName";
         private const string SQL_SET_BS_TO_OPS = @"INSERT INTO dbo.BSTOOPS (BS, OPS) VALUES (@Bs, @Ops)";
         private const string SQL_UPDATE_BS_TO_OPS = @"UPDATE dbo.BSTOOPS WITH (ROWLOCK) SET OPS=@Ops WHERE BS=@Bs";
-        private const string SQL_COUNT_BS = @"SELECT COUNT(*) as count FROM dbo.SERVICE WHERE SERVICENAME LIKE '%_BS'";
+        private const string SQL_COUNT_BS = @"SELECT COUNT(*) as count FROM dbo.SERVICE WHERE SERVICENAME LIKE '%_BS' OR SERVICENAME LIKE '%_BSSEC'";
         private const string SQL_COUNT_OPS = @"SELECT COUNT(*) as count FROM dbo.SERVICE WHERE SERVICENAME LIKE '%_OPS' OR SERVICENAME LIKE '%_OPSSEC'";
-        private const string SQL_GET_BS = @"SELECT SERVICENAME, URL, SEC FROM dbo.SERVICE WHERE SERVICENAME LIKE '%_BS'";
+        private const string SQL_GET_BS = @"SELECT SERVICENAME, URL, SEC FROM dbo.SERVICE WHERE SERVICENAME LIKE '%_BS' OR SERVICENAME LIKE '%_BSSEC'";
         private const string SQL_GET_OPS = @"SELECT SERVICENAME, URL, SEC FROM dbo.SERVICE WHERE SERVICENAME LIKE '%_OPS' OR SERVICENAME LIKE '%_OPSSEC'";
         private const string SQL_UPDATE_SERVICE_LOCATION = @"UPDATE dbo.SERVICE WITH (ROWLOCK) SET URL = @Url, SEC = @Sec WHERE SERVICENAME = @ServiceName";
         private const string SQL_INSERT_SERVICE_LOCATION = @"INSERT INTO dbo.SERVICE (SERVICENAME, URL, SEC) VALUES (@ServiceName, @Url, @Sec)";

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/common/OrderProcessorServiceConfigurationSettings/Settings.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/common/OrderProcessorServiceConfigurationSettings/Settings.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/common/OrderProcessorServiceConfigurationSettings/Settings.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/common/OrderProcessorServiceConfigurationSettings/Settings.cs Wed Jul 22 03:40:44 2009
@@ -63,10 +63,6 @@
     public class Settings 
     {
 
-        
-      
-        public static string EVENT_LOG = "Order Processor Event Log";
-
         public static string DBServer;
         public static string Database;
         public static string UserID;

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/common/ServiceConfigurationSettings/Settings.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/common/ServiceConfigurationSettings/Settings.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/common/ServiceConfigurationSettings/Settings.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/common/ServiceConfigurationSettings/Settings.cs Wed Jul 22 03:40:44 2009
@@ -100,7 +100,6 @@
         /// </summary>
         static Settings()
         {
-            Settings.EVENT_LOG = ConfigurationManager.AppSettings.Get("EVENT_LOG");
             Settings.MAX_DISPLAY_ORDERS = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MAX_DISPLAY_ORDERS"));
             Settings.MAX_DISPLAY_TOP_ORDERS = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MAX_DISPLAY_TOP_ORDERS"));
             Settings.DISPLAY_DUPLICATE_KEY_EXCEPTIONS = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("DISPLAY_DUPLICATE_KEY_EXCEPTIONS"));

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.cs Wed Jul 22 03:40:44 2009
@@ -37,9 +37,12 @@
 using System.Diagnostics;
 using System.ServiceModel;
 using System.ServiceModel.Description;
+using System.Configuration;
+using Trade.Utility.Loggers;
 
 namespace Trade.Utility
 {
+
     /// <summary>
     /// Utility class with constants used in StockTrader app/services. 
     /// </summary>
@@ -142,72 +145,36 @@
         //Random class on each buy/sell;  
         private static Random rand = new Random(DateTime.Now.Millisecond);
 
-
-        /// <summary>
-        /// Writes messages to Main console of Windows self-host base form or console.
-        /// <param name="message">String with message to display/log.</param> 
-        /// <param name="messageType">Event Log entry type code</param> 
-        /// <param name="logEntry">Whether to log entry.  Entry will be logged if configuration database is set for detailed logging and this parameter is true</param> 
-        /// <param name="eventLog">The event log source name</param> 
-        public static void writeConsoleMessage(string message, EventLogEntryType messageType, bool logEntry, string eventLog)
-        {
-            try
-            {
-                LogMessage(message, messageType, logEntry, eventLog);
-            }
-            catch
-            {
-            }
-            return;
-        }
-
-        /// <summary>
-        /// Writes messages to errors console of Windows self-host base form or console. 
-        /// </summary>
-        /// <param name="message">String with message to display/log.</param> 
-        /// <param name="messageType">Event Log entry type code</param> 
-        /// <param name="logEntry">Whether to log entry.  Entry will be logged if configuration database is set for detailed logging and this parameter is true</param> 
-        /// <param name="eventLog">The event log source name</param>
-        public static void writeErrorConsoleMessage(string message, EventLogEntryType messageType, bool logEntry, string eventLog)
-        {
-            try
-            {
-                LogMessage(message, messageType, logEntry, eventLog);
-            }
-            catch
-            {
-            }
-        }
-
-        /// <summary>Writes to event log.</summary>
-        /// <param name="message">String with message to display/log.</param> 
-        /// <param name="messageType">Event Log entry type code</param> 
-        /// <param name="logEntry">Whether to log entry.  Entry will be logged if configuration database is set for detailed logging and this parameter is true</param> 
-        /// <param name="eventLog">The event log source name</param>
-        public static void LogMessage(string message, EventLogEntryType messageType, bool logEntry, string eventLog)
+        private static ILogger logger;
+        public static ILogger Logger
         {
-            if (!logEntry)
-                return;
-            try
-            {
-                EventLog EventLog1 = new EventLog();
-                EventLog1.Source = eventLog;
-                EventLog1.WriteEntry(message, messageType);
-            }
-            catch (Exception e)
+            get
             {
-                //Choice here:  sometimes Web apps will throw a security exception 
-                //writing to the event log if the source is not setup properly and the account 'Network Service'
-                //given "Full Control" to the event log to be able to write entries.  Really, this exception should
-                //be thrown so user knows they are not getting event log info; however, to avoid frustration
-                //for those that get it, I am simply trapping here.  Otherwise, you may wish to uncomment this line:
-                //
-                //     throw new Exception("An exception occurred attempting to write to the Windows Application Event Log. Please make sure the 'Network Service' account (the account ASP.NET runs under) has write access to the Application Event Log.  You will use RegEdit to add permissions, refer to the StockTrader Readme.html for precise instructions.\nThe specific exception writing to the " + EVENT_LOG + " Application Log event source is: " + e.ToString());
-                //
-                //So if you catch an exception here, check e to see if a security exception.  If so, likely need to add Network
-                //Service to EventLog permissions via regedit, current control set, services, Event Log (select), then 
-                //from main menu choose Permissions to add Network Service with Full Control (so ASP.NET/IIS can create/and write to).
-                string throwaway = e.Message;
+                if (logger == null)
+                {
+                    string logging_enabled = ConfigurationManager.AppSettings.Get("LOGGING_ENABLED");
+                    if (!logging_enabled.Equals("ON", StringComparison.InvariantCultureIgnoreCase))
+                    {
+                        logger = new NullLogger();
+                    }
+                    else
+                    {
+                        string loggerMode = ConfigurationManager.AppSettings.Get("LOGGER_MODE");
+                        switch (loggerMode)
+                        {
+                            case ("CONSOLE"):
+                                logger = new ConsoleLogger();
+                                break;
+                            case ("EVENT_VIEWER"):
+                                logger = new EventViewerLogger();
+                                break;
+                            default:
+                                logger = new NullLogger();
+                                break;
+                        }
+                    }
+                }
+                return logger;
             }
         }
 

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.csproj
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.csproj?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.csproj (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/common/StockTraderUtility/Utility.csproj Wed Jul 22 03:40:44 2009
@@ -46,6 +46,7 @@
   <ItemGroup>
     <Reference Include="Accessibility" />
     <Reference Include="System" />
+    <Reference Include="System.configuration" />
     <Reference Include="System.Core">
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
     </Reference>
@@ -62,8 +63,12 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ConfigCertificatePolicy.cs" />
+    <Compile Include="Loggers\ConsoleLogger.cs" />
     <Compile Include="CustomCertificateValidator.cs" />
     <Compile Include="CustomUserNameValidator.cs" />
+    <Compile Include="Loggers\EventViewerLogger.cs" />
+    <Compile Include="Loggers\ILogger.cs" />
+    <Compile Include="Loggers\NullLogger.cs" />
     <Compile Include="SQLHelper.cs" />
     <Compile Include="Utility.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/App.config
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/App.config?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/App.config (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/App.config Wed Jul 22 03:40:44 2009
@@ -36,6 +36,12 @@
     <add key="CLIENT_LABEL" value="DOTNET_CLIENT"/>
     <add key="BS_LABEL" value="DOTNET_BS"/>
     <add key="OPS_LABEL" value="DOTNET_OPS"/>
+
+    <!--Possible values for logger mode: CONSOLE, EVENT_VIEWER-->
+    <add key="LOGGER_MODE" value="CONSOLE"/>
+    <add key ="EVENT_LOG" value="Trade Config Service"/>
+    <add key="LOGGING_ENABLED" value="ON"/>
+
   </appSettings>
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/Program.cs
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/Program.cs?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/Program.cs (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/config_service/ConfigServiceConsoleHost/Program.cs Wed Jul 22 03:40:44 2009
@@ -108,7 +108,10 @@
             public void Dispose()
             {
                 if (host != null)
+                {
+                    host.Abort();
                     host.Close();
+                }
             }
         }
 
@@ -141,6 +144,8 @@
                     request.ClientName = Settings.CLIENT_LABEL;
                     var response = proxy.GetClientConfig(request);
 
+                    if (response == null)
+                        throw new Exception("No DB Entry for " + Settings.CLIENT_LABEL + ". Run SetupActions.sln to set up the database correctly"); 
                     Console.ForegroundColor = ConsoleColor.Green;
                     Console.WriteLine("Test Success");
                     Console.WriteLine(" Current DOTNET_CLIENT-> BS = {0}", response.BSName);
@@ -149,10 +154,7 @@
                 catch (Exception ex)
                 {
                     //Debugger.Break();
-                    Console.ForegroundColor = ConsoleColor.Red;
-                    Console.WriteLine("Error Running Test");
-                    Console.WriteLine(ex.ToString());
-                    Console.ForegroundColor = ConsoleColor.Gray;
+                    StockTraderUtility.Logger.WriteErrorMessage("Error running tests: " + ex.ToString());
                 }
             }
 
@@ -169,10 +171,17 @@
                     var request = new ClientConfigRequest();
                     request.ClientName = Settings.CLIENT_LABEL;
                     var response = proxy.GetClientConfig(request);
+
+                    if (response == null)
+                        throw new Exception("No DB Entry for " + Settings.CLIENT_LABEL + ". Run SetupActions.sln to set up the database correctly"); 
+
                     var bsrequest = new BSConfigRequest();
                     bsrequest.BSName = response.BSName;
                     var bs = proxy.GetBSConfig(bsrequest);
 
+                    if (bs == null)
+                        throw new Exception("No DB Entry for " + Settings.BS_LABEL + ". Run SetupActions.sln to set up the database correctly");
+                    
                     Console.ForegroundColor = ConsoleColor.Green;
                     Console.WriteLine("Test Success");
                     Console.WriteLine(" Current {0}-> OPS = {1}", response.BSName, bs.OPSName);
@@ -182,10 +191,7 @@
                 catch (Exception ex)
                 {
                     //Debugger.Break();
-                    Console.ForegroundColor = ConsoleColor.Red;
-                    Console.WriteLine("Error Running Test");
-                    Console.WriteLine(ex.ToString());
-                    Console.ForegroundColor = ConsoleColor.Gray;
+                    StockTraderUtility.Logger.WriteErrorMessage("Error running tests: " + ex.ToString());
                 }
             }
 
@@ -205,21 +211,28 @@
             {
                 using (ConfigHost configHost = new ConfigHost())
                 {
-                    configHost.startUp();
-
-                    Console.WriteLine(" {0} is started.", Console.Title);
-                    Console.WriteLine();
-
-                    // Run Tests
-                    Console.ForegroundColor = ConsoleColor.Yellow;
-                    Console.WriteLine(" Running Tests for {0}", Console.Title);
-                    Console.WriteLine();
-
-                    ConfigTestClient client = new ConfigTestClient();
-                    client.RunClientTest();
-                    client.RunBsTest();
-
-                    Console.WriteLine();
+                    try
+                    {
+                        configHost.startUp();
+
+                        Console.WriteLine(" {0} is started.", Console.Title);
+                        Console.WriteLine();
+
+                        // Run Tests
+                        Console.ForegroundColor = ConsoleColor.Yellow;
+                        Console.WriteLine(" Running Tests for {0}", Console.Title);
+                        Console.WriteLine();
+
+                        ConfigTestClient client = new ConfigTestClient();
+                        client.RunClientTest();
+                        client.RunBsTest();
+
+                        Console.WriteLine();
+                    }
+                    catch (Exception ex)
+                    {
+                        StockTraderUtility.Logger.WriteException(ex);
+                    }
 
                     Console.WriteLine("Press Enter to quit or Ctrl+R to restart");
 

Modified: incubator/stonehenge/trunk/stocktrader/dotnet/order_processor/OrderProcessorConsoleServiceHost/App.config
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/order_processor/OrderProcessorConsoleServiceHost/App.config?rev=796609&r1=796608&r2=796609&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/dotnet/order_processor/OrderProcessorConsoleServiceHost/App.config (original)
+++ incubator/stonehenge/trunk/stocktrader/dotnet/order_processor/OrderProcessorConsoleServiceHost/App.config Wed Jul 22 03:40:44 2009
@@ -34,6 +34,12 @@
     <add key="DISPLAYNUMBERORDERITERATIONS" value="3" />
     <add key="CS_DOTNET_ENDPOINT_CONFIG_HTTP" value="ConfigClient_DotNet_BasicHttpBinding"/>
     <add key="OPS_LABEL" value="DOTNET_OPS"/>
+
+    <!--Possible values for logger mode: CONSOLE, EVENT_VIEWER-->
+    <add key="LOGGER_MODE" value="CONSOLE"/>
+    <add key="EVENT_LOG" value="Trade Order Processor"/>
+    <add key="LOGGING_ENABLED" value="ON"/>
+
   </appSettings>
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">