public Task UpdateCurrentState(DeviceState state) { if (DeviceLogHandlers.Any()) { Task.Run(async() => { foreach (var handler in DeviceLogHandlers) { try { await handler.DeviceUpdate(state); } catch (Exception ex) { Console.WriteLine(ex); } } }); } return(DeviceDatabase.Shared.InsertDeviceState(state)); }
//public async void TestUpdates () //{ // try { // var device = TestDevices [0]; // var update = new DeviceState { DeviceId = device.Id, Key = "Temperature", Value = 70, DataType = DataTypes.Decimal, DataFormat = "F" }; // var json = update.ToSimpleObject ().ToJson (); // await DatabaseConnection.InsertOrReplaceAsync (update); // var resp = await DatabaseConnection.Table<DeviceState> ().Where (x => x.DeviceId == device.Id).ToListAsync(); // Console.WriteLine (resp [0]); // } catch (Exception ex) { // Console.WriteLine (ex); // } //} public Task InsertDeviceState(DeviceState state) { return(DatabaseConnection.InsertOrReplaceAsync(state)); }