public async override void Execute()
        {
            var newPodcastUrl = newSubscriptionService.GetSubscriptionUrl();

            if (newPodcastUrl != null)
            {
                var pod = new Podcast()
                {
                    SubscriptionUrl = newPodcastUrl
                };
                try
                {
                    await podcastLoader.UpdatePodcast(pod);

                    subscriptionManager.AddSubscription(pod);
                    Utils.AddPodcastToTreeView(pod, subscriptionView);
                }
                catch (WebException)
                {
                    messageBoxDisplayService.Show("Sorry, that podcast could not be found. Please check the URL");
                }
                catch (XmlException)
                {
                    messageBoxDisplayService.Show("Sorry, that URL is not a podcast feed");
                }
            }
        }
        private static void RegisterHandlerType(ISubscriptionManager subcriptionsManager, IRequestHandlerManager requestManager, Type aHandlerType)
        {
            var interfaces = aHandlerType.GetInterfaces();

            foreach (var aInterface in interfaces)
            {
                if (!typeof(IHandler).IsAssignableFrom(aInterface))
                {
                    continue;
                }

                var genericArgs = aInterface.GetGenericArguments();
                if (genericArgs.Length == 1)
                {
                    if (typeof(IRequestHandler).IsAssignableFrom(aInterface))
                    {
                        requestManager.AddRequestHandler(genericArgs[0], new IocHandlerFactory(aHandlerType, genericArgs[0]));
                    }
                    else
                    {
                        subcriptionsManager.AddSubscription(genericArgs[0], new IocHandlerFactory(aHandlerType, genericArgs[0]));
                    }
                }
            }
        }
Example #3
0
        public async override void Execute()
        {
            var newPodcastUrl = newSubscriptionService.GetSubscriptionUrl();

            if (newPodcastUrl != null)
            {
                var pod = new Podcast {
                    SubscriptionUrl = newPodcastUrl
                };
                try
                {
                    await podcastLoader.UpdatePodcast(pod);

                    subscriptionManager.AddSubscription(pod);
                    EventAggregator.Instance.Publish(new PodcastLoadedMessage(pod));
                }
                catch (WebException)
                {
                    messageBoxDisplayService.Show("Sorry, that podcast could not be found. Please check the URL");
                }
                catch (XmlException)
                {
                    messageBoxDisplayService.Show("Sorry, that URL is not a podcast feed");
                }
            }
        }
Example #4
0
        public void SetUp()
        {
            _subscriptionManager          = Substitute.For <ISubscriptionManager>();
            _rabbitMqPersistentConnection = Substitute.For <IRabbitMqPersistentConnection>();
            _rabbitConsumerInitializer    = Substitute.For <IRabbitConsumerInitializer>();
            var rabbitMqEventBusOptions = Substitute.For <IOptions <RabbitMqEventBusOptions> >();
            var value = Substitute.For <RabbitMqEventBusOptions>();

            rabbitMqEventBusOptions.Value.Returns(value);
            _rabbitMqEventBusOptionsValue = value;
            var queueName    = Guid.NewGuid().ToString();
            var exchangeName = Guid.NewGuid().ToString();

            value.QueueName.Returns(queueName);
            value.ExchangeName.Returns(exchangeName);
            _model = Substitute.For <IModel>();
            _rabbitMqPersistentConnection.CreateModel().Returns(_model);
            _subscription = new Subscription <Event>();
            _subscriptionManager.AddSubscription <Event>().Returns(_subscription);


            _sut = new RabbitMqEventSubscriber(_subscriptionManager, _rabbitMqPersistentConnection, _rabbitConsumerInitializer, rabbitMqEventBusOptions, Substitute.For <ILogger <RabbitMqEventSubscriber> >());

            _rabbitConsumerInitializer.Received(1).InitializeConsumersChannelsAsync();
        }
Example #5
0
        public Subscription <T> Subscribe <T>() where T : Event
        {
            var subscription = _subscriptionManager.AddSubscription <T>();

            SubscribeToRabbitMq(subscription);
            return(subscription);
        }
 public ResultWrapper <string> eth_subscribe(string subscriptionName, Filter arguments = null)
 {
     if (Enum.TryParse(typeof(SubscriptionType), subscriptionName, true, out var subscriptionType))
     {
         return(ResultWrapper <string> .Success(_subscriptionManager.AddSubscription(Context.DuplexClient, (SubscriptionType)subscriptionType, arguments)));
     }
     return(ResultWrapper <string> .Fail($"Wrong subscription type: {subscriptionName}."));
 }
        public void Subscribe <IEvent, IEventHandler>()
            where IEvent : IntergrationEvent
            where IEventHandler : IIntergrationEventHandler <IEvent>
        {
            var eventName = typeof(IEvent).Name;

            _subscriptionManager.AddSubscription(eventName, typeof(IEventHandler));
        }
Example #8
0
        public void Subscribe <T, TH>()
            where T : Event
            where TH : IEventHandler <T>
        {
            var eventName = _subsManager.GetEventKey <T>();

            DoInternalSubscription(eventName);
            _subsManager.AddSubscription <T, TH>();
        }
Example #9
0
        public void Subscribe <T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler <T>
        {
            var eventName = _subsManager.GetEventKey <T>();

            Subscription(eventName);
            _subsManager.AddSubscription <T, TH>();
        }
Example #10
0
        /// <summary>
        /// Subscribe to a
        /// </summary>
        /// <typeparam name="T">Integration event of type</typeparam>
        /// <typeparam name="TH">Integration event handler type</typeparam>
        public void Subscribe <T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler <T>
        {
            if (_consumerChannel == null || _consumerChannel.IsClosed)
            {
                _consumerChannel = CreateConsumerChannel();
            }

            _subscriptionManager.AddSubscription <T, TH>();
        }
Example #11
0
        public void Subscribe <T, TH>()
            where T : MessageQueueEvent
            where TH : IMessageQueueEventHandler <T>
        {
            var eventName = _subsManager.GetEventKey <T>();

            DoInternalSubscription(eventName);

            _logger.LogInformation("Subscribing to event {EventName} with {EventHandler}", eventName, typeof(TH).GetGenericTypeName());

            _subsManager.AddSubscription <T, TH>();
            StartBasicConsume();
        }
Example #12
0
        public void Subscribe <E, EH>()
            where E : IntegrationEvent
            where EH : IIntegrationEventHandler
        {
            var eventName = _subManager.GetEventKey <E>();

            DoInternalSubscription(eventName);

            _logger.LogInformation(
                "Subscribing to event: {EventName} with handler: {EventHandler}"
                , eventName
                , typeof(EH).Name
                );

            _subManager.AddSubscription <E, EH>();
            StartBasicConsume();
        }
        public async Task <ActionResult> Create(CreateOrUpdateSubscriptionRequest request)
        {
            try {
                await _manager.AddSubscription(request);

                return(RedirectToAction(nameof(ShowSubscriptions)));
            }
            catch (ArgumentNullException) {
                return(RedirectToAction("ErrorPage", nameof(Main), new { message = "Error: can not add new subscription", call = nameof(Subscription) }));
            }
            catch (DbUpdateException) {
                return(RedirectToAction("ErrorPage", nameof(Main), new { message = "Error: invalid input", call = nameof(Subscription) }));
            }
            catch (ArgumentException) {
                return(RedirectToAction("ErrorPage", nameof(Main), new { message = "Error: value should be positiv", call = nameof(Subscription) }));
            }
        }
Example #14
0
 public void Subscribe <TEvent, THandler>(ILifetimeScope currentScope)
     where TEvent : Event
     where THandler : IEventHandler <TEvent>
 {
     _subsManager.AddSubscription <TEvent, THandler>(currentScope);
 }
        public ResultWrapper <string> eth_subscribe(string subscriptionName, string?args = null)
        {
            try
            {
                ResultWrapper <string> successfulResult = ResultWrapper <string> .Success(_subscriptionManager.AddSubscription(Context.DuplexClient, subscriptionName, args));

                return(successfulResult);
            }
            catch (KeyNotFoundException)
            {
                return(ResultWrapper <string> .Fail($"Wrong subscription type: {subscriptionName}."));
            }
            catch (ArgumentException e)
            {
                return(ResultWrapper <string> .Fail($"Invalid params", ErrorCodes.InvalidParams, e.Message));
            }
        }
Example #16
0
 /// <summary>
 /// Add Subscription for event by factory
 /// </summary>
 /// <param name="eventType">The type of event must inherit TransportTray</param>
 /// <param name="factory">The factory of handler</param>
 public void AddSubscription(Type eventType, IHandlerFactory factory)
 {
     _subcriptionManager.AddSubscription(eventType, factory);
 }