示例#1
0
 protected override void OnStop()
 {
     _shutdownEvent.Set();
     _serviceHostNative.Stop();
     _serviceHostNative.Stop();
     if (!_thread.Join(3000))
     {
         // give the thread 3 seconds to stop
         _thread.Abort();
     }
 }
示例#2
0
        private ServiceCommandOutput <object> CheckServiceConnectivity(string port, ServiceType type,
                                                                       ServiceSecurityMode mode)
        {
            var service = new WcfService <ICommandService <object>, DummyNativeCommandService>("localhost", ServiceName);

            service.AddBinding(BindingFactory.Create(new BindingConfiguration {
                Port = port, ServiceType = type
            }));
            if (mode == ServiceSecurityMode.BasicSSL)
            {
                var serviceSecurity = new ServiceSecurity
                {
                    SecurityMode             = ServiceSecurityMode.BasicSSL,
                    CertificateConfiguration = _certificateConfiguration
                };

                service.SetSecured(serviceSecurity);
            }

            service.Host();

            var client = WcfClient <ICommandService <object> > .Create(type, "localhost", port, ServiceName, "api", mode);

            var output = client.Contract.ExecuteCommand("test", "token");

            service.Stop();
            return(output);
        }
 public void Dispose()
 {
     if (service != null)
     {
         service.Stop();
         service.Dispose();
     }
 }
示例#4
0
 /// <summary>
 ///   When implemented in a derived class, executes when a Stop command is sent to the service by the Service Control Manager (SCM). Specifies actions to take when a service stops running.
 /// </summary>
 protected override void OnStop()
 {
     try
     {
         m_FeatureStoreServiceImpl.Stop();
     }
     catch (Exception e)
     {
         m_Logger.Error(e);
         throw;
     }
 }
示例#5
0
        public void TestAccessingWcfServices()
        {
            var binding = new BasicHttpBinding();
            var address = new Uri("http://localhost:12342/SBService");
            var log     = new List <bool>();

            var subscriptionManager = GetMockSubscriptionManager();
            var sendingManager      = GetMockSendingManager();
            var receivingManager    = GetMockReceivingManager();
            var logger            = GetMockLogger();
            var statisticsService = GetMockStatisticsService();
            var objectRepository  = GetMockObjectRepository();
            var service           = new WcfService(subscriptionManager, sendingManager, receivingManager, logger, statisticsService, objectRepository)
            {
                UseWcfSettingsFromConfig = false,
                Binding = binding,
                Address = address
            };

            using (service)
            {
                service.Start();

                ThreadStart act = () =>
                {
                    var  channelFactory    = new ChannelFactory <IServiceBusService>(binding, new EndpointAddress(address));
                    var  serviceBusService = channelFactory.CreateChannel();
                    bool isUp = serviceBusService.IsUp();

                    log.Add(isUp);
                };

                Thread thread1 = new Thread(act);
                Thread thread2 = new Thread(act);

                thread1.Start();
                thread2.Start();
                thread1.Join();
                thread2.Join();

                service.Stop();
            }

            Assert.Equal(2, log.Count);
            foreach (var b in log)
            {
                Assert.True(b);
            }
        }
示例#6
0
 /// <summary>
 /// Stops the WCF service.
 /// </summary>
 private void StopService()
 {
     m_Service.Stop();
 }
 public void Dispose()
 {
     service.Stop();
     service.Dispose();
 }
示例#8
0
        private ServiceCommandOutput<object> CheckServiceConnectivity(string port, ServiceType type,
            ServiceSecurityMode mode)
        {
            var service = new WcfService<ICommandService<object>, DummyNativeCommandService>("localhost", ServiceName);
            service.AddBinding(BindingFactory.Create(new BindingConfiguration {Port = port, ServiceType = type}));
            if (mode == ServiceSecurityMode.BasicSSL)
            {
                var serviceSecurity = new ServiceSecurity
                {
                    SecurityMode = ServiceSecurityMode.BasicSSL,
                    CertificateConfiguration = _certificateConfiguration
                };

                service.SetSecured(serviceSecurity);
            }

            service.Host();

            var client = WcfClient<ICommandService<object>>.Create(type, "localhost", port, ServiceName, "api", mode);
            var output = client.Contract.ExecuteCommand("test", "token");

            service.Stop();
            return output;
        }