Exemplo n.º 1
0
        public void Initialize(string username, string[] servers, ILoggerFactory loggerFactory = null, string authToken = null)
        {
            _loggerFactory      = loggerFactory ?? new DebugLoggerFactory();
            _log                = _loggerFactory.Create(typeof(ReactiveTrader));
            _connectionProvider = new ConnectionProvider(username, servers, _loggerFactory);

            var referenceDataServiceClient = new ReferenceDataServiceClient(_connectionProvider, _loggerFactory);
            var executionServiceClient     = new ExecutionServiceClient(_connectionProvider);
            var blotterServiceClient       = new BlotterServiceClient(_connectionProvider, _loggerFactory);
            var pricingServiceClient       = new PricingServiceClient(_connectionProvider, _loggerFactory);

            if (authToken != null)
            {
                var controlServiceClient = new ControlServiceClient(new AuthTokenProvider(authToken), _connectionProvider, _loggerFactory);
                _controlRepository = new ControlRepository(controlServiceClient);
            }

            PriceLatencyRecorder = new PriceLatencyRecorder();
            var concurrencyService = new ConcurrencyService();

            var tradeFactory              = new TradeFactory();
            var executionRepository       = new ExecutionRepository(executionServiceClient, tradeFactory, concurrencyService);
            var priceFactory              = new PriceFactory(executionRepository, PriceLatencyRecorder);
            var priceRepository           = new PriceRepository(pricingServiceClient, priceFactory, _loggerFactory);
            var currencyPairUpdateFactory = new CurrencyPairUpdateFactory(priceRepository);

            TradeRepository = new TradeRepository(blotterServiceClient, tradeFactory);
            ReferenceData   = new ReferenceDataRepository(referenceDataServiceClient, currencyPairUpdateFactory);
        }
Exemplo n.º 2
0
        public void Initialize(string username, string[] servers, ILoggerFactory loggerFactory = null, string authToken = null) 
        {
            _loggerFactory = loggerFactory ?? new DebugLoggerFactory();
            _log = _loggerFactory.Create(typeof(ReactiveTrader));
            _connectionProvider = new ConnectionProvider(username, servers, _loggerFactory);

            var referenceDataServiceClient = new ReferenceDataServiceClient(_connectionProvider, _loggerFactory);
            var executionServiceClient = new ExecutionServiceClient(_connectionProvider);
            var blotterServiceClient = new BlotterServiceClient(_connectionProvider, _loggerFactory);
            var pricingServiceClient = new PricingServiceClient(_connectionProvider, _loggerFactory);
            PricingServiceClient = pricingServiceClient;

            if (authToken != null)
            {
                var controlServiceClient = new ControlServiceClient(new AuthTokenProvider(authToken), _connectionProvider, _loggerFactory);
                _controlRepository = new ControlRepository(controlServiceClient);
            }

            PriceLatencyRecorder = new PriceLatencyRecorder();
            var concurrencyService = new ConcurrencyService();

            var tradeFactory = new TradeFactory();
            var executionRepository = new ExecutionRepository(executionServiceClient, tradeFactory, concurrencyService);
            var priceFactory = new PriceFactory(executionRepository, PriceLatencyRecorder);
            var priceRepository = new PriceRepository(pricingServiceClient, priceFactory, _loggerFactory);
            var currencyPairUpdateFactory = new CurrencyPairUpdateFactory(priceRepository);
            TradeRepository = new TradeRepository(blotterServiceClient, tradeFactory);
            ReferenceData = new ReferenceDataRepository(referenceDataServiceClient, currencyPairUpdateFactory);
        }
Exemplo n.º 3
0
        internal static Client <ControlServiceClient> ConstructControlServiceClient(string endpointConfigName, string userName, string userPassword)
        {
            ControlServiceClient   client    = null;
            ChannelEndpointElement channelEE = _configDictionary[typeof(ControlService).FullName].Find(delegate(ChannelEndpointElement cee) { return(cee.Name == endpointConfigName); });

            if (null != channelEE)
            {
                client = new ControlServiceClient(endpointConfigName, channelEE.Address.ToString());
                client.ClientCredentials.UserName.UserName = userName;
                client.ClientCredentials.UserName.Password = userPassword;
            }

            return(ClientFactory.CreateClient <ControlServiceClient, ControlService>(client));
        }
Exemplo n.º 4
0
        public void WebServiceTest_Connect()
        {
            var serverThread = new Thread(new ThreadStart(() =>
            {
                var st = new ServiceTest();
                st.ServiceTest_WCFAndCalculationAndWatcherAndCommand(10*60*1000);
            }));
            serverThread.Start();
            try
            {
                var evnt = new ServiceSubscriber();
                evnt.IsCalculationActiveEvent += (s, e) =>
                {
                    Debug.WriteLine(string.Format("[WebServiceTest] IsActive changed to '{0}' by user '{1}'", e.IsActive, e.UserName));
                };
                evnt.LogChangedEvent += (s, e) =>
                {
                    Debug.WriteLine(string.Format("[WebServiceTest] Log changed (id:'{0}')", e != null && e.Id != null ? e.Id : "null"));
                };
                evnt.QueueChangedEvent += (s, e) =>
                {
                    Debug.WriteLine(string.Format("[WebServiceTest] Queue changed (file:'{0}', action:'{1}')", e.Element.File, e.Action));
                };
                InstanceContext evntContext = new InstanceContext(evnt as IControlServiceCallback);

                Thread.Sleep(3000);
                var clientId = Guid.NewGuid();
                using (var proxy = new ControlServiceClient(evntContext))
                {
                    proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;

                    Debug.WriteLine("[WebServiceTest] subscribe events");
                    proxy.SubscribeEvents(clientId);

                    var queueElements = proxy.GetQueue();
                    Assert.AreEqual(3, queueElements.Length);

                    string folderName = @"D:\test3";
                    for (int i = 3; i < 5; i++)
                        System.IO.File.WriteAllText(string.Format(@"{0}\test.d{1}", folderName, i.ToString("00")), "test");

                    Thread.Sleep(3000);

                    queueElements = proxy.GetQueue();
                    Assert.AreEqual(5, queueElements.Length);

                    Debug.WriteLine("[WebServiceTest] SetIsCalculationActive(true)");
                    proxy.SetIsCalculationActive(true);
                    Thread.Sleep(1000);

                    while ((queueElements = proxy.GetQueue()).Length > 0
                        && (proxy.GetIsCalculationActive()))
                        Thread.Sleep(1000);

                    Debug.WriteLine("[WebServiceTest] SetIsCalculationActive(false)");
                    proxy.SetIsCalculationActive(false);
                    Thread.Sleep(1000);

                    Debug.WriteLine("[WebServiceTest] unsubscribe events");
                    proxy.UnsubscribeEvents(clientId);
                }
            }
            finally
            {
                serverThread.Abort();
            }
        }
Exemplo n.º 5
0
        private async void TryToConnect()
        {
            try
            {
#if !DEBUG
                var binding = new NetTcpBinding(SecurityMode.Transport);
                var endPoint = new EndpointAddress("net.tcp://S01-ASTRA.OFFICE.GTT.GAZPROM.RU:9929/CalculationManager/ControlService");
                //var endPoint = new EndpointAddress("net.tcp://WS27SYCHSS.OFFICE.GTT.GAZPROM.RU:9929/CalculationManager/ControlService");
                proxy = new ControlServiceClient(new InstanceContext(subscriber as IControlServiceCallback), binding, endPoint);
#else
                proxy = new ControlServiceClient(new InstanceContext(subscriber as IControlServiceCallback));
#endif
                proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                proxy.Open();
                ErrorClear();
                
                proxy.SubscribeEvents(clientId);

                ReloadFileQueue();
                ReloadCalculation();

                await Task.Factory.StartNew(() => 
                {
                    lastIsActive = proxy.GetIsCalculationActive();
                    RaisePropertyChanged("IsActive");
                });

                IsConnected = true;
                //lastIsActive = await proxy.GetIsCalculationActiveAsync();
                //RaisePropertyChanged("IsActive");
            }
            catch (Exception ex)
            {
                ErrorSet(ex.Message);
            }
        }