// .NET StockTrader Sample WCF Application for Benchmarking, Performance Analysis and Design Considerations for Service-Oriented Applications //====================================================================================================== // The Settings class for the StockTrader Web Application. Please note well that we only override the // inherited settings (with the new keyword) becuase of the special case StockTrader allows for running // BSL in-process with the StockTrader Composite Web Application, vs. remote calls. 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.Data; using System.Collections; using System.Diagnostics; using System.Messaging; using System.Text; using System.Reflection; using Trade.Utility; namespace Trade.StockTraderWebApplicationSettings { /// /// Any app or service implementing the Configuration Service needs a custom Settings class that will contain it's /// config settings. These are (largely) 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. /// public class Settings //db : ConfigurationSettingsBase //Inherit from base implementation!! { public static string BSL_DOTNET_ENDPOINT_CONFIG_HTTP; public static string BSL_DOTNET_ENDPOINT_CONFIG_WSHTTP; public static string BSL_WSO2_ENDPOINT_CONFIG_WSHTTP; public static string BSL_USERID; public static string BSL_PASSWORD; public static string ACCESS_MODE; public static int MAX_DISPLAY_ORDERS; public static int MAX_DISPLAY_TOP_ORDERS; public static bool DISPLAY_DUPLICATE_KEY_EXCEPTIONS; public static bool CHECK_ORDER_ALERT_EVERY_REQUEST; public static int ORDER_ALERT_CHECK_FREQUENCY; public static string EVENT_LOG; public static int interfaceMode = -1; public static readonly string CACHE_KEY_CLOSED_ORDERSALERT = "O"; //Page Names for StockTrader application public static readonly string PAGE_HOME = "TradeHome.aspx"; public static readonly string PAGE_LOGIN = "Login.aspx"; public static readonly string PAGE_LOGOUT = "Logout.aspx"; public static readonly string PAGE_QUOTES = "Quotes.aspx"; public static readonly string PAGE_ORDER = "Order.aspx"; public static readonly string PAGE_TRADE = "StockTrade.aspx"; public static readonly string PAGE_PORTFOLIO = "Portfolio.aspx"; //public static readonly string PAGE_PATH_CONFIG = "ConfigWeb/default.aspx"; //Trade HTML Fomatting Constants public static readonly string GAINSTYLECSS = "GainTextStyle"; public static readonly string LOSSSTYLECSS = "LossTextStyle"; public static readonly string UPARROWLINK = "\"\""; public static readonly string DOWNARROWLINK = "\"\""; /// /// Settings (Constructor) - handles the config. /// Sets the items in the appSettings to public variables. /// static Settings() { Settings.ACCESS_MODE = ConfigurationManager.AppSettings.Get("ACCESS_MODE"); 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")); Settings.CHECK_ORDER_ALERT_EVERY_REQUEST = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("DISPLAY_DUPLICATE_KEY_EXCEPTIONS")); Settings.ORDER_ALERT_CHECK_FREQUENCY = Convert.ToInt32(ConfigurationManager.AppSettings.Get("ORDER_ALERT_CHECK_FREQUENCY")); Settings.BSL_DOTNET_ENDPOINT_CONFIG_HTTP = ConfigurationManager.AppSettings.Get("BSL_DOTNET_ENDPOINT_CONFIG_HTTP"); Settings.BSL_DOTNET_ENDPOINT_CONFIG_WSHTTP = ConfigurationManager.AppSettings.Get("BSL_DOTNET_ENDPOINT_CONFIG_WSHTTP"); Settings.BSL_WSO2_ENDPOINT_CONFIG_WSHTTP = ConfigurationManager.AppSettings.Get("BSL_WSO2_ENDPOINT_CONFIG_WSHTTP"); Settings.BSL_USERID = ConfigurationManager.AppSettings.Get("BSL_USERID"); Settings.BSL_PASSWORD = ConfigurationManager.AppSettings.Get("BSL_PASSWORD"); setAccessMode(); } /// /// Sets the selected AccessMode to an int constant. Faster for switch statements than parsing a string. /// static public int setAccessMode() { switch (ACCESS_MODE) { case StockTraderUtility.ACCESS_STRING_Direct: { //no endpoint needs to be set in this mode. interfaceMode = StockTraderUtility.ACCESS_Direct; break; } case StockTraderUtility.ACCESS_STRING_WEB_SERVICE_HTTP: { interfaceMode = StockTraderUtility.ACCESS_WebService_Http; break; } case StockTraderUtility.ACCESS_STRING_WEB_SERVICE_HTTP_MESECURITY: { interfaceMode = StockTraderUtility.ACCESS_WebService_WSHttp; break; } case StockTraderUtility.ACCESS_STRING_WSO2_WEB_SERVICE_HTTP_MESECURITY: { interfaceMode = StockTraderUtility.ACCESS_WebService_WSHttp_WSO2; break; } default: { throw new Exception(ACCESS_MODE + ": " + StockTraderUtility.EXCEPTION_MESSAGE_INVALID_ACCESSMODE_CONFIG); } } return interfaceMode; } } }