Sfoglia il codice sorgente

内部调用时,手动添加url前缀 "http://sers.internal"
ApiClient调用api时,route自动剔除search(?以及后面的字符串),并根据url query构建body

lith 5 anni fa
parent
commit
3d059fe150
45 ha cambiato i file con 248 aggiunte e 80 eliminazioni
  1. 10 1
      dotnet/Doc/UpgradeLog/Sers2.1.1.txt
  2. 1 1
      dotnet/Sers/ApiLoader/Sers.NetcoreLoader/Sers.NetcoreLoader.csproj
  3. 7 3
      dotnet/Sers/ApiLoader/Sers.Serslot/Extensions/SerslotServer_ProcessRequest_Extensions.cs
  4. 1 1
      dotnet/Sers/ApiLoader/Sers.Serslot/Sers.Serslot.csproj
  5. 1 1
      dotnet/Sers/Sers.CL/Ipc/Sers.CL.Ipc.SharedMemory/Sers.CL.Ipc.SharedMemory.csproj
  6. 1 1
      dotnet/Sers/Sers.CL/Socket/Sers.CL.Socket.Iocp/Sers.CL.Socket.Iocp.csproj
  7. 1 1
      dotnet/Sers/Sers.CL/Socket/Sers.CL.Socket.ThreadWait/Sers.CL.Socket.ThreadWait.csproj
  8. 1 1
      dotnet/Sers/Sers.CL/WebSocket/Sers.CL.WebSocket/Sers.CL.WebSocket.csproj
  9. 1 1
      dotnet/Sers/Sers.CL/Zmq/FullDuplex/Sers.CL.Zmq.FullDuplex/Sers.CL.Zmq.FullDuplex.csproj
  10. 1 1
      dotnet/Sers/Sers.CL/Zmq/ThreadWait/Sers.CL.ClrZmq.ThreadWait/Sers.CL.ClrZmq.ThreadWait.csproj
  11. 1 1
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiClient.cs
  12. 19 2
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/Rpc/Extendsions/IRpcContextDataExtensions.cs
  13. 60 6
      dotnet/Sers/Sers.Core/Sers.Core/Module/Message/Extendsions/ApiMessageExtensions.cs
  14. 1 1
      dotnet/Sers/Sers.Core/Sers.Core/Sers.Core.csproj
  15. 2 2
      dotnet/Sers/Sers.Core/Sers.Core/SersLoader/LocalApiNode.cs
  16. 0 1
      dotnet/Sers/Sers.Gateway/Sers.Gateway/GatewayHelp.cs
  17. 1 1
      dotnet/Sers/Sers.Gateway/Sers.Gateway/Sers.Gateway.csproj
  18. 1 1
      dotnet/Sers/Sers.Hardware/Sers.Hardware/Sers.Hardware.csproj
  19. 1 1
      dotnet/Sers/Sers.Ioc/Sers.Ioc/Sers.Ioc.csproj
  20. 11 1
      dotnet/Sers/Sers.ServiceCenter/Sers.Gover/Base/ApiLoadBalancingMng_RESTful.cs
  21. 1 2
      dotnet/Sers/Sers.ServiceCenter/Sers.Gover/Base/GoverManage.cs
  22. 1 1
      dotnet/Sers/Sers.ServiceStation/Sers.ServiceStation/Sers.ServiceStation.csproj
  23. 1 1
      dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/Did.SersLoader.Demo.csproj
  24. 1 1
      dotnet/StationDemo/SersLoader/Did.SersLoader.HelloWorld/Did.SersLoader.HelloWorld.csproj
  25. 1 1
      dotnet/Vit/Vit.Core/Test/Vit.Core.MsTest/Util/ComponentModel/ExceptionTest.cs
  26. 7 1
      dotnet/Vit/Vit.Core/Vit.Core/Extensions/byte/ArraySegmentByteExtensions.cs
  27. 1 2
      dotnet/Vit/Vit.Core/Vit.Core/Module/Log/LogMng.cs
  28. 47 15
      dotnet/Vit/Vit.Core/Vit.Core/Util/ComponentModel/SsError/Extensions/ExceptionExtensions.cs
  29. 31 0
      dotnet/Vit/Vit.Core/Vit.Core/Util/ComponentModel/SsError/Extensions/SsErrorExtensions.cs
  30. 1 1
      dotnet/Vit/Vit.Core/Vit.Core/Util/ComponentModel/SsError/SsError.cs
  31. 1 1
      dotnet/Vit/Vit.Core/Vit.Core/Util/ComponentModel/SsError/SsException.cs
  32. 17 7
      dotnet/Vit/Vit.Core/Vit.Core/Util/Net/HttpClient.cs
  33. 2 3
      dotnet/Vit/Vit.Core/Vit.Core/Util/Threading/LongTaskHelp.cs
  34. 2 4
      dotnet/Vit/Vit.Core/Vit.Core/Util/Threading/LongTaskHelp_TimeLimit.cs
  35. 2 2
      dotnet/Vit/Vit.Core/Vit.Core/Util/Threading/RepeatTaskHelp.cs
  36. 1 1
      dotnet/Vit/Vit.Core/Vit.Core/Vit.Core.csproj
  37. 1 0
      dotnet/Vit/Vit.Ioc/Test/Vit.Ioc.MsTest/IocHelpTest.cs
  38. 1 1
      dotnet/Vit/Vit.Ioc/Vit.Ioc/Vit.Ioc.csproj
  39. 1 1
      dotnet/Vit/Vit.Net.Http.FormFile/Vit.Net.Http.FormFile.csproj
  40. 1 1
      dotnet/Vit/Vit.WebHost/Vit.WebHost.csproj
  41. 1 1
      dotnet/netcore/Gateway/App.Gateway/App.Gateway.csproj
  42. 1 1
      dotnet/netcore/ServiceCenter/App.Gover.Gateway/App.Gover.Gateway.csproj
  43. 1 1
      dotnet/netcore/ServiceCenter/App.ServiceCenter/App.ServiceCenter.csproj
  44. 1 1
      dotnet/netcore/Station/App.Ioc.Station/App.Ioc.Station.csproj
  45. 1 1
      dotnet/netcore/Station/App.Robot.Station/App.Robot.Station.csproj

+ 10 - 1
dotnet/Doc/UpgradeLog/Sers2.1.1.txt

@@ -53,4 +53,13 @@ ServiceStationUnqueKey 
 [tag]Sers2.1.1.281
 ------------------------------------------------------------------------------------------------------------------
 [2020-03-01]
-修复SsRpcVerify
+修复SsRpcVerify
+
+[tag]Sers2.1.1.290
+------------------------------------------------------------------------------------------------------------------
+[2020-03-02]
+内部调用时,手动添加url前缀 "http://sers.internal"
+ApiClient调用api时,route自动剔除search(?以及后面的字符串),并根据url query构建body
+
+[tag]Sers2.1.1.291
+------------------------------------------------------------------------------------------------------------------

+ 1 - 1
dotnet/Sers/ApiLoader/Sers.NetcoreLoader/Sers.NetcoreLoader.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 7 - 3
dotnet/Sers/ApiLoader/Sers.Serslot/Extensions/SerslotServer_ProcessRequest_Extensions.cs

@@ -42,10 +42,14 @@ namespace Vit.Extensions
                 };
 
                 #region http header
-                foreach (var t in rpcData.http_headers_Get())
+                var headers = rpcData.http_headers_Get();
+                if (headers != null)
                 {
-                    requestFeature.Headers.Add(t.Key, t.Value.ConvertToString());
-                }
+                    foreach (var t in headers)
+                    {
+                        requestFeature.Headers.Add(t.Key, t.Value.ConvertToString());
+                    }
+                }                 
                 #endregion
 
                 //var requestFeature = new HttpRequestFeature

+ 1 - 1
dotnet/Sers/ApiLoader/Sers.Serslot/Sers.Serslot.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/Ipc/Sers.CL.Ipc.SharedMemory/Sers.CL.Ipc.SharedMemory.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/Socket/Sers.CL.Socket.Iocp/Sers.CL.Socket.Iocp.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/Socket/Sers.CL.Socket.ThreadWait/Sers.CL.Socket.ThreadWait.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/WebSocket/Sers.CL.WebSocket/Sers.CL.WebSocket.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.CL/Zmq/FullDuplex/Sers.CL.Zmq.FullDuplex/Sers.CL.Zmq.FullDuplex.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
   

+ 1 - 1
dotnet/Sers/Sers.CL/Zmq/ThreadWait/Sers.CL.ClrZmq.ThreadWait/Sers.CL.ClrZmq.ThreadWait.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
   

+ 1 - 1
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiClient.cs

@@ -67,7 +67,7 @@ namespace Sers.Core.Module.Api
                 var reply = CallApi(request.Package());
                 if (null == reply || reply.Count == 0)
                 {
-                    //Logger.Error(new Exception().SsError_Set(SsError.Err_Timeout));
+                    //Logger.Error(SsError.Err_Timeout.ToException());
                     //返回请求超时,无回应数据
                     return new ApiMessage().InitAsApiReplyMessageByError(SsError.Err_Timeout);
                 }

+ 19 - 2
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/Rpc/Extendsions/IRpcContextDataExtensions.cs

@@ -211,15 +211,27 @@ namespace Vit.Extensions
 
 
         #region http_url
+        /// <summary>
+        /// 若为内部调用,在调用时构建的url前缀为  "http://sers.internal"。
+        /// 如 "http://sers.internal/Station1/getName"
+        /// </summary>
+        /// <param name="data"></param>
+        /// <returns></returns>
         public static String http_url_Get(this IRpcContextData data)
         {
             return data?.oriJson?["http"]?["url"]?.ConvertToString();
         }
 
-        public static void http_url_Set(this IRpcContextData data, String value)
+        /// <summary>
+        /// 若为内部调用,手动添加url前缀 "http://sers.internal"。
+        /// 如 "http://sers.internal/Station1/getName"
+        /// </summary>
+        /// <param name="data"></param>
+        /// <param name="url"></param>
+        public static void http_url_Set(this IRpcContextData data, String url)
         {
             if (null == data) return;
-            data.oriJson.GetOrCreateJObject("http")["url"] = value;
+            data.oriJson.GetOrCreateJObject("http")["url"] = url;
         }
         #endregion
 
@@ -344,6 +356,11 @@ namespace Vit.Extensions
         #endregion      
 
         #region http_headers
+        /// <summary>
+        /// 若没指定headers则返回null
+        /// </summary>
+        /// <param name="data"></param>
+        /// <returns></returns>
         public static JObject http_headers_Get(this IRpcContextData data)
         {
             return data?.oriJson?.JTokenGetByPath("http", "headers") as JObject;

+ 60 - 6
dotnet/Sers/Sers.Core/Sers.Core/Module/Message/Extendsions/ApiMessageExtensions.cs

@@ -3,6 +3,7 @@ using System;
 using Sers.Core.Module.Message;
 using Vit.Core.Util.ComponentModel.Data;
 using Vit.Core.Util.ComponentModel.SsError;
+using Newtonsoft.Json.Linq;
 
 namespace Vit.Extensions
 {
@@ -36,19 +37,72 @@ namespace Vit.Extensions
         /// 
         /// </summary>
         /// <param name="apiRequestMessage"></param>
-        /// <param name="route"></param>
+        /// <param name="url"> /api/cotrollers1/value?name=lith </param>
         /// <param name="arg"></param>
         /// <param name="httpMethod">可为 GET、POST、DELETE、PUT等,可不指定</param>
         /// <returns></returns>
-        public static ApiMessage InitAsApiRequestMessage(this ApiMessage apiRequestMessage, string route, Object arg=null,string httpMethod=null)
-        {
-            apiRequestMessage.value_OriData = arg.SerializeToArraySegmentByte();
+        public static ApiMessage InitAsApiRequestMessage(this ApiMessage apiRequestMessage, string url, Object arg=null,string httpMethod=null)
+        {   
 
             var rpcData = RpcFactory.Instance.CreateRpcContextData().InitFromRpcContext();
 
-            rpcData.route = route;
-            rpcData.http_url_Set(route);
+            //(x.1)设置url
+            rpcData.http_url_Set("http://sers.internal" + url);
+
+            //问号的位置
+            var queryIndex = url.IndexOf('?');
+
+            #region (x.2)设置route
+            //去除query string(url ?后面的字符串)           
+            {
+                // b2?a=c
+                if (queryIndex >= 0)
+                {
+                    rpcData.route = url.Substring(0, queryIndex);
+                }
+                else
+                {
+                    rpcData.route = url;
+                }
+            }
+            #endregion
+
+            #region (x.3)设置body
+            {
+                ArraySegment<byte> bodyData;
+                if (arg != null && (bodyData = arg.SerializeToArraySegmentByte()).HasData())
+                {
+                    apiRequestMessage.value_OriData = bodyData;
+                }
+                else 
+                {
+                    //从 query获取数据
+                    if (queryIndex >= 0)
+                    {
+                        try
+                        {
+                            // ?a=1&b=2
+                            var query = url.Substring(queryIndex );
+                            var kvs = System.Web.HttpUtility.ParseQueryString(query);
+
+                            JObject data = new JObject();
+                            foreach (string key in kvs)
+                            {
+                                var value = kvs.Get(key);
+                                data[key] = value;
+                            }
+                            apiRequestMessage.value_OriData = data.SerializeToArraySegmentByte();
+                        }
+                        catch (Exception ex)
+                        {                           
+                        }                       
+                    }
+                }
+                
+            }
+            #endregion
 
+                       
             if (httpMethod != null) rpcData.http_method_Set(httpMethod);
 
 

+ 1 - 1
dotnet/Sers/Sers.Core/Sers.Core/Sers.Core.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 2 - 2
dotnet/Sers/Sers.Core/Sers.Core/SersLoader/LocalApiNode.cs

@@ -19,7 +19,7 @@ namespace Sers.SersLoader
         public LocalApiNode(SsApiDesc apiDesc,  MethodInfo apiController_Method,Object apiController_Obj)
         {
             this.apiDesc = apiDesc;
-            this.apiController_Method = apiController_Method;
+            //this.apiController_Method = apiController_Method;
             this.apiController_Obj = apiController_Obj;
             executor = new DynamicMethodExecutor(apiController_Method);
         }
@@ -42,7 +42,7 @@ namespace Sers.SersLoader
         #region apiController        
 
         //private Type apiController_Type;
-        MethodInfo apiController_Method;
+        //MethodInfo apiController_Method;
         Object apiController_Obj;
         #endregion
 

+ 0 - 1
dotnet/Sers/Sers.Gateway/Sers.Gateway/GatewayHelp.cs

@@ -293,7 +293,6 @@ namespace Sers.Gateway
             if (null != replyRpcData)
             {
                 var joHeaders=replyRpcData.http_headers_Get();
-
                 if (null != joHeaders)
                 {
                     foreach (var item in joHeaders)

+ 1 - 1
dotnet/Sers/Sers.Gateway/Sers.Gateway/Sers.Gateway.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.Hardware/Sers.Hardware/Sers.Hardware.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Sers/Sers.Ioc/Sers.Ioc/Sers.Ioc.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 11 - 1
dotnet/Sers/Sers.ServiceCenter/Sers.Gover/Base/ApiLoadBalancingMng_RESTful.cs

@@ -35,7 +35,17 @@ namespace Sers.Gover.Base
             var method= rpcData.http_method_Get()?.ToUpper();
             if (string.IsNullOrEmpty(method)) method = "_";
 
-            var oriRoute = rpcData.route;
+            var oriRoute = rpcData.route;          
+            #region 去除query string(url ?后面的字符串)           
+            //{
+            //    // b2?a=c
+            //    var index = oriRoute.IndexOf('?');
+            //    if (index >= 0) 
+            //    {
+            //        oriRoute = oriRoute.Substring(0, index);
+            //    }
+            //}
+            #endregion
 
             var route = "/"+method + oriRoute;
             var lb = routeMap.Routing(route, out routeType);

+ 1 - 2
dotnet/Sers/Sers.ServiceCenter/Sers.Gover/Base/GoverManage.cs

@@ -15,7 +15,6 @@ using Sers.ServiceCenter.ApiCenter;
 using Sers.ServiceCenter.Entity;
 using Vit.Core.Module.Log;
 using Vit.Core.Util.ComponentModel.SsError;
-using Vit.Core.Util.ComponentModel.SsError.Extensions;
 using Vit.Core.Util.ConfigurationManager;
 using Vit.Extensions;
 
@@ -204,7 +203,7 @@ namespace Sers.Gover.Base
             {
                 Logger.Error(ex);
 
-                ApiSysError.LogSysError(rpcData, requestMessage, ex.SsError_Get());
+                ApiSysError.LogSysError(rpcData, requestMessage, ex.ToSsError());
  
                 SendReply(SsError.Err_SysErr);
                 return;

+ 1 - 1
dotnet/Sers/Sers.ServiceStation/Sers.ServiceStation/Sers.ServiceStation.csproj

@@ -3,7 +3,7 @@
  
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/Did.SersLoader.Demo.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>

+ 1 - 1
dotnet/StationDemo/SersLoader/Did.SersLoader.HelloWorld/Did.SersLoader.HelloWorld.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Vit/Vit.Core/Test/Vit.Core.MsTest/Util/ComponentModel/ExceptionTest.cs

@@ -1,6 +1,6 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Vit.Core.Util.ComponentModel.SsError;
-using Vit.Core.Util.ComponentModel.SsError.Extensions;
+using Vit.Extensions;
 
 namespace Vit.Core.MsTest.Util.ComponentModel
 {

+ 7 - 1
dotnet/Vit/Vit.Core/Vit.Core/Extensions/byte/ArraySegmentByteExtensions.cs

@@ -12,7 +12,13 @@ namespace Vit.Extensions
         //    return new ArraySegment<T>(new T[0], 0,0);
         //}
 
-        
+        public static bool HasData<T>(this ArraySegment<T> seg)
+        {
+            return seg!=null && seg.Array!=null && seg.Count>0;
+        }
+
+
+
         internal static void CopyTo<T>(this ArraySegment<T> seg,T[] bytes,int curIndex=0)
         {
             Array.Copy(seg.Array, seg.Offset, bytes, curIndex, seg.Count); 

+ 1 - 2
dotnet/Vit/Vit.Core/Vit.Core/Module/Log/LogMng.cs

@@ -3,7 +3,6 @@ using System;
 using System.IO;
 using System.Linq;
 using Vit.Core.Util.ComponentModel.SsError;
-using Vit.Core.Util.ComponentModel.SsError.Extensions;
 
 namespace Vit.Core.Module.Log
 {
@@ -186,7 +185,7 @@ namespace Vit.Core.Module.Log
             if (null != ex)
             {
                 ex = ex.GetBaseException();
-                var ssError = ex.SsError_Get().Serialize();
+                var ssError = ex.ToSsError().Serialize();
                 //if (!string.IsNullOrWhiteSpace(ssError))
                 strMsg += Environment.NewLine + " ssError:" + ssError;
                 strMsg += Environment.NewLine + " StackTrace:" + ex.StackTrace;

+ 47 - 15
dotnet/Vit/Vit.Core/Vit.Core/Util/ComponentModel/SsError/Extensions/ExceptionExtensions.cs

@@ -1,14 +1,21 @@
 using System;
 using Newtonsoft.Json.Linq;
+using Vit.Core.Util.ComponentModel.SsError;
 using Vit.Extensions;
 
-namespace Vit.Core.Util.ComponentModel.SsError.Extensions
+namespace Vit.Extensions
 {
     public static partial class ExceptionExtensions 
     {
         #region Data
 
-
+        /// <summary>
+        /// SsError
+        /// </summary>
+        /// <typeparam name="Type"></typeparam>
+        /// <param name="ex"></param>
+        /// <param name="key"></param>
+        /// <param name="data"></param>
         public static void Data_Set<Type>(this Exception ex, string key,Type data)
         {
             if (ex == null)
@@ -19,6 +26,13 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
         }
 
 
+        /// <summary>
+        /// SsError
+        /// </summary>
+        /// <typeparam name="Type"></typeparam>
+        /// <param name="ex"></param>
+        /// <param name="key"></param>
+        /// <returns></returns>
         public static Type Data_Get<Type>(this Exception ex, string key)
         {
             if (ex == null)
@@ -32,12 +46,23 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
 
         #region ErrorCode
 
+        /// <summary>
+        /// SsError
+        /// </summary>
+        /// <param name="ex"></param>
+        /// <param name="ErrorCode"></param>
+        /// <returns></returns>
         public static Exception ErrorCode_Set(this Exception ex,int? ErrorCode)
         {
             ex.Data_Set("ErrorCode", ErrorCode);
             return ex;
         }
 
+        /// <summary>
+        /// SsError
+        /// </summary>
+        /// <param name="ex"></param>
+        /// <returns></returns>
         public static int? ErrorCode_Get(this Exception ex)
         {
             return ex.Data_Get<int?>("ErrorCode");
@@ -47,6 +72,12 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
 
         #region ErrorMessage
 
+        /// <summary>
+        /// SsError
+        /// </summary>
+        /// <param name="ex"></param>
+        /// <param name="ErrorMessage"></param>
+        /// <returns></returns>
         public static Exception ErrorMessage_Set(this Exception ex, string ErrorMessage)
         {
             ex.Data_Set("ErrorMessage", ErrorMessage);
@@ -62,7 +93,7 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
 
         #region ErrorTag
         /// <summary>
-        /// 自定义ErrorTag格式。每处ErrorTag建议唯一。建议格式为 日期_作者缩写_自定义序号,例如:"150721_lith_1"
+        /// SsError。自定义ErrorTag。每处ErrorTag建议唯一。建议格式为 日期_作者缩写_自定义序号,例如:"150721_lith_1"
         /// </summary>
         /// <param name="ex"></param>
         /// <param name="ErrorTag"></param>
@@ -73,7 +104,7 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
         }
 
         /// <summary>
-        /// 自定义ErrorTag格式。每处ErrorTag建议唯一。建议格式为 日期_作者缩写_自定义序号,例如:"150721_lith_1"
+        /// SsError。自定义ErrorTag。每处ErrorTag建议唯一。建议格式为 日期_作者缩写_自定义序号,例如:"150721_lith_1"
         /// </summary>
         /// <param name="ex"></param>
         /// <returns></returns>
@@ -86,7 +117,7 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
 
         #region ErrorDetail
         /// <summary>
-        /// 设置ErrorDetail
+        /// SsError。设置ErrorDetail
         /// </summary>
         /// <param name="ex"></param>
         /// <param name="ErrorDetail"></param>
@@ -96,7 +127,7 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
             return ex;
         }
         /// <summary>
-        /// 获取ErrorDetail,可能为null
+        /// SsError。获取ErrorDetail,可能为null
         /// </summary>
         /// <param name="ex"></param>
         /// <returns></returns>
@@ -108,7 +139,7 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
 
         #region ErrorDetail
         /// <summary>
-        /// 设置ErrorDetail的属性值。若ErrorDetail为null,则会自动创建
+        /// SsError。设置ErrorDetail的属性值。若ErrorDetail为null,则会自动创建
         /// </summary>
         /// <param name="ex"></param>
         /// <param name="key"></param>
@@ -127,7 +158,7 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
         }
 
         /// <summary>
-        /// 获取ErrorDetail的属性值
+        /// SsError。获取ErrorDetail的属性值
         /// </summary>
         /// <param name="ex"></param>
         /// <param name="key"></param>
@@ -142,23 +173,24 @@ namespace Vit.Core.Util.ComponentModel.SsError.Extensions
 
         #region SsError
         /// <summary>
-        /// 
+        /// SsError
         /// </summary>
         /// <param name="ex"></param>
-        /// <param name="key"></param>
-        /// <param name="value"></param>
+        /// <param name="ssError"></param>
+        /// <returns></returns>
 
         public static Exception SsError_Set(this Exception ex, SsError ssError)
-        {            
-            return ssError.SetErrorToException(ex);
+        {
+            ssError?.SetErrorToException(ex);
+            return ex;
         }
 
         /// <summary>
-        /// 
+        /// SsError
         /// </summary>
         /// <param name="ex"></param>
         /// <returns></returns>
-        public static SsError SsError_Get(this Exception ex)
+        public static SsError ToSsError(this Exception ex)
         {
             return new SsError().LoadFromException(ex);
         }

+ 31 - 0
dotnet/Vit/Vit.Core/Vit.Core/Util/ComponentModel/SsError/Extensions/SsErrorExtensions.cs

@@ -0,0 +1,31 @@
+using System;
+using Newtonsoft.Json.Linq;
+using Vit.Core.Util.ComponentModel.SsError;
+using Vit.Extensions;
+
+namespace Vit.Extensions
+{
+    public static partial class SsErrorExtensions 
+    {
+
+
+
+        #region ToException
+        /// <summary>
+        /// error可为null(若为null,则返回空Exception)
+        /// </summary>
+        /// <param name="error"></param>
+        /// <param name="message"></param>
+        /// <returns></returns>
+        public static Exception ToException(this SsError error,string message=null)
+        {
+            var ex = new Exception(message??"Error");
+            error?.SetErrorToException(ex);
+            return ex;            
+        }
+      
+        #endregion
+
+
+    }
+}

+ 1 - 1
dotnet/Vit/Vit.Core/Vit.Core/Util/ComponentModel/SsError/SsError.cs

@@ -2,7 +2,7 @@
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using Vit.Core.Util.ComponentModel.Model;
-using Vit.Core.Util.ComponentModel.SsError.Extensions;
+using Vit.Extensions;
 
 namespace Vit.Core.Util.ComponentModel.SsError
 {

+ 1 - 1
dotnet/Vit/Vit.Core/Vit.Core/Util/ComponentModel/SsError/SsException.cs

@@ -1,6 +1,6 @@
 using System;
 using Newtonsoft.Json.Linq;
-using Vit.Core.Util.ComponentModel.SsError.Extensions;
+using Vit.Extensions;
 
 namespace Vit.Core.Util.ComponentModel.SsError
 {

+ 17 - 7
dotnet/Vit/Vit.Core/Vit.Core/Util/Net/HttpClient.cs

@@ -171,7 +171,21 @@ namespace Vit.Core.Util.Net
                 if (buff.Length > 0) buff.Length--;
                 return buff.ToString();
             }
-            else if (parameters is JObject joParameters)
+            else if (parameters is JObject jo)
+            {
+                return FormatJObject(jo);
+                
+            }
+            else if (parameters is string)
+            {
+                return (string)parameters;
+            }
+
+            return FormatJObject(parameters.ConvertBySerialize<JObject>());
+
+
+            #region FormatJObject
+            string FormatJObject(JObject joParameters) 
             {
                 StringBuilder buff = new StringBuilder();
                 foreach (var kv in joParameters)
@@ -181,11 +195,7 @@ namespace Vit.Core.Util.Net
                 if (buff.Length > 0) buff.Length--;
                 return buff.ToString();
             }
-            else if (parameters is string)
-            {
-                return (string)parameters;
-            }
-            throw new Exception("Url_BuildParam,不支持的url参数格式[" + parameters.GetType().Name + "]");
+            #endregion 
         }
         #endregion
 
@@ -245,7 +255,7 @@ namespace Vit.Core.Util.Net
         /// </summary>
         public string httpMethod;
         /// <summary>
-        /// 放到url中的参数。可为string、IDictionary、JObject
+        /// 放到url中的参数。可为string、IDictionary、JObject。若为其他类型则自动转换为JObject在进行处理
         /// </summary>
         public Object urlParams;
 

+ 2 - 3
dotnet/Vit/Vit.Core/Vit.Core/Util/Threading/LongTaskHelp.cs

@@ -3,7 +3,6 @@ using System.Threading;
 using Vit.Extensions;
 using Vit.Core.Module.Log;
 using Vit.Core.Util.ComponentModel.SsError;
-using Vit.Core.Util.ComponentModel.SsError.Extensions;
 
 namespace Vit.Core.Util.Threading
 {
@@ -38,7 +37,7 @@ namespace Vit.Core.Util.Threading
             get => _threadCount;
             set
             {
-                if (IsRunning) throw new Exception().SsError_Set(Error_CannotChangeThreadCountWhileRunning);
+                if (IsRunning) throw Error_CannotChangeThreadCountWhileRunning.ToException();
                 _threadCount = value;
                 if (_threadCount > 0)
                     semaphore = new Semaphore(_threadCount, _threadCount);
@@ -131,7 +130,7 @@ namespace Vit.Core.Util.Threading
         {
             if (IsRunning)
             {
-                throw new Exception().SsError_Set(LongTaskHelp.Error_CannotStartWhileRunning);
+                throw LongTaskHelp.Error_CannotStartWhileRunning.ToException();
             }
             if (threadCount <=0)
             {

+ 2 - 4
dotnet/Vit/Vit.Core/Vit.Core/Util/Threading/LongTaskHelp_TimeLimit.cs

@@ -1,9 +1,7 @@
 using System;
 using System.Threading;
-using System.Linq;
 using Vit.Extensions;
 using Vit.Core.Module.Log;
-using Vit.Core.Util.ComponentModel.SsError.Extensions;
 
 namespace Vit.Core.Util.Threading
 {
@@ -38,7 +36,7 @@ namespace Vit.Core.Util.Threading
             get => _threadCount;
             set
             {
-                if (IsRunning) throw new Exception().SsError_Set(LongTaskHelp.Error_CannotChangeThreadCountWhileRunning);
+                if (IsRunning) throw LongTaskHelp.Error_CannotChangeThreadCountWhileRunning.ToException();
                 _threadCount = value;
                 if (_threadCount > 0)
                     semaphore = new Semaphore(_threadCount, _threadCount);
@@ -117,7 +115,7 @@ namespace Vit.Core.Util.Threading
         {
             if (IsRunning)
             {
-                throw new Exception().SsError_Set(LongTaskHelp.Error_CannotStartWhileRunning);
+                throw LongTaskHelp.Error_CannotStartWhileRunning.ToException();
             }
             if (threadCount <=0)
             {

+ 2 - 2
dotnet/Vit/Vit.Core/Vit.Core/Util/Threading/RepeatTaskHelp.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Threading;
 using Vit.Core.Module.Log;
-using Vit.Core.Util.ComponentModel.SsError.Extensions;
+using Vit.Extensions;
 
 namespace Vit.Core.Util.Threading
 {
@@ -122,7 +122,7 @@ namespace Vit.Core.Util.Threading
         {
             if (IsRunning)
             {
-                throw new Exception().SsError_Set(LongTaskHelp.Error_CannotStartWhileRunning);
+                throw LongTaskHelp.Error_CannotStartWhileRunning.ToException();
             }
 
             sendStopSignal = false;

+ 1 - 1
dotnet/Vit/Vit.Core/Vit.Core/Vit.Core.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 0
dotnet/Vit/Vit.Ioc/Test/Vit.Ioc.MsTest/IocHelpTest.cs

@@ -21,6 +21,7 @@ namespace Vit.Ioc.MsTest
         {            
             //(x.1)Singleton
             IocHelp.AddSingleton<InterfaceA, ClassA>();
+            IocHelp.Update();
             var obj0_1 = IocHelp.Create<InterfaceA>();
             var obj0_1_HashCode = obj0_1.GetHashCode();
 

+ 1 - 1
dotnet/Vit/Vit.Ioc/Vit.Ioc/Vit.Ioc.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Vit/Vit.Net.Http.FormFile/Vit.Net.Http.FormFile.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Vit/Vit.WebHost/Vit.WebHost.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/netcore/Gateway/App.Gateway/App.Gateway.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/netcore/ServiceCenter/App.Gover.Gateway/App.Gover.Gateway.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/netcore/ServiceCenter/App.ServiceCenter/App.ServiceCenter.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/netcore/Station/App.Ioc.Station/App.Ioc.Station.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/netcore/Station/App.Robot.Station/App.Robot.Station.csproj

@@ -4,7 +4,7 @@
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
     <RunPostBuildEvent>Always</RunPostBuildEvent>
-    <Version>2.1.1.290</Version>
+    <Version>2.1.1.291</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>