Exemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            _logger.LogInfo("Service starting... ");

            if (_webHost != null)
            {
                _webHost.Close( );
            }

            _batchSenderThread.Start( );

            _webHost = new WebServiceHost(typeof(Microsoft.ConnectTheDots.Gateway.GatewayService));
            Gateway.GatewayService service = new Microsoft.ConnectTheDots.Gateway.GatewayService(
                _gatewayQueue,
                _batchSenderThread,
                m => DataTransforms.QueuedItemFromSensorDataContract(
                    DataTransforms.AddTimeCreated(DataTransforms.SensorDataContractFromString(m, _logger)), _logger)
                );
            _webHost.Description.Behaviors.Add(new ServiceBehavior(() => service));

            service.Logger         = _logger;
            service.OnDataInQueue += OnData;

            _webHost.Open( );

            _dataIntakeLoader.StartAll(service.Enqueue);

            _logger.LogInfo("...started");
        }
Exemplo n.º 2
0
        private static void Start( )
        {
            _logger.LogInfo("Service starting... ");

            if (_webHost != null)
            {
                _webHost.Close( );
            }

            _batchSenderThread.Start( );

            _webHost = new WebServiceHost(typeof(Microsoft.ConnectTheDots.Gateway.GatewayService));

            Gateway.GatewayService service = new Microsoft.ConnectTheDots.Gateway.GatewayService(
                _gatewayQueue,
                _batchSenderThread,
                _gatewayTransform
                );
            _webHost.Description.Behaviors.Add(new ServiceBehavior(() => service));

            service.Logger         = _logger;
            service.OnDataInQueue += OnData;

            _webHost.Open( );

            _dataIntakeLoader.StartAll(service.Enqueue);

            _logger.LogInfo("...started");
        }
        private static GatewayService CreateGateway(AMQPConfig amqpConfig)
        {
            try
            {
                var _gatewayQueue = new GatewayQueue<QueuedItem>();

                var _AMPQSender = new AMQPSender<string>(
                                                    amqpConfig.AMQPSAddress,
                                                    amqpConfig.EventHubName,
                                                    amqpConfig.EventHubMessageSubject,
                                                    amqpConfig.EventHubDeviceId,
                                                    amqpConfig.EventHubDeviceDisplayName,
                                                    _Logger
                                                    );

                var _batchSenderThread = new BatchSenderThread<QueuedItem, string>(
                                                    _gatewayQueue,
                                                    _AMPQSender,
                                                    null,
                                                    m => m.JsonData,
                                                    _Logger);

                _batchSenderThread.Start();

                GatewayService service = new GatewayService(
                    _gatewayQueue,
                    _batchSenderThread
                )
                {
                    Logger = _Logger
                };

                service.OnDataInQueue += (data) => _batchSenderThread.Process();
                _Logger.Flush();

                return service;
            }
            catch (Exception ex)
            {
                _Logger.LogError("Exception on creating Gateway: " + ex.Message);
            }

            return null;
        }
Exemplo n.º 4
0
        protected override void OnStart( string[] args )
        {
            _logger.LogInfo( "Service starting... " );

            if( _webHost != null )
            {
                _webHost.Close( );
            }

            _batchSenderThread.Start( );

            _webHost = new WebServiceHost( typeof( Microsoft.ConnectTheDots.Gateway.GatewayService ) );

            Gateway.GatewayService service = new Microsoft.ConnectTheDots.Gateway.GatewayService(
                _gatewayQueue,
                _batchSenderThread,
                _gatewayTransform
            );
            _webHost.Description.Behaviors.Add( new ServiceBehavior( ( ) => service ) );

            service.Logger = _logger;
            service.OnDataInQueue += OnData;

            _webHost.Open( );

            _dataIntakeLoader.StartAll( service.Enqueue );

            _logger.LogInfo( "...started" );
        }
Exemplo n.º 5
0
        private GatewayService PrepareGatewayService( )
        {
            _batchSenderThread.Start( );

            GatewayService service = new GatewayService(
                _gatewayQueue,
                _batchSenderThread,
                _gatewayTransform
            );

            service.Logger = _logger;
            service.OnDataInQueue += DataInQueue;

            _batchSenderThread.OnEventsBatchProcessed += EventBatchProcessed;

            return service;
        }
        private GatewayService PrepareGatewayService( )
        {
            _batchSenderThread.Start( );

            GatewayService service = new GatewayService( _gatewayQueue, _batchSenderThread,
                m => DataTransforms.QueuedItemFromSensorDataContract(
                        DataTransforms.AddTimeCreated( DataTransforms.SensorDataContractFromString( m, _logger ) ), _logger ) );

            service.Logger = _logger;
            service.OnDataInQueue += DataInQueue;

            _batchSenderThread.OnEventsBatchProcessed += EventBatchProcessed;

            return service;
        }