// // 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 Configuration Service. //====================================================================================================== //====================================================================================================== // 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.Diagnostics; using System.Messaging; using System.Text; using System.Reflection; using Trade.Utility; namespace Trade.ConfigServiceConfigurationSettings { /// /// 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 EVENT_LOG = "Configuration Service Event Log"; 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 CLIENT_LABEL; public static string BS_LABEL; public static string OPS_LABEL; public Settings() { Settings.DBServer = ConfigurationManager.AppSettings.Get("DBServer"); Settings.Database = ConfigurationManager.AppSettings.Get("Database"); Settings.UserID = ConfigurationManager.AppSettings.Get("UserID"); Settings.Password = ConfigurationManager.AppSettings.Get("Password"); Settings.MinDBConnections = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MinDBConnections")); Settings.MaxDBConnections = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MaxDBConnections")); Settings.DAL = ConfigurationManager.AppSettings.Get("DAL"); Settings.CLIENT_LABEL = ConfigurationManager.AppSettings.Get("CLIENT_LABEL"); Settings.BS_LABEL = ConfigurationManager.AppSettings.Get("BS_LABEL"); Settings.OPS_LABEL = ConfigurationManager.AppSettings.Get("OPS_LABEL"); 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_MYSQL: { Settings.TRADEDB_SQL_CONN_STRING = "server=" + Settings.DBServer + ";database=" + Settings.Database + ";user id=" + Settings.UserID + ";password=" + Settings.Password + ";pooling=false;"; break; } } } } }