Beispiel #1
0
        private void ConnectToService()
        {
            NetTcpBinding binding = new NetTcpBinding();

            binding.Security = new NetTcpSecurity()
            {
                Mode = SecurityMode.None
            };
            factory = new ChannelFactory <IPubSubCalculateEngine>(binding, new EndpointAddress("net.tcp://localhost:19000/IPubSubCalculateEngine"));
            proxy   = factory.CreateChannel();
        }
 public ServiceManager(IPubSubCalculateEngine pubSubCalculateEngine)
 {
     try
     {
         nmsToCe = new SendDataFromNMSToCE();
         StartSubscriptionService(pubSubCalculateEngine);
         StartService();
         StartServiceForTM();
     }
     catch (Exception e)
     {
         //MessageBox.Show(e.Message,"Error",MessageBoxButton.OK,MessageBoxImage.Error);
     }
 }
        private void StartSubscriptionService(IPubSubCalculateEngine subcriptionService)
        {
            serviceHostPubSubCE = new ServiceHost(subcriptionService);
            var behaviour = serviceHostPubSubCE.Description.Behaviors.Find <ServiceBehaviorAttribute>();

            behaviour.InstanceContextMode = InstanceContextMode.Single;
            NetTcpBinding binding = new NetTcpBinding();

            binding.Security = new NetTcpSecurity()
            {
                Mode = SecurityMode.None
            };
            string address = String.Format("net.tcp://localhost:19000/IPubSubCalculateEngine");

            serviceHostPubSubCE.AddServiceEndpoint(typeof(IPubSubCalculateEngine), binding, address);
            serviceHostPubSubCE.Open();
            Console.WriteLine("CalculationEngineService listening at:");
            Console.WriteLine(address);
        }