CrazyIter_Bin 11 月之前
父節點
當前提交
d38c89d792

+ 7 - 7
TEAMModelOS.FunctionV4/Program.cs

@@ -39,10 +39,12 @@ namespace TEAMModelOS.FunctionV4
 #endif
 
              
-            var host = new HostBuilder()
-            .ConfigureFunctionsWorkerDefaults(funccontext => {
-                funccontext.UseMiddleware<TimeMonitorMiddleware>();
-            } )
+            //var host = new HostBuilder()
+            //.ConfigureFunctionsWorkerDefaults(funccontext => {
+            //    funccontext.UseMiddleware<TimeMonitorMiddleware>();
+            //} )
+
+             var host = new HostBuilder().ConfigureFunctionsWorkerDefaults()
            .ConfigureAppConfiguration((context, configure) =>
            {
                //configure.AddCommandLine(args);
@@ -84,9 +86,7 @@ namespace TEAMModelOS.FunctionV4
                }
                services.AddMultipleAzureStorage(storageConnects);
                services.AddHostedService<BlobRootServiceBusSub>();
-               services.AddIPSearcher("");
-               services.TryAddSingleton(new Region2LongitudeLatitudeTranslator(""));
-               services.AddNetMail( );
+            //  services.AddIPSearcher("");
            })
            .Build();
             await host.RunAsync();

+ 9 - 0
TEAMModelOS.FunctionV4/Properties/serviceDependencies.TEAMModelFunction - Zip Deploy.json

@@ -0,0 +1,9 @@
+{
+  "dependencies": {
+    "storage1": {
+      "resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/Microsoft.Storage/storageAccounts/teammodellog",
+      "type": "storage.azure",
+      "connectionId": "AzureWebJobsStorage"
+    }
+  }
+}

+ 6 - 10
TEAMModelOS.FunctionV4/TimeTrigger/IESTimerTrigger.cs

@@ -55,12 +55,10 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
         private readonly SnowflakeId _snowflakeId;
         private readonly IHttpClientFactory _httpClient;
         private readonly CoreAPIHttpService _coreAPIHttpService;
-        private IPSearcher _ipSearcher;
-        private readonly Region2LongitudeLatitudeTranslator _longitudeLatitudeTranslator;
-        private readonly MailFactory _mailFactory;
+        //private IPSearcher _ipSearcher;
         private readonly IConfiguration _configuration;
 
-        public IESTimerTrigger(IConfiguration configuration,MailFactory mailFactory,  CoreAPIHttpService coreAPIHttpService, Region2LongitudeLatitudeTranslator longitudeLatitudeTranslator, IPSearcher ipSearcher, IHttpClientFactory httpClient, SnowflakeId snowflakeId, IConverter converter, AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis)
+        public IESTimerTrigger(IConfiguration configuration,  CoreAPIHttpService coreAPIHttpService,   IHttpClientFactory httpClient, SnowflakeId snowflakeId, IConverter converter, AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
@@ -69,10 +67,8 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
             _converter = converter;
             _snowflakeId=snowflakeId;
             _httpClient = httpClient;
-            _ipSearcher = ipSearcher;
+          //  _ipSearcher = ipSearcher;
             _coreAPIHttpService = coreAPIHttpService;
-            _longitudeLatitudeTranslator = longitudeLatitudeTranslator;
-            _mailFactory = mailFactory;
             _configuration= configuration;
         }
         /// <summary>
@@ -120,7 +116,7 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
                     {
                         client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
                     }
-                    var data = await TEAMModelOS.SDK.Models.Service.SystemService.AccumulateDaily(_configuration,_azureRedis, _azureCosmos, _coreAPIHttpService, _dingDing, client, _snowflakeId, url, _mailFactory, am, pm);
+                    var data = await TEAMModelOS.SDK.Models.Service.SystemService.AccumulateDaily(_configuration,_azureRedis, _azureCosmos, _coreAPIHttpService, _dingDing, client, _snowflakeId, url,   am, pm);
                     //await _dingDing.SendBotMsg($"返回数据{data.ToJsonString()}", GroupNames.成都开发測試群組);
                 }
             }
@@ -159,7 +155,7 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
                 {
                     //string path = $"resourceId=/SUBSCRIPTIONS/73B7F9EF-D8B7-4444-9E8D-D80B43BF3CD4/RESOURCEGROUPS/TEAMMODELCHENGDU/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/OSFIREWARE/y={y}/m={m}/d={d}/h={h}/m=00/PT1H.json";
                     string path = $"resourceId=/SUBSCRIPTIONS/73B7F9EF-D8B7-4444-9E8D-D80B43BF3CD4/RESOURCEGROUPS/TEAMMODELCHENGDU/PROVIDERS/MICROSOFT.WEB/SITES/TEAMMODELOS/y={y}/m={m}/d={d}/h={h}/m=00/PT1H.json";
-                    var retn = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _ipSearcher, _dingDing, path, "LogStorage");
+                    var retn = await BILogAnalyseService.GetPathAnalyse(_azureStorage,  _dingDing, path, "LogStorage");
                     if (retn.recCnts.IsNotEmpty())
                     {
                         //https://teammodelos.blob.core.chinacloudapi.cn/0-public/pie-borderRadius.html
@@ -208,7 +204,7 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
                         var ptD = pastTime.Day >= 10 ? $"{pastTime.Day}" : $"0{pastTime.Day}";
 
                         string dayPath = $"resourceId=/SUBSCRIPTIONS/73B7F9EF-D8B7-4444-9E8D-D80B43BF3CD4/RESOURCEGROUPS/TEAMMODELCHENGDU/PROVIDERS/MICROSOFT.WEB/SITES/TEAMMODELOS/y={ptY}/m={ptM}/d={ptD}";
-                        var retnDay = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _ipSearcher, _dingDing, dayPath, "LogStorage", timeType: "Day");
+                        var retnDay = await BILogAnalyseService.GetPathAnalyse(_azureStorage,   _dingDing, dayPath, "LogStorage", timeType: "Day");
 
                         if (retn.recCnts.IsNotEmpty())
                         {

+ 63 - 63
TEAMModelOS.SDK/Models/Service/BI/BILogAnalyseService.cs

@@ -97,7 +97,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         /// <param name="path">防火墙路径</param>
         /// <param name="connectStr">连接字串</param>
         /// <returns></returns>
-        public static async Task<(List<RecCnt> recCnts, List<string> saveUrls)> GetPathAnalyse(AzureStorageFactory _azureStorage, IPSearcher _ipSearcher, DingDing _dingDing, string path, string connectName, string timeType = "Hour")
+        public static async Task<(List<RecCnt> recCnts, List<string> saveUrls)> GetPathAnalyse(AzureStorageFactory _azureStorage,   DingDing _dingDing, string path, string connectName, string timeType = "Hour")
          {
             List<RecCnt> recCnts = new();
             List<string> urls = new();
@@ -199,37 +199,37 @@ namespace TEAMModelOS.SDK.Models.Service.BI
 
                         var ipcounts = saveCnts.ipCnt.Select(z => new IdCodeCount { id = z.ip, count = z.count }).ToList();
                         ipcounts.ForEach(async x => {
-                            string region = await _ipSearcher.SearchIpAsync(x.id);
-                            if (!string.IsNullOrWhiteSpace(region))
-                            {
-                                string[] dis = region.Split("·");
-                                if (dis.Length >= 2)
-                                {
-                                    x.code = dis[dis.Length - 1];
-                                    x.name = dis[dis.Length - 2];  // 不保留省份
-                                                                   //x.name = region.Substring(0, region.LastIndexOf("·"));  //保留省份
-                                }
-                                else
-                                {
-                                    var disrs = Regex.Split(region.TrimStart().TrimEnd(), @"\s+");
-                                    if (disrs.Length >= 2)
-                                    {
-                                        x.code = disrs[disrs.Length - 1];
-                                        x.name = disrs[disrs.Length - 2];   //不保留省份
-                                                                            //x.name = region.Substring(0, region.LastIndexOf("·")); //保留省份
-                                    }
-                                    else
-                                    {
-                                        x.code = region;
-                                        x.name = region;
-                                    }
-                                }
-                            }
-                            else
-                            {
-                                x.name = x.id;
-                                x.code = x.id;
-                            }
+                            //string region = await _ipSearcher.SearchIpAsync(x.id);
+                            //if (!string.IsNullOrWhiteSpace(region))
+                            //{
+                            //    string[] dis = region.Split("·");
+                            //    if (dis.Length >= 2)
+                            //    {
+                            //        x.code = dis[dis.Length - 1];
+                            //        x.name = dis[dis.Length - 2];  // 不保留省份
+                            //                                       //x.name = region.Substring(0, region.LastIndexOf("·"));  //保留省份
+                            //    }
+                            //    else
+                            //    {
+                            //        var disrs = Regex.Split(region.TrimStart().TrimEnd(), @"\s+");
+                            //        if (disrs.Length >= 2)
+                            //        {
+                            //            x.code = disrs[disrs.Length - 1];
+                            //            x.name = disrs[disrs.Length - 2];   //不保留省份
+                            //                                                //x.name = region.Substring(0, region.LastIndexOf("·")); //保留省份
+                            //        }
+                            //        else
+                            //        {
+                            //            x.code = region;
+                            //            x.name = region;
+                            //        }
+                            //    }
+                            //}
+                            //else
+                            //{
+                            //    x.name = x.id;
+                            //    x.code = x.id;
+                            //}
                         });
                         List<RecRegionCnt> regionCnts = new();
                         ipcounts.GroupBy(x => x.name).ToList().ForEach(z => {
@@ -265,37 +265,37 @@ namespace TEAMModelOS.SDK.Models.Service.BI
 
                     var ipcounts = dayIpCnt.Select(z => new IdCodeCount { id = z.ip, count = z.count }).ToList();
                     ipcounts.ForEach(async x => {
-                        string region = await _ipSearcher.SearchIpAsync(x.id);
-                        if (!string.IsNullOrWhiteSpace(region))
-                        {
-                            string[] dis = region.Split("·");
-                            if (dis.Length >= 2)
-                            {
-                                x.code = dis[dis.Length - 1];
-                                x.name = dis[dis.Length - 2];  // 不保留省份
-                                //x.name = region.Substring(0, region.LastIndexOf("·"));  //保留省份
-                            }
-                            else
-                            {
-                                var disrs = Regex.Split(region.TrimStart().TrimEnd(), @"\s+");
-                                if (disrs.Length >= 2)
-                                {
-                                    x.code = disrs[disrs.Length - 1];
-                                    x.name = disrs[disrs.Length - 2];   //不保留省份
-                                    //x.name = region.Substring(0, region.LastIndexOf("·")); //保留省份
-                                }
-                                else
-                                {
-                                    x.code = region;
-                                    x.name = region;
-                                }
-                            }
-                        }
-                        else
-                        {
-                            x.name = x.id;
-                            x.code = x.id;
-                        }
+                        //string region = await _ipSearcher.SearchIpAsync(x.id);
+                        //if (!string.IsNullOrWhiteSpace(region))
+                        //{
+                        //    string[] dis = region.Split("·");
+                        //    if (dis.Length >= 2)
+                        //    {
+                        //        x.code = dis[dis.Length - 1];
+                        //        x.name = dis[dis.Length - 2];  // 不保留省份
+                        //        //x.name = region.Substring(0, region.LastIndexOf("·"));  //保留省份
+                        //    }
+                        //    else
+                        //    {
+                        //        var disrs = Regex.Split(region.TrimStart().TrimEnd(), @"\s+");
+                        //        if (disrs.Length >= 2)
+                        //        {
+                        //            x.code = disrs[disrs.Length - 1];
+                        //            x.name = disrs[disrs.Length - 2];   //不保留省份
+                        //            //x.name = region.Substring(0, region.LastIndexOf("·")); //保留省份
+                        //        }
+                        //        else
+                        //        {
+                        //            x.code = region;
+                        //            x.name = region;
+                        //        }
+                        //    }
+                        //}
+                        //else
+                        //{
+                        //    x.name = x.id;
+                        //    x.code = x.id;
+                        //}
                     });
                     List<RecRegionCnt> regionCnts = new();
                     ipcounts.GroupBy(x => x.name).ToList().ForEach(z => {

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

@@ -34,6 +34,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         {
             try
             {
+                return; 
                 if (string.IsNullOrEmpty(scId) || scId.Equals("SYSTEM_NO_SCHOOL",StringComparison.OrdinalIgnoreCase))
                     return;
 

+ 1 - 1
TEAMModelOS.SDK/Models/Service/SystemService.cs

@@ -129,7 +129,7 @@ IES Morning Report:
         /// <param name="pm"></param>
         /// <returns></returns>
         public static async Task<List<CodeValue> > AccumulateDaily(IConfiguration _configuration,AzureRedisFactory _azureRedis,AzureCosmosFactory _azureCosmos,
-            CoreAPIHttpService coreAPIHttpService, DingDing dingDing,HttpClient _httpClient, SnowflakeId _snowflakeId,string notifyUrl, MailFactory _mailFactory, int am=0 ,int pm=0)
+            CoreAPIHttpService coreAPIHttpService, DingDing dingDing,HttpClient _httpClient, SnowflakeId _snowflakeId,string notifyUrl,  int am=0 ,int pm=0)
         {
             DateTimeOffset now = DateTimeOffset.Now;
             string day = now.ToString("yyyyMMdd");

+ 1 - 1
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -153,7 +153,7 @@ namespace TEAMModelOS.Controllers
             {
                 client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
             }
-            List<CodeValue> notifys= await SystemService.AccumulateDaily(_configuration, _azureRedis,_azureCosmos, _coreAPIHttpService,_dingDing,client, _snowflakeId, url,_mailFactory,am ,pm );
+            List<CodeValue> notifys= await SystemService.AccumulateDaily(_configuration, _azureRedis,_azureCosmos, _coreAPIHttpService,_dingDing,client, _snowflakeId, url,am ,pm );
             return Ok(new { notifys });
         }