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;
                }
            }
        }
 public static DataServiceHost StartService( Uri baseUri )
 {
     var factory = new ODataServiceHostFactory();
     _host = factory.CreateServiceHost(baseUri);
     _host.Open();
     _baseUri = new Uri(baseUri + "/");
     return _host;
 }
        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("Запустили сервис");

        }
Exemple #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();
        }
Exemple #5
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);
        }
        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);
        }