Esempio n. 1
0
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            RabbitMQSubscriber subscriber = new RabbitMQSubscriber(
                new RabbitMQConnectionFactory(config.RabbitMQ.Hostname,
                                              config.RabbitMQ.Username,
                                              config.RabbitMQ.Password));
            IModel           channel  = subscriber.SubscribeToSubject(subject);
            RabbitMQListener listener = new RabbitMQListener(channel);


            ICallbackService      documentUpdaterService = new DocumentUpdater(config, restClient);
            EventingBasicConsumer consumer = listener.CreateConsumer(documentUpdaterService);

            listener.StartConsumer(consumer, subject);
            return(Task.CompletedTask);
        }
        public async Task UpdateAsync(IContent content, string container)
        {
            if (content.Id == null)
            {
                throw new InvalidOperationException($"This content cannot be updated as it doesn't seem to exist (Id is null). Did you mean to use IContentCreator?");
            }

            var contentType = ContentTypeRepository.Get(content.ContentTypeId);

            if (contentType == null)
            {
                throw new InvalidOperationException($"This content has no content type (or rather its base class has no [ContentType] attribute)");
            }

            var document = ContentSerializer.Serialize(content, contentType);

            await DocumentUpdater.UpdateAsync(container, content.Id, document);
        }
Esempio n. 3
0
        public async Task UpdateAsync(IContent content)
        {
            if (content.Id == null)
            {
                throw new InvalidOperationException($"This content cannot be updated as it doesn't seem to exist (Id is null). Did you mean to use IContentCreator?");
            }

            var contentType = ContentTypeRepository.Get(content.ContentTypeId);

            if (contentType == null)
            {
                throw new TypeNotRegisteredContentTypeException(content.GetType());
            }

            foreach (var saveListener in SaveListenerProvider.GetFor(content))
            {
                saveListener.BeforeSave(content);
            }

            var document = ContentSerializer.Serialize(content, contentType);

            await DocumentUpdater.UpdateAsync(contentType.Container, content.Id, document);
        }