yukang.wu преди 11 месеца
родител
ревизия
a1876009d4

+ 0 - 56
Ys.Scada.Core/Channel/Consumer.cs

@@ -1,56 +0,0 @@
-//using System.Threading.Channels;
-//using Ys.Scada.Core.EventBus.Publisher;
-
-//namespace Ys.Scada.Core
-//{
-//    public interface IConsumer
-//    {
-//        Task ConsumeDataAsync(CancellationToken cancellationToken = default);
-//    }
-//    /// <summary>
-//    /// 入系统的历史数据库
-//    /// </summary>
-//    public class DataConsumer : IConsumer
-//    {
-//        private readonly IEventPublisher _eventPublisher;
-//        private readonly ChannelReader<PointData> _reader;
-//        public DataConsumer(ChannelReader<PointData> reader, IEventPublisher eventPublisher)
-//        {
-//            _reader = reader;
-//            _eventPublisher = eventPublisher;
-//        }
-//        public async Task ConsumeDataAsync(CancellationToken cancellationToken = default)
-//        {
-//            while (await _reader.WaitToReadAsync(cancellationToken))
-//            {
-//                if (_reader.TryRead(out var message))
-//                {
-//                    _eventPublisher.Publish(message);
-//                }
-//            }
-//        }
-//    }
-//    /// <summary>
-//    /// 内存队列消费者
-//    /// </summary>
-//    /// <typeparam name="T"></typeparam>
-//    public class Consumer : IConsumer
-//    {
-//        private readonly ChannelReader<GatherData> _reader;
- 
-//        public Consumer(ChannelReader<GatherData> reader)
-//        {
-//            _reader = reader;
-//        }
-//        public async Task ConsumeDataAsync(CancellationToken cancellationToken = default)
-//        {
-//            while (await _reader.WaitToReadAsync(cancellationToken))
-//            {
-//                if (_reader.TryRead(out var message))
-//                {
-                    
-//                }
-//            }
-//        }
-//    }
-//}

+ 0 - 3
Ys.Scada.Core/Channel/PointData.cs

@@ -1,3 +0,0 @@
-namespace Ys.Scada.Core
-{
-}

+ 0 - 13
Ys.Scada.Core/Common/IBoot.cs

@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Ys.Scada.Core.Common
-{
-    public interface IBoot
-    {
-        Task Excute();
-    }
-}

+ 0 - 79
Ys.Scada.Core/Common/ITypeFinder.cs

@@ -1,79 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Ys.Scada.Core.Common
-{
-    public class TypeFinder
-    {
-        public virtual IEnumerable<Type> FindClassesOfType<T>(IEnumerable<Assembly> assemblies)
-        {
-            return FindClassesOfType(typeof(T), assemblies) ;
-        }
-        public virtual IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, IEnumerable<Assembly> assemblies)
-        {
-            var result = new List<Type>();
-            try
-            {
-                foreach (var a in assemblies)
-                {
-                    Type[] types = null;
-                    try
-                    {
-                        types = a.GetTypes();
-                    }
-                    catch
-                    {
-                    }
-
-                    if (types == null)
-                        continue;
-
-                    foreach (var t in types)
-                    {
-                        if (!assignTypeFrom.IsAssignableFrom(t) && (!assignTypeFrom.IsGenericTypeDefinition || !DoesTypeImplementOpenGeneric(t, assignTypeFrom)))
-                            continue;
-
-                        if (t.IsInterface)
-                            continue;
-
-                        result.Add(t);
-                    }
-                }
-            }
-            catch (ReflectionTypeLoadException ex)
-            {
-                var msg = string.Empty;
-
-                if (ex.LoaderExceptions.Any())
-                    msg = ex.LoaderExceptions.Where(e => e != null)
-                        .Aggregate(msg, (current, e) => $"{current}{e.Message + Environment.NewLine}");
-
-                var fail = new Exception(msg, ex);
-                Debug.WriteLine(fail.Message, fail);
-
-                throw fail;
-            }
-
-            return result;
-        }
-        protected virtual bool DoesTypeImplementOpenGeneric(Type type, Type openGeneric)
-        {
-            try
-            {
-                var genericTypeDefinition = openGeneric.GetGenericTypeDefinition();
-                return type.FindInterfaces((_, _) => true, null)
-                    .Where(implementedInterface => implementedInterface.IsGenericType).Any(implementedInterface =>
-                        genericTypeDefinition.IsAssignableFrom(implementedInterface.GetGenericTypeDefinition()));
-            }
-            catch
-            {
-                return false;
-            }
-        }
-    }
-}

+ 2 - 12
Ys.Scada.Core/MQ/Headers.cs

@@ -8,17 +8,7 @@ namespace Ys.Scada.Core.MQ
 {
     public static class Headers
     {
-        public const string MessageId = "cap-msg-id";
-        public const string MessageName = "cap-msg-name";
-        public const string Group = "cap-msg-group";
-        public const string Type = "cap-msg-type";
-        public const string CorrelationId = "cap-corr-id";
-        public const string CorrelationSequence = "cap-corr-seq";
-        public const string CallbackName = "cap-callback-name";
-        public const string ExecutionInstanceId = "cap-exec-instance-id";
-        public const string SentTime = "cap-senttime";
-        public const string DelayTime = "cap-delaytime";
-        public const string Exception = "cap-exception";
-        public const string TraceParent = "traceparent";
+        public const string MessageId = "msg-id";
+        public const string Group = "msg-group";
     }
 }

+ 0 - 132
Ys.Scada.Core/MQ/Helper.cs

@@ -1,132 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Net;
-using System.Reflection;
-using System.Runtime.ExceptionServices;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-
-namespace Ys.Scada.Core.MQ
-{
-
-    public static class Helper
-    {
-        public static bool IsController(TypeInfo typeInfo)
-        {
-            if (!typeInfo.IsClass) return false;
-            if (typeInfo.IsAbstract) return false;
-            if (!typeInfo.IsPublic) return false;
-
-            if (typeInfo.ContainsGenericParameters) return false;
-
-            return !typeInfo.ContainsGenericParameters
-                   && typeInfo.Name.EndsWith("Controller", StringComparison.OrdinalIgnoreCase);
-        }
-
-        public static bool IsComplexType(Type type)
-        {
-            return !CanConvertFromString(type);
-        }
-
-        public static string WildcardToRegex(string wildcard)
-        {
-            if (wildcard.IndexOf('*') >= 0) return ("^" + wildcard + "$").Replace("*", "[0-9a-zA-Z]+").Replace(".", "\\.");
-
-            if (wildcard.IndexOf('#') >= 0)
-                return ("^" + wildcard.Replace(".", "\\.") + "$").Replace("#", "[0-9a-zA-Z\\.]+");
-
-            return wildcard;
-        }
-
-        public static string? GetInstanceHostname()
-        {
-            try
-            {
-                var hostName = Dns.GetHostName();
-                if (hostName.Length <= 50) return hostName;
-                return hostName.Substring(0, 50);
-            }
-            catch
-            {
-                return null;
-            }
-        }
-
-        public static string Normalized(string name)
-        {
-            if (string.IsNullOrEmpty(name)) return name;
-            var pattern = "[\\>\\.\\ \\*]";
-            return Regex.IsMatch(name, pattern) ? Regex.Replace(name, pattern, "_") : name;
-        }
-
-        public static bool IsUsingType<T>(in Type type)
-        {
-            var flags = BindingFlags.Public | BindingFlags.NonPublic |
-                        BindingFlags.Static | BindingFlags.Instance |
-                        BindingFlags.DeclaredOnly;
-            return type.GetFields(flags).Any(x => x.FieldType == typeof(T));
-        }
-
-        public static bool IsInnerIP(string ipAddress)
-        {
-            var ipNum = GetIpNum(ipAddress);
-
-            //Private IP:
-            //category A: 10.0.0.0-10.255.255.255
-            //category B: 172.16.0.0-172.31.255.255
-            //category C: 192.168.0.0-192.168.255.255  
-
-            var aBegin = GetIpNum("10.0.0.0");
-            var aEnd = GetIpNum("10.255.255.255");
-            var bBegin = GetIpNum("172.16.0.0");
-            var bEnd = GetIpNum("172.31.255.255");
-            var cBegin = GetIpNum("192.168.0.0");
-            var cEnd = GetIpNum("192.168.255.255");
-            return IsInner(ipNum, aBegin, aEnd) || IsInner(ipNum, bBegin, bEnd) || IsInner(ipNum, cBegin, cEnd);
-        }
-
-        private static long GetIpNum(string ipAddress)
-        {
-            var ip = ipAddress.Split('.');
-            long a = int.Parse(ip[0]);
-            long b = int.Parse(ip[1]);
-            long c = int.Parse(ip[2]);
-            long d = int.Parse(ip[3]);
-
-            var ipNum = a * 256 * 256 * 256 + b * 256 * 256 + c * 256 + d;
-            return ipNum;
-        }
-
-        private static bool IsInner(long userIp, long begin, long end)
-        {
-            return userIp >= begin && userIp <= end;
-        }
-
-        private static bool CanConvertFromString(Type destinationType)
-        {
-            destinationType = Nullable.GetUnderlyingType(destinationType) ?? destinationType;
-            return IsSimpleType(destinationType) ||
-                   TypeDescriptor.GetConverter(destinationType).CanConvertFrom(typeof(string));
-        }
-
-        private static bool IsSimpleType(Type type)
-        {
-            return type.GetTypeInfo().IsPrimitive ||
-                   type == typeof(decimal) ||
-                   type == typeof(string) ||
-                   type == typeof(DateTime) ||
-                   type == typeof(Guid) ||
-                   type == typeof(DateTimeOffset) ||
-                   type == typeof(TimeSpan) ||
-                   type == typeof(Uri);
-        }
-
-        internal static void ReThrow(this Exception exception)
-        {
-            ExceptionDispatchInfo.Capture(exception).Throw();
-        }
-    }
-}

+ 0 - 13
Ys.Scada.Core/MQ/IConsumerClientFactory.cs

@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Ys.Scada.Core.MQ
-{
-    public interface IConsumerClientFactory
-    {
-        IConsumerClient Create();
-    }
-}

+ 0 - 15
Ys.Scada.Core/PageDataInput.cs

@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Ys.Scada.Core
-{
-    public class PageDataInput
-    {
-        public int PageIndex { get; set; }
-        public int PageSize { get; set; }
-    }
-}