public override async Task <bool> Update() { bool result = false; try { MsgLogger.WriteDebug($"{GetType().Name} - Update", $"Is channel='{Channel.Id}' registered..."); if (await IsChannelRegistered()) { MsgLogger.WriteDebug($"{GetType().Name} - Update", $"Is any channel='{Channel.Id}' device not registered..."); if (await AnyDeviceUnRegistered()) { MsgLogger.WriteLine($"re-register channel='{Channel.Id}' devices"); if (!await DeviceControllerAdapter.RegisterDevices()) { MsgLogger.WriteError($"{GetType().Name} - Update", $"register channel='{Channel.Id}' devices failed!"); } } MsgLogger.Write($"{GetType().Name} - Update", $"Updating channel='{Channel.Id}' status..."); result = await SetChannelStatus(ChannelStatus.Online); } else { MsgLogger.WriteLine($"Registering channel='{Channel.Id}' ..."); if (await RegisterChannel()) { MsgLogger.Write($"{GetType().Name} - Update", $"updating channel='{Channel.Id}' status ..."); result = await SetChannelStatus(ChannelStatus.Online); if (result) { MsgLogger.WriteLine($"update channel='{Channel.Id}' status success"); } else { MsgLogger.WriteError($"{GetType().Name} - Update", $"update channel='{Channel.Id}' status failed!"); } } else { MsgLogger.WriteError($"{GetType().Name} - Update", $"register channel='{Channel.Id}' failed!"); } if (result) { MsgLogger.WriteLine($"Registering devices='{Channel.Id}' ..."); result = await DeviceControllerAdapter.RegisterDevices(); if (result) { MsgLogger.WriteLine($"register channel='{Channel.Id}' devices success"); } else { MsgLogger.WriteError($"{GetType().Name} - Update", $"register channel='{Channel.Id}' devices failed!"); } } } } catch (Exception e) { MsgLogger.Exception($"{GetType().Name} - AnyDeviceUnRegistered", e); } return(result); }