Inheritance: System.ServiceModel.Web.WebServiceHost
        void Listen(CancellationToken cancellationToken)
        {
            using (var host = new DataServiceHost(typeof(ProductDataService), new[] { BaseAddress }))
            {
                try
                {
                    host.Open();

                    Active = true;

                    while (!cancellationToken.IsCancellationRequested)
                    {
                        Thread.Sleep(100);
                    }

                    Active = false;

                    host.Close();
                }
                catch(Exception e)
                {
                    Active = false;
                    Failed = true;
                    Console.WriteLine(e);
                    throw;
                }
            }
        }
Exemplo n.º 2
0
 public static DataServiceHost StartService( Uri baseUri )
 {
     var factory = new ODataServiceHostFactory();
     _host = factory.CreateServiceHost(baseUri);
     _host.Open();
     _baseUri = new Uri(baseUri + "/");
     return _host;
 }
Exemplo n.º 3
0
        protected override void OnStart(string[] args)
        {
            Type ServiceType = typeof(DatamineDataService);
            Uri baseAddress = new Uri("http://localhost:6000");
            Uri[] baseAddresses = new Uri[] { baseAddress };
            DataServiceHost host = new DataServiceHost(ServiceType,baseAddresses);
            host.Open();
            


            //log.Info("Запустили сервис");
            //logCon.Info("Запустили сервис");

        }
Exemplo n.º 4
0
        private void StartDataHost(string baseAdress)
        {
            m_DataHost = new DomainModelHost(m_DomainModelInstanceProvider, typeof (DomainModelDataService), new[]
                                                                                                       {
                                                                                                         new Uri(baseAdress + "OpenResKitHub")
                                                                                                       });

              var binding = new WebHttpBinding();
              binding.MaxReceivedMessageSize = int.MaxValue;
              binding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
              binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
              m_DataHost.AddServiceEndpoint(typeof (IRequestHandler), binding, "")
                .Behaviors.Add(new EnableCrossOriginResourceSharingBehavior());
              m_DataHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
              m_DataHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = m_CustomUserNameValidator;
              m_DataHost.Open();
        }
Exemplo n.º 5
0
        private void stop_OData_package_service()
        {
            if (serviceHost != null)
            {
                log.Debug("Packages OData feed is listening.");
                log.Debug("Stopping Packages OData feed...");

                using (serviceHost)
                {
                    serviceHost.Close();
                }
                serviceHost = null;

                log.Info("Packages OData feed stopped.");
            }
        }
Exemplo n.º 6
0
        private void start_OData_package_service(Uri baseUri)
        {
            stop_OData_package_service();

            var packages_odata_uri = build_Packages_OData_feed_uri(baseUri);

            Uri[] uriArray = { packages_odata_uri };
            Type serviceType = typeof(Packages);
            serviceHost = new DataServiceHost(serviceType, uriArray);

            serviceHost.Open();

            log.InfoFormat("Packages OData feed now listenting at: {0}", packages_odata_uri);
        }
 public DataServiceHost CreateServiceHost(Uri baseUri)
 {
     var host = new DataServiceHost(typeof (ODataService), new[] {baseUri });
     host.AddServiceEndpoint(typeof (IRequestHandler), new WebHttpBinding(), "");
     return host;
 }
Exemplo n.º 8
0
 public static void StopService()
 {
     _host.Close();
     _host = null;
     BrightstarService.Shutdown();
 }
        private void start_OData_package_service()
        {
            stop_OData_package_service();

            var packages_odata_uri = new Uri(settings.PackageListUri);

            Uri[] uriArray = { packages_odata_uri };
            Type serviceType = typeof(Packages);
            serviceHost = new DataServiceHost(serviceType, uriArray);

            serviceHost.Open();

            log.InfoFormat("Packages OData feed now listening at: {0}", packages_odata_uri);
        }