From a4daff98006b5564b994c62826445d096238080a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Thu, 7 Apr 2022 10:14:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HBLConsole.Business/HeartbeatReport.cs | 2 +- HBLConsole.MainConsole/Main.cs | 3 +- HBLConsole.PryUserControl/IcoButton.xaml | 31 ++++++++ HBLConsole.PryUserControl/IcoButton.xaml.cs | 48 +++++++++++ HBLConsole.Service/ThreadManage.cs | 18 ++--- HBLConsole/App.config | 2 +- .../ResourceDictionarys/BasicStyle.xaml | 79 +++++++++++++++++++ HBLConsole/View/BatchingAddView.xaml | 2 +- 8 files changed, 171 insertions(+), 14 deletions(-) create mode 100644 HBLConsole.PryUserControl/IcoButton.xaml create mode 100644 HBLConsole.PryUserControl/IcoButton.xaml.cs diff --git a/HBLConsole.Business/HeartbeatReport.cs b/HBLConsole.Business/HeartbeatReport.cs index 518e5c1..5359177 100644 --- a/HBLConsole.Business/HeartbeatReport.cs +++ b/HBLConsole.Business/HeartbeatReport.cs @@ -47,7 +47,7 @@ namespace HBLConsole.Business MessagePackage.Message = deviceStatus;//GetMessage == null ? deviceStatus : GetMessage(); MqttHelper.GetInstance.MqttPublishAsync(Topic, MessagePackage.Serialize()); Thread.Sleep(1000); - }), "设备心跳上报"); + }), "设备心跳上报", true); } } diff --git a/HBLConsole.MainConsole/Main.cs b/HBLConsole.MainConsole/Main.cs index 5bc3549..8a4a368 100644 --- a/HBLConsole.MainConsole/Main.cs +++ b/HBLConsole.MainConsole/Main.cs @@ -46,7 +46,6 @@ namespace HBLConsole.MainConsole Json.Save(); Sqlite.GetInstance.Save(); TextHelper.GetInstance.SaveLogInfo(MessageLog.GetInstance.LogInfo, "LogInfo", "OrderInfoLog"); - } public void BusinessInit() @@ -54,7 +53,7 @@ namespace HBLConsole.MainConsole ThreadManage.GetInstance.Start(new Action(() => { InternetInfo.ConfigInit();//从 consul 获取配置数据 - //IotReport.GetInstance.Initialize(); + IotReport.GetInstance.Initialize(); Topics.Clear(); Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); diff --git a/HBLConsole.PryUserControl/IcoButton.xaml b/HBLConsole.PryUserControl/IcoButton.xaml new file mode 100644 index 0000000..362925c --- /dev/null +++ b/HBLConsole.PryUserControl/IcoButton.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + diff --git a/HBLConsole.PryUserControl/IcoButton.xaml.cs b/HBLConsole.PryUserControl/IcoButton.xaml.cs new file mode 100644 index 0000000..5e528ab --- /dev/null +++ b/HBLConsole.PryUserControl/IcoButton.xaml.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace HBLConsole.PryUserControl +{ + /// + /// IcoButton.xaml 的交互逻辑 + /// + public partial class IcoButton : UserControl + { + public IcoButton() + { + InitializeComponent(); + } + + public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + (d as IcoButton).Refresh(); + } + + private void Refresh() + { + + } + + public int BorderThickness + { + get { return (int)GetValue(BorderThicknessProperty); } + set { SetValue(BorderThicknessProperty, value); } + } + public static readonly DependencyProperty BorderThicknessProperty = + DependencyProperty.Register("BorderThickness", typeof(int), typeof(IcoButton), + new PropertyMetadata(2, new PropertyChangedCallback(OnPropertyChanged))); + + } +} diff --git a/HBLConsole.Service/ThreadManage.cs b/HBLConsole.Service/ThreadManage.cs index 46d20bd..3ab8e21 100644 --- a/HBLConsole.Service/ThreadManage.cs +++ b/HBLConsole.Service/ThreadManage.cs @@ -46,28 +46,28 @@ namespace HBLConsole.Service CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource()); bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() => { - ccc: + ReStart: try { while (!CancellationTokenSources[guid + key].IsCancellationRequested) { - if (action != null) - { - action(); - } + if (action != null) action(); } } catch (Exception ex) { - MessageLog.GetInstance.Show(ex.ToString()); - - if (IsRestart) goto ccc; + if (IsRestart) + { + Thread.Sleep(2000); + MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启"); + goto ReStart; + } else { CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp); Threads.TryRemove(guid + key, out Task temp1); - MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启"); + MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已退出"); } } }), CancellationTokenSources[guid + key].Token).ContinueWith(new Action((t, o) => diff --git a/HBLConsole/App.config b/HBLConsole/App.config index 4286ab6..19426ed 100644 --- a/HBLConsole/App.config +++ b/HBLConsole/App.config @@ -11,7 +11,7 @@ - + diff --git a/HBLConsole/Resources/ResourceDictionarys/BasicStyle.xaml b/HBLConsole/Resources/ResourceDictionarys/BasicStyle.xaml index d8caac4..04ea3f1 100644 --- a/HBLConsole/Resources/ResourceDictionarys/BasicStyle.xaml +++ b/HBLConsole/Resources/ResourceDictionarys/BasicStyle.xaml @@ -474,6 +474,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + Source="http://1.14.74.54:8808/welcome" />