//
// 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 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_PHP_ENDPOINT_CONFIG_HTTP;
public static string BSL_WSAS_ENDPOINT_CONFIG_HTTP;
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 = "price-gain";
public static readonly string LOSSSTYLECSS = "price-loss";
//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_PHP_ENDPOINT_CONFIG_HTTP = ConfigurationManager.AppSettings.Get("BSL_PHP_ENDPOINT_CONFIG_HTTP");
Settings.BSL_WSAS_ENDPOINT_CONFIG_HTTP = ConfigurationManager.AppSettings.Get("BSL_WSAS_ENDPOINT_CONFIG_HTTP");
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_InProcess:
{
//no endpoint needs to be set in this mode.
interfaceMode = StockTraderUtility.ACCESS_Direct;
break;
}
case StockTraderUtility.ACCESS_STRING_DotNet_Http_WcfService:
{
interfaceMode = StockTraderUtility.ACCESS_DotNet_Http_WcfService;
break;
}
case StockTraderUtility.ACCESS_STRING_DotNet_WsHttp_WcfService:
{
interfaceMode = StockTraderUtility.ACCESS_DotNet_WsHttp_WcfService;
break;
}
case StockTraderUtility.ACCESS_STRING_PHP_Http_WebService:
{
interfaceMode = StockTraderUtility.ACCESS_PHP_Http_WebService;
break;
}
case StockTraderUtility.ACCESS_STRING_WSAS_Http_WebService:
{
interfaceMode = StockTraderUtility.ACCESS_WSAS_Http_WebService;
break;
}
default:
{
throw new Exception(ACCESS_MODE + ": " + StockTraderUtility.EXCEPTION_MESSAGE_INVALID_ACCESSMODE_CONFIG);
}
}
return interfaceMode;
}
}
}