lith 5 年之前
父節點
當前提交
00f31bd757
共有 59 個文件被更改,包括 510 次插入388 次删除
  1. 2 1
      dotnet/Sers/ApiLoader/Sers.NetcoreLoader/ApiLoader.cs
  2. 1 1
      dotnet/Sers/ApiLoader/Sers.NetcoreLoader/Sers.NetcoreLoader.csproj
  3. 1 1
      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. 22 0
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/ApiScope/IApiScope.cs
  12. 4 3
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/BeforeCallApi/Bearer/Bearer.cs
  13. 0 80
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/BeforeCallApi/EventBuilder.cs
  14. 3 0
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/BeforeCallApi/IBeforeCallApi.cs
  15. 155 0
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/EventBuilder.cs
  16. 1 2
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiTrace/ApiTraceLog.cs
  17. 0 27
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiTrace/Extensions/LocalApiMngExtensions.cs
  18. 29 0
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiTrace/Extensions/UseApiTraceLogExtensions.cs
  19. 0 81
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiTrace/Rpc/RpcContextWithApiTrace.cs
  20. 44 0
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/Event/LocalApiEvent.cs
  21. 82 0
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/Event/LocalApiEventMng.cs
  22. 13 25
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/LocalApiService.cs
  23. 2 2
      dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/StaticFileMap.cs
  24. 2 2
      dotnet/Sers/Sers.Core/Sers.Core/Module/Message/Extendsions/ApiMessageExtensions.cs
  25. 9 43
      dotnet/Sers/Sers.Core/Sers.Core/Module/Rpc/RpcContext.cs
  26. 3 31
      dotnet/Sers/Sers.Core/Sers.Core/Module/Rpc/RpcFactory.cs
  27. 1 2
      dotnet/Sers/Sers.Core/Sers.Core/Sers.Core.csproj
  28. 3 5
      dotnet/Sers/Sers.Gateway/Sers.Gateway/GatewayHelp.cs
  29. 1 1
      dotnet/Sers/Sers.Gateway/Sers.Gateway/Sers.Gateway.csproj
  30. 1 1
      dotnet/Sers/Sers.Hardware/Sers.Hardware/Sers.Hardware.csproj
  31. 0 21
      dotnet/Sers/Sers.Ioc/Sers.Ioc/Extensions/RpcFactoryExtensions.cs
  32. 21 0
      dotnet/Sers/Sers.Ioc/Sers.Ioc/Extensions/UseIocExtensions.cs
  33. 1 1
      dotnet/Sers/Sers.Ioc/Sers.Ioc/Sers.Ioc.csproj
  34. 1 1
      dotnet/Sers/Sers.ServiceCenter/Sers.Gover/Sers.Gover.csproj
  35. 1 1
      dotnet/Sers/Sers.ServiceCenter/Sers.ServiceCenter/ApiCenter/ApiCenterService.cs
  36. 1 1
      dotnet/Sers/Sers.ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter.csproj
  37. 1 1
      dotnet/Sers/Sers.ServiceStation/Sers.ServiceStation/Sers.ServiceStation.csproj
  38. 2 1
      dotnet/StationDemo/NetcoreLoader/Did.NetcoreLoader.Demo/Program.cs
  39. 2 1
      dotnet/StationDemo/NetcoreLoader/Did.NetcoreLoader.HelloWorld/Program.cs
  40. 1 1
      dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/Controllers/Demo/SampleController.cs
  41. 1 1
      dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/Did.SersLoader.Demo.csproj
  42. 16 2
      dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/appsettings.json
  43. 1 1
      dotnet/StationDemo/SersLoader/Did.SersLoader.HelloWorld/Did.SersLoader.HelloWorld.csproj
  44. 16 2
      dotnet/StationDemo/Serslot/Did.Serslot.Demo/appsettings.json
  45. 3 3
      dotnet/Test/Sers/Sers.Core/Sers.Core.Module.Rpc.MsTest/UnitTest1.cs
  46. 1 1
      dotnet/Vit/Vit.Core/Vit.Core/Vit.Core.csproj
  47. 1 1
      dotnet/Vit/Vit.Ioc/Vit.Ioc/Vit.Ioc.csproj
  48. 1 1
      dotnet/Vit/Vit.Net.Http.FormFile/Vit.Net.Http.FormFile.csproj
  49. 1 1
      dotnet/Vit/Vit.WebHost/Vit.WebHost.csproj
  50. 1 1
      dotnet/netcore/Gateway/App.Gateway/App.Gateway.csproj
  51. 6 2
      dotnet/netcore/Gateway/App.Gateway/appsettings.json
  52. 1 1
      dotnet/netcore/ServiceCenter/App.Gover.Gateway/App.Gover.Gateway.csproj
  53. 10 16
      dotnet/netcore/ServiceCenter/App.Gover.Gateway/appsettings.json
  54. 1 1
      dotnet/netcore/ServiceCenter/App.ServiceCenter/App.ServiceCenter.csproj
  55. 1 1
      dotnet/netcore/ServiceCenter/App.ServiceCenter/Program.cs
  56. 28 6
      dotnet/netcore/ServiceCenter/App.ServiceCenter/appsettings.json
  57. 1 1
      dotnet/netcore/Station/App.Ioc.Station/App.Ioc.Station.csproj
  58. 2 1
      dotnet/netcore/Station/App.Ioc.Station/Program.cs
  59. 1 1
      dotnet/netcore/Station/App.Robot.Station/App.Robot.Station.csproj

+ 2 - 1
dotnet/Sers/ApiLoader/Sers.NetcoreLoader/ApiLoader.cs

@@ -8,6 +8,7 @@ using Sers.Core.Module.Api.LocalApi;
 using Sers.Serslot;
 using Vit.Extensions;
 using Vit.Ioc;
+using Sers.Core.Module.Api.LocalApi.Event;
 
 namespace Sers.NetcoreLoader
 {
@@ -16,7 +17,7 @@ namespace Sers.NetcoreLoader
         static ApiLoader()
         {
             #region use ioc            
-            global::Sers.Core.Module.Rpc.RpcFactory.Instance.UseIoc();            
+            LocalApiEventMng.Instance.UseIoc();            
             #endregion
         }
 

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

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

+ 1 - 1
dotnet/Sers/ApiLoader/Sers.Serslot/Extensions/SerslotServer_ProcessRequest_Extensions.cs

@@ -72,7 +72,7 @@ namespace Vit.Extensions
 
 
                 #region (x.3)build reply info
-                var rpcReply = RpcFactory.Instance.CreateRpcContextData();
+                var rpcReply = RpcFactory.CreateRpcContextData();
 
                 //(x.x.1)StatusCode
                 rpcReply.http_statusCode_Set(responseFeature.StatusCode);

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

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
   

+ 22 - 0
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/ApiScope/IApiScope.cs

@@ -0,0 +1,22 @@
+using Newtonsoft.Json.Linq;
+using Sers.Core.Module.Message;
+using Sers.Core.Module.Rpc;
+using System;
+
+namespace Sers.Core.Module.Api.ApiEvent.ApiScope
+{
+    /// <summary>
+    /// 调用Api时的自定义Scope对象
+    /// </summary>
+    public interface  IApiScope
+    {
+        void Init(JObject config);
+
+   
+        /// <summary>
+        /// 返回对象在apiScope结束时被调用,可为空
+        /// </summary>
+        /// <returns></returns>
+        IDisposable OnCreateScope();
+    }
+}

+ 4 - 3
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/BeforeCallApi/Bearer/Bearer.cs

@@ -25,7 +25,7 @@ namespace Sers.Core.Module.Api.ApiEvent.BeforeCallApi.Bearer
         string Api_verifyAt;
         string Api_httpMethod;
 
-        public  ApiReturn<JObject> VerifyAt(string at)
+        ApiReturn<JObject> VerifyAt(string at)
         {
             //var arg = "{\"at\":\"" + at + "\"}";
             return ApiClient.CallRemoteApi<ApiReturn<JObject>>(Api_verifyAt, new { at }, Api_httpMethod);
@@ -51,9 +51,10 @@ namespace Sers.Core.Module.Api.ApiEvent.BeforeCallApi.Bearer
                 if (null != rpcData.user_userInfo_Get()) return;
 
                 ApiReturn<JObject> ret;
-                using (var rpcContext = RpcFactory.Instance.CreateRpcContext())
+                using (var rpcContext = RpcFactory.CreateRpcContext())
                 {
-                    RpcContext.Current.rpcData=rpcData;
+                    //RpcContext.Current.rpcData=rpcData;
+                    rpcContext.rpcData = rpcData;
                     ret = VerifyAt(bear);
                 }
 

+ 0 - 80
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/BeforeCallApi/EventBuilder.cs

@@ -1,80 +0,0 @@
-using Newtonsoft.Json.Linq;
-using Vit.Extensions;
-using Vit.Core.Module.Log;
-using Sers.Core.Module.Rpc;
-using Vit.Core.Util.Common;
-using System;
-using System.Reflection;
-using Sers.Core.Module.Message;
-
-namespace Sers.Core.Module.Api.ApiEvent.BeforeCallApi
-{
-    public class EventBuilder
-    {
-        public static Action<IRpcContextData, ApiMessage> LoadEvent(JArray events)
-        {
-            Action<IRpcContextData, ApiMessage> BeforeCallApi = null;
-
-            if (events == null || events.Count == 0) return BeforeCallApi;
-
-            foreach (JObject config in events)
-            {
-                try
-                {
-                    //(x.x.1) GetInstance
-                    var item = GetInstance(config);
-                    if (item == null) continue;
-
-                    //(x.x.2) init
-                    item.Init(config);
-
-                    //(x.x.3) add event
-                    BeforeCallApi += item.BeforeCallApi;
-
-                }
-                catch (Exception ex)
-                {
-                    Logger.Error(ex);
-                }
-            }
-
-            return BeforeCallApi;
-
-            #region GetInstance
-            IBeforeCallApi GetInstance(JObject config)
-            {
-                //(x.x.1) get className    
-                var className = config["className"].ConvertToString();
-                if (string.IsNullOrEmpty(className)) return null;
-
-                #region (x.x.2)是否内置对象
-                if (className == "Bearer" || className == "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.Bearer.Bearer")
-                {
-                    return new Bearer.Bearer();
-                }
-                if (className == "AccountInCookie" || className == "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.AccountInCookie.AccountInCookie")
-                {
-                    return new AccountInCookie.AccountInCookie();
-                }
-                #endregion
-
-
-                #region (x.x.3) get assembly
-                Assembly assembly = null;
-                var assemblyFile = config["assemblyFile"].ConvertToString();
-                if (string.IsNullOrEmpty(assemblyFile))
-                {
-                    return null;
-                }
-                assembly = Assembly.LoadFrom(CommonHelp.GetAbsPath(assemblyFile));
-                #endregion
-
-                //(x.x.4) create class
-                return assembly?.CreateInstance(className) as IBeforeCallApi;
-            }
-            #endregion
-        }
-
-
-    }
-}

+ 3 - 0
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/BeforeCallApi/IBeforeCallApi.cs

@@ -4,6 +4,9 @@ using Sers.Core.Module.Rpc;
 
 namespace Sers.Core.Module.Api.ApiEvent.BeforeCallApi
 {
+    /// <summary>
+    /// 调用api前的事件
+    /// </summary>
     public interface  IBeforeCallApi
     {
         void Init(JObject config);

+ 155 - 0
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/ApiEvent/EventBuilder.cs

@@ -0,0 +1,155 @@
+using Newtonsoft.Json.Linq;
+using Vit.Extensions;
+using Vit.Core.Module.Log;
+using Sers.Core.Module.Rpc;
+using Vit.Core.Util.Common;
+using System;
+using System.Reflection;
+using Sers.Core.Module.Message;
+using Sers.Core.Module.Api.ApiEvent.BeforeCallApi;
+using Sers.Core.Module.Api.ApiEvent.BeforeCallApi.Bearer;
+using Sers.Core.Module.Api.ApiEvent.BeforeCallApi.AccountInCookie;
+using Sers.Core.Module.Api.ApiEvent.ApiScope;
+
+namespace Sers.Core.Module.Api.ApiEvent
+{
+    public class EventBuilder
+    {
+
+        #region LoadEvent_BeforeCallApi        
+        /// <summary>
+        /// 从传入的配置项加载BeforeCallApi事件
+        /// </summary>
+        /// <param name="events"></param>
+        /// <returns></returns>
+        public static Action<IRpcContextData, ApiMessage> LoadEvent_BeforeCallApi(JArray events)
+        {
+            if (events == null || events.Count == 0) return null;
+
+            Action<IRpcContextData, ApiMessage> BeforeCallApi = null;           
+
+            foreach (JObject config in events)
+            {
+                try
+                {
+                    //(x.x.1) GetInstance
+                    var item = GetInstance(config);
+                    if (item == null) continue;
+
+                    //(x.x.2) init
+                    item.Init(config);
+
+                    //(x.x.3) add event
+                    BeforeCallApi += item.BeforeCallApi;
+
+                }
+                catch (Exception ex)
+                {
+                    Logger.Error(ex);
+                }
+            }
+
+            return BeforeCallApi;
+
+            #region GetInstance
+            IBeforeCallApi GetInstance(JObject config)
+            {
+                //(x.x.1) get className    
+                var className = config["className"].ConvertToString();
+                if (string.IsNullOrEmpty(className)) return null;
+
+                #region (x.x.2)是否内置对象
+                if (className == "Bearer" || className == "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.Bearer.Bearer")
+                {
+                    return new Bearer();
+                }
+                if (className == "AccountInCookie" || className == "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.AccountInCookie.AccountInCookie")
+                {
+                    return new AccountInCookie();
+                }
+                #endregion
+
+
+                #region (x.x.3) get assembly
+                Assembly assembly = null;
+                var assemblyFile = config["assemblyFile"].ConvertToString();
+                if (string.IsNullOrEmpty(assemblyFile))
+                {
+                    return null;
+                }
+                assembly = Assembly.LoadFrom(CommonHelp.GetAbsPath(assemblyFile));
+                #endregion
+
+                //(x.x.4) create class
+                return assembly?.CreateInstance(className) as IBeforeCallApi;
+            }
+            #endregion
+        }
+
+        #endregion
+
+
+
+        #region LoadEvent_OnCreateScope    
+        /// <summary>
+        /// 从传入的配置项加载OnCreateScope事件
+        /// </summary>
+        /// <param name="events"></param>
+        /// <returns></returns>
+        public static Func<IDisposable> LoadEvent_OnCreateScope(JArray events)
+        {       
+            if (events == null || events.Count == 0) return null;
+
+
+            Func<IDisposable> OnCreateScope = null;
+
+            foreach (JObject config in events)
+            {
+                try
+                {
+                    //(x.x.1) GetInstance
+                    var item = GetInstance(config);
+                    if (item == null) continue;
+
+                    //(x.x.2) init
+                    item.Init(config);
+
+                    //(x.x.3) add event
+                    OnCreateScope += item.OnCreateScope;
+
+                }
+                catch (Exception ex)
+                {
+                    Logger.Error(ex);
+                }
+            }
+
+            return OnCreateScope;
+
+            #region GetInstance
+            IApiScope GetInstance(JObject config)
+            {
+                //(x.x.1) get className    
+                var className = config["className"].ConvertToString();
+                if (string.IsNullOrEmpty(className)) return null;      
+
+
+                #region (x.x.3) get assembly
+                Assembly assembly = null;
+                var assemblyFile = config["assemblyFile"].ConvertToString();
+                if (string.IsNullOrEmpty(assemblyFile))
+                {
+                    return null;
+                }
+                assembly = Assembly.LoadFrom(CommonHelp.GetAbsPath(assemblyFile));
+                #endregion
+
+                //(x.x.4) create class
+                return assembly?.CreateInstance(className) as IApiScope;
+            }
+            #endregion
+        }
+
+        #endregion
+    }
+}

+ 1 - 2
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiTrace/Rpc/ApiTraceLog.cs → dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiTrace/ApiTraceLog.cs

@@ -4,7 +4,7 @@ using Sers.Core.Module.Rpc;
 using System;
 using System.Text;
 
-namespace Sers.Core.Module.Api.LocalApi.ApiTrace.Rpc
+namespace Sers.Core.Module.Api.LocalApi.ApiTrace
 {
     public class ApiTraceLog:IDisposable
     {
@@ -18,7 +18,6 @@ namespace Sers.Core.Module.Api.LocalApi.ApiTrace.Rpc
         static void LogTrace(ApiTraceLog trace)
         {
 
-
             var rpcContext = RpcContext.Current;
 
             StringBuilder msg = new StringBuilder();

+ 0 - 27
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiTrace/Extensions/LocalApiMngExtensions.cs

@@ -1,27 +0,0 @@
-using Sers.Core.Module.Api.LocalApi;
-using Sers.Core.Module.Api.LocalApi.ApiTrace.Rpc;
-using Sers.Core.Module.Rpc;
-using Vit.Core.Util.ConfigurationManager;
-
-
-namespace Vit.Extensions
-{
-    public static partial class LocalApiMngExtensions
-    {
-        /// <summary>
-        /// txt log  ("2018-01-01apitrace.log")
-        /// </summary>
-        /// <param name="localApiMng"></param>
-        public static void UseApiTraceLog(this LocalApiService localApiMng)
-        {
-
-            if (true != ConfigurationManager.Instance.GetByPath<bool?>("Sers.LocalApiService.PrintTrace"))
-                return;
-
-            RpcFactory.AddRpcContextEvent(()=> new ApiTraceLog() );
-        }
-
-
-
-    }
-}

+ 29 - 0
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiTrace/Extensions/UseApiTraceLogExtensions.cs

@@ -0,0 +1,29 @@
+using Sers.Core.Module.Api.LocalApi.ApiTrace;
+using Sers.Core.Module.Api.LocalApi.Event;
+using Vit.Core.Util.ConfigurationManager;
+
+
+namespace Vit.Extensions
+{
+    public static partial class UseApiTraceLogExtensions
+    {
+        static bool eventIsAdded = false;
+        /// <summary>
+        /// txt log  ("2018-01-01apitrace.log")
+        /// </summary>
+        /// <param name="data"></param>
+        public static void UseApiTraceLog(this LocalApiEventMng data)
+        {
+            if (eventIsAdded) return;
+            eventIsAdded = true;
+
+            if (true != ConfigurationManager.Instance.GetByPath<bool?>("Sers.LocalApiService.PrintTrace"))
+                return;
+
+            data.AddEvent_OnCreateScope(() => new ApiTraceLog());
+        }
+
+
+
+    }
+}

+ 0 - 81
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/ApiTrace/Rpc/RpcContextWithApiTrace.cs

@@ -1,81 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Sers.Core.Extensions;
-using Sers.Core.Module.Log;
-
-namespace Sers.ServiceStation.ApiTrace.Rpc
-{
-    class RpcContextWithApiTrace: Sers.Core.Module.Rpc.RpcContext
-    {
-        private DateTime beginTime;
-        private DateTime endTime;
-        public RpcContextWithApiTrace()
-        {
-            beginTime=DateTime.Now;
-            
-        }
-
-        static void LogTrace(RpcContextWithApiTrace rpcContext)
-        {
-            StringBuilder msg=new StringBuilder();
-
-            msg.Append(Environment.NewLine).Append("┍------------ ---------┑");
-
-            msg.Append(Environment.NewLine).Append("--BeginTime:").Append(rpcContext.beginTime.ToString("[HH:mm:ss.ffffff]"));
-            msg.Append(Environment.NewLine).Append("--EndTime  :").Append(rpcContext.endTime.ToString("[HH:mm:ss.ffffff]"));
-            msg.Append(Environment.NewLine).Append("--route    :").Append(rpcContext.rpcData.route);
-            msg.Append(Environment.NewLine).Append("--duration :").Append((rpcContext.endTime- rpcContext.beginTime).TotalMilliseconds).Append(" ms");
-
-
-            msg.Append(Environment.NewLine).Append("--Req rpc  :").Append(rpcContext.rpcData.oriJson);
-
-            try
-            {
-                string str = rpcContext.apiRequestMessage.value_OriData.ArraySegmentByteToString();
-                msg.Append(Environment.NewLine).Append("--Req data :").Append(str);
-            }
-            catch
-            {
-            }
-
-            try
-            {
-                string str = rpcContext.apiReplyMessage.value_OriData.ArraySegmentByteToString();
-                msg.Append(Environment.NewLine).Append("--Rep data :").Append(str);
-            }
-            catch
-            {
-            }
-            try
-            {
-                string str = rpcContext.apiReplyMessage.rpcContextData_OriData.ArraySegmentByteToString();
-                msg.Append(Environment.NewLine).Append("--Rep rpc  :").Append(str);
-            }
-            catch
-            {
-            }
-
-            msg.Append(Environment.NewLine).Append("┕------------ ---------┙").Append(Environment.NewLine);
-
-            Logger.log.LogTxt(Level.ApiTrace,msg.ToString());
-
-        }
-
-
-        public override void Dispose()
-        {
-            endTime = DateTime.Now;
-            try
-            {
-                LogTrace(this);
-            }
-            catch (Exception ex)
-            {
-                Logger.Error(ex.GetBaseException());
-            }
-
-            base.Dispose();
-        }
-    }
-}

+ 44 - 0
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/Event/LocalApiEvent.cs

@@ -0,0 +1,44 @@
+using Sers.Core.Module.Message;
+using Sers.Core.Module.Rpc;
+using System;
+using System.Collections.Generic;
+using Vit.Core.Module.Log;
+
+namespace Sers.Core.Module.Api.LocalApi.Event
+{
+    public class LocalApiEvent : IDisposable
+    {         
+
+        private List<IDisposable> events_OnDispose;
+
+        internal LocalApiEvent(List<IDisposable> events_OnDispose)
+        {
+            this.events_OnDispose = events_OnDispose;
+        }
+       
+
+        public void BeforeCallApi(IRpcContextData rpcData, ApiMessage requestMessage) 
+        {
+            LocalApiEventMng.Instance.BeforeCallApi?.Invoke(rpcData, requestMessage);
+        }
+
+        public virtual void Dispose()
+        {
+            if (events_OnDispose == null) return;
+
+            events_OnDispose.ForEach(end =>
+            {
+                try
+                {
+                    end?.Dispose();
+                }
+                catch (Exception ex)
+                {
+                    Logger.Error(ex);
+                }
+            });
+            events_OnDispose = null;
+        }
+
+    }
+}

+ 82 - 0
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/Event/LocalApiEventMng.cs

@@ -0,0 +1,82 @@
+using Newtonsoft.Json.Linq;
+using Sers.Core.Module.Message;
+using Sers.Core.Module.Rpc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Vit.Core.Module.Log;
+using Vit.Core.Util.ConfigurationManager;
+
+namespace Sers.Core.Module.Api.LocalApi.Event
+{
+    /// <summary>
+    /// 事件顺序为  OnCreateScope -> BeforeCallApi -> OnDispose
+    /// </summary>
+    public class LocalApiEventMng
+    {
+
+        public static readonly LocalApiEventMng Instance  = new LocalApiEventMng();      
+        
+
+        public LocalApiEventMng()
+        {
+            #region (x.1)构建 Api Event OnCreateScope
+            {
+                var onCreateScope = Sers.Core.Module.Api.ApiEvent.EventBuilder.LoadEvent_OnCreateScope(ConfigurationManager.Instance.GetByPath<JArray>("Sers.LocalApiService.OnCreateScope"));
+                if (onCreateScope != null) AddEvent_OnCreateScope(onCreateScope);
+            }
+            #endregion
+
+            #region (x.2)构建 Api Event BeforeCallApi
+            {
+                var beforeCallApi = Sers.Core.Module.Api.ApiEvent.EventBuilder.LoadEvent_BeforeCallApi(ConfigurationManager.Instance.GetByPath<JArray>("Sers.LocalApiService.BeforeCallApi"));
+                if (beforeCallApi != null) BeforeCallApi += beforeCallApi;
+            }
+            #endregion
+        }
+
+
+
+        #region OnCreateScope
+        internal List<Func<IDisposable>> Events_OnCreateScope { get; set; } = null;      
+        public void AddEvent_OnCreateScope(Func<IDisposable> ev)
+        {
+            if (null == ev) return;
+
+            if (null == Events_OnCreateScope)
+            {
+                Events_OnCreateScope = new List<Func<IDisposable>>();
+            }
+            Events_OnCreateScope.Add(ev);
+        }
+        #endregion
+
+        public LocalApiEvent CreateApiEvent()
+        {
+            List<IDisposable> events_OnDispose =
+                Events_OnCreateScope?.Select(event_OnCreateScope =>
+                {
+                    try
+                    {
+                        return event_OnCreateScope();
+                    }
+                    catch (Exception ex)
+                    {
+                        Logger.Error(ex);
+                    }
+                    return null;
+                })
+                .ToList();
+
+            return new LocalApiEvent(events_OnDispose);
+        }
+
+
+        /// <summary>
+        /// BeforeCallApi(IRpcContextData rpcData, ApiMessage requestMessage)
+        /// </summary>
+        internal Action<IRpcContextData, ApiMessage> BeforeCallApi = null;
+
+
+    }
+}

+ 13 - 25
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/LocalApiService.cs

@@ -2,7 +2,6 @@
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Threading;
-using Newtonsoft.Json.Linq;
 using Vit.Extensions;
 using Vit.Core.Module.Log;
 using Sers.Core.Module.Rpc;
@@ -16,6 +15,7 @@ using Sers.Core.CL.CommunicationManage;
 using Sers.Core.CL.MessageOrganize;
 using Sers.Core.Module.Message;
 using Vit.Core.Util.ComponentModel.SsError;
+using Sers.Core.Module.Api.LocalApi.Event;
 
 namespace Sers.Core.Module.Api.LocalApi
 {
@@ -33,16 +33,8 @@ namespace Sers.Core.Module.Api.LocalApi
         }
 
         public void Init()
-        { 
-
-            this.UseApiTraceLog();
-
-
-            #region 构建 Api Event BeforeCallApi
-            var BeforeCallApi = Sers.Core.Module.Api.ApiEvent.BeforeCallApi.EventBuilder.LoadEvent(ConfigurationManager.Instance.GetByPath<JArray>("Sers.LocalApiService.BeforeCallApi"));
-            if (BeforeCallApi != null) this.BeforeCallApi += BeforeCallApi;
-            #endregion
-
+        {
+            LocalApiEventMng.Instance.UseApiTraceLog();
         }
 
 
@@ -94,10 +86,6 @@ namespace Sers.Core.Module.Api.LocalApi
         #endregion
 
 
-        /// <summary>
-        /// BeforeCallApi(IRpcContextData rpcData, ApiMessage requestMessage)
-        /// </summary>
-        public Action<IRpcContextData, ApiMessage> BeforeCallApi=null;
 
 
         #region CallLocalApi
@@ -107,8 +95,9 @@ namespace Sers.Core.Module.Api.LocalApi
         /// <param name="apiRequest"></param>
         /// <returns></returns>
         internal ApiMessage CallLocalApi(ApiMessage apiRequest)
-        {
-            using (var rpcContext = RpcFactory.Instance.CreateRpcContext())
+        {           
+            using (var rpcContext = RpcFactory.CreateRpcContext())
+            using (var localApiEvent = LocalApiEventMng.Instance.CreateApiEvent())
             {
                 try
                 {
@@ -116,18 +105,17 @@ namespace Sers.Core.Module.Api.LocalApi
                     rpcContext.apiRequestMessage = apiRequest;
                     rpcContext.apiReplyMessage = new ApiMessage();
 
-                    var rpcData = RpcFactory.Instance.CreateRpcContextData();
+                    var rpcData = RpcFactory.CreateRpcContextData();
                     rpcData.UnpackOriData(apiRequest.rpcContextData_OriData);
-                    rpcContext.rpcData=rpcData;
-
+                    rpcContext.rpcData = rpcData;
 
                     //(x.2) BeforeCallApi
-                    BeforeCallApi?.Invoke(rpcData, apiRequest);
+                    localApiEvent.BeforeCallApi(rpcData, apiRequest);
 
                     //(x.3)get apiNode and call
                     apiNodeMng.TryGet(rpcData, out var apiNode);
                     if (null == apiNode)
-                    {                    
+                    {
                         rpcContext.apiReplyMessage.InitAsApiReplyMessageByError(SsError.Err_ApiNotExists);
                     }
                     else
@@ -137,9 +125,9 @@ namespace Sers.Core.Module.Api.LocalApi
 
                 }
                 catch (Exception ex) when ((ex.GetBaseException() is ThreadInterruptedException))
-                {         
+                {
                     //处理超时
-                    rpcContext.apiReplyMessage.rpcContextData_OriData= const_ApiReply_Err_Timeout.rpcContextData_OriData;
+                    rpcContext.apiReplyMessage.rpcContextData_OriData = const_ApiReply_Err_Timeout.rpcContextData_OriData;
                     rpcContext.apiReplyMessage.value_OriData = const_ApiReply_Err_Timeout.value_OriData;
                     throw;
                 }
@@ -148,7 +136,7 @@ namespace Sers.Core.Module.Api.LocalApi
                     ex = ex.GetBaseException();
                     Logger.Error(ex);
                     SsError error = ex;
-                    rpcContext.apiReplyMessage.InitAsApiReplyMessageByError(error);       
+                    rpcContext.apiReplyMessage.InitAsApiReplyMessageByError(error);
                 }
                 return rpcContext.apiReplyMessage;
             }

+ 2 - 2
dotnet/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/StaticFileMap.cs

@@ -134,7 +134,7 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
             }
 
             #region reply header
-            var replyRpcData = RpcFactory.Instance.CreateRpcContextData();
+            var replyRpcData = RpcFactory.CreateRpcContextData();
 
             if (responseHeaders != null) 
             {
@@ -197,7 +197,7 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
             }
 
             #region reply header
-            var replyRpcData = RpcFactory.Instance.CreateRpcContextData();
+            var replyRpcData = RpcFactory.CreateRpcContextData();
 
             var header = new JObject();
 

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

@@ -16,7 +16,7 @@ namespace Vit.Extensions
             if (data == null || error == null) return data;
 
             #region (x.1) set rpcData
-            var rpcData = RpcFactory.Instance.CreateRpcContextData();
+            var rpcData = RpcFactory.CreateRpcContextData();
             rpcData.error_Set(error);
 
             data.RpcContextData_OriData_Set(rpcData);
@@ -85,7 +85,7 @@ namespace Vit.Extensions
         public static ApiMessage InitAsApiRequestMessage(this ApiMessage apiRequestMessage, string url, Object arg=null,string httpMethod=null,Action<IRpcContextData>InitRpc=null)
         {   
             //(x.1)初始化rpcData
-            var rpcData = RpcFactory.Instance.CreateRpcContextData().InitFromRpcContext().Init(url, httpMethod);
+            var rpcData = RpcFactory.CreateRpcContextData().InitFromRpcContext().Init(url, httpMethod);
             InitRpc?.Invoke(rpcData);
             apiRequestMessage.RpcContextData_OriData_Set(rpcData);
 

+ 9 - 43
dotnet/Sers/Sers.Core/Sers.Core/Module/Rpc/RpcContext.cs

@@ -1,26 +1,22 @@
-using Sers.Core.Module.Api.Rpc;
-using Vit.Core.Module.Log;
-using Vit.Core.Util.Threading;
+using Vit.Core.Util.Threading;
 using System;
-using System.Collections.Generic;
-using System.Linq;
 using Sers.Core.Module.Message;
 
 namespace Sers.Core.Module.Rpc
 {
-    public class RpcContext: IDisposable
+    public class RpcContext : IDisposable
     {
 
         #region static
 
         static AsyncCache<RpcContext> CurrentRpcContext_AsyncCache = new AsyncCache<RpcContext>();
 
-        public static RpcContext Current => CurrentRpcContext_AsyncCache.Value; 
+        public static RpcContext Current => CurrentRpcContext_AsyncCache.Value;
 
         public static IRpcContextData RpcData => Current?.rpcData;
 
         #endregion
-                     
+
 
         public ApiMessage apiRequestMessage;
         public ApiMessage apiReplyMessage;
@@ -31,52 +27,22 @@ namespace Sers.Core.Module.Rpc
 
         #region 构造函数 和 Dispose
 
-        private List<IDisposable> onEnds;
         public RpcContext()
         {
             //lock (CurrentRpcContext_AsyncCache)
             //{
-                CurrentRpcContext_AsyncCache.Value = this;
+            CurrentRpcContext_AsyncCache.Value = this;
             //}
-
-            if (RpcFactory.RpcContext_OnBegins != null)
-            {
-                try
-                {
-                    onEnds = (from ev in RpcFactory.RpcContext_OnBegins
-                              select ev.Invoke()).ToList();
-                }
-                catch (Exception ex)
-                {
-                    Logger.Error(ex);
-                }
-            }
         }
 
         public virtual void Dispose()
         {
-            if (onEnds != null)
-            {
-                onEnds.ForEach(end =>
-                {
-                    try
-                    {
-                        end.Dispose();
-                    }
-                    catch (Exception ex)
-                    {
-                        Logger.Error(ex);
-                    }
-                });
-                onEnds = null;
-            }
-
             //lock (CurrentRpcContext_AsyncCache)
             //{
-                if (CurrentRpcContext_AsyncCache.Value == this)
-                {
-                    CurrentRpcContext_AsyncCache.Value = null;
-                }
+            if (CurrentRpcContext_AsyncCache.Value == this)
+            {
+                CurrentRpcContext_AsyncCache.Value = null;
+            }
             //}
         }
         #endregion

+ 3 - 31
dotnet/Sers/Sers.Core/Sers.Core/Module/Rpc/RpcFactory.cs

@@ -1,43 +1,15 @@
 using System;
-using System.Collections.Generic;
-using System.Text;
 using Sers.Core.Module.Api.Rpc;
 
 namespace Sers.Core.Module.Rpc
 {
-    public class RpcFactory
+    public static class RpcFactory
     {
-
-        public static readonly RpcFactory Instance = new RpcFactory();
-
-
-
-        public Func<RpcContext> CreateRpcContext =
+        public static Func<RpcContext> CreateRpcContext  =
             () => new RpcContext();
 
 
-        public Func<IRpcContextData> CreateRpcContextData =
+        public static Func<IRpcContextData> CreateRpcContextData =
             () => new RpcContextData();
-
-
-
-        #region static OnBegin OnEnd
-        internal static List<Func<IDisposable>> RpcContext_OnBegins = null;
-
-        public static void AddRpcContextEvent(Func<IDisposable> ev)
-        {
-            if (null == ev) return;
-
-            if (null == RpcContext_OnBegins)
-            {
-                RpcContext_OnBegins = new List<Func<IDisposable>>();
-            }
-            RpcContext_OnBegins.Add(ev);
-        }
-        #endregion
-
-
-
-
     }
 }

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

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.323</Version>
+    <Version>2.1.1.326</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 
@@ -17,7 +17,6 @@
     <EmbeddedResource Remove="SersLoader\ApiDesc\Attribute\Valid\delete\**" />
     <None Remove="SersLoader\ApiDesc\Attribute\Valid\delete\**" />
     <None Remove="SersLoader\ApiDesc\Attribute\Valid\delete\**" />
-    <Compile Remove="Module\Api\LocalApi\ApiTrace\Rpc\RpcContextWithApiTrace.cs" />
   </ItemGroup>  
  
   

+ 3 - 5
dotnet/Sers/Sers.Gateway/Sers.Gateway/GatewayHelp.cs

@@ -1,7 +1,5 @@
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.StaticFiles;
-using Microsoft.Extensions.DependencyInjection;
 using Newtonsoft.Json.Linq;
 using Sers.Core.Module.Api;
 using Sers.Core.Module.Message;
@@ -34,7 +32,7 @@ namespace Sers.Gateway
             var gatewayHelp = new GatewayHelp();
 
             #region (x.x.1)构建 Api Event BeforeCallApi
-            var BeforeCallApi = Sers.Core.Module.Api.ApiEvent.BeforeCallApi.EventBuilder.LoadEvent(ConfigurationManager.Instance.GetByPath<JArray>("Sers.Gateway.BeforeCallApi"));
+            var BeforeCallApi = Sers.Core.Module.Api.ApiEvent.EventBuilder.LoadEvent_BeforeCallApi(ConfigurationManager.Instance.GetByPath<JArray>("Sers.Gateway.BeforeCallApi"));
             if (BeforeCallApi != null) gatewayHelp.BeforeCallApi += BeforeCallApi;
             #endregion
 
@@ -193,7 +191,7 @@ namespace Sers.Gateway
         {
        
    
-            var rpcData = RpcFactory.Instance.CreateRpcContextData().Init(Rpc_CallerSource);
+            var rpcData = RpcFactory.CreateRpcContextData().Init(Rpc_CallerSource);
 
             rpcData.route = request.Path.Value;
  
@@ -282,7 +280,7 @@ namespace Sers.Gateway
                 var rpcContextData_OriData = apiReply.rpcContextData_OriData;
                 if (null != rpcContextData_OriData && rpcContextData_OriData.Count > 0)
                 {
-                    return RpcFactory.Instance.CreateRpcContextData().UnpackOriData(rpcContextData_OriData);  
+                    return RpcFactory.CreateRpcContextData().UnpackOriData(rpcContextData_OriData);  
                 }
                 return null;
             }

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

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 0 - 21
dotnet/Sers/Sers.Ioc/Sers.Ioc/Extensions/RpcFactoryExtensions.cs

@@ -1,21 +0,0 @@
-using Sers.Core.Module.Rpc;
-using Vit.Ioc;
-
-namespace Vit.Extensions
-{
-    /// <summary>
-    ///  
-    /// </summary>
-    public static class RpcFactoryExtensions
-    {
-        static bool RpcContextEventAdded = false;
-        public static void UseIoc(this RpcFactory data)
-        {
-            if (RpcContextEventAdded) return;
-
-            RpcContextEventAdded = true;
-            RpcFactory.AddRpcContextEvent(IocHelp.CreateScope);
-        }
-
-    }
-}

+ 21 - 0
dotnet/Sers/Sers.Ioc/Sers.Ioc/Extensions/UseIocExtensions.cs

@@ -0,0 +1,21 @@
+using Sers.Core.Module.Api.LocalApi.Event;
+using Vit.Ioc;
+
+namespace Vit.Extensions
+{
+    /// <summary>
+    ///  
+    /// </summary>
+    public static class UseIocExtensions
+    {
+        static bool eventIsAdded = false;
+        public static void UseIoc(this LocalApiEventMng data)
+        {
+            if (eventIsAdded) return;
+            eventIsAdded = true;
+
+            data.AddEvent_OnCreateScope(IocHelp.CreateScope);
+        }
+
+    }
+}

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

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

+ 1 - 1
dotnet/Sers/Sers.ServiceCenter/Sers.Gover/Sers.Gover.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.323</Version>
+    <Version>2.1.1.326</Version>
   </PropertyGroup>
 
   <PropertyGroup>

+ 1 - 1
dotnet/Sers/Sers.ServiceCenter/Sers.ServiceCenter/ApiCenter/ApiCenterService.cs

@@ -23,7 +23,7 @@ namespace Sers.ServiceCenter.ApiCenter
 
             var requestMessage = new ApiMessage(apiRequest);
 
-            var rpcData = RpcFactory.Instance.CreateRpcContextData().UnpackOriData(requestMessage.rpcContextData_OriData);
+            var rpcData = RpcFactory.CreateRpcContextData().UnpackOriData(requestMessage.rpcContextData_OriData);
 
             CallApiAsync(rpcData, requestMessage, sender, callback);
         }

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

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.323</Version>
+    <Version>2.1.1.326</Version>
   </PropertyGroup>
 
 

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

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

+ 2 - 1
dotnet/StationDemo/NetcoreLoader/Did.NetcoreLoader.Demo/Program.cs

@@ -1,6 +1,7 @@
 using Microsoft.AspNetCore;
 using Microsoft.AspNetCore.Hosting;
 using Newtonsoft.Json.Linq;
+using Sers.Core.Module.Api.LocalApi.Event;
 using Sers.ServiceStation;
 using Vit.Extensions;
 
@@ -16,7 +17,7 @@ namespace Did.NetcoreLoader.Demo
 
                 ServiceStation.Init();
 
-                global::Sers.Core.Module.Rpc.RpcFactory.Instance.UseIoc();
+                LocalApiEventMng.Instance.UseIoc();
 
                 #region (x.x)加载api             
                 ServiceStation.Instance.localApiService.LoadNetcoreApi(typeof(Program).Assembly);

+ 2 - 1
dotnet/StationDemo/NetcoreLoader/Did.NetcoreLoader.HelloWorld/Program.cs

@@ -1,6 +1,7 @@
 using Microsoft.AspNetCore;
 using Microsoft.AspNetCore.Hosting;
 using Newtonsoft.Json.Linq;
+using Sers.Core.Module.Api.LocalApi.Event;
 using Sers.ServiceStation;
 using Vit.Extensions;
 
@@ -16,7 +17,7 @@ namespace Did.NetcoreLoader.HellolWorld
 
                 ServiceStation.Init();
 
-                global::Sers.Core.Module.Rpc.RpcFactory.Instance.UseIoc();
+                LocalApiEventMng.Instance.UseIoc();
 
                 #region (x.x)加载api             
                 ServiceStation.Instance.localApiService.LoadNetcoreApi(typeof(Program).Assembly);

+ 1 - 1
dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/Controllers/Demo/SampleController.cs

@@ -403,7 +403,7 @@ namespace Did.SersLoader.Demo.Controllers.Demo
             #region reply header
 
             RpcContext.Current.apiReplyMessage.rpcContextData_OriData =
-                    RpcFactory.Instance.CreateRpcContextData()
+                    RpcFactory.CreateRpcContextData()
                     .http_statusCode_Set(201)
                     //.http_header_Set("Content-Type", "application/json")
                     .http_header_ContentType_Set("application/json")

+ 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.323</Version>
+    <Version>2.1.1.326</Version>
     <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>

+ 16 - 2
dotnet/StationDemo/SersLoader/Did.SersLoader.Demo/appsettings.json

@@ -193,11 +193,25 @@
 
 
 
-      //调用api前的事件,可不指定
+      /* 调用Api时的自定义Scope对象。可不指定。事件顺序为  OnCreateScope -> BeforeCallApi -> OnDispose */
+      "//OnCreateScope": [
+        {
+          /* 在此Assembly中加载类 */
+          "assemblyFile": "Sers.ApiTrace.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScope */
+          "className": "Sers.ApiTrace.ApiScope"
+        }
+      ],
+
+      /* 调用api前的事件,可不指定。事件顺序为  OnCreateScope -> BeforeCallApi -> OnDispose */
       "//BeforeCallApi": [
         {
-          //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+          /* 在此Assembly中加载类 */
+          //"assemblyFile": "Sers.Core.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
           "className": "Bearer",
+          //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+
           /* 验证at接口的地址 */
           "api_verifyAt": "/AuthCenter/account/verifyAt",
           /* 验证at接口的httpMethod。(如 GET POST 可不指定) */

+ 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.323</Version>
+    <Version>2.1.1.326</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 16 - 2
dotnet/StationDemo/Serslot/Did.Serslot.Demo/appsettings.json

@@ -115,11 +115,25 @@
       ],
 
 
-      //调用api前的事件,可不指定
+      /* 调用Api时的自定义Scope对象。可不指定。事件顺序为  OnCreateScope -> BeforeCallApi -> OnDispose */
+      "//OnCreateScope": [
+        {
+          /* 在此Assembly中加载类 */
+          "assemblyFile": "Sers.ApiTrace.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScope */
+          "className": "Sers.ApiTrace.ApiScope"
+        }
+      ],
+
+      /* 调用api前的事件,可不指定。事件顺序为  OnCreateScope -> BeforeCallApi -> OnDispose */
       "//BeforeCallApi": [
         {
-          //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+          /* 在此Assembly中加载类 */
+          //"assemblyFile": "Sers.Core.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
           "className": "Bearer",
+          //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+
           /* 验证at接口的地址 */
           "api_verifyAt": "/AuthCenter/account/verifyAt",
           /* 验证at接口的httpMethod。(如 GET POST 可不指定) */

+ 3 - 3
dotnet/Test/Sers/Sers.Core/Sers.Core.Module.Rpc.MsTest/UnitTest1.cs

@@ -12,14 +12,14 @@ namespace Sers.Core.Module.Rpc.MsTest
         {
             try
             {
-                using (var rpcContext = RpcFactory.Instance.CreateRpcContext())
+                using (var rpcContext = RpcFactory.CreateRpcContext())
                 {
-                    var rpcData = RpcFactory.Instance.CreateRpcContextData();
+                    var rpcData = RpcFactory.CreateRpcContextData();
                     rpcContext.rpcData = rpcData;
                     rpcData.http_method_Set("POST");
 
 
-                    var rpcData2 = RpcFactory.Instance.CreateRpcContextData();
+                    var rpcData2 = RpcFactory.CreateRpcContextData();
                     rpcData2.UnpackOriData(rpcData.PackageOriData());
                 }
                  

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

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

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

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.1.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</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.323</Version>
+    <Version>2.1.1.326</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 6 - 2
dotnet/netcore/Gateway/App.Gateway/appsettings.json

@@ -94,8 +94,12 @@
       //调用api前的事件,可不指定
       "BeforeCallApi": [
         {
-          //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
-          //"className": "Bearer",
+          /* 在此Assembly中加载类 */
+          //"assemblyFile": "Sers.Core.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
+          "className": "Bearer",
+          //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+
           /* 验证at接口的地址 */
           "api_verifyAt": "/AuthCenter/account/verifyAt",
           /* 验证at接口的httpMethod。(如 GET POST 可不指定) */

+ 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.323</Version>
+    <Version>2.1.1.326</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 10 - 16
dotnet/netcore/ServiceCenter/App.Gover.Gateway/appsettings.json

@@ -35,9 +35,6 @@
 
 
 
-
-
-
     /* 网关配置 */
     "Gateway": {
 
@@ -84,12 +81,17 @@
         }
 
       },
+ 
 
-      //调用api前的事件,可不指定
-      "BeforeCallApi": [
+      /* 调用api前的事件,可不指定。 */
+      "//BeforeCallApi": [
         {
-          //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
-          //"className": "Bearer",
+          /* 在此Assembly中加载类 */
+          //"assemblyFile": "Sers.Core.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
+          "className": "Bearer",
+          //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+
           /* 验证at接口的地址 */
           "api_verifyAt": "/AuthCenter/account/verifyAt",
           /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
@@ -102,17 +104,9 @@
           "account": [
             {
               "userToken": "admin_123456",
-              "CallerSource": "Internal",
-              "//userInfo": {
-                "name": "系统维护员"
-              }
-            },
-            {
-              "userToken": "order_123456",
               //"CallerSource": "Internal",
               "userInfo": {
-                "name": "订单报表查看员",
-                "role": "订单报表查看员",
+                "name": "超级管理员",
                 "入口": "Gover网关"
               }
             }

+ 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.323</Version>
+    <Version>2.1.1.326</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/netcore/ServiceCenter/App.ServiceCenter/Program.cs

@@ -23,7 +23,7 @@ namespace App.ServiceCenter
 
 
             #region (x.x.2)加载 ServiceCenter ApiEvent BeforeCallApi
-            var BeforeCallApi = Sers.Core.Module.Api.ApiEvent.BeforeCallApi.EventBuilder.LoadEvent(ConfigurationManager.Instance.GetByPath<JArray>("Sers.ServiceCenter.BeforeCallApi"));
+            var BeforeCallApi = Sers.Core.Module.Api.ApiEvent.EventBuilder.LoadEvent_BeforeCallApi(ConfigurationManager.Instance.GetByPath<JArray>("Sers.ServiceCenter.BeforeCallApi"));
             if (BeforeCallApi != null) Sers.ServiceCenter.ServiceCenter.Instance.apiCenterService.BeforeCallApi += BeforeCallApi;
             #endregion
 

+ 28 - 6
dotnet/netcore/ServiceCenter/App.ServiceCenter/appsettings.json

@@ -203,11 +203,25 @@
       ],
 
 
-      //调用api前的事件,可不指定
+      /* 调用Api时的自定义Scope对象。可不指定。事件顺序为  OnCreateScope -> BeforeCallApi -> OnDispose */
+      "//OnCreateScope": [
+        {
+          /* 在此Assembly中加载类 */
+          "assemblyFile": "Sers.ApiTrace.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScope */
+          "className": "Sers.ApiTrace.ApiScope"
+        }
+      ],
+
+      /* 调用api前的事件,可不指定。事件顺序为  OnCreateScope -> BeforeCallApi -> OnDispose */
       "//BeforeCallApi": [
         {
-          //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+          /* 在此Assembly中加载类 */
+          //"assemblyFile": "Sers.Core.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
           "className": "Bearer",
+          //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+
           /* 验证at接口的地址 */
           "api_verifyAt": "/AuthCenter/account/verifyAt",
           /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
@@ -273,8 +287,12 @@
       //调用api前的事件,可不指定
       "BeforeCallApi": [
         {
-          //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
-          //"className": "Bearer",
+          /* 在此Assembly中加载类 */
+          //"assemblyFile": "Sers.Core.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
+          "className": "Bearer",
+          //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+
           /* 验证at接口的地址 */
           "api_verifyAt": "/AuthCenter/account/verifyAt",
           /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
@@ -353,8 +371,12 @@
       //调用api前的事件,可不指定
       "BeforeCallApi": [
         {
-          //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
-          //"className": "Bearer",
+          /* 在此Assembly中加载类 */
+          //"assemblyFile": "Sers.Core.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
+          "className": "Bearer",
+          //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+
           /* 验证at接口的地址 */
           "api_verifyAt": "/AuthCenter/account/verifyAt",
           /* 验证at接口的httpMethod。(如 GET POST 可不指定) */

+ 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.323</Version>
+    <Version>2.1.1.326</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>
 

+ 2 - 1
dotnet/netcore/Station/App.Ioc.Station/Program.cs

@@ -2,6 +2,7 @@
 using Sers.ServiceStation;
 using static App.Ioc.Station.Controllers.DemoController;
 using Vit.Ioc;
+using Sers.Core.Module.Api.LocalApi.Event;
 
 namespace App.Ioc.Station
 {
@@ -15,7 +16,7 @@ namespace App.Ioc.Station
 
             #region ioc
             //use ioc
-            Sers.Core.Module.Rpc.RpcFactory.Instance.UseIoc();
+            LocalApiEventMng.Instance.UseIoc();
 
             IocHelp.AddSingleton<ISingleton, ArgModel>();
             IocHelp.AddScoped<IScoped, ArgModel>();

+ 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.323</Version>
+    <Version>2.1.1.326</Version>
     <Description>https://github.com/sersms/Sers/tree/2.1.1/release</Description>
   </PropertyGroup>