重构MQTT事件处理和激活状态管理功能
This commit is contained in:
@@ -55,17 +55,6 @@ public interface IEventService
|
||||
|
||||
#region MQTT事件
|
||||
|
||||
/// <summary>
|
||||
/// MQTT连接状态改变事件
|
||||
/// </summary>
|
||||
event EventHandler<MqttConnectionChangedEventArgs> MqttConnectionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 触发MQTT连接状态改变事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">MQTT连接状态改变事件参数</param>
|
||||
void RaiseMqttConnectionChanged(object sender, MqttConnectionChangedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// MQTT服务器改变事件
|
||||
@@ -107,7 +96,6 @@ public interface IEventService
|
||||
/// <param name="e">变量值改变事件参数</param>
|
||||
void RaiseVariableChanged(object sender, VariableChangedEventArgs e);
|
||||
|
||||
void RaiseVariableActiveChanged(object sender,VariablesActiveChangedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// 批量导入变量事件
|
||||
@@ -121,11 +109,6 @@ public interface IEventService
|
||||
/// <param name="e">批量导入变量事件参数</param>
|
||||
void RaiseBatchImportVariables(object sender, BatchImportVariablesEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// 变量启停改变事件
|
||||
/// </summary>
|
||||
event EventHandler<VariablesActiveChangedEventArgs> OnVariableActiveChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 数据加载完成事件
|
||||
/// </summary>
|
||||
|
||||
@@ -29,6 +29,7 @@ public class MappingProfile : Profile
|
||||
|
||||
// MqttServer 映射
|
||||
CreateMap<MqttServer, MqttServerDto>().ReverseMap();
|
||||
CreateMap<MqttServerDto, MqttServerDto>().ReverseMap();
|
||||
|
||||
// VariableMqttAlias 映射
|
||||
CreateMap<VariableMqttAlias, VariableMqttAliasDto>()
|
||||
|
||||
@@ -85,15 +85,6 @@ public class EventService : IEventService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 变量启停改变事件
|
||||
/// </summary>
|
||||
public event EventHandler<VariablesActiveChangedEventArgs> OnVariableActiveChanged;
|
||||
public void RaiseVariableActiveChanged(object sender, VariablesActiveChangedEventArgs e)
|
||||
{
|
||||
OnVariableActiveChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量导入变量事件
|
||||
/// </summary>
|
||||
@@ -128,22 +119,6 @@ public class EventService : IEventService
|
||||
#endregion
|
||||
|
||||
#region MQTT事件
|
||||
|
||||
/// <summary>
|
||||
/// MQTT连接状态改变事件
|
||||
/// </summary>
|
||||
public event EventHandler<MqttConnectionChangedEventArgs> MqttConnectionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 触发MQTT连接状态改变事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">MQTT连接状态改变事件参数</param>
|
||||
public void RaiseMqttConnectionChanged(object sender, MqttConnectionChangedEventArgs e)
|
||||
{
|
||||
MqttConnectionChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MQTT服务器改变事件
|
||||
/// </summary>
|
||||
|
||||
@@ -105,12 +105,6 @@ public class MqttManagementService : IMqttManagementService
|
||||
this, new MqttServerChangedEventArgs(ActionChangeType.Updated, mMqttServerDto, property));
|
||||
}
|
||||
|
||||
// 如果没有任何属性发生变化,至少触发一次更新事件
|
||||
if (changedProperties.Count == 0)
|
||||
{
|
||||
_eventService.RaiseMqttServerChanged(
|
||||
this, new MqttServerChangedEventArgs(ActionChangeType.Updated, mMqttServerDto, MqttServerPropertyType.All));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user