修复了一些问题
This commit is contained in:
@@ -49,7 +49,7 @@ public class DbMqtt
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// MQTT客户端登录密码。
|
/// MQTT客户端登录密码。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public string PassWord { get; set; } = String.Empty;
|
public string PassWord { get; set; } = String.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -66,25 +66,25 @@ public class DbMqtt
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// MQTT发布主题。
|
/// MQTT发布主题。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public string PublishTopic { get; set; } = String.Empty;
|
public string PublishTopic { get; set; } = String.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MQTT备注。
|
/// MQTT备注。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public string Remark { get; set; } = String.Empty;
|
public string Remark { get; set; } = String.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MQTT订阅主题。
|
/// MQTT订阅主题。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public string SubTopics { get; set; } = String.Empty;
|
public string SubTopic { get; set; } = String.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MQTT客户端登录用户名。
|
/// MQTT客户端登录用户名。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public string UserName { get; set; } = String.Empty;
|
public string UserName { get; set; } = String.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public partial class Mqtt : ObservableObject
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// MQTT订阅主题。
|
/// MQTT订阅主题。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SubTopics { get; set; }
|
public string SubTopic { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MQTT客户端登录用户名。
|
/// MQTT客户端登录用户名。
|
||||||
|
|||||||
@@ -161,8 +161,8 @@ namespace PMSWPF.Services
|
|||||||
mqtt.IsConnected = true;
|
mqtt.IsConnected = true;
|
||||||
|
|
||||||
// 订阅主题
|
// 订阅主题
|
||||||
await client.SubscribeAsync(new MqttTopicFilterBuilder().WithTopic("test").Build());
|
await client.SubscribeAsync(new MqttTopicFilterBuilder().WithTopic(mqtt.SubTopic).Build());
|
||||||
NlogHelper.Info($"MQTT客户端 {mqtt.Name} 已订阅主题: {mqtt.SubTopics}");
|
NlogHelper.Info($"MQTT客户端 {mqtt.Name} 已订阅主题: {mqtt.SubTopic}");
|
||||||
});
|
});
|
||||||
|
|
||||||
// 设置接收消息处理程序
|
// 设置接收消息处理程序
|
||||||
@@ -183,6 +183,8 @@ namespace PMSWPF.Services
|
|||||||
// 服务停止
|
// 服务停止
|
||||||
if (_stopEvent.WaitOne(0))
|
if (_stopEvent.WaitOne(0))
|
||||||
return;
|
return;
|
||||||
|
if (!mqtt.IsActive)
|
||||||
|
return;
|
||||||
|
|
||||||
NlogHelper.Info($"5秒后重新连接Mqtt服务器:{mqtt.Name}");
|
NlogHelper.Info($"5秒后重新连接Mqtt服务器:{mqtt.Name}");
|
||||||
// 尝试重新连接。
|
// 尝试重新连接。
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<TextBlock Text="订阅主题"
|
<TextBlock Text="订阅主题"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Style="{StaticResource TextBlockSubTitle}" />
|
Style="{StaticResource TextBlockSubTitle}" />
|
||||||
<TextBox Text="{Binding Mqtt.SubTopics, UpdateSourceTrigger=PropertyChanged}" />
|
<TextBox Text="{Binding Mqtt.SubTopic, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
<CheckBox FontSize="16"
|
<CheckBox FontSize="16"
|
||||||
Content="是否设为默认"
|
Content="是否设为默认"
|
||||||
Margin="0 30 0 0"
|
Margin="0 30 0 0"
|
||||||
|
|||||||
@@ -126,7 +126,7 @@
|
|||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
FontSize="14" />
|
FontSize="14" />
|
||||||
<TextBlock Text="{Binding SubTopics}" />
|
<TextBlock Text="{Binding SubTopic}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
Margin="0,2">
|
Margin="0,2">
|
||||||
|
|||||||
Reference in New Issue
Block a user