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