CrazyIter_Bin 1 سال پیش
والد
کامیت
f477f75f35

+ 124 - 97
TEAMModelBI/Filter/RequestAuditFilter.cs

@@ -12,135 +12,162 @@ using Azure.Core;
 using TEAMModelOS.SDK.DI;
 using Microsoft.Extensions.Primitives;
 using HTEXLib.Helpers.ShapeHelpers;
+using System.Net.Http;
+using System.ServiceModel.Channels;
+using System.Net;
+using System.Net.Http.Json;
 
 namespace TEAMModelOS.Filter
 {
     public class RequestAuditFilter : IAsyncActionFilter
     {
         //private readonly ILogger _logger;
-        private readonly HttpTrigger _httpTrigger;
-        public RequestAuditFilter(/*ILoggerFactory loggerFactory*/HttpTrigger httpTrigger)
+       // private readonly HttpTrigger _httpTrigger;
+        private readonly IHttpClientFactory _httpClient;
+        private readonly DingDing _dingding;
+        public RequestAuditFilter(/*ILoggerFactory loggerFactory*/IHttpClientFactory httpClient, DingDing dingding)
         {
             //  _logger = loggerFactory.CreateLogger<RequestAuditFilter>();
-            _httpTrigger = httpTrigger;
+            // _httpTrigger = httpTrigger;
+            _httpClient = httpClient;
+            _dingding=dingding;
         }
         public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
         {
-            string id = string.Empty, name = string.Empty, picture = string.Empty, school = string.Empty, scope = string.Empty, roles = string.Empty;
 
-            //============== 这里是执行方法之前获取数据 ====================
+            try {
+                string id = string.Empty, name = string.Empty, picture = string.Empty, school = string.Empty, scope = string.Empty, roles = string.Empty;
 
-            // 获取控制器、路由信息
-            //var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
+                //============== 这里是执行方法之前获取数据 ====================
 
-            // 获取请求的方法
-            //var method = actionDescriptor.MethodInfo;
+                // 获取控制器、路由信息
+                //var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
 
-            // 获取 HttpContext 和 HttpRequest 对象
-            var httpContext = context.HttpContext;
-            string ua = httpContext.GetUserAgent();
-            var httpRequest = httpContext.Request;
+                // 获取请求的方法
+                //var method = actionDescriptor.MethodInfo;
 
-            // 获取客户端 Ipv4 地址
-            var remoteIPv4 = httpContext.GetRemoteIpAddressToIPv4();
+                // 获取 HttpContext 和 HttpRequest 对象
+                var httpContext = context.HttpContext;
+                string ua = httpContext.GetUserAgent();
+                var httpRequest = httpContext.Request;
 
-            // 获取请求的 Url 地址
-            // var requestUrl = httpRequest.GetRequestUrlAddress();
+                // 获取客户端 Ipv4 地址
+                var remoteIPv4 = httpContext.GetRemoteIpAddressToIPv4();
 
+                // 获取请求的 Url 地址
+                // var requestUrl = httpRequest.GetRequestUrlAddress();
 
-            // 获取来源 Url 地址
-            var refererUrl = httpRequest.GetRefererUrlAddress();
 
-            // 获取请求参数(写入日志,需序列化成字符串后存储)
-            var parameters = context.ActionArguments;
+                // 获取来源 Url 地址
+                var refererUrl = httpRequest.GetRefererUrlAddress();
 
-            // 获取操作人(必须授权访问才有值)"userId" 为你存储的 claims type,jwt 授权对应的是 payload 中存储的键名
-            //var userId = httpContext.User?.FindFirstValue("userId");
-            var authtoken = context.HttpContext.GetXAuth("AuthToken");
-            string tokenSha = string.Empty, client = string.Empty;
-            if (context.HttpContext.Request.Headers.TryGetValue("Authorization", out StringValues Authorization))
-            {
-                var jwt = new JwtSecurityTokenHandler().ReadJwtToken(Authorization.ToString().Replace("Bearer ", ""));
-                client= roles = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("roles"))?.Value;
-                tokenSha= ShaHashHelper.GetSHA1(Authorization.ToString());
-            }
-            if (context.HttpContext.Request.Headers.TryGetValue("X-Auth-IdToken", out StringValues XAuthIdToken))
-            {
-                var jwt = new JwtSecurityTokenHandler().ReadJwtToken(XAuthIdToken);
-                id = jwt.Payload.Sub;
-                name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
-                if (string.IsNullOrEmpty(tokenSha))
+                // 获取请求参数(写入日志,需序列化成字符串后存储)
+                var parameters = context.ActionArguments;
+
+                // 获取操作人(必须授权访问才有值)"userId" 为你存储的 claims type,jwt 授权对应的是 payload 中存储的键名
+                //var userId = httpContext.User?.FindFirstValue("userId");
+                var authtoken = context.HttpContext.GetXAuth("AuthToken");
+                string tokenSha = string.Empty, client = string.Empty;
+                if (context.HttpContext.Request.Headers.TryGetValue("Authorization", out StringValues Authorization))
                 {
-                    tokenSha= ShaHashHelper.GetSHA1(XAuthIdToken.ToString());
+                    var jwt = new JwtSecurityTokenHandler().ReadJwtToken(Authorization.ToString().Replace("Bearer ", ""));
+                    client= roles = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("roles"))?.Value;
+                    tokenSha= ShaHashHelper.GetSHA1(Authorization.ToString());
                 }
-            }
-            if (context.HttpContext.Request.Headers.TryGetValue("X-Auth-School", out StringValues XAuthSchool))
-            {
-                try
+                if (context.HttpContext.Request.Headers.TryGetValue("X-Auth-IdToken", out StringValues XAuthIdToken))
                 {
-                    school = XAuthSchool.ToString();
+                    var jwt = new JwtSecurityTokenHandler().ReadJwtToken(XAuthIdToken);
+                    id = jwt.Payload.Sub;
+                    name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
+                    if (string.IsNullOrEmpty(tokenSha))
+                    {
+                        tokenSha= ShaHashHelper.GetSHA1(XAuthIdToken.ToString());
+                    }
+                }
+                if (context.HttpContext.Request.Headers.TryGetValue("X-Auth-School", out StringValues XAuthSchool))
+                {
+                    try
+                    {
+                        school = XAuthSchool.ToString();
+                    }
+                    catch (Exception ex) { }
                 }
-                catch (Exception ex) { }
-            }
 
-            if (!string.IsNullOrWhiteSpace(authtoken))
-            {
-                var jwt = new JwtSecurityTokenHandler().ReadJwtToken(authtoken);
-                id = jwt.Payload.Sub;
-                school = jwt.Payload.Azp;
-                name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
-                scope = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("scope"))?.Value;
+                if (!string.IsNullOrWhiteSpace(authtoken))
+                {
+                    var jwt = new JwtSecurityTokenHandler().ReadJwtToken(authtoken);
+                    id = jwt.Payload.Sub;
+                    school = jwt.Payload.Azp;
+                    name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
+                    scope = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("scope"))?.Value;
+                    if (string.IsNullOrEmpty(tokenSha))
+                    {
+                        tokenSha= ShaHashHelper.GetSHA1(authtoken);
+                    }
+                }
+                string secChUaPlatform = string.Empty;
+                if (httpContext.Request.Headers.TryGetValue("Sec-Ch-Ua-Platform", out var values))
+                {
+                    secChUaPlatform = values.FirstOrDefault();
+                }
                 if (string.IsNullOrEmpty(tokenSha))
+
                 {
-                    tokenSha= ShaHashHelper.GetSHA1(authtoken);
+                    tokenSha= ShaHashHelper.GetSHA1($"{ua}{remoteIPv4}{httpRequest.Host}{secChUaPlatform}");
                 }
-            }
-            string secChUaPlatform = string.Empty;
-            if (httpContext.Request.Headers.TryGetValue("Sec-Ch-Ua-Platform", out var values))
-            {
-                secChUaPlatform = values.FirstOrDefault();
-            }
-            if (string.IsNullOrEmpty(tokenSha))
+                // 请求时间
+                var requestedTime = DateTimeOffset.Now.GetGMTTime(8).ToUnixTimeMilliseconds();
+                //============== 这里是执行方法之后获取数据 ====================
+                var actionContext = await next();
+                // 获取返回的结果
+                // var returnResult = actionContext.Result;
+
+                // 判断是否请求成功,没有异常就是请求成功
+                // var isRequestSucceed = actionContext.Exception == null;
+
+                // 获取调用堆栈信息,提供更加简单明了的调用和异常堆栈
+                // var stackTrace = EnhancedStackTrace.Current();
+                // string region = await _searcher.SearchIpAsync(remoteIPv4);
+                //同一个账号,同一IP,同一接口,UA标识(UA标识随意切换则表示可能会存在DDOS),时间段
+                //_logger.LogInformation(new{ ua=httpContext.GetUserAgent(), ip=remoteIPv4,time=requestedTime,path =$"{httpRequest.PathBase}{httpRequest.Path}",host= $"{httpRequest.Host}", param=parameters,id ,name ,school,succeed =isRequestSucceed }.ToJsonString());
+
+                var data = new
+                {
+                    //ua =ua,
+                    ip = remoteIPv4,
+                    time = requestedTime,
+                    path = $"{httpRequest.PathBase}{httpRequest.Path}",
+                    host = $"{httpRequest.Host}",
+                    param = parameters,
+                    id = id,
+                    name = name,
+                    school = school,
+                    client = client,
+                    tid = tokenSha,
+                    scope = scope,
+                    // referer = refererUrl,
+                    //platform = secChUaPlatform,
+                    p = "bi",
+                    //idToken=XAuthIdToken
+                };
+
+#if DEBUG
+                var response = await _httpClient.CreateClient().PostAsJsonAsync("http://cdhabook.teammodel.cn:8805/api/http-log", data);
+                if (response.StatusCode==HttpStatusCode.OK)
+                {
+                    string result = await response.Content.ReadAsStringAsync();
 
-            {
-                tokenSha= ShaHashHelper.GetSHA1($"{ua}{remoteIPv4}{httpRequest.Host}{secChUaPlatform}");
+                }
+#else
+            _=  _httpClient.CreateClient().PostAsJsonAsync("http://cdhabook.teammodel.cn:8805/api/http-log",data);
+#endif
+                //   _ = _httpTrigger.RequestHttpTrigger(data, "China", "http-log");
             }
-            // 请求时间
-            var requestedTime = DateTimeOffset.Now.GetGMTTime(8).ToUnixTimeMilliseconds();
-            //============== 这里是执行方法之后获取数据 ====================
-            var actionContext = await next();
-            // 获取返回的结果
-            // var returnResult = actionContext.Result;
-
-            // 判断是否请求成功,没有异常就是请求成功
-            // var isRequestSucceed = actionContext.Exception == null;
-
-            // 获取调用堆栈信息,提供更加简单明了的调用和异常堆栈
-            // var stackTrace = EnhancedStackTrace.Current();
-            // string region = await _searcher.SearchIpAsync(remoteIPv4);
-            //同一个账号,同一IP,同一接口,UA标识(UA标识随意切换则表示可能会存在DDOS),时间段
-            //_logger.LogInformation(new{ ua=httpContext.GetUserAgent(), ip=remoteIPv4,time=requestedTime,path =$"{httpRequest.PathBase}{httpRequest.Path}",host= $"{httpRequest.Host}", param=parameters,id ,name ,school,succeed =isRequestSucceed }.ToJsonString());
-
-            var data = new
+            catch (Exception ex)
             {
-                //ua =ua,
-                ip = remoteIPv4,
-                time = requestedTime,
-                path = $"{httpRequest.PathBase}{httpRequest.Path}",
-                host = $"{httpRequest.Host}",
-                param = parameters,
-                id = id,
-                name = name,
-                school = school,
-                client = client,
-                tid = tokenSha,
-                scope = scope,
-                // referer = refererUrl,
-                //platform = secChUaPlatform,
-                p = "os",
-                //idToken=XAuthIdToken
-            };
-            _= _httpTrigger.RequestHttpTrigger(data, "China", "http-log");
+                await _dingding.SendBotMsg($"HTTP日志访问错误:{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                var actionContext = await next();
+            }
 
         }
     }

+ 24 - 14
TEAMModelOS.FunctionV4/HttpTrigger/IESHttpTrigger.cs

@@ -81,22 +81,32 @@ namespace TEAMModelOS.FunctionV4
         /// <returns></returns>
         [Function("http-log")]
         public async Task<HttpResponseData> HttpLog([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req) {
-            string data = await new StreamReader(req.Body).ReadToEndAsync();
             var response = req.CreateResponse(HttpStatusCode.OK);
-            var gmt8Time =  DateTimeOffset.UtcNow.GetGMTTime(8);
-            var appendBlob = _azureStorage.GetBlobContainerClient("0-service-log").GetAppendBlobClient($"http-log/{gmt8Time:yyyy}/{gmt8Time:MM}/{gmt8Time:dd}/{gmt8Time:HH}.log");
-            if (!appendBlob.Exists())
-            {
-                appendBlob.Create();
-                using var stream = new MemoryStream(Encoding.UTF8.GetBytes($"{data},\n"));
-                await appendBlob.AppendBlockAsync(stream);
-            }
-            else
-            {
-                using var stream = new MemoryStream(Encoding.UTF8.GetBytes($"{data},\n"));
-                await appendBlob.AppendBlockAsync(stream);
+            try {
+                string data;
+                using (var reader = new StreamReader(req.Body))
+                {
+                    data = await reader.ReadToEndAsync();
+                }
+                var gmt8Time = DateTimeOffset.UtcNow.GetGMTTime(8);
+                var appendBlob = _azureStorage.GetBlobContainerClient("0-service-log").GetAppendBlobClient($"http-log/{gmt8Time:yyyy}/{gmt8Time:MM}/{gmt8Time:dd}/{gmt8Time:HH}.log");
+                if (!await appendBlob.ExistsAsync())
+                {
+                    await appendBlob.CreateAsync();
+                }
+                using (var stream = new MemoryStream(Encoding.UTF8.GetBytes($"{data},\n")))
+                {
+                    await appendBlob.AppendBlockAsync(stream);
+                }
+                await response.WriteAsJsonAsync(new { code = 1 });
+                return response;  
+
+            } catch(Exception ex ) {
+                await _dingDing.SendBotMsg($"{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                await response.WriteAsJsonAsync(new { code = 1 });
+                return response;
             }
-            return response;
+           
         }
 
          /// <summary>

+ 9 - 10
TEAMModelOS.FunctionV4/TEAMModelOS.FunctionV4.csproj

@@ -48,20 +48,19 @@
 		<!--<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />-->
 		<!--<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" />-->
 		<!--<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.11.0" />-->
-		<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
+		<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.15.0" />
 		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
-		<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />
 	
-		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
-		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.3.0" />
-		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.17.0" />
-		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.7.0" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="5.0.1" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.7.0" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.0.0-preview2" />
 		<!--<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="3.0.9" />-->
-		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs" Version="6.3.0" />
-		<PackageReference Include="SPS.SBCompressor" Version="0.8.0" />
-		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs" Version="5.0.1" />
+		<PackageReference Include="SPS.SBCompressor" Version="0.6.5" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
 		<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
-		<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
 	</ItemGroup>
 	<ItemGroup>
 		<ProjectReference Include="..\TEAMModelOS.SDK\TEAMModelOS.SDK.csproj" />

+ 46 - 49
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -1,56 +1,53 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
-  <PropertyGroup>
-    <TargetFramework>net6.0</TargetFramework>
-    <Version>5.2403.20</Version>
-    <AssemblyVersion>5.2403.20.1</AssemblyVersion>
-    <FileVersion>5.2403.20.1</FileVersion>
-    <PackageReleaseNotes>发版</PackageReleaseNotes>
-  </PropertyGroup>
+	<PropertyGroup>
+		<TargetFramework>net6.0</TargetFramework>
+		<Version>5.2403.20</Version>
+		<AssemblyVersion>5.2403.20.1</AssemblyVersion>
+		<FileVersion>5.2403.20.1</FileVersion>
+		<PackageReleaseNotes>发版</PackageReleaseNotes>
+	</PropertyGroup>
 
-  <ItemGroup>
-    <PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
-    <PackageReference Include="CHTCHSConv" Version="1.0.0" />
-    <PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" />
-    <PackageReference Include="Azure.Cosmos" Version="4.0.0-preview3" />
-    <PackageReference Include="Azure.Identity" Version="1.10.4" />
-    <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.17.4" />
-    <PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.6.0" />
-    <PackageReference Include="Azure.Storage.Blobs.Batch" Version="12.16.1" />
-    <PackageReference Include="Azure.Storage.Queues" Version="12.17.1" />
-    <PackageReference Include="ClouDASLibx" Version="1.3.2" />
-    <PackageReference Include="DinkToPdf" Version="1.0.8" />
-    <PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
-    <PackageReference Include="HTEXLib" Version="5.2401.1024" />
-    <PackageReference Include="HtmlAgilityPack" Version="1.11.59" />
-    <PackageReference Include="Lib.AspNetCore.ServerSentEvents" Version="9.0.0" />
-    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.28" />
-    <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
-    <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.28" />
-    <PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.25.1" />
-    <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="8.0.3" />
-    <PackageReference Include="Microsoft.Identity.Client" Version="4.59.0" />
-    <PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.24" />
-    <PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
-    <PackageReference Include="NUnit" Version="3.13.2" />
-    <PackageReference Include="PinYinConverterCore" Version="1.0.2" />
-    <PackageReference Include="StackExchange.Redis" Version="2.7.33" />
-    <PackageReference Include="SvgNet" Version="3.0.0" />
-    <PackageReference Include="System.Drawing.Common" Version="6.0.0" />
-    <PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="2.0.0-preview" />
-    <PackageReference Include="System.Net.Http.Json" Version="6.0.1" />
-    <PackageReference Include="NPinyin.Core" Version="3.0.0" />
-    <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
-    <PackageReference Include="System.ServiceModel.Primitives" Version="6.2.0" />
-    <PackageReference Include="VueCliMiddleware" Version="6.0.0" />
-	<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
-	<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.3.0" />
-	<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
-  </ItemGroup>
+	<ItemGroup>
+		<PackageReference Include="CHTCHSConv" Version="1.0.0" />
+		<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.2.0" />
+		<PackageReference Include="Azure.Cosmos" Version="4.0.0-preview3" />
+		<PackageReference Include="Azure.Identity" Version="1.5.0" />
+		<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.7.0" />
+		<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.2.0" />
+		<PackageReference Include="Azure.Storage.Blobs.Batch" Version="12.8.0" />
+		<PackageReference Include="Azure.Storage.Queues" Version="12.9.0" />
+		<PackageReference Include="ClouDASLibx" Version="1.3.2" />
+		<PackageReference Include="DinkToPdf" Version="1.0.8" />
+		<PackageReference Include="DocumentFormat.OpenXml" Version="2.15.0" />
+		<PackageReference Include="HTEXLib" Version="5.2401.1024" />
+		<PackageReference Include="HtmlAgilityPack" Version="1.11.42" />
+		<PackageReference Include="Lib.AspNetCore.ServerSentEvents" Version="8.2.0" />
+		<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.3" />
+		<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
+		<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.3" />
+		<PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.18.0" />
+		<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="7.0.5" />
+		<PackageReference Include="Microsoft.Identity.Client" Version="4.39.0" />
+		<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
+		<PackageReference Include="NUnit" Version="3.13.2" />
+		<PackageReference Include="PinYinConverterCore" Version="1.0.2" />
+		<PackageReference Include="StackExchange.Redis" Version="2.6.45" />
+		<PackageReference Include="SvgNet" Version="2.2.2" />
+		<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
+		<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="2.0.0-preview" />
+		<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
+		<PackageReference Include="NPinyin.Core" Version="3.0.0" />
+		<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
+		<PackageReference Include="VueCliMiddleware" Version="6.0.0" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.10.0" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.1.0" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
+	</ItemGroup>
 
 
 
-  <ItemGroup>
-    <Folder Include="DI\BBAPI\" />
-  </ItemGroup>
+	<ItemGroup>
+		<Folder Include="DI\BBAPI\" />
+	</ItemGroup>
 </Project>

+ 18 - 5
TEAMModelOS/Filter/RequestAuditFilter.cs

@@ -17,18 +17,20 @@ using Microsoft.Extensions.Primitives;
 using HTEXLib.Helpers.ShapeHelpers;
 using TEAMModelOS.Controllers;
 using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
 
 namespace TEAMModelOS.Filter
 {
     public class RequestAuditFilter : IAsyncActionFilter
     {
         //private readonly ILogger _logger;
-        private readonly HttpTrigger _httpTrigger;
+        private readonly IHttpClientFactory _httpClient;
         private readonly DingDing _dingding;
-        public RequestAuditFilter(/*ILoggerFactory loggerFactory*/HttpTrigger httpTrigger, DingDing dingding)
+        public RequestAuditFilter(/*ILoggerFactory loggerFactory*/IHttpClientFactory httpClient, DingDing dingding)
         {
             //  _logger = loggerFactory.CreateLogger<RequestAuditFilter>();
-            _httpTrigger = httpTrigger;
+            _httpClient = httpClient;
             _dingding=dingding;
         }
         public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
@@ -187,11 +189,22 @@ namespace TEAMModelOS.Filter
                     p = "os",
                     //idToken=XAuthIdToken
                 };
-                _= _httpTrigger.RequestHttpTrigger(data, "China", "http-log");
+
+#if DEBUG
+                var  response = await   _httpClient.CreateClient().PostAsJsonAsync("http://cdhabook.teammodel.cn:8805/api/http-log", data);
+                if (response.StatusCode==HttpStatusCode.OK) 
+                {
+                    string result =   await response.Content.ReadAsStringAsync();
+                    
+                }
+#else
+            _=  _httpClient.CreateClient().PostAsJsonAsync("http://cdhabook.teammodel.cn:8805/api/http-log",data);
+#endif
+                //   _ = _httpTrigger.RequestHttpTrigger(data, "China", "http-log");
             }
             catch (Exception ex)
             {
-                await _dingding.SendBotMsg($"{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                await _dingding.SendBotMsg($"HTTP日志访问错误:{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
                 var actionContext = await next();
             }
 

+ 118 - 114
TEAMModelOS/TEAMModelOS.csproj

@@ -1,136 +1,140 @@
 <Project Sdk="Microsoft.NET.Sdk.Web">
 
-  <PropertyGroup>
-    <TargetFramework>net6.0</TargetFramework>
-  </PropertyGroup>
-  <ItemGroup>
-    <PackageReference Include="DotNetZip" Version="1.16.0" />
-	<PackageReference Include="DinkToPdf" Version="1.0.8" />
-	<PackageReference Include="EPPlus" Version="7.0.10" />
-	<PackageReference Include="IP2Region.Net" Version="2.0.2" />
-	<PackageReference Include="JsonPath.Net" Version="1.0.0" />
-    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0-preview.2.24128.5" />
-	<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.1.0" />
-	<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Remove="ClientApp\src\static\BaseDataDefault.json" />
-  </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Controllers\Third\Xkw\Hmac\" />
-    <Folder Include="logfile\" />
-    <Folder Include="Lib\" />
-  </ItemGroup>
+	<PropertyGroup>
+		<TargetFramework>net6.0</TargetFramework>
+	</PropertyGroup>
+	<ItemGroup>
+		<PackageReference Include="DotNetZip" Version="1.16.0" />
+		<PackageReference Include="DinkToPdf" Version="1.0.8" />
+		<PackageReference Include="EPPlus" Version="6.2.6" />
+		<PackageReference Include="IP2Region.Net" Version="2.0.2" />
+		<PackageReference Include="JsonPath.Net" Version="1.0.0" />
+		<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
+		<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="2.20.0" />
+		<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
+	</ItemGroup>
+	<ItemGroup>
+		<None Remove="ClientApp\src\static\BaseDataDefault.json" />
+	</ItemGroup>
+	<ItemGroup>
+		<Folder Include="Controllers\Third\Xkw\Hmac\" />
+		<Folder Include="logfile\" />
+		<Folder Include="Lib\" />
+	</ItemGroup>
 
-  <ItemGroup>
-    <None Include="TEAMModelOS.csproj" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\TEAMModelOS.SDK\TEAMModelOS.SDK.csproj" />
-	 
-  </ItemGroup>
-  <ItemGroup>
-    <Reference Include="topsdk-net-core">
-      <HintPath>Lib\topsdk-net-core.dll</HintPath>
-    </Reference>
-  </ItemGroup>
-  <ItemGroup>
-    <Content Update="Lang\en-us.json">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-      <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
-      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
-    </Content>
-    <Content Update="Lang\zh-cn.json">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-      <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
-      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
-    </Content>
-    <Content Update="Lang\zh-tw.json">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-      <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
-      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
-    </Content>
-    <Content Update="LogLang\en-us.json">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </Content>
-    <Content Update="LogLang\zh-cn.json">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </Content>
-    <Content Update="LogLang\zh-tw.json">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </Content>
-  </ItemGroup>
+	<ItemGroup>
+		<None Include="TEAMModelOS.csproj" />
+	</ItemGroup>
+	<ItemGroup>
+		<ProjectReference Include="..\TEAMModelOS.SDK\TEAMModelOS.SDK.csproj" />
+
+	</ItemGroup>
+	<ItemGroup>
+		<Reference Include="topsdk-net-core">
+			<HintPath>Lib\topsdk-net-core.dll</HintPath>
+		</Reference>
+	</ItemGroup>
+	<ItemGroup>
+		<Content Update="Lang\en-us.json">
+			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+			<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
+			<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
+		</Content>
+		<Content Update="Lang\zh-cn.json">
+			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+			<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
+			<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
+		</Content>
+		<Content Update="Lang\zh-tw.json">
+			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+			<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
+			<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
+		</Content>
+		<Content Update="LogLang\en-us.json">
+			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+		</Content>
+		<Content Update="LogLang\zh-cn.json">
+			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+		</Content>
+		<Content Update="LogLang\zh-tw.json">
+			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+		</Content>
+	</ItemGroup>
 	<ItemGroup>
 		<None Update="JsonFile\Core\ip2region.db">
-		  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
 		</None>
 		<None Update="JsonFile\Core\ip2region.xdb">
-		  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
 		</None>
 		<None Update="JsonFile\Core\mail.html">
-		  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
 		</None>
 		<None Update="libwkhtmltox.dll">
 			<CopyToOutputDirectory>Always</CopyToOutputDirectory>
 		</None>
 	</ItemGroup>
-  <PropertyGroup>
-    <!-- Typescript/Javascript Client Configuration -->
-    <SpaRoot>ClientApp\</SpaRoot>
-    <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
-    <UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-    <Version>5.2403.20</Version>
-    <AssemblyVersion>5.2403.20.1</AssemblyVersion>
-    <FileVersion>5.2403.20.1</FileVersion>
-    <Description>TEAMModelOS(IES5)</Description>
-    <PackageReleaseNotes>IES版本说明版本切换标记5.2403.20.1</PackageReleaseNotes>
-    <PackageId>TEAMModelOS</PackageId>
-    <Authors>teammodel</Authors>
-    <Company>醍摩豆(成都)信息技术有限公司</Company>
-    <Product>TEAMModelOS</Product>
-    <Copyright>© 2021 HABOOK Group 醍摩豆</Copyright>
-    <PackageProjectUrl>https://www.teammodel.cn</PackageProjectUrl>
-  </PropertyGroup>
+	<PropertyGroup>
+		<!-- Typescript/Javascript Client Configuration -->
+		<SpaRoot>ClientApp\</SpaRoot>
+		<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
+		<UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
+		<Version>5.2403.20</Version>
+		<AssemblyVersion>5.2403.20.1</AssemblyVersion>
+		<FileVersion>5.2403.20.1</FileVersion>
+		<Description>TEAMModelOS(IES5)</Description>
+		<PackageReleaseNotes>IES版本说明版本切换标记5.2403.20.1</PackageReleaseNotes>
+		<PackageId>TEAMModelOS</PackageId>
+		<Authors>teammodel</Authors>
+		<Company>醍摩豆(成都)信息技术有限公司</Company>
+		<Product>TEAMModelOS</Product>
+		<Copyright>© 2021 HABOOK Group 醍摩豆</Copyright>
+		<PackageProjectUrl>https://www.teammodel.cn</PackageProjectUrl>
+	</PropertyGroup>
 
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build">
-    <!-- Build Target:  Ensure Node.js is installed -->
-    <Exec Command="node --version" ContinueOnError="true">
-      <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
-    </Exec>
-    <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
-  </Target>
+	<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+		<WarningLevel>4</WarningLevel>
+	</PropertyGroup>
+	<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build">
+		<!-- Build Target:  Ensure Node.js is installed -->
+		<Exec Command="node --version" ContinueOnError="true">
+			<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
+		</Exec>
+		<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
+	</Target>
 
-  <Target Name="DebugEnsureNpm" AfterTargets="DebugEnsureNodeEnv">
-    <!-- Build Target:  Ensure Node.js is installed -->
-    <Exec Command="npm --version" ContinueOnError="true">
-      <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
-    </Exec>
-  </Target>
+	<Target Name="DebugEnsureNpm" AfterTargets="DebugEnsureNodeEnv">
+		<!-- Build Target:  Ensure Node.js is installed -->
+		<Exec Command="npm --version" ContinueOnError="true">
+			<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
+		</Exec>
+	</Target>
 
-  <Target Name="EnsureNodeModulesInstalled" BeforeTargets="Build" Inputs="package.json" Outputs="packages-lock.json">
-    <!-- Build Target: Restore NPM packages using npm -->
-    <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
+	<Target Name="EnsureNodeModulesInstalled" BeforeTargets="Build" Inputs="package.json" Outputs="packages-lock.json">
+		<!-- Build Target: Restore NPM packages using npm -->
+		<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
 
-    <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
-  </Target>
+		<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
+	</Target>
 
-  <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
-    <!-- Build Target: Run webpack dist build -->
-    <Message Importance="high" Text="Running npm build..." />
-    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />
+	<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
+		<!-- Build Target: Run webpack dist build -->
+		<Message Importance="high" Text="Running npm build..." />
+		<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />
 
-    <!-- Include the newly-built files in the publish output -->
-    <ItemGroup>
-      <DistFiles Include="$wwwroot\**" />
-      <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
-        <RelativePath>%(DistFiles.Identity)</RelativePath>
-        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
-      </ResolvedFileToPublish>
-    </ItemGroup>
-  </Target>
+		<!-- Include the newly-built files in the publish output -->
+		<ItemGroup>
+			<DistFiles Include="$wwwroot\**" />
+			<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
+				<RelativePath>%(DistFiles.Identity)</RelativePath>
+				<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
+			</ResolvedFileToPublish>
+		</ItemGroup>
+	</Target>
 
-  <ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" clientapp_4package_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
+	<ProjectExtensions>
+		<VisualStudio>
+			<UserProperties appsettings_1json__JsonSchema="" clientapp_4package_1json__JsonSchema="" />
+		</VisualStudio>
+	</ProjectExtensions>
 </Project>