|
|
@@ -60,15 +60,19 @@ namespace YSAI.Core.data
|
|
|
addressValue.Time = DateTime.Now.ToLocalTime();
|
|
|
addressValue.Quality = 1;
|
|
|
|
|
|
- //转发
|
|
|
- OperateResult operateResult = Produce(PacketType.Message.ToString(), addressValue.ToJson().JsonFormatting());
|
|
|
- if (!operateResult.State)
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
{
|
|
|
- //当数据转发失败,就存到本地
|
|
|
- DynamicObj.Value = addressValue.ToJson();
|
|
|
- DynamicObj.State = operateResult.State;
|
|
|
- DynamicObj.Exception = operateResult.Message;
|
|
|
- LogHelper.FailData(DynamicObj.ToJson(), FailDataLog);
|
|
|
+ //转发
|
|
|
+ OperateResult operateResult = Produce(PacketType.Message.ToString(), addressValue.ToJson().JsonFormatting());
|
|
|
+ if (!operateResult.State)
|
|
|
+ {
|
|
|
+ //当数据转发失败,就存到本地
|
|
|
+ DynamicObj.Value = addressValue.ToJson();
|
|
|
+ DynamicObj.State = operateResult.State;
|
|
|
+ DynamicObj.Exception = operateResult.Message;
|
|
|
+ LogHelper.FailData(DynamicObj.ToJson(), FailDataLog);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return addressValue;
|
|
|
@@ -134,12 +138,20 @@ namespace YSAI.Core.data
|
|
|
/// <returns>统一出参</returns>
|
|
|
public static OperateResult Subscribe(string Topic, string ISn)
|
|
|
{
|
|
|
- //类的唯一标识符
|
|
|
- string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
- //方法的唯一标识符
|
|
|
- string MethodSN = "[Subscribe]";
|
|
|
- //执行转发方法
|
|
|
- return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { Topic, ISn }) as OperateResult;
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
+ {
|
|
|
+ //类的唯一标识符
|
|
|
+ string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
+ //方法的唯一标识符
|
|
|
+ string MethodSN = "[Subscribe]";
|
|
|
+ //执行转发方法
|
|
|
+ return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { Topic, ISn }) as OperateResult;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new OperateResult(false, $"反射状态 {reflectionOperate.ReflectionState} 不做此操作", 0.1);
|
|
|
+ }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 取消订阅
|
|
|
@@ -149,12 +161,20 @@ namespace YSAI.Core.data
|
|
|
/// <returns>统一出参</returns>
|
|
|
public static OperateResult UnSubscribe(string Topic, string ISn)
|
|
|
{
|
|
|
- //类的唯一标识符
|
|
|
- string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
- //方法的唯一标识符
|
|
|
- string MethodSN = "[UnSubscribe]";
|
|
|
- //执行转发方法
|
|
|
- return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { Topic, ISn }) as OperateResult;
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
+ {
|
|
|
+ //类的唯一标识符
|
|
|
+ string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
+ //方法的唯一标识符
|
|
|
+ string MethodSN = "[UnSubscribe]";
|
|
|
+ //执行转发方法
|
|
|
+ return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { Topic, ISn }) as OperateResult;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new OperateResult(false, $"反射状态 {reflectionOperate.ReflectionState} 不做此操作", 0.1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -166,12 +186,20 @@ namespace YSAI.Core.data
|
|
|
/// <returns>统一出参</returns>
|
|
|
public static OperateResult Produce(string Topic, string Content,List<string>? ISns = null)
|
|
|
{
|
|
|
- //类的唯一标识符
|
|
|
- string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
- //方法的唯一标识符
|
|
|
- string MethodSN = "[Produce]";
|
|
|
- //执行转发方法
|
|
|
- return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { Topic, Content, ISns }) as OperateResult;
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
+ {
|
|
|
+ //类的唯一标识符
|
|
|
+ string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
+ //方法的唯一标识符
|
|
|
+ string MethodSN = "[Produce]";
|
|
|
+ //执行转发方法
|
|
|
+ return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { Topic, Content, ISns }) as OperateResult;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new OperateResult(false, $"反射状态 {reflectionOperate.ReflectionState} 不做此操作", 0.1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -179,24 +207,40 @@ namespace YSAI.Core.data
|
|
|
/// </summary>
|
|
|
public static List<string>? TypeSns()
|
|
|
{
|
|
|
- //类的唯一标识符
|
|
|
- string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
- //方法的唯一标识符
|
|
|
- string MethodSN = "[TypeSns]";
|
|
|
- //执行转发方法
|
|
|
- return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", null) as List<string>;
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
+ {
|
|
|
+ //类的唯一标识符
|
|
|
+ string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
+ //方法的唯一标识符
|
|
|
+ string MethodSN = "[TypeSns]";
|
|
|
+ //执行转发方法
|
|
|
+ return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", null) as List<string>;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 实例唯一标识符集合
|
|
|
/// </summary>
|
|
|
public static List<string>? InstanceSns()
|
|
|
{
|
|
|
- //类的唯一标识符
|
|
|
- string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
- //方法的唯一标识符
|
|
|
- string MethodSN = "[InstanceSns]";
|
|
|
- //执行转发方法
|
|
|
- return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", null) as List<string>;
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
+ {
|
|
|
+ //类的唯一标识符
|
|
|
+ string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
+ //方法的唯一标识符
|
|
|
+ string MethodSN = "[InstanceSns]";
|
|
|
+ //执行转发方法
|
|
|
+ return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", null) as List<string>;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 释放指定实例
|
|
|
@@ -205,12 +249,20 @@ namespace YSAI.Core.data
|
|
|
/// <returns>统一出参</returns>
|
|
|
public static OperateResult DisposeISn(string ISn)
|
|
|
{
|
|
|
- //类的唯一标识符
|
|
|
- string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
- //方法的唯一标识符
|
|
|
- string MethodSN = "[DisposeISn]";
|
|
|
- //执行转发方法
|
|
|
- return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { ISn }) as OperateResult;
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
+ {
|
|
|
+ //类的唯一标识符
|
|
|
+ string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
+ //方法的唯一标识符
|
|
|
+ string MethodSN = "[DisposeISn]";
|
|
|
+ //执行转发方法
|
|
|
+ return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { ISn }) as OperateResult;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new OperateResult(false, $"反射状态 {reflectionOperate.ReflectionState} 不做此操作", 0.1);
|
|
|
+ }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 移除指定实例
|
|
|
@@ -219,12 +271,20 @@ namespace YSAI.Core.data
|
|
|
/// <returns>统一出参</returns>
|
|
|
public static OperateResult RemoveISn(string ISn)
|
|
|
{
|
|
|
- //类的唯一标识符
|
|
|
- string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
- //方法的唯一标识符
|
|
|
- string MethodSN = "[RemoveISn]";
|
|
|
- //执行转发方法
|
|
|
- return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { ISn }) as OperateResult;
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
+ {
|
|
|
+ //类的唯一标识符
|
|
|
+ string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
+ //方法的唯一标识符
|
|
|
+ string MethodSN = "[RemoveISn]";
|
|
|
+ //执行转发方法
|
|
|
+ return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { ISn }) as OperateResult;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new OperateResult(false, $"反射状态 {reflectionOperate.ReflectionState} 不做此操作", 0.1);
|
|
|
+ }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 打开
|
|
|
@@ -233,12 +293,20 @@ namespace YSAI.Core.data
|
|
|
/// <returns>统一出参</returns>
|
|
|
public static OperateResult On(string ISn)
|
|
|
{
|
|
|
- //类的唯一标识符
|
|
|
- string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
- //方法的唯一标识符
|
|
|
- string MethodSN = "[On]";
|
|
|
- //执行转发方法
|
|
|
- return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { ISn }) as OperateResult;
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
+ {
|
|
|
+ //类的唯一标识符
|
|
|
+ string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
+ //方法的唯一标识符
|
|
|
+ string MethodSN = "[On]";
|
|
|
+ //执行转发方法
|
|
|
+ return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { ISn }) as OperateResult;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new OperateResult(false, $"反射状态 {reflectionOperate.ReflectionState} 不做此操作", 0.1);
|
|
|
+ }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 关闭
|
|
|
@@ -247,12 +315,20 @@ namespace YSAI.Core.data
|
|
|
/// <returns>统一出参</returns>
|
|
|
public static OperateResult Off(string ISn)
|
|
|
{
|
|
|
- //类的唯一标识符
|
|
|
- string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
- //方法的唯一标识符
|
|
|
- string MethodSN = "[Off]";
|
|
|
- //执行转发方法
|
|
|
- return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { ISn }) as OperateResult;
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
+ {
|
|
|
+ //类的唯一标识符
|
|
|
+ string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
+ //方法的唯一标识符
|
|
|
+ string MethodSN = "[Off]";
|
|
|
+ //执行转发方法
|
|
|
+ return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", new object[] { ISn }) as OperateResult;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new OperateResult(false, $"反射状态 {reflectionOperate.ReflectionState} 不做此操作", 0.1);
|
|
|
+ }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 转发事件注册
|
|
|
@@ -260,7 +336,8 @@ namespace YSAI.Core.data
|
|
|
/// <returns></returns>
|
|
|
public static OperateResult RelayEventRegister(Action<object, object> action, bool Register = true)
|
|
|
{
|
|
|
- try
|
|
|
+ //反射状态为true才进行操作
|
|
|
+ if (reflectionOperate.ReflectionState)
|
|
|
{
|
|
|
//类的唯一标识符
|
|
|
string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
|
|
|
@@ -269,9 +346,9 @@ namespace YSAI.Core.data
|
|
|
//注册事件
|
|
|
return reflectionOperate.RegisterEvent($"{ClassSN}{EventSN}", Register, P2: action);
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ else
|
|
|
{
|
|
|
- return new OperateResult(false, $"转发事件注册异常:{ex.Message}", 0.1);
|
|
|
+ return new OperateResult(false, $"反射状态 {reflectionOperate.ReflectionState} 不做此操作", 0.1);
|
|
|
}
|
|
|
}
|
|
|
|