@@ -47,7 +47,7 @@ namespace HBLConsole.Business | |||
MessagePackage.Message = deviceStatus;//GetMessage == null ? deviceStatus : GetMessage(); | |||
MqttHelper.GetInstance.MqttPublishAsync(Topic, MessagePackage.Serialize()); | |||
Thread.Sleep(1000); | |||
}), "设备心跳上报"); | |||
}), "设备心跳上报", true); | |||
} | |||
} | |||
@@ -46,7 +46,6 @@ namespace HBLConsole.MainConsole | |||
Json<KeepDataBase>.Save(); | |||
Sqlite<Alarm>.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)); | |||
@@ -0,0 +1,31 @@ | |||
<UserControl x:Class="HBLConsole.PryUserControl.IcoButton" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:HBLConsole.PryUserControl" | |||
mc:Ignorable="d" | |||
d:DesignHeight="30" d:DesignWidth="130"> | |||
<UserControl.Resources> | |||
<ControlTemplate TargetType="Button" x:Key="iconButtonTemp"> | |||
<Border x:Name="br" BorderThickness="2" > | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</UserControl.Resources> | |||
<Grid> | |||
<Button> | |||
</Button> | |||
<!--<Canvas Width="auto" Height="auto"> | |||
<Button> | |||
</Button> | |||
</Canvas>--> | |||
</Grid> | |||
</UserControl> |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// IcoButton.xaml 的交互逻辑 | |||
/// </summary> | |||
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))); | |||
} | |||
} |
@@ -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<Task, object>((t, o) => | |||
@@ -11,7 +11,7 @@ | |||
<!--客户端ID--> | |||
<!--MorkD = 2,MorkS 且时且多 = 8,MorkS 珠海 = 9,冰淇淋 = 4,咖啡机 = 13--> | |||
<add key="ClientId" value="9"/> | |||
<add key="ClientId" value="4"/> | |||
<add key="COM_Coffee" value="COM8"/> | |||
<add key="BAUD_Coffee" value="115200"/> | |||
@@ -474,6 +474,85 @@ | |||
</Style> | |||
<!--#endregion--> | |||
<!--#region 图标按钮--> | |||
<Style x:Key="IcoButtonStyle" TargetType="Button"> | |||
<Setter Property="FontFamily" Value="../Fonts/#iconfont" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border | |||
x:Name="br" | |||
Background="Transparent" | |||
BorderBrush="#FF19B7EC" | |||
BorderThickness="2"> | |||
<StackPanel | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontFamily="{Binding}" | |||
Text="{Binding ElementName=br}" /> | |||
<ContentControl | |||
Margin="10,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
Foreground="{TemplateBinding Foreground}" /> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||
</Trigger> | |||
<Trigger Property="IsPressed" Value="true"> | |||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<ControlTemplate x:Key="IcoButtonTemp" TargetType="Button"> | |||
<Border | |||
x:Name="br" | |||
Background="Transparent" | |||
BorderBrush="#FF19B7EC" | |||
BorderThickness="2"> | |||
<StackPanel | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontFamily="../Fonts/#iconfont" | |||
Text="{Binding Path=Content, RelativeSource={RelativeSource AncestorType=Button, Mode=TemplatedParent}}" /> | |||
<ContentControl | |||
Margin="10,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
Foreground="{TemplateBinding Foreground}" /> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||
</Trigger> | |||
<Trigger Property="IsPressed" Value="true"> | |||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
<!--#endregion--> | |||
<!--#region 新建按钮--> | |||
<ControlTemplate x:Key="NewButtonTemp" TargetType="Button"> | |||
<Border | |||
@@ -14,6 +14,6 @@ | |||
Name="webView" | |||
Width="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualWidth}" | |||
Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualHeight}" | |||
Source="http://162.14.105.138:8804/welcome" /> | |||
Source="http://1.14.74.54:8808/welcome" /> | |||
</Grid> | |||
</UserControl> |