Created
July 11, 2011 18:13
-
-
Save jnericks/1076420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.ServiceModel; | |
| using BenchmarkPlus.RMS.Infrastructure.AlphaCorrelations; | |
| using BenchmarkPlus.RMS.Infrastructure.Configuraiton; | |
| namespace BenchmarkPlus.RMS.Infrastructure.Services | |
| { | |
| public class WcfCalculationService : ICalculationService | |
| { | |
| ChannelFactory<AlphaCorrelationsServiceChannel> _factory; | |
| public WcfCalculationService(IConfigurationManager configurationManager) | |
| { | |
| _factory = new ChannelFactory<AlphaCorrelationsServiceChannel>(configurationManager.AppSettings["CalculationServicesBinding"]); | |
| } | |
| public void CalculateBenchmarkMismatchPieces(int fundKey) | |
| { | |
| Call(svc => svc.CalculateBenchmarkMismatchPieces(fundKey)); | |
| } | |
| public void CalculateMismatchStream(int fundKey) | |
| { | |
| Call(svc => svc.CalculateMismatchStream(fundKey)); | |
| } | |
| public void CalculateMismatchCorrelations(int fundKey) | |
| { | |
| Call(svc => svc.CalculateMismatchCorrelations(fundKey)); | |
| } | |
| public void CalculateMismatchStandardDeviation(int fundKey) | |
| { | |
| Call(svc => svc.CalculateMismatchStandardDeviation(fundKey)); | |
| } | |
| public void CalculateCommonHoldingStandardDeviation(int fundKey, int correlatedFundKey) | |
| { | |
| Call(svc => svc.CalculateCommonHoldingStandardDeviation(fundKey, correlatedFundKey)); | |
| } | |
| public void CalculateCorrelationForMarkToMarketIndexesForAFund(int fundKey) | |
| { | |
| Call(svc => svc.CalculateCorrelationForMarkToMarketIndexesForAFund(fundKey)); | |
| } | |
| public void CalculateCorrelationForMarkToMarketIndexesForAnIndex(int fundKey) | |
| { | |
| Call(svc => svc.CalculateCorrelationForMarkToMarketIndexesForAnIndex(fundKey)); | |
| } | |
| public void CalculateAlphaCorrelationsForAFund(int fundKey) | |
| { | |
| Call(svc => svc.CalculateAlphaCorrelationsForAFund(fundKey)); | |
| } | |
| public void CalculateAlphaCorrelationsForAMarkToMarketIndex(int markToMarketIndexKey) | |
| { | |
| Call(svc => svc.CalculateAlphaCorrelationsForAMarkToMarketIndex(markToMarketIndexKey)); | |
| } | |
| public void CalculateMarkToMarketCorrelations(int fundKey) | |
| { | |
| Call(svc => svc.CalculateMarkToMarketCorrelations(fundKey)); | |
| } | |
| void Call(Action<AlphaCorrelationsServiceChannel> action) | |
| { | |
| var channel = _factory.CreateChannel(); | |
| try | |
| { | |
| action(channel); | |
| } | |
| catch (CommunicationException) { } | |
| catch (TimeoutException) { } | |
| finally | |
| { | |
| if (channel.State == CommunicationState.Faulted) | |
| channel.Abort(); | |
| else | |
| channel.Close(); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment