Exemplo n.º 1
0
        public async Task <HttpStatusCode> EventActiveStateChanged(IEventActiveStateChangedMessage message)
        {
            RestRequest request = await PrepareQuery("Signals/ActiveState", Method.POST);

            request.AddParameter("application/json", JsonConvert.SerializeObject(message), ParameterType.RequestBody);

            var queryResult = await _client.ExecuteTaskAsync(request);

            if (!queryResult.IsSuccessful)
            {
                _logger.LogError($"EventActiveStateChanged: Error while sending a message: {queryResult.StatusCode}");
            }
            return(queryResult.StatusCode);
        }
Exemplo n.º 2
0
 private async Task <bool> PushMessageToQueue(IEventActiveStateChangedMessage message)
 {
     try
     {
         if (_config.PushToQueueTimeToLive > 0)
         {
             await _serviceBus.BusAccess.Publish(message, p => { p.TimeToLive = TimeSpan.FromSeconds(_config.PushToQueueTimeToLive); });
         }
         else
         {
             await _serviceBus.BusAccess.Publish(message);
         }
     }
     catch (Exception e)
     {
         _logger.LogError($"PushMessageToQueue: {e.Message}");
         return(false);
     }
     return(true);
 }