// // 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 Config Service implementation class/business logic. //====================================================================================================== using System; using System.Configuration; using System.Diagnostics; using System.ServiceModel; using System.Runtime.Serialization; using Trade.ConfigServiceConfigurationSettings; using Trade.ConfigServiceDataContract; using Trade.ConfigServiceContract; using Trade.IDAL; using Trade.DALFactory; using Trade.Utility; namespace Trade.ConfigServiceImplementation { /// /// Service class which implements the Configuration service contract. /// ReleaseServiceInstanceOnTransactionComplete is marked as false to support transacted batches from the /// transacted (persisted) durable MSMQ message queue. This is required! /// [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerCall, IncludeExceptionDetailInFaults = true)] public class ConfigService : IConfigService { private IConfig dalConfig; private Trade.IDAL.IConfig startDAL() { dalConfig = Trade.DALFactory.Config.Create(Settings.DAL); dalConfig.Open(Settings.TRADEDB_SQL_CONN_STRING); return dalConfig; } public ClientConfigResponse GetClientConfig(ClientConfigRequest client) { dalConfig = startDAL(); ClientConfigResponse ans = dalConfig.GetClientConfig(client.ClientName); dalConfig.Close(); return ans; } public BSConfigResponse GetBSConfig(BSConfigRequest bs) { dalConfig = startDAL(); BSConfigResponse ans = dalConfig.GetBSConfig(bs.BSName); dalConfig.Close(); return ans; } public OPSConfigResponse GetOPSConfig(OPSConfigRequest ops) { dalConfig = startDAL(); OPSConfigResponse ans = dalConfig.GetOPSConfig(ops.OPSName); dalConfig.Close(); return ans; } public void SetClientToBS(ClientToBS clientConfig) { dalConfig = startDAL(); dalConfig.SetClientToBS(clientConfig); dalConfig.Close(); } public void SetBSToOPS(BSToOPS bsConfig) { dalConfig = startDAL(); dalConfig.SetBSToOPS(bsConfig); dalConfig.Close(); } public ServiceLocation[] GetBSLocations() { dalConfig = startDAL(); ServiceLocation[] ans = dalConfig.GetBSLocations(); dalConfig.Close(); return ans; } public ServiceLocation[] GetOPSLocations() { dalConfig = startDAL(); ServiceLocation[] ans = dalConfig.GetOPSLocations(); dalConfig.Close(); return ans; } public void SetServiceLocation(ServiceLocation location) { dalConfig = startDAL(); dalConfig.SetServiceLocation(location); } } }