Shun 2 лет назад
Родитель
Сommit
9dbe0eaa99

+ 1 - 1
src/YSAI.Core/YSAI.Core.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.328.39457</Version>
+    <Version>23.328.40195</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>

+ 10 - 3
src/YSAI.Core/handler/AddressHandler.cs

@@ -4,6 +4,7 @@ using YSAI.Core.relay;
 using YSAI.Core.script;
 using YSAI.Log;
 using YSAI.Model.data;
+using YSAI.Unility;
 
 namespace YSAI.Core.handler
 {
@@ -27,6 +28,11 @@ namespace YSAI.Core.handler
         /// </summary>
         private static readonly string RelayLog = "Core/Relay.log";
 
+        /// <summary>
+        /// 转发失败数据备份日志输出文件
+        /// </summary>
+        private static readonly string RelayBackupsLog = "Core/RelayBackups.log";
+
         /// <summary>
         /// 转发容器
         /// </summary>
@@ -60,13 +66,14 @@ namespace YSAI.Core.handler
                 //数据质量(当数据为空时,数据是异常的)
                 int Quality = 0;
 
+                //解析
+                value = Parse(addressDetails, value);
+
                 //如果数据为空
                 if (!string.IsNullOrWhiteSpace(value))
                 {
                     //数据质量
                     Quality = 1;
-                    //解析
-                    value = Parse(addressDetails, value);
                 }
 
                 //最终数据组织
@@ -123,7 +130,7 @@ namespace YSAI.Core.handler
                             OperateResult operateResult = RelayIoc[basics].Produce(addressDetails.AddressRelayParam?.Topic, value, addressDetails.AddressRelayParam?.ISns);
                             if (!operateResult.State)
                             {
-                                LogHelper.Error($"转发失败,{operateResult.Message}", RelayLog);
+                                LogHelper.Error("{" + $"\"Topic\":\"{addressDetails.AddressRelayParam?.Topic}\",\"Content\":\"{value}\",\"ISns\":{addressDetails.AddressRelayParam?.ISns?.ToJson()}" + "}", RelayBackupsLog);
                             }
                         }
                     }

+ 0 - 298
src/YSAI.Core/handler/RelayHandler.cs

@@ -1,298 +0,0 @@
-namespace YSAI.Core.handler
-{
-    /// <summary>
-    /// 转发处理
-    /// </summary>
-    public class RelayHandler
-    {
-        /// <summary>
-        /// 反射操作
-        /// </summary>
-        //private static readonly RIOperate reflectionOperate = RIOperate.Instance();
-
-        ///// <summary>
-        ///// 订阅
-        ///// </summary>
-        ///// <param name="Topic">主题</param>
-        ///// <param name="ISn">实例唯一标识符</param>
-        ///// <returns>统一出参</returns>
-        //public static OperateResult Subscribe(string Topic, string ISn)
-        //{
-        //    try
-        //    {
-        //        //反射状态为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} 不做此操作", 1);
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new OperateResult(false, $"转发事件注册异常:{ex.Message}", 1);
-        //    }
-        //}
-
-        ///// <summary>
-        ///// 取消订阅
-        ///// </summary>
-        ///// <param name="Topic">主题</param>
-        ///// <param name="ISn">实例唯一标识符</param>
-        ///// <returns>统一出参</returns>
-        //public static OperateResult UnSubscribe(string Topic, string ISn)
-        //{
-        //    try
-        //    {
-        //        //反射状态为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} 不做此操作", 1);
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new OperateResult(false, $"转发事件注册异常:{ex.Message}", 1);
-        //    }
-        //}
-
-        ///// <summary>
-        ///// 生产
-        ///// </summary>
-        ///// <param name="Topic">主题</param>
-        ///// <param name="Content">内容</param>
-        ///// <param name="ISns">实例唯一标识符集合,空则全部发送</param>
-        ///// <returns>统一出参</returns>
-        //public static OperateResult Produce(string Topic, string Content, List<string>? ISns = null)
-        //{
-        //    try
-        //    {
-        //        //反射状态为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} 不做此操作", 1);
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new OperateResult(false, $"转发事件注册异常:{ex.Message}", 1);
-        //    }
-        //}
-
-        ///// <summary>
-        ///// 程序集唯一标识符集合
-        ///// </summary>
-        //public static List<string>? TypeSns()
-        //{
-        //    if (reflectionOperate != null)
-        //    {
-        //        //反射状态为true才进行操作
-        //        if (reflectionOperate.ReflectionState)
-        //        {
-        //            //类的唯一标识符
-        //            string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
-        //            //方法的唯一标识符
-        //            string MethodSN = "[TypeSns]";
-        //            //执行转发方法
-        //            return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", null) as List<string>;
-        //        }
-        //    }
-        //    return null;
-        //}
-
-        ///// <summary>
-        ///// 实例唯一标识符集合
-        ///// </summary>
-        //public static List<string>? InstanceSns()
-        //{
-        //    if (reflectionOperate != null)
-        //    {
-        //        //反射状态为true才进行操作
-        //        if (reflectionOperate.ReflectionState)
-        //        {
-        //            //类的唯一标识符
-        //            string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
-        //            //方法的唯一标识符
-        //            string MethodSN = "[InstanceSns]";
-        //            //执行转发方法
-        //            return reflectionOperate.ExecuteMethod($"{ClassSN}{MethodSN}", null) as List<string>;
-        //        }
-        //    }
-        //    return null;
-        //}
-
-        ///// <summary>
-        ///// 释放指定实例
-        ///// </summary>
-        ///// <param name="ISn">实例唯一标识符</param>
-        ///// <returns>统一出参</returns>
-        //public static OperateResult DisposeISn(string ISn)
-        //{
-        //    try
-        //    {
-        //        //反射状态为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} 不做此操作", 1);
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new OperateResult(false, $"转发事件注册异常:{ex.Message}", 1);
-        //    }
-        //}
-
-        ///// <summary>
-        ///// 移除指定实例
-        ///// </summary>
-        ///// <param name="ISn">实例唯一标识符</param>
-        ///// <returns>统一出参</returns>
-        //public static OperateResult RemoveISn(string ISn)
-        //{
-        //    try
-        //    {
-        //        //反射状态为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} 不做此操作", 1);
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new OperateResult(false, $"转发事件注册异常:{ex.Message}", 1);
-        //    }
-        //}
-
-        ///// <summary>
-        ///// 打开
-        ///// </summary>
-        ///// <param name="ISn">实例唯一标识符</param>
-        ///// <returns>统一出参</returns>
-        //public static OperateResult On(string ISn)
-        //{
-        //    try
-        //    {
-        //        //反射状态为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} 不做此操作", 1);
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new OperateResult(false, $"转发事件注册异常:{ex.Message}", 1);
-        //    }
-        //}
-
-        ///// <summary>
-        ///// 关闭
-        ///// </summary>
-        ///// <param name="ISn">实例唯一标识符</param>
-        ///// <returns>统一出参</returns>
-        //public static OperateResult Off(string ISn)
-        //{
-        //    try
-        //    {
-        //        //反射状态为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} 不做此操作", 1);
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new OperateResult(false, $"转发事件注册异常:{ex.Message}", 1);
-        //    }
-        //}
-
-        ///// <summary>
-        ///// 转发事件注册
-        ///// </summary>
-        ///// <returns></returns>
-        //public static OperateResult RelayEventRegister(Action<object, object> action, bool Register = true)
-        //{
-        //    try
-        //    {
-        //        //反射状态为true才进行操作
-        //        if (reflectionOperate.ReflectionState)
-        //        {
-        //            //类的唯一标识符
-        //            string ClassSN = "YSAI.RelayManage.RelayManageOperate[Instance]";
-        //            //事件的唯一标识符
-        //            string EventSN = "[OnEvent]";
-        //            //注册事件
-        //            return reflectionOperate.RegisterEvent($"{ClassSN}{EventSN}", Register, P2: action);
-        //        }
-        //        else
-        //        {
-        //            return new OperateResult(false, $"反射状态 {reflectionOperate.ReflectionState} 不做此操作", 1);
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new OperateResult(false, $"转发事件注册异常:{ex.Message}", 1);
-        //    }
-        //}
-    }
-}

+ 8 - 8
src/YSAI.VT/Program.cs

@@ -22,14 +22,14 @@ namespace YSAI.VT
 
                 "YSAI.Core",
 
-                "YSAI.Rpc",
-                "YSAI.Redis",
-
-                "YSAI.Kafka",
-                "YSAI.Mqtt",
-                "YSAI.NetMQ",
-                "YSAI.Netty",
-                "YSAI.RabbitMQ",
+                //"YSAI.Rpc",
+                //"YSAI.Redis",
+
+                //"YSAI.Kafka",
+                //"YSAI.Mqtt",
+                //"YSAI.NetMQ",
+                //"YSAI.Netty",
+                //"YSAI.RabbitMQ",
 
                 //"YSAI.AllenBradley",
                 //"YSAI.Beckhoff",