public TerminalEquipmentConnectivityObserver(ILogger <TerminalEquipmentConnectivityObserver> logger, IToposTypedEventObservable <RouteNetworkElementContainedEquipmentUpdated> toposTypedEventObserable, IQueryDispatcher queryDispatcher)
 {
     _logger = logger;
     _toposTypedEventObserable = toposTypedEventObserable;
     _queryDispatcher          = queryDispatcher;
     _toposTypedEventObserable.OnEvent.Subscribe(this);
 }
Ejemplo n.º 2
0
 public SchematicDiagramObserver(ILogger <SchematicDiagramObserver> logger, IToposTypedEventObservable <RouteNetworkElementContainedEquipmentUpdated> toposTypedEventObserable, IQueryDispatcher queryDispatcher)
 {
     _logger = logger;
     _toposTypedEventObserable = toposTypedEventObserable;
     _queryDispatcher          = queryDispatcher;
     _toposTypedEventObserable.OnEvent.Subscribe(this);
 }
 public EventConsumer(ILogger <EventConsumer <BaseEventType> > logger, IToposTypedEventObservable <BaseEventType> eventObservable, string kafkaServer, string topicName)
 {
     _logger          = logger;
     _eventDispatcher = eventObservable;
     _kafkaServer     = kafkaServer;
     _topicName       = topicName;
 }
        public RouteNetworkEventConsumer(ILoggerFactory loggerFactory, IEventStore eventStore, IOptions <KafkaSetting> kafkaSetting, IOptions <EventStoreDatabaseSetting> eventStoreDatabaseSetting, IOptions <GeoDatabaseSetting> geoDatabaseSetting, IToposTypedEventObservable <RouteNetworkEditOperationOccuredEvent> eventDispatcher, RouteNetworkEventHandler routeNetworkEventHandler, IRouteNetworkState routeNetworkState, ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher)
        {
            _loggerFactory             = loggerFactory;
            _logger                    = _loggerFactory.CreateLogger <RouteNetworkEventConsumer>();
            _eventStore                = eventStore;
            _kafkaSetting              = kafkaSetting.Value;
            _eventStoreDatabaseSetting = eventStoreDatabaseSetting.Value;
            _geoDatabaseSetting        = geoDatabaseSetting.Value;

            _commandDispatcher = commandDispatcher;
            _queryDispatcher   = queryDispatcher;

            _eventDispatcher          = eventDispatcher;
            _routeNetworkEventHandler = routeNetworkEventHandler;
            _routeNetworkState        = routeNetworkState;
        }
 public RouteNetworkEventSubscription(IToposTypedEventObservable <RouteNetworkEditOperationOccuredEvent> toposTypedEventObserable)
 {
     _toposTypedEventObserable = toposTypedEventObserable;
 }
        public void SubscribeRouteNetwork()
        {
            int incremantalId = 0;

            var serilogLogger = new LoggerConfiguration()
                                .MinimumLevel.Debug()
                                .Enrich.FromLogContext()
                                .WriteTo.Console()
                                .CreateLogger();

            var loggerFactory = (ILoggerFactory) new LoggerFactory();

            loggerFactory.AddSerilog(serilogLogger);

            _eventDispatcher = new ToposTypedEventObservable <RouteNetworkEditOperationOccuredEvent>(loggerFactory.CreateLogger <ToposTypedEventMediator <RouteNetworkEditOperationOccuredEvent> >());

            var kafkaConsumer = _eventDispatcher.Config("route_network_event_" + Guid.NewGuid(), c => c.UseKafka("20.73.229.67:9094")
                                                        .WithCertificate("/home/mihai/Certificates/kafka-aura-prod.crt"))
                                .Positions(p => p.StoreInMemory(new InMemPositionsStorage()))
                                .Topics(t => t.Subscribe("domain.route-network"))
                                .Handle(async(messages, context, token) =>
            {
                foreach (var message in messages)
                {
                    if (message.Body is RouteNetworkEditOperationOccuredEvent)
                    {
                        var route = (RouteNetworkEditOperationOccuredEvent)message.Body;
                        if (route.RouteNetworkCommands != null)
                        {
                            foreach (var command in route.RouteNetworkCommands)
                            {
                                if (command.RouteNetworkEvents != null)
                                {
                                    foreach (var routeNetworkEvent in command.RouteNetworkEvents)
                                    {
                                        try
                                        {
                                            switch (routeNetworkEvent)
                                            {
                                            case RouteNodeAdded domainEvent:
                                                incremantalId++;
                                                if (domainEvent.NamingInfo.Name != null)
                                                {
                                                    var node = new RouteNode
                                                    {
                                                        id            = domainEvent.NodeId,
                                                        incrementalId = incremantalId,
                                                        name          = domainEvent.NamingInfo.Name,
                                                        coordinates   = domainEvent.Geometry
                                                    };
                                                    if (node != null)
                                                    {
                                                        await addRouteNode(node);
                                                    }
                                                }
                                                break;

                                            case RouteNodeMarkedForDeletion domainEvent:
                                                await DeleteRouteNode(domainEvent.NodeId);
                                                break;

                                            case RouteNodeGeometryModified domainEvent:
                                                await UpdateGeometryNode(domainEvent.NodeId, domainEvent.Geometry);
                                                break;

                                            case OpenFTTH.Events.Core.NamingInfoModified domainEvent:
                                                await UpdateNameNode(domainEvent.EventId, domainEvent.NamingInfo.Name);
                                                break;
                                            }
                                        }
                                        catch (System.NullReferenceException e)
                                        {
                                            _logger.LogInformation("exception caught");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }).Start();
        }
 public UtilityNetworkUpdatedEventConsumer(ILogger <UtilityNetworkUpdatedEventConsumer> logger, IOptions <KafkaSetting> kafkaSetting, IToposTypedEventObservable <RouteNetworkElementContainedEquipmentUpdated> eventDispatcher)
 {
     _logger          = logger;
     _kafkaSetting    = kafkaSetting.Value;
     _eventDispatcher = eventDispatcher;
 }