// // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // .Net StockTrader Sample WCF Application for Benchmarking, Performance Analysis and Design Considerations for Service-Oriented Applications //====================================================================================================== // The Settings class for the Order Processor Service. Please note well that we only override the // inherited settings (with the new keyword) becuase of the special case StockTrader allows for running // OPS in-process with the Business Service layer, vs. remote. You will NOT need to do this for your // services--your Settings class will be much simpler, simply using the *inherited* global settings, and only // specifying app-specific settings here. //====================================================================================================== //====================================================================================================== // Code originally contributed by Microsoft Corporation. // This contribution to the Stonehenge project is limited strictly // to the source code that is submitted in this submission. // Any technology, including underlying platform technology, // that is referenced or required by the submitted source code // is not a part of the contribution. // For example and not by way of limitation, // any systems/Windows libraries (WPF, WCF, ASP.NET etc.) // required to run the submitted source code is not a part of the contribution //====================================================================================================== using System; using System.Collections.Generic; using System.Configuration; using System.Web; using System.ServiceModel; using System.ServiceModel.Channels; using System.Data; //using System.Collections; using System.Diagnostics; using System.Messaging; using System.Text; using System.Reflection; using Trade.Utility; namespace Trade.OrderProcessorServiceConfigurationSettings { /// /// Any app or service implementing the Configuration Service needs a custom Settings class that will contain it's /// app-specific config settings. These are loaded from the SQL repository on startup with current values as set for service. /// Your custom settings class should inherit from the ConfigurationSettingsBase class, which contains common /// settings used by all services implementing the config service, in addition to the app-specific settings defined here. /// public class Settings { public static string DBServer; public static string Database; public static string UserID; public static string Password; public static int MinDBConnections; public static int MaxDBConnections; public static string TRADEDB_SQL_CONN_STRING; public static string DAL; public static string ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING; public static int SYSTEMDOTTRANSACTION_TIMEOUT; public static string ORDER_PROCESSING_BEHAVIOR; public static int DISPLAYNUMBERORDERITERATIONS; public static string OPS_LABEL; public static string OPS_USERID; public static string OPS_PASSWORD; public Settings() { Settings.MinDBConnections = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MinDBConnections")); Settings.MaxDBConnections = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MaxDBConnections")); Settings.DAL = ConfigurationManager.AppSettings.Get("DAL"); Settings.ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING = ConfigurationManager.AppSettings.Get("ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING"); Settings.SYSTEMDOTTRANSACTION_TIMEOUT = Convert.ToInt32(ConfigurationManager.AppSettings.Get("SYSTEMDOTTRANSACTION_TIMEOUT")); Settings.ORDER_PROCESSING_BEHAVIOR = ConfigurationManager.AppSettings.Get("ORDER_PROCESSING_BEHAVIOR"); Settings.DISPLAYNUMBERORDERITERATIONS = Convert.ToInt32(ConfigurationManager.AppSettings.Get("DISPLAYNUMBERORDERITERATIONS")); Settings.OPS_LABEL = ConfigurationManager.AppSettings.Get("OPS_LABEL"); Settings.OPS_USERID = ConfigurationManager.AppSettings.Get("OPS_USERID"); Settings.OPS_PASSWORD = ConfigurationManager.AppSettings.Get("OPS_PASSWORD"); buildConnString(); } /// /// This method builds a connection string based on DAL setting and settings for the database name, location, uid and password. /// Called on host initialization and also when the DAL or DB connection parameters are changed via ConfigWeb. /// private void buildConnString() { switch (Settings.DAL) { case Trade.Utility.StockTraderUtility.DAL_SQLSERVER: { Settings.TRADEDB_SQL_CONN_STRING = "server=" + Settings.DBServer + ";database=" + Settings.Database + ";user id=" + Settings.UserID + ";password=" + Settings.Password + ";min pool size=" + Settings.MinDBConnections + ";max pool size=" + Settings.MaxDBConnections; break; } case Trade.Utility.StockTraderUtility.DAL_ORACLE: { Settings.TRADEDB_SQL_CONN_STRING = "Data Source=" + Settings.Database + ";user id=" + Settings.UserID + ";password=" + Settings.Password + ";min pool size=" + Settings.MinDBConnections + ";max pool size=" + Settings.MaxDBConnections + ";enlist=dynamic;"; break; } case Trade.Utility.StockTraderUtility.DAL_DB2: { Settings.TRADEDB_SQL_CONN_STRING = "Network Transport Library=TCPIP;Network Address=" + Settings.DBServer + ";Initial Catalog=" + Settings.Database + ";Package Collection=" + Settings.Database + ";Default Schema=Schema;User ID=" + Settings.UserID + ";Password=" + Settings.Password + ";network port=50000;Units of Work=RUW; Connection Pooling=True;defer prepare=false;CCSID=37;PC Code Page=1252"; break; } } } //You can of course also add any constants or statics in this class as well, not initialized from //repository but just initialized here in code. /// /// Local Settings Not From Config Database Repository. Note that any of these could optionally be moved into the /// config repository instead of being initialized in code. /// /// } }