Exemplo n.º 1
0
        public void PubSubTest()
        {
            UdpBus bus = (UdpBus)Reflector.GetField(this.pool, "bus");

            object received = null;

            System.Threading.AutoResetEvent evt = new System.Threading.AutoResetEvent(false);

            this.pool.Start();

            HostConfiguration hostSpec = new HostConfiguration(0){ CameraID = 2, Name = "mike", };

            bus.Publish(Topics.HostReply, hostSpec, 3000);

            System.Threading.Thread.Sleep(6000);

            var host = this.pool[hostSpec.StationID];

            Assert.IsNotNull(host);

            Assert.AreEqual("mike", host.Config.Name);

            hostSpec.Name = "jack";

            bus.Publish(Topics.HostReply, hostSpec, 3000);

            System.Threading.Thread.Sleep(6000);

            host = this.pool[hostSpec.StationID];
            Assert.AreEqual("jack", host.Config.Name);
        }
Exemplo n.º 2
0
        public void ContainsIDTest()
        {
            HostConfiguration config = new HostConfiguration(0) {  CameraID = 3,  Name = "abc" };
            var host = new Host{ Config = config, Status = HostStatus.OnLine, LastSeen = DateTime.Now,};

            HostConfiguration config1 = new HostConfiguration(0) { CameraID = 4, Name = "abc" };
            var host1 = new Host { Config = config, Status = HostStatus.OnLine, LastSeen = DateTime.Now, };

            pool.Add(host);

            Assert.IsTrue(pool.ContainsID(host.Config.StationID));
            Assert.IsTrue(pool.Contains(host1));

            Assert.IsFalse(pool.ContainsID(4));

            var h = pool[config.StationID];

            Assert.IsNotNull(h);

            h.Config.Name = "benny";
            h.LastSeen = DateTime.Now;

            h = pool[config.StationID];

            Assert.AreEqual("benny", h.Config.Name);

            pool.Add(host1);
        }
Exemplo n.º 3
0
        protected RabbitMessenger(HostConfiguration hostConfig)
        {
            if (hostConfig == null)
                throw new ArgumentNullException("hostConfig");

            HostConfig = hostConfig;
        }
Exemplo n.º 4
0
 public void It_can_load_the_connectionStrings()
 {
     var config = new HostConfiguration();
     Assert.NotNull(config.kafkaConfiguration);
     Assert.Equal(config.PortalPacienteConnectionString, "PortalPacienteConnectionString_string");
     Assert.Equal(config.VisionLocalConnectionString, "VisionLocalConnectionString_string");
 }
Exemplo n.º 5
0
 private void OnCenterQuery(object s, TopicArgs args)
 {
     if (args.DataObject is HostConfigurationQuery)
     {
         var cfg = new HostConfiguration(Configuration.Instance.GetStationID());
         cfg.CameraID = 2;
         cfg.Name = Properties.Settings.Default.HostName;
         cfg.TotalStorageCapacityMB = new FileSystemStorage(Properties.Settings.Default.OutputPath).GetTotalStorageMB();
         cfg.ReservedStorageCapacityMB = Configuration.Instance.GetReservedSpaceinMB();
         bus.Publish(Topics.HostReply, cfg, 3000);
     }
 }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            HostConfiguration hostConfig  = HostConfiguration.GetConfig();
            string            baseAddress = hostConfig.HostEndpoint.BaseAddress;

            // Start OWIN host
            using (WebApp.Start <Startup>(url: baseAddress))
            {
                Console.WriteLine("Started listening on port {0}.{1}Press Enter to quit.", baseAddress, Environment.NewLine);
                Console.ReadLine();
            }
        }
Exemplo n.º 7
0
 public EscalationController(
     IHttpContextAccessor httpContextAccessor,
     IUserService userService,
     IMapper mapper,
     ISrfRequestService srf,
     ISrfEscalationRequestService service,
     IVacancyListService vacancy,
     ICandidateInfoService candidate,
     IDepartementService department,
     IHostingEnvironment env,
     IServicePackService ssow,
     IPackageTypeService packageType,
     ICostCenterService costCenter,
     MailingHelper mailingHelper,
     IOptions <HostConfiguration> hostConfiguration,
     NotifHelper notif,
     IDepartementSubService departmentSub,
     IServicePackCategoryService ssowCategory,
     IJobStageService jobsTage,
     IUserProfileService profileService,
     INetworkNumberService network,
     IAccountNameService account,
     UserManager <ApplicationUser> userManager,
     RoleManager <ApplicationRole> roleManager,
     SignInManager <ApplicationUser> signInManager,
     FileHelper fileHelper,
     ConfigHelper config,
     IUserHelper userHelper) :
     base(httpContextAccessor, userService, mapper, service, userHelper)
 {
     _srf               = srf;
     _vacancy           = vacancy;
     _candidate         = candidate;
     _department        = department;
     _packageType       = packageType;
     _ssow              = ssow;
     _ssowCategory      = ssowCategory;
     _jobStage          = jobsTage;
     _departmentSub     = departmentSub;
     _profileService    = profileService;
     _network           = network;
     _account           = account;
     _env               = env;
     _notif             = notif;
     _hostConfiguration = hostConfiguration.Value;
     _mailingHelper     = mailingHelper;
     _userHelper        = userHelper;
     _costCenter        = costCenter;
     _userManager       = userManager;
     _roleManager       = roleManager;
     _fileHelper        = fileHelper;
     _config            = config;
 }
Exemplo n.º 8
0
 public void It_can_load_the_kafkaConfiguration()
 {
     var config = new HostConfiguration();
     Assert.NotNull(config.kafkaConfiguration);
     Assert.Equal(config.kafkaConfiguration.Address[0], "http://webmail.contigotic.com/");
     Assert.Equal(config.kafkaConfiguration.Address[1], "https://www.google.es/");
     Assert.Equal(config.kafkaConfiguration.Uri[0], new Uri(config.kafkaConfiguration.Address[0]));
     Assert.Equal(config.kafkaConfiguration.Uri[1], new Uri(config.kafkaConfiguration.Address[1]));
     Assert.Equal(config.kafkaConfiguration.ConsumerGroup, "aConsumer");
     Assert.Equal(config.kafkaConfiguration.TopicsToListen[0], "one");
     Assert.Equal(config.kafkaConfiguration.TopicsToListen[1], "two");
     Assert.Equal(config.kafkaConfiguration.TopicsToListen[2], "all");
 }
Exemplo n.º 9
0
        public RabbitReceiver(  HostConfiguration hostConfig, 
                                QueueConfiguration queueConfig, 
                                bool autoAckMessages = true , 
                                bool requeueRejectedMessages = true)
            :base(hostConfig)
        {
            if (queueConfig == null)
                throw new ArgumentNullException("queueConfig");

            _queueConfig = queueConfig;
            _autoAckMessages = autoAckMessages;
            _requeueRejectedMessages = requeueRejectedMessages;
            
            InitializeConnection();
        }
Exemplo n.º 10
0
        private static IConnection OpenNewConnection(HostConfiguration hostConfig)
        {
            if (hostConfig == null)
                throw new ArgumentNullException("hostConfig");

            var factory = new ConnectionFactory
            {
                HostName = hostConfig.HostName,
                VirtualHost = hostConfig.VirtualHost,
                Port = hostConfig.Port,
                UserName = hostConfig.Username,
                Password = hostConfig.Password
            };

            return factory.CreateConnection();
        }
Exemplo n.º 11
0
        public static IModel OpenChannelToHost(HostConfiguration hostConfig)
        {
            if(hostConfig == null)
                throw new ArgumentNullException("hostConfig");

            if (ConnectionPool.ContainsKey(hostConfig) && ConnectionPool[hostConfig].IsOpen)
            {
                return ConnectionPool[hostConfig].CreateModel();
            }

            var newConnection = OpenNewConnection(hostConfig);
            ConnectionPool.AddOrUpdate(hostConfig, newConnection, (config, oldValue) => newConnection);
            var channel = newConnection.CreateModel();
            newConnection.AutoClose = true; // Set the connection to auto close after opening first channel
            return channel;
        }
Exemplo n.º 12
0
        public void It_can_load_the_MessagesHandlers()
        {
            var config = new HostConfiguration();
            Assert.Equal(config.MessagesHandlers.Count, 3);

            Assert.Equal(config.MessagesHandlers.First().MessageHandlerName, "firstMessageHandler");
            Assert.Equal(config.MessagesHandlers.First().SystemToSynchronize.Count, 2);
            Assert.True(config.MessagesHandlers.First().SystemToSynchronize.Any(s => s == ESynchroSystem.VisionLocal));
            Assert.True(config.MessagesHandlers.First().SystemToSynchronize.Any(s => s == ESynchroSystem.PortalPaciente));

            Assert.Equal(config.MessagesHandlers.Skip(1).First().MessageHandlerName, "secondMessageHandler");
            Assert.Equal(config.MessagesHandlers.Skip(1).First().SystemToSynchronize.Count, 1);
            Assert.Equal(config.MessagesHandlers.Skip(1).First().SystemToSynchronize.First(), ESynchroSystem.VisionLocal);

            Assert.Equal(config.MessagesHandlers.Last().MessageHandlerName, "theLast");
            Assert.Equal(config.MessagesHandlers.Last().SystemToSynchronize.Count, 0);
        }
Exemplo n.º 13
0
        public RabbitPublisher(
            HostConfiguration hostConfig, 
            ExchangeConfiguration exchangeConfig, 
            bool messagesMustBeRouted,
            QueueConfiguration deadLetterQueueConfig
            ) 
        : base(hostConfig)
        {
            if (exchangeConfig == null)
                throw new ArgumentNullException("exchangeConfig");
            if (messagesMustBeRouted && deadLetterQueueConfig == null)
                throw new ArgumentNullException("deadLetterQueueConfig");

            _exchangeConfig = exchangeConfig;
            _messagesMustBeRouted = messagesMustBeRouted;
            _deadLetterQueueConfig = deadLetterQueueConfig;

            InitializeConnection();
        }
Exemplo n.º 14
0
        public void Should_be_able_to_get_from_contentlength_selfhost()
        {
            HostConfiguration configuration = new HostConfiguration()
            {
                AllowChunkedEncoding = false
            };
            using (CreateAndOpenSelfHost(null, configuration))
            {
                var response = WebRequest.Create(new Uri(BaseUri, "rel")).GetResponse();

                Assert.Equal(null, response.Headers["Transfer-Encoding"]);
                Assert.Equal(22, Convert.ToInt32(response.Headers["Content-Length"]));

                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    var contents = reader.ReadToEnd();
                    contents.ShouldEqual("This is the site route");
                }
            }
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            const string webUrl = "http://localhost:31410";
            const string signalrUrl = "http://localhost:31411";

            var config = new HostConfiguration()
            {
                UrlReservations = new UrlReservations() {  CreateAutomatically = true }
            };

            using (var webHost = new Nancy.Hosting.Self.NancyHost(
                config,
                new Uri(webUrl)))
            {
                using (WebApp.Start<Startup>(signalrUrl))
                {
                    webHost.Start();
                    Console.Write("Press any key");
                    Console.ReadKey();
                    webHost.Stop();
                }
            }
        }
Exemplo n.º 16
0
        private static NancyHostWrapper CreateAndOpenSelfHost(INancyBootstrapper nancyBootstrapper = null, HostConfiguration configuration = null)
        {
            if (nancyBootstrapper == null)
            {
                nancyBootstrapper = new DefaultNancyBootstrapper();
            }

            var host = new NancyHost(
                nancyBootstrapper,
                configuration,
                BaseUri);

            try
            {
                host.Start();
            }
            catch
            {
                throw new SkipException("Skipped due to no Administrator access - please see test fixture for more information.");
            }

            return new NancyHostWrapper(host);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Initializes nginx location configuration from self configuration
        /// </summary>
        /// <param name="host">The parent server configuration</param>
        /// <param name="serviceName">Location name</param>
        /// <param name="config">Section of self configuration, dedicated for the service configuration</param>
        private void InitServiceFromConfiguration(HostConfiguration host, string serviceName, Config config)
        {
            StringBuilder serviceConfig = new StringBuilder();
            foreach (var parameter in config.AsEnumerable())
            {
                if (parameter.Value.IsString())
                {
                    serviceConfig.AppendFormat("\t\t{0} {1};\n", parameter.Key, parameter.Value.GetString());
                }
                else if (parameter.Value.IsArray())
                {
                    var hoconValues = parameter.Value.GetArray();
                    foreach (var hoconValue in hoconValues)
                    {
                        serviceConfig.AppendFormat("\t\t{0} {1};\n", parameter.Key, hoconValue.GetString());
                    }
                }
            }

            // proxy_set_header Host $http_host;
            var headers = config.GetValue("proxy_set_header");
            if (headers == null
                || (headers.IsString()
                    && (headers.GetString() ?? string.Empty).ToLower()
                           .IndexOf("Host ", StringComparison.InvariantCulture) < 0)
                || (headers.IsArray()
                    && headers.GetArray()
                           .Select(v => v.GetString())
                           .All(
                               v =>
                               (v ?? string.Empty).ToLower().IndexOf("Host ", StringComparison.InvariantCulture) < 0)))
            {
                serviceConfig.Append("\t\tproxy_set_header Host $http_host;\n");
            }

            host[serviceName].Config = serviceConfig.ToString();
        }
Exemplo n.º 18
0
		private void InitHostConfiguration()
		{
			lock(this)
			{
				if(_hostConfig == null)
				{
					_hostConfig = new HostConfiguration();
				}
			}
		}
Exemplo n.º 19
0
		private void InitHostConfig()
		{
			if (this.Proxy == null || this.Proxy == WebRequest.DefaultWebProxy)
				return;
			if(this.Proxy.IsBypassed(GetOriginalAddress()))
				return;

			_hostConfig = new HostConfiguration();			
			_hostConfig.setHost(new HttpHost(_method.getURI()));

			
			if(this.Proxy is WebProxy)
			{
				WebProxy wp = (WebProxy) this.Proxy;
				_hostConfig.setProxyHost(new ProxyHost(wp.Address.Host, wp.Address.Port));
			}
			else
				throw new NotImplementedException("Cannot accept Proxy which is not System.Net.WebProxy instance");

			
		}
        public static NancyPack Use(this NancyPack pack, HostConfiguration configuration)
        {
            Guard.AgainstNullArgument("pack", pack);

            pack.Config = configuration;
            return pack;
        }