private async void OnDataReceived(MqttApplicationMessageReceivedEventArgs arg) { try { SensorData data = JsonConvert.DeserializeObject <SensorData>( Encoding.UTF8.GetString(arg.ApplicationMessage.Payload)); Console.WriteLine($"type: {data.SensorType}, val: {data.Value}"); _model[data.SensorType] = data.Value; if (!_model.Check()) { return; } string eventVal = GetEventBasedOnModel(); Console.WriteLine($"val: {eventVal}"); if (Events.Contains(eventVal)) { var point = PointData .Measurement("AnalyticsData") .Field("event", eventVal) .Timestamp(DateTime.UtcNow, WritePrecision.Ms); _database.Write(point); SendActionRequestToCommandMicroservice(eventVal); SendEventToWebDashboard(eventVal); } _model.Clear(); } catch (Exception e) { Console.WriteLine(e.Message); } }