Пример #1
0
 public async Task SendReadings(SensorReadings readings)
 {
     if (sendToAzure)
     {
         await azureServiceBus.Send(readings);
     }
 }
Пример #2
0
        public async Task Send(SensorReadings readings)
        {
            try
            {
                var message   = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(readings));
                var eventData = new EventData(message);

                // Write the body of the message to the console
                Console.WriteLine($"Sending message: {Encoding.UTF8.GetString(message)}");

                await eventHubClient.SendAsync(eventData);
            }
            catch (Exception exception)
            {
                Console.WriteLine($"{DateTime.Now} > Exception: {exception.Message}");
            }
        }