Forráskód Böngészése

update 调整BI注入方式

CrazyIter_Bin 2 éve
szülő
commit
9f0b72f069

+ 2 - 3
TEAMModelBI/Startup.cs

@@ -16,8 +16,7 @@ using System.IdentityModel.Tokens.Jwt;
 using System.Linq;
 using System.Threading.Tasks;
 using TEAMModelBI.Controllers;
-using TEAMModelBI.DI;
-using TEAMModelBI.DI.BIAzureStorage;
+using TEAMModelBI.DI.BI;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Models;
 using TEAMModelOS.Filter;
@@ -29,7 +28,7 @@ using TEAMModelOS.SDK.Filter;
 using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Service;
-using VueCliMiddleware; 
+using VueCliMiddleware;
 
 namespace TEAMModelBI
 {

+ 54 - 0
TEAMModelOS.FunctionV4/HttpTrigger/IESTimerTrigger.cs

@@ -0,0 +1,54 @@
+using Azure.Cosmos;
+using Azure.Storage.Blobs.Models;
+using HTEXLib.COMM.Helpers;
+using Microsoft.Azure.Cosmos.Table;
+using Microsoft.Azure.Functions.Worker;
+using Microsoft.Azure.Functions.Worker.Http;
+using Microsoft.Extensions.Logging;
+using StackExchange.Redis;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Reflection;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Extension;
+using TEAMModelOS.SDK.Models;
+using TEAMModelOS.SDK.Models.Cosmos.Teacher;
+using TEAMModelOS.SDK.Models.Service.BI;
+using TEAMModelOS.SDK.Models.Table;
+using static TEAMModelOS.SDK.Models.Teacher;
+
+namespace TEAMModelOS.FunctionV4.HttpTrigger
+{
+    public class IESTimerTrigger
+    {
+        private readonly AzureCosmosFactory _azureCosmos;
+        private readonly DingDing _dingDing;
+        private readonly AzureStorageFactory _azureStorage;
+        private readonly AzureRedisFactory _azureRedis;
+        public IESTimerTrigger(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis)
+        {
+            _azureCosmos = azureCosmos;
+            _dingDing = dingDing;
+            _azureStorage = azureStorage;
+            _azureRedis = azureRedis;
+        } /// <summary>
+          /// </summary>
+          /// <param name="req"></param>
+          /// <param name="log"></param>
+          /// <returns></returns>
+        [Function("FireWallFileLog")]
+        //https://docs.azure.cn/zh-cn/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp
+        //一天中每小时的第 1 分钟
+        public async Task FireWallFileLog([TimerTrigger("0 1 * * * *")] TimerInfo myTimer, ILogger log) {
+            await _dingDing.SendBotMsg($"FireWallFileLog 防火墙日志记录(测试): {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", GroupNames.成都开发測試群組);
+            BILogAnalyseService.GetPathAnalyse(_azureStorage,"",);
+        }
+    }
+}

+ 1 - 0
TEAMModelOS.FunctionV4/TEAMModelOS.FunctionV4.csproj

@@ -30,6 +30,7 @@
 		<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="5.0.0" />
+		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
 		<PackageReference Include="SPS.SBCompressor" Version="0.6.0" />
 		<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
 	</ItemGroup>

+ 1 - 0
TEAMModelOS.FunctionV4/local.settings.json

@@ -4,6 +4,7 @@
     "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
     "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
     "Azure:Storage:ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn",
+    "Azure:LogStorage:ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
     "Azure:ServiceBus:ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
     "Azure:Cosmos:ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;",
     "Azure:Redis:ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240",

+ 1 - 1
TEAMModelBI/DI/BIAzureCosmosFactoryExtensions.cs

@@ -5,7 +5,7 @@ using System.Collections.Generic;
 using System.Text;
 using TEAMModelOS.SDK.DI;
 
-namespace TEAMModelBI.DI
+namespace TEAMModelBI.DI.BI
 {
     public static class BIAzureCosmosFactoryExtensions
     {

+ 2 - 2
TEAMModelBI/DI/BIAzureRedisFactoryExtensions.cs

@@ -5,7 +5,7 @@ using System.Collections.Generic;
 using System.Text;
 using TEAMModelOS.SDK.DI;
 
-namespace TEAMModelBI.DI
+namespace TEAMModelBI.DI.BI
 {
     public static class BIAzureRedisFactoryExtensions
     {
@@ -16,7 +16,7 @@ namespace TEAMModelBI.DI
         /// <param name="connectionInfos"></param>
         /// <returns></returns>
         /// <exception cref="ArgumentNullException"></exception>
-        public static IServiceCollection AddBIAzureRedis(this IServiceCollection services, List<(string name ,string  connectionString)> connectionInfos)
+        public static IServiceCollection AddBIAzureRedis(this IServiceCollection services, List<(string name, string connectionString)> connectionInfos)
         {
             if (services == null) throw new ArgumentNullException(nameof(services));
             if (connectionInfos == null) throw new ArgumentNullException(nameof(connectionInfos));

+ 5 - 4
TEAMModelBI/DI/BIAzureServiceBusFactoryExtensions.cs

@@ -5,7 +5,7 @@ using System.Collections.Generic;
 using System.Text;
 using TEAMModelOS.SDK.DI;
 
-namespace TEAMModelBI.DI
+namespace TEAMModelBI.DI.BI
 {
     public static class BIAzureServiceBusFactoryExtensions
     {
@@ -17,7 +17,7 @@ namespace TEAMModelBI.DI
         /// <returns></returns>
         /// <exception cref="ArgumentNullException"></exception>
         /// <exception cref="AccessViolationException"></exception>
-        public static IServiceCollection AddBIAzureServiceBus(this IServiceCollection services, List<(string name, string connectionString)> connectInfos) 
+        public static IServiceCollection AddBIAzureServiceBus(this IServiceCollection services, List<(string name, string connectionString)> connectInfos)
         {
             if (services == null) throw new ArgumentNullException(nameof(services));
             if (connectInfos == null) throw new AccessViolationException(nameof(connectInfos));
@@ -25,8 +25,9 @@ namespace TEAMModelBI.DI
             services.TryAddSingleton<AzureServiceBusFactory>();
 
             //多个注入
-            connectInfos.ForEach(connect => {
-                services.Configure<AzureServiceBusFactoryOptions>(connect.name, o => { o.Name = connect.name; o.ServiceBusConnectionString = connect.connectionString; });            
+            connectInfos.ForEach(connect =>
+            {
+                services.Configure<AzureServiceBusFactoryOptions>(connect.name, o => { o.Name = connect.name; o.ServiceBusConnectionString = connect.connectionString; });
             });
 
             //services.Configure<AzureServiceBusFactoryOptions>(name, o => { o.Name = name; o.ServiceBusConnectionString = connectionString; });//单一注入

+ 1 - 1
TEAMModelBI/DI/BIAzureStorage/BIAzureStorageFactoryExtensions.cs

@@ -5,7 +5,7 @@ using System.Collections.Generic;
 using System.Text;
 using TEAMModelOS.SDK.DI;
 
-namespace TEAMModelBI.DI.BIAzureStorage
+namespace TEAMModelBI.DI.BI
 {
     public static class BIAzureStorageFactoryExtensions
     {

+ 0 - 1
TEAMModelOS.SDK/Models/Service/BI/BILogAnalyseService.cs

@@ -106,7 +106,6 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             List<RecCnt> recCnts = new();
             List<string> urls = new();
 
-            string logName = "resourceId=/SUBSCRIPTIONS/73B7F9EF-D8B7-4444-9E8D-D80B43BF3CD4/RESOURCEGROUPS/TEAMMODELCHENGDU/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/OSFIREWARE";
             await foreach (BlobItem blobItem in blobClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, path))
             {
                 StringBuilder visits = new("[");