コード例 #1
0
        public static void CheckWeeds(Field field, IDataProvider dataProvider, IRabbitMqBus bus)
        {
            var result = WeedCheckDataGenerator.Generate(dataProvider.GetWeedsAsync().Result);

            if (result != null)
            {
                var severity = DangerLevel.Low;
                if (result.Percentage >= 10 && result.Percentage <= 60)
                {
                    severity = DangerLevel.High;
                }
                else if (result.Percentage > 60)
                {
                    severity = DangerLevel.Critical;
                }

                var message = new WeedDetectedMessage()
                {
                    FieldId        = field.Id,
                    OrganizationId = field.OrganizationId,
                    WeedId         = result.WeedId,
                    Percentage     = result.Percentage,
                    Severity       = severity
                };

                bus.Publish(message);
            }
        }
コード例 #2
0
 public FieldController(IFieldService fieldService, IMapper mapper, IImageService imageService, IRabbitMqBus bus)
 {
     _fieldService = fieldService;
     _mapper       = mapper;
     _imageService = imageService;
     _bus          = bus;
 }
コード例 #3
0
        public static void CheckPets(Field field, IDataProvider dataProvider, IRabbitMqBus bus)
        {
            var result = PestCheckDataGenerator.Generate(dataProvider.GetPestsAsync().Result);

            if (result != null)
            {
                var severity = DangerLevel.Low;
                if (result.CountOnSquareMeter >= 50 && result.CountOnSquareMeter < 100)
                {
                    severity = DangerLevel.High;
                }
                else if (result.CountOnSquareMeter > 100)
                {
                    severity = DangerLevel.Critical;
                }

                var message = new PestDetectedMessage()
                {
                    FieldId            = field.Id,
                    OrganizationId     = field.OrganizationId,
                    PestId             = result.PestId,
                    CountOnSquareMeter = result.CountOnSquareMeter,
                    Severity           = severity
                };

                bus.Publish(message);
            }
        }
コード例 #4
0
 public UserService(IUserRepository repository, IMapper mapper, PasswordManager passwordManager, IMediator mediator, IRabbitMqBus bus, IOrganisationRepository organisationRepository)
 {
     _repository = repository;
     _mapper = mapper;
     _passwordManager = passwordManager;
     _bus = bus;
     _organisationRepository = organisationRepository;
 }
コード例 #5
0
        public static IObservable <TEvent> SubscribeToExchange <TEvent>(this IRabbitMqBus rabbitMqBus,
                                                                        string exchange,
                                                                        string queueName          = "",
                                                                        string exchangeType       = "topic",
                                                                        bool isExchangeDurable    = true,
                                                                        bool isExchangeAutoDelete = true,
                                                                        bool isQueueDurable       = false,
                                                                        bool isQueueAutoAck       = false,
                                                                        bool isQueueAutoDelete    = true,
                                                                        bool isQueueExclusive     = true,
                                                                        Expression <Func <TEvent, bool> >?routingStrategy = null)
            where TEvent : class, IRabbitMqEvent
        {
            var rabbitMqQueueConfiguration = new RabbitMqQueueConfiguration <TEvent>(routingStrategy,
                                                                                     queueName,
                                                                                     isQueueAutoAck,
                                                                                     isQueueDurable,
                                                                                     isQueueAutoDelete,
                                                                                     isQueueExclusive);

            var rabbitMqExchangeConfiguration = new RabbitMqExchangeConfiguration(exchange,
                                                                                  exchangeType,
                                                                                  true,
                                                                                  true,
                                                                                  isExchangeAutoDelete,
                                                                                  isExchangeDurable);

            var observable = Observable.Create <TEvent>((observer) =>
            {
                var rabbitMqSubscription = new RabbitMqEventSubscription <TEvent>((@event) =>
                {
                    observer.OnNext((TEvent)@event.Content);

                    return(Task.CompletedTask);
                }, rabbitMqQueueConfiguration, rabbitMqExchangeConfiguration);

                rabbitMqBus.SubscribeToExchange(rabbitMqSubscription);

                return(Disposable.Create(() => rabbitMqBus.UnsubscribeFromExchange(rabbitMqSubscription)));
            });

            return(observable);
        }
コード例 #6
0
 public UserController(IRabbitMqBus rabbitMqBus)
 {
     _rabbitMqBus = rabbitMqBus;
 }
コード例 #7
0
 public TicketController(IEventBus eventBus, IRabbitMqBus rabbitMqBus)
 {
     _eventBus    = eventBus;
     _rabbitMqBus = rabbitMqBus;
 }
コード例 #8
0
 public CheckAllFieldsOnDemandHandler(IRabbitMqBus bus, IDataProvider dataProvider)
 {
     _bus          = bus;
     _dataProvider = dataProvider;
 }
コード例 #9
0
 public BackgroundCheckWorker(IRabbitMqBus bus, IDataProvider dataProvider)
 {
     _bus          = bus;
     _dataProvider = dataProvider;
 }
コード例 #10
0
 public CheckFieldOnDemandHandler(IRabbitMqBus bus, IFieldService fieldService, IDataProvider dataProvider)
 {
     _bus          = bus;
     _fieldService = fieldService;
     _dataProvider = dataProvider;
 }