private async Task SendDataAsync(McDoopDeviceData mcDoopDeviceData)
        {
            try
            {
                await _dataSender.SendDataAsync(mcDoopDeviceData);

                WriteLog($"Data Sent: {mcDoopDeviceData}");
            }
            catch (Exception ex)
            {
                WriteLog($"Exception: {ex.Message}");
            }
        }
        private async Task CreateMcDoopDeviceData(string sensorType, string sensorValue)
        {
            var mcDoopDeviceData = new McDoopDeviceData
            {
                City        = _device.City,
                Id          = _device.Id,
                SensorType  = sensorType,
                SensorValue = sensorValue,
                EventTime   = DateTime.Now
            };

            await SendDataAsync(mcDoopDeviceData);
        }
Beispiel #3
0
 public async Task SendDataAsync(McDoopDeviceData data)
 {
     var dataAsJson = JsonConvert.SerializeObject(data);
     var eventData  = new EventData(Encoding.UTF8.GetBytes(dataAsJson));
     await _eventHubClient.SendAsync(eventData);
 }