林豪 左 3 yıl önce
ebeveyn
işleme
7ab59a3253

+ 4 - 2
WCS.Core/Exception.cs → WCS.BaseExtensions/ExceptionExtension.cs

@@ -1,6 +1,8 @@
 using System;
+using System.Collections.Generic;
+using System.Text;
 
-namespace WCS.Service
+namespace WCS.BaseExtensions
 {
     /// <summary>
     /// 警告异常
@@ -68,4 +70,4 @@ namespace WCS.Service
         {
         }
     }
-}
+}

+ 1 - 1
WCS.BaseExtensions/Properties/PublishProfiles/FolderProfile.pubxml

@@ -8,6 +8,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
     <Platform>Any CPU</Platform>
     <PublishDir>D:\XM\Release\DLL</PublishDir>
     <PublishProtocol>FileSystem</PublishProtocol>
-    <VersionPrefix>1.0.0</VersionPrefix>
+    <VersionPrefix>1.0.1</VersionPrefix>
   </PropertyGroup>
 </Project>

+ 0 - 237
WCS.Core/Expands/TypeExtension.cs

@@ -1,237 +0,0 @@
-using Log;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Linq;
-using System.Reflection;
-using System.Security.Cryptography;
-
-namespace WCS.Core.Expands
-{
-    /// <summary>
-    ///
-    /// </summary>
-    public static class TypeExtension
-    {
-        /// <summary>
-        /// 将字符串转换为short
-        /// </summary>
-        /// <param name="value">需要转换的字符串</param>
-        /// <returns></returns>
-        public static short ToShort(this string value)
-        {
-            return Convert.ToInt16(value);
-        }
-
-        /// <summary>
-        /// 将int转换为short
-        /// </summary>
-        /// <param name="value">需要转换的字符串</param>
-        /// <returns></returns>
-        public static short ToShort(this int value)
-        {
-            return Convert.ToInt16(value);
-        }
-
-        /// <summary>
-        /// 将decimal转换为short
-        /// </summary>
-        /// <param name="value">需要转换的字符串</param>
-        /// <returns></returns>
-        public static short ToShort(this decimal value)
-        {
-            return Convert.ToInt16(value);
-        }
-
-        /// <summary>
-        /// 将字符串转换为int
-        /// </summary>
-        /// <param name="value">需要转换的字符串</param>
-        /// <returns></returns>
-        public static int ToInt(this string value)
-        {
-            return Convert.ToInt32(value);
-        }
-
-        /// <summary>
-        /// 判断值为奇数/偶数
-        /// </summary>
-        /// <param name="value">需要判断的值</param>
-        /// <returns> true:是奇数   false:是偶数</returns>
-        public static bool OddNumberOrEven(this short value)
-        {
-            return value % 2 != 0;
-        }
-
-        /// <summary>
-        /// 获取short类型Code,只限设备组
-        /// </summary>
-        /// <param name="value"></param>
-        /// <returns></returns>
-        public static short GetShortCode(this string value)
-        {
-            return value.Replace("G", "").ToShort();
-        }
-
-        /// <summary>
-        /// 数据映射
-        /// </summary>
-        /// <typeparam name="D"></typeparam>
-        /// <typeparam name="S"></typeparam>
-        /// <param name="s"></param>
-        /// <returns></returns>
-        public static D Mapper<D, S>(S s)
-        {
-            D d = Activator.CreateInstance<D>();
-
-            var sType = s.GetType();
-            var dType = typeof(D);
-            foreach (PropertyInfo sP in sType.GetProperties())
-            {
-                foreach (PropertyInfo dP in dType.GetProperties())
-                {
-                    if (dP.Name == sP.Name)
-                    {
-                        dP.SetValue(d, sP.GetValue(s));
-                        break;
-                    }
-                }
-            }
-            return d;
-        }
-
-        /// <summary>
-        /// 获取字典
-        /// </summary>
-        /// <typeparam name="T1"></typeparam>
-        /// <typeparam name="T2"></typeparam>
-        /// <typeparam name="T3"></typeparam>
-        /// <param name="t3"></param>
-        /// <returns></returns>
-        public static Dictionary<string, object> EntityClassToDictionary<T>(T t)
-        {
-            Type type = typeof(SugarColumn);
-            Dictionary<string, object> d = new Dictionary<string, object>();
-
-            var sType = t.GetType();
-            foreach (PropertyInfo sP in sType.GetProperties())
-            {
-                if (sP.CustomAttributes.Any(v => v.AttributeType == type) && sP.Name != "VER" && sP.Name != "ID")
-                {
-                    d.Add(sP.Name, sP.GetValue(t));
-                }
-            }
-
-            return d;
-        }
-
-        /// <summary>
-        /// 获取MD5字符串
-        /// </summary>
-        /// <param name="myString"></param>
-        /// <returns></returns>
-        public static string GetMD5(this string myString)
-        {
-            MD5 md5 = MD5.Create();
-            byte[] fromData = System.Text.Encoding.Unicode.GetBytes(myString);
-            byte[] targetData = md5.ComputeHash(fromData);
-            string byte2String = null;
-
-            for (int i = 0; i < targetData.Length; i++)
-            {
-                byte2String += targetData[i].ToString("x");
-            }
-
-            return byte2String;
-        }
-
-        /// <summary>
-        /// DataTable转换成实体类
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="dt"></param>
-        /// <returns></returns>
-        public static List<object> TableToEntity(this DataTable dt, string typeName)
-        {
-            List<object> list = new List<object>();
-            try
-            {
-                foreach (DataRow row in dt.Rows)
-                {
-                    Type entity = Type.GetType(typeName);
-                    PropertyInfo[] pArray = entity.GetType().GetProperties();
-
-                    foreach (PropertyInfo p in pArray)
-                    {
-                        if (dt.Columns.Contains(p.Name))
-                        {
-                            if (!p.CanWrite) continue;
-                            var value = row[p.Name];
-                            if (value != DBNull.Value)
-                            {
-                                Type targetType = p.PropertyType;
-                                Type convertType = targetType;
-                                if (targetType.IsGenericType && targetType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
-                                {
-                                    //可空类型
-                                    NullableConverter nullableConverter = new NullableConverter(targetType);
-                                    convertType = nullableConverter.UnderlyingType;
-                                }
-                                if (!string.IsNullOrEmpty(convertType.FullName) && !string.IsNullOrEmpty(value.ToString()))
-                                {
-                                    value = Convert.ChangeType(value, convertType);
-                                }
-                                switch (convertType.FullName)
-                                {
-                                    case "System.Decimal":
-                                        p.SetValue(entity, Convert.ToDecimal(value), null);
-                                        break;
-
-                                    case "System.String":
-                                        p.SetValue(entity, Convert.ToString(value), null);
-                                        break;
-
-                                    case "System.Int32":
-                                        p.SetValue(entity, Convert.ToInt32(value), null);
-                                        break;
-
-                                    case "System.Int64":
-                                        p.SetValue(entity, Convert.ToInt64(value), null);
-                                        break;
-
-                                    case "System.Int16":
-                                        p.SetValue(entity, Convert.ToInt16(value), null);
-                                        break;
-
-                                    case "System.Double":
-                                        p.SetValue(entity, Convert.ToDouble(value), null);
-                                        break;
-
-                                    case "System.Single":
-                                        p.SetValue(entity, Convert.ToSingle(value), null);
-                                        break;
-
-                                    case "System.DateTime":
-                                        p.SetValue(entity, Convert.ToDateTime(value), null);
-                                        break;
-
-                                    default:
-                                        p.SetValue(entity, value, null);
-                                        break;
-                                }
-                            }
-                        }
-                    }
-                    list.Add(entity);
-                }
-            }
-            catch (Exception ex)
-            {
-                InfoLog.INFO_ERROR("Table转换实体类失败:" + ex.Message);
-            }
-            return list;
-        }
-    }
-}

+ 1 - 2
WCS.Core/Properties/PublishProfiles/FolderProfile.pubxml

@@ -8,7 +8,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
     <Platform>Any CPU</Platform>
     <PublishDir>D:\XM\Release\DLL</PublishDir>
     <PublishProtocol>FileSystem</PublishProtocol>
-    <VersionPrefix>1.0.4</VersionPrefix>
-    <describe>新增类型扩展支持类型转换</describe>
+    <VersionPrefix>1.0.5</VersionPrefix>
   </PropertyGroup>
 </Project>

+ 1 - 0
WCS.Core/WCS.Core.csproj

@@ -4,6 +4,7 @@
     <TargetFramework>netstandard2.1</TargetFramework>
     <Nullable>enable</Nullable>
     <GenerateDocumentationFile>True</GenerateDocumentationFile>
+    <Description>核心包</Description>
   </PropertyGroup>
 
   <ItemGroup>

+ 1 - 1
WCS.Service/ProtocolProxy.cs

@@ -7,9 +7,9 @@ using System.Collections.Concurrent;
 using System.Diagnostics;
 using System.Linq.Dynamic.Core;
 using System.Reflection;
+using WCS.BaseExtensions;
 using WCS.Core;
 using WCS.Core.DataTrans;
-using WCS.Core.Expands;
 using WCS.Entity;
 using WCS.Entity.Protocol;
 

+ 1 - 1
WCS.Service/WCS.Service.csproj

@@ -25,7 +25,7 @@
     <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.8" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
-    <PackageReference Include="WCS.Core" Version="1.0.4" />
+    <PackageReference Include="WCS.Core" Version="1.0.5" />
     <PackageReference Include="WCS.Entity.Protocol" Version="1.0.1" />
     <PackageReference Include="WCS.Virtual_PLC" Version="1.0.0" />
   </ItemGroup>

+ 1 - 1
WCS.WebApi/APICaller.cs

@@ -1,4 +1,4 @@
-using Logs;
+using Log;
 using Newtonsoft.Json;
 using System;
 using System.Collections.Concurrent;

+ 2 - 0
WCS.WebApi/WCS.WebApi.csproj

@@ -9,6 +9,8 @@
     <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.8" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
+    <PackageReference Include="WCS.BaseExtensions" Version="1.0.1" />
+    <PackageReference Include="WCS.Core" Version="1.0.5" />
     <PackageReference Include="WCS.Entity.Protocol" Version="1.0.1" />
   </ItemGroup>
 

+ 1 - 1
WCS.WebApi/WCSApi.cs

@@ -1,4 +1,4 @@
-using DBHelper_SqlSugar;
+using DbHelper;
 using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Collections.Generic;

+ 3 - 1
WCS.WebApi/WMS/WMS.cs

@@ -1,8 +1,10 @@
-using Logs;
+using Log;
 using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using WCS.BaseExtensions;
+using WCS.Core;
 using WCS.Service.Entity;
 
 namespace WCS.Service