diff --git a/projects/Infrastructure/Extensions/ExceptionExtensions.cs b/projects/Infrastructure/Extensions/ExceptionExtensions.cs index 3726cd6b..af4614f2 100644 --- a/projects/Infrastructure/Extensions/ExceptionExtensions.cs +++ b/projects/Infrastructure/Extensions/ExceptionExtensions.cs @@ -1,16 +1,18 @@ using System; +using System.Runtime.CompilerServices; namespace Infrastructure.Extensions { public static class ExceptionExtensions { - public static void PrintStack(this Exception ex, string message = null) + public static void PrintStack(this Exception ex, string message = null, [CallerMemberName] string memberName = "") { Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")); if (message != null) { Console.WriteLine(message); } + Console.WriteLine(memberName); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); ex.InnerException?.PrintStack(); diff --git a/projects/IoT/IoT.Shared/DeviceServices/FBee/FBeeService.cs b/projects/IoT/IoT.Shared/DeviceServices/FBee/FBeeService.cs index e1b1754f..324d4057 100644 --- a/projects/IoT/IoT.Shared/DeviceServices/FBee/FBeeService.cs +++ b/projects/IoT/IoT.Shared/DeviceServices/FBee/FBeeService.cs @@ -66,17 +66,21 @@ namespace IoT.Shared.DeviceServices.FBee { while (!_tokenSource.IsCancellationRequested) { - try + foreach (var item in this.Clients) { - foreach (var item in this.Clients) + try { Console.WriteLine($"check gateway:{item.Key}"); this.X9d(item.Key); } - } - catch (Exception ex) - { - ex.PrintStack(); + catch (Exception ex) + { + ex.PrintStack(); + if (!item.Value.Client.Connected) + { + this.Connect(item.Value); + } + } } await Task.Delay(1000 * 60); }