浏览代码

Merge branch 'develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop

CrazyIter_Bin 2 年之前
父节点
当前提交
d5c1930286

+ 1 - 1
TEAMModelBI/Controllers/BIBlob/AnalyseFileController.cs

@@ -61,7 +61,7 @@ namespace TEAMModelBI.Controllers.BIBlob
 
             await foreach (BlobItem blobItem in blobCilent.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"visitCnt/{day}"))
             {
-                if (blobItem.Name.EndsWith(".json"))
+                if (blobItem.Name.EndsWith(".json") && !blobItem.Name.EndsWith("/days.json"))
                 {
                     BlobClient tempClient = blobCilent.GetBlobClient(blobItem.Name);
                     if (await tempClient.ExistsAsync())

+ 1 - 1
TEAMModelBI/Controllers/BIHome/OnLineController.cs

@@ -101,7 +101,7 @@ namespace TEAMModelBI.Controllers.BIHome
             List<RecCnt> recCnts = new();
             await foreach (BlobItem blobItem in blobClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"visitCnt/{cDay}"))
             {
-                if(blobItem.Name.EndsWith(".json"))
+                if (blobItem.Name.EndsWith(".json") && !blobItem.Name.EndsWith("/days.json"))
                 {
                     BlobClient tempBlobClient = blobClient.GetBlobClient(blobItem.Name);
                     if (await tempBlobClient.ExistsAsync())

+ 155 - 65
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -51,6 +51,7 @@ using TEAMModelOS.SDK.Context.Constant;
 using Azure.Storage.Blobs.Models;
 using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Specialized;
+using System.Web;
 
 namespace TEAMModelBI.Controllers.BITest
 {
@@ -70,7 +71,7 @@ namespace TEAMModelBI.Controllers.BITest
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly HttpClient _httpClient;
         private IPSearcher _ipSearcher;
-        public TestController(IPSearcher ipSearcher,AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient)
+        public TestController(IPSearcher ipSearcher, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient)
         {
             _azureCosmos = azureCosmos;
             _azureStorage = azureStorage;
@@ -280,7 +281,7 @@ namespace TEAMModelBI.Controllers.BITest
 
             //access_token的有效期为7200秒(2小时),有效期内重复获取会返回相同结果并自动续期,过期后获取会返回新的access_token
             string access_token = response.AccessToken;
-            
+
             IDingTalkClient quitStaffClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/querydimission");
             OapiSmartworkHrmEmployeeQuerydimissionRequest reqDimission = new() { Offset = 0L, Size = 50L };
             OapiSmartworkHrmEmployeeQuerydimissionResponse rspDimission = quitStaffClient.Execute(reqDimission, access_token);
@@ -356,7 +357,7 @@ namespace TEAMModelBI.Controllers.BITest
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-onthejob")]
-        public async Task<IActionResult> GetOnTheJob() 
+        public async Task<IActionResult> GetOnTheJob()
         {
 
             string appKey = _configuration["DingDingAuth:appKey"];
@@ -396,10 +397,10 @@ namespace TEAMModelBI.Controllers.BITest
             {
                 return Ok(new { state = 200, msg = jobrsp.SubErrMsg });
             }
-                foreach (var item in jobrsp.Result.DataList)
-                {
-                    
-                }
+            foreach (var item in jobrsp.Result.DataList)
+            {
+
+            }
 
             var ser = jobrsp.Result.DataList;  // jobrsp.Body.GetEnumerator("result");
 
@@ -583,28 +584,28 @@ namespace TEAMModelBI.Controllers.BITest
         /// </summary>
         /// <returns></returns>
         [HttpPost("set-rolesorperm")]
-        public async Task<IActionResult> SetRolesOrPermissions() 
+        public async Task<IActionResult> SetRolesOrPermissions()
         {
             var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
             List<DingDingUserInfo> ddUserId = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", "continent" } });
             List<string> read = new() { "abilitystandard-read", "batcharea-read", "batchschool-read", "orgusers-read" };
             List<DingDingUserInfo> tempUserInfo = new();
-            foreach (var user in ddUserId) 
+            foreach (var user in ddUserId)
             {
-                if (string.IsNullOrEmpty(user.roles)) 
+                if (string.IsNullOrEmpty(user.roles))
                 {
                     user.roles = "assist";
                 }
 
-                if (string.IsNullOrEmpty(user.permissions)) 
+                if (string.IsNullOrEmpty(user.permissions))
                 {
                     user.permissions = string.Join(",", read);
                 }
                 List<string> tempRead = new(user.permissions.Split(","));
 
-                foreach (var temp in read) 
+                foreach (var temp in read)
                 {
-                    if (!tempRead.Contains(temp)) 
+                    if (!tempRead.Contains(temp))
                     {
                         tempRead.Add(temp);
                     }
@@ -694,7 +695,7 @@ namespace TEAMModelBI.Controllers.BITest
             {
                 ste = new DateTime(ere.Year, ere.Month - 4, 1);
             }
-            else 
+            else
             {
                 ste = new DateTime(ere.Year - 1, ere.Month, 1);
             }
@@ -714,7 +715,7 @@ namespace TEAMModelBI.Controllers.BITest
             //return Ok(new { strList, dateTime, year, start, end, endList, endList1, endList2 });
 
 
-            return Ok(new { day7, day30, datetime7, start1, end1, start2, end2, start3, end3, start4, end4 , start5, end5 , start6, end6 , start7, end7 });
+            return Ok(new { day7, day30, datetime7, start1, end1, start2, end2, start3, end3, start4, end4, start5, end5, start6, end6, start7, end7 });
         }
 
         public static List<string> monthsOfYear(string yearMonth)
@@ -723,11 +724,11 @@ namespace TEAMModelBI.Controllers.BITest
             int year = dateTime.Year;
             int month = dateTime.Month;
             List<string> months = new List<string>();
-            while (year > dateTime.Year - 1 || month > dateTime.Month) 
+            while (year > dateTime.Year - 1 || month > dateTime.Month)
             {
                 months.Add($"{year}-{(month < 10 ? "0" : "") + month}");
                 month -= 1;
-                if (month <= 0) 
+                if (month <= 0)
                 {
                     year -= 1;
                     month = 12;
@@ -903,10 +904,10 @@ namespace TEAMModelBI.Controllers.BITest
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [HttpPost("get-repeat")]
-        public async Task<IActionResult> GetRepeat(JsonElement jsonElement) 
+        public async Task<IActionResult> GetRepeat(JsonElement jsonElement)
         {
             jsonElement.TryGetProperty("datetime", out JsonElement _datetime);
-            Dictionary<string, string> prodict = new() { { "YMPCVCIM", "学情分析模组" }, { "IPDYZYLC", "智慧学校管理服务" }, { "3CLYJ6NP", "AClass ONE智慧学伴" }, { "IPALJ6NY", "数据储存服务空间" },{ "VABAJ6NV", "卷卡合一阅卷系统" } };
+            Dictionary<string, string> prodict = new() { { "YMPCVCIM", "学情分析模组" }, { "IPDYZYLC", "智慧学校管理服务" }, { "3CLYJ6NP", "AClass ONE智慧学伴" }, { "IPALJ6NY", "数据储存服务空间" }, { "VABAJ6NV", "卷卡合一阅卷系统" } };
             var ste = prodict["IPDYZYLC"];
 
             List<string> str_str = new() { "12", "20", "13", "13", "14", "16" };
@@ -926,7 +927,7 @@ namespace TEAMModelBI.Controllers.BITest
             int pydays = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? 366 : 365;
             //int pydays = DateTimeHelper.getDays(year);
 
-            return Ok(new { state = 200, pydays, days, strends , str_strend1, str_strend2 , ste  });
+            return Ok(new { state = 200, pydays, days, strends, str_strend1, str_strend2, ste });
         }
 
         /// <summary>
@@ -935,7 +936,7 @@ namespace TEAMModelBI.Controllers.BITest
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [HttpPost("get-dateday")]
-        public async Task<IActionResult> GetDateDay(JsonElement jsonElement) 
+        public async Task<IActionResult> GetDateDay(JsonElement jsonElement)
         {
             jsonElement.TryGetProperty("year", out JsonElement _year);
             jsonElement.TryGetProperty("moth", out JsonElement _moth);
@@ -968,29 +969,29 @@ namespace TEAMModelBI.Controllers.BITest
                         if (item <= 8 && item >= 3)
                             years = year;
                         else
-                            years = year+1;
+                            years = year + 1;
 
-                        if (years % 4 == 0 && year % 100 != 0 || year % 400 == 0)                        
-                            days = 29;                        
+                        if (years % 4 == 0 && year % 100 != 0 || year % 400 == 0)
+                            days = 29;
                         else
                             days = 28;
-                        break;                        
+                        break;
                 }
 
                 day += days;
             }
 
             return Ok(new { state = 200, day });
-            
+
         }
-        
+
         /// <summary>
         /// 测试CosmosDB分页查询  SQL语句分页
         /// </summary>
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [HttpPost("get-page")]
-        public async Task<IActionResult> cosmosDBPage(JsonElement jsonElement) 
+        public async Task<IActionResult> cosmosDBPage(JsonElement jsonElement)
         {
             if (!jsonElement.TryGetProperty("pageSize", out JsonElement pageSize)) return BadRequest();
             if (!jsonElement.TryGetProperty("endPosition", out JsonElement endPosition)) return BadRequest();
@@ -998,7 +999,7 @@ namespace TEAMModelBI.Controllers.BITest
             List<School> schools = new List<School>();
             //string sqlTxt = $"SELECT * FROM c where c.code='Base' order by c.id offset {endPosition} limit {pageSize}";
             string sqlTxt = $"SELECT * FROM c order by c.id offset {pageSize} limit {endPosition}";
-            await foreach (var tempPage in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions:new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var tempPage in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
             {
                 using var json = await JsonDocument.ParseAsync(tempPage.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
@@ -1028,9 +1029,9 @@ namespace TEAMModelBI.Controllers.BITest
             int? pageSize = null;
             string continuationToken = string.Empty;
             string pageToken = default;
-            if (jsonElement.TryGetProperty("pageSize", out JsonElement jsonPageSize)) 
+            if (jsonElement.TryGetProperty("pageSize", out JsonElement jsonPageSize))
             {
-                if (!jsonPageSize.ValueKind.Equals(JsonValueKind.Undefined) && !jsonPageSize.ValueKind.Equals(JsonValueKind.Null) && jsonPageSize.TryGetInt32(out int tempPageSize)) 
+                if (!jsonPageSize.ValueKind.Equals(JsonValueKind.Undefined) && !jsonPageSize.ValueKind.Equals(JsonValueKind.Null) && jsonPageSize.TryGetInt32(out int tempPageSize))
                 {
                     pageSize = tempPageSize;
                 }
@@ -1051,14 +1052,14 @@ namespace TEAMModelBI.Controllers.BITest
             await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: "select value(c) from c", continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0) 
+                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         schools.Add(obj.ToObject<School>());
                     }
 
-                    if (iscontinuation) 
+                    if (iscontinuation)
                     {
                         continuationToken = item.GetContinuationToken();
                         break;
@@ -1095,7 +1096,7 @@ namespace TEAMModelBI.Controllers.BITest
             list2.Add(new Test { score = 100, name = "010" });
 
             //list3 return 2
-            List<Test> list3 = list1.Where(x => !list2.Any(x2 => x.score == x2.score && x.name==x2.name)).ToList();
+            List<Test> list3 = list1.Where(x => !list2.Any(x2 => x.score == x2.score && x.name == x2.name)).ToList();
             //list4 return 2
             List<Test> list4 = list1.Where(x => list2.All(x2 => x.score != x2.score)).ToList();
 
@@ -1120,8 +1121,8 @@ namespace TEAMModelBI.Controllers.BITest
             var ss = DateTime.Now.AddDays(0 - Convert.ToInt16(DateTime.Now.DayOfWeek) - 7).ToString("yyyy-MM-dd");//上周日
             var sss = DateTime.Now.AddDays(6 - Convert.ToInt16(DateTime.Now.DayOfWeek) - 7).ToString("yyyy-MM-dd");//上周六
 
-            var ssss = DateTime.Now.AddDays(1 - Convert.ToInt16(DateTime.Now.DayOfWeek) - 7+1).ToString("yyyy-MM-dd");//上周一
-            var sssss = DateTime.Now.AddDays(7 - Convert.ToInt16(DateTime.Now.DayOfWeek) - 7+1).ToString("yyyy-MM-dd");//上周日
+            var ssss = DateTime.Now.AddDays(1 - Convert.ToInt16(DateTime.Now.DayOfWeek) - 7 + 1).ToString("yyyy-MM-dd");//上周一
+            var sssss = DateTime.Now.AddDays(7 - Convert.ToInt16(DateTime.Now.DayOfWeek) - 7 + 1).ToString("yyyy-MM-dd");//上周日
 
             //计算上周
             var date = DateTime.Now;
@@ -1132,7 +1133,7 @@ namespace TEAMModelBI.Controllers.BITest
 
             var (lastWeekStart, lastWeekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastweek");
 
-            return Ok(new { state = 200, Mon,Sun, ss, sss, ssss, sssss, lastWeekStart, lastWeekEnd, have, en2, bingji, cha, jiaoji, chaji, list3, list4, temp, list1 });
+            return Ok(new { state = 200, Mon, Sun, ss, sss, ssss, sssss, lastWeekStart, lastWeekEnd, have, en2, bingji, cha, jiaoji, chaji, list3, list4, temp, list1 });
         }
 
         /// <summary>
@@ -1141,11 +1142,11 @@ namespace TEAMModelBI.Controllers.BITest
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [HttpPost("get-tablepage")]
-        public async Task<IActionResult> GetTablePage(JsonElement jsonElement) 
+        public async Task<IActionResult> GetTablePage(JsonElement jsonElement)
         {
             jsonElement.TryGetProperty("page", out JsonElement jpage);
             jsonElement.TryGetProperty("size", out JsonElement jsize);
-            int page = string.IsNullOrEmpty($"{jsize}") ?1: int.Parse($"{jpage}");
+            int page = string.IsNullOrEmpty($"{jsize}") ? 1 : int.Parse($"{jpage}");
             int size = string.IsNullOrEmpty($"{jsize}") ? 2 : int.Parse($"{jsize}");
             var table = _azureStorage.GetCloudTableClient().GetTableReference("BIOptLog");
 
@@ -1182,7 +1183,7 @@ namespace TEAMModelBI.Controllers.BITest
             Console.WriteLine(sw.Elapsed);
 
             HttpContext.Response.ContentType = "text/plain";
-            
+
             StreamWriter writer;
             //using (writer = new StreamWriter(HttpContext.Response.Body))
             //    for (int i = 0; i < 100; i++)
@@ -1191,21 +1192,21 @@ namespace TEAMModelBI.Controllers.BITest
             //    }
             //    //await writer.FlushAsync("Hello World");
 
-            return Ok(new { state = 200});
+            return Ok(new { state = 200 });
         }
 
         [HttpPost("get-linqcount")]
-        public async Task<IActionResult> GetLinqCount() 
+        public async Task<IActionResult> GetLinqCount()
         {
             List<linqTest> linqTests = new();
             for (int i = 0; i < 10; i++)
             {
-                linqTest linqt = new() { id = $"qwe{i}",name=$"名字{i}" ,linq1s = new List<linq1> { new linq1 { id =$"abc{i}",times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}, new linq1 { id = $"def{i}", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } } };
+                linqTest linqt = new() { id = $"qwe{i}", name = $"名字{i}", linq1s = new List<linq1> { new linq1 { id = $"abc{i}", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }, new linq1 { id = $"def{i}", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } } };
                 linqTests.Add(linqt);
             }
 
             //var set = linqTests.Select((x, y) => x.linq1s.Find(l => l.id.Equals($"abc0"))).ToList();
-            var set = linqTests.Where(x=> !string.IsNullOrEmpty(x.linq1s.Find(l => l.id.Equals($"abc0")).ToString()) );
+            var set = linqTests.Where(x => !string.IsNullOrEmpty(x.linq1s.Find(l => l.id.Equals($"abc0")).ToString()));
             //var tem220p = linqTests.ForEach(x => {
             //    var coreUser = linqTests.Find(c => c.id.Equals("abc0"));
             //   });  //.Except(linqTests.Select(y => y.linq1s.Find(n => n.times.Equals("abc0"))));
@@ -1256,7 +1257,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             var redisGl = _azureRedis.GetRedisClient(dbnum: 0, name: "Global");
 
-            var temps= await _azureRedis.GetRedisClient(dbnum: 0, name: "Global").SortedSetIncrementAsync($"Login:IES:Test", $"1", 1);//一天24小时  小时为单位
+            var temps = await _azureRedis.GetRedisClient(dbnum: 0, name: "Global").SortedSetIncrementAsync($"Login:IES:Test", $"1", 1);//一天24小时  小时为单位
 
             var cosmosDefaulat = _azureCosmos.GetCosmosClient(); //默认数据库
             List<School> schools = new();
@@ -1321,7 +1322,7 @@ namespace TEAMModelBI.Controllers.BITest
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [HttpPost("get-loganalyse")]
-        public async Task<IActionResult> GetLogAnalyse(JsonElement jsonElement) 
+        public async Task<IActionResult> GetLogAnalyse(JsonElement jsonElement)
         {
             if (!jsonElement.TryGetProperty("path", out JsonElement path)) return BadRequest();
 
@@ -1342,11 +1343,100 @@ namespace TEAMModelBI.Controllers.BITest
             //    }
             //}
 
-            var (an, saveUrl) = await BILogAnalyseService.GetPathAnalyse(_azureStorage,_ipSearcher,_dingDing, $"{path}", BIConst.LogGlobal);
+            var (an, saveUrl) = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _ipSearcher, _dingDing, $"{path}", BIConst.LogChina);
 
             return Ok(new { state = RespondCode.Ok, cnt = filename.Count, filename, an, saveUrl });
         }
 
+        /// <summary>
+        /// 小时/天读取防火墙文件,分析;
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [HttpPost("get-savefile")]
+        public async Task<IActionResult> GetSaveFile(JsonElement jsonElement)
+        {
+            if (!jsonElement.TryGetProperty("time", out JsonElement time)) return BadRequest();
+
+            long str = time.GetInt64();
+            DateTimeOffset dateTimeJ = TimeHelper.GetDateTime(str);
+
+            var datetime = dateTimeJ.AddHours(-1);
+            var y = datetime.Year;
+            var m = datetime.Month >= 10 ? $"{datetime.Month}" : $"0{datetime.Month}";
+            var d = datetime.Day >= 10 ? $"{datetime.Day}" : $"0{datetime.Day}";
+            var h = datetime.Hour >= 10 ? $"{datetime.Hour}" : $"0{datetime.Hour}";
+
+            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";
+            var retn = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _ipSearcher, _dingDing, path, BIConst.LogChina);
+            if (retn.recCnts.IsNotEmpty())
+            {
+                //https://teammodelos.blob.core.chinacloudapi.cn/0-public/pie-borderRadius.html
+                string publishUrl = $"https://teammodelos.blob.core.chinacloudapi.cn/0-public/api-count.html?url={HttpUtility.UrlEncode(retn.saveUrls.First(), Encoding.UTF8)}&time={HttpUtility.UrlEncode(datetime.AddHours(8).ToString("yyyy年MM月dd日 HH时"), Encoding.UTF8)}";
+                string ulrs = $"https://teammodelos.blob.core.chinacloudapi.cn/0-public/api-count.html?url={retn.saveUrls.First()}&time={datetime.AddHours(8).ToString("yyyy年MM月dd日 HH时")}";
+                string ulr = $"http://cdhabook.teammodel.cn:8805/screen/screenshot-png?width=1920&height=1450&url={HttpUtility.UrlEncode(ulrs, Encoding.UTF8)}&delay=6000";
+                string image = "";
+
+                try
+                {
+                    string strs = await _httpClient.GetStringAsync(ulr);
+                    if (!string.IsNullOrWhiteSpace(strs))
+                    {
+                        JsonElement json = strs.ToObject<JsonElement>();
+                        json.TryGetProperty("url", out JsonElement base64);
+                        using (MemoryStream ms = new MemoryStream(Convert.FromBase64String($"{base64}")))
+                        {
+                            image = await _azureStorage.GetBlobContainerClient("0-public").UploadFileByContainer(ms, $"visitCnt/{y}{m}{d}", $"{y}{m}{d}{h}.png", false);
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+
+                }
+                await _dingDing.SendBotMarkdown("防火墙日志记录", $"#### 测试(小时)-防火墙日志记录\n> 记录时间:{datetime.AddHours(8).ToString("yyyy-MM-dd HH")}\n> ![screenshot]({image})\n> ###### 发布时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}" +
+                    $" [发布地址]({publishUrl}) \n", GroupNames.醍摩豆服務運維群組);
+            }
+            List<RecCnt> recCnts = new();
+            List<string> saveUrls = new();
+
+            if (h.Equals("00"))
+            {
+                var pastTime = datetime.AddHours(-1);
+                var ptY = pastTime.Year;
+                var ptM = pastTime.Month >= 10 ? $"{pastTime.Month}" : $"0{pastTime.Month}";
+                var ptD = pastTime.Day >= 10 ? $"{pastTime.Day}" : $"0{pastTime.Day}";
+
+                string dayPath = $"resourceId=/SUBSCRIPTIONS/73B7F9EF-D8B7-4444-9E8D-D80B43BF3CD4/RESOURCEGROUPS/TEAMMODELCHENGDU/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/OSFIREWARE/y={ptY}/m={ptM}/d={ptD}";
+                (recCnts, saveUrls) = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _ipSearcher, _dingDing, dayPath, BIConst.LogChina);
+
+                if (recCnts.IsNotEmpty())
+                {
+                    //一天的统计
+                    string dayPublishUrl = $"https://teammodelos.blob.core.chinacloudapi.cn/0-public/api-count.html?url={HttpUtility.UrlEncode(saveUrls.First(), Encoding.UTF8)}&time={HttpUtility.UrlEncode(pastTime.ToString("yyyy年MM月dd日"), Encoding.UTF8)}";
+                    string dayUrls = $"https://teammodelos.blob.core.chinacloudapi.cn/0-public/api-count.html?url={saveUrls.First()}&time={pastTime.ToString("yyyy年MM月dd日")}";
+                    string dayUrl = $"http://cdhabook.teammodel.cn:8805/screen/screenshot-png?width=1920&height=1450&url={HttpUtility.UrlEncode(dayUrls, Encoding.UTF8)}&delay=6000";
+                    string dayImage = "";
+
+                    string dayStr = await _httpClient.GetStringAsync(dayUrl);
+                    if (!string.IsNullOrWhiteSpace(dayStr))
+                    {
+                        JsonElement dayJson = dayStr.ToObject<JsonElement>();
+                        dayJson.TryGetProperty("url", out JsonElement dayBase64);
+                        using (MemoryStream dayMs = new(Convert.FromBase64String($"{dayBase64}")))
+                        {
+                            dayImage = await _azureStorage.GetBlobContainerClient("0-public").UploadFileByContainer(dayMs, $"visitCnt/{ptY}{ptM}{ptD}", "days.png", false);
+                        }
+                    }
+
+                    await _dingDing.SendBotMarkdown("测试-防火墙日志记录", $"#### 测试(天)-防火墙日志记录\n> 记录时间:{pastTime.ToString("yyyy-MM-dd")}\n> ![screenshot]({dayImage})\n> ###### 发布时间:{pastTime.ToString("yyyy-MM-dd HH:mm:ss")}" +$" [发布地址]({dayPublishUrl}) \n", GroupNames.成都开发測試群組);
+
+                }
+            }
+
+            return Ok(new { state = 200, recCnts });
+        }
+
 
         /// <summary>
         /// 测试研究table 表分页的问题
@@ -1354,34 +1444,34 @@ namespace TEAMModelBI.Controllers.BITest
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [HttpPost("get-logrec")]
-        public async Task<IActionResult> GetLogRec(JsonElement jsonElement) 
-        {
-            int takeCount = 500;
-            var table = _azureStorage.GetCloudTableClient().GetTableReference("BIOptLog");
-            var table1 = _azureStorage.GetCloudTableClient();
-            int pagesize = 10;
-            int pageNum = 2;
+            public async Task<IActionResult> GetLogRec(JsonElement jsonElement)
+            {
+                int takeCount = 500;
+                var table = _azureStorage.GetCloudTableClient().GetTableReference("BIOptLog");
+                var table1 = _azureStorage.GetCloudTableClient();
+                int pagesize = 10;
+                int pageNum = 2;
 
-            var query = (from entity in table.CreateQuery<BIOptLog>()
-                          select entity).ToList().Skip(pagesize * (pageNum - 1)).Take(pagesize);
+                var query = (from entity in table.CreateQuery<BIOptLog>()
+                             select entity).ToList().Skip(pagesize * (pageNum - 1)).Take(pagesize);
 
-            //var query = (from entity in table.CreateQuery<BIOptLog>()
-            //             orderby entity.time descending
-            //             select  entity).Skip(pagesize * (pageNum - 1)).Take(pagesize);
-            //var ster = AzureStorageTableExtensions.GetTablePage<BIOptLog>(table1, "BIOptLog", 10, 1);
-            return Ok(new { state = 200 , query });
+                //var query = (from entity in table.CreateQuery<BIOptLog>()
+                //             orderby entity.time descending
+                //             select  entity).Skip(pagesize * (pageNum - 1)).Take(pagesize);
+                //var ster = AzureStorageTableExtensions.GetTablePage<BIOptLog>(table1, "BIOptLog", 10, 1);
+                return Ok(new { state = 200, query });
 
-        }
+            }
 
 
         public class linqTest
         {
-            public string id{ get; set; }
+            public string id { get; set; }
             public string name { get; set; }
             public List<linq1> linq1s { get; set; }
         }
 
-        public class linq1 
+        public class linq1
         {
             public string id { get; set; }
             public long times { get; set; }
@@ -1422,7 +1512,7 @@ namespace TEAMModelBI.Controllers.BITest
 
         }
 
-        public static long GetMonthEnd(DateTimeOffset dt) 
+        public static long GetMonthEnd(DateTimeOffset dt)
         {
             DateTime dtNew = new DateTime(dt.Year, dt.Month, 1);
             var ste = dtNew.AddMonths(1).AddDays(-1).Day;

+ 2 - 1
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -486,7 +486,8 @@ namespace TEAMModelBI.Controllers.Census
             scCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", commSql,  "Base");
             tecCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", commSql,"Base");
             stuCount = await CommonFind.GetSqlValueCount(cosmosClient, "Student", commSql,  "Base");
-            allSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", commSql,  "Base");
+            string sizeSql = "select value(sum(c.size)) from c";
+            allSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", sizeSql,  "Base");
 
 
             weekScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.createTime >= {weekStart} and c.createTime <= {weekEnd}", "Base");

二进制
TEAMModelBI/JsonFile/Core/ip2region.db


+ 3 - 0
TEAMModelBI/Startup.cs

@@ -137,6 +137,9 @@ namespace TEAMModelBI
             services.AddHttpContextAccessor();
             services.Configure<Option>(options => Configuration.GetSection("Option").Bind(options));
             services.AddControllers();
+
+            string path = $"{ environment.ContentRootPath}/JsonFile/Core";
+            services.AddIPSearcher(path);
             services.AddSpaStaticFiles(configuration =>
             {
                 configuration.RootPath = "ClientApp";

+ 3 - 3
TEAMModelOS.FunctionV4/CosmosDB/TriggerHomework.cs

@@ -196,7 +196,7 @@ namespace TEAMModelOS.FunctionV4
                     {
                         z.members.ForEach(y =>
                         {
-                            if (y.id.Equals(x) && y.type == 1)
+                            if (y.id.Equals(x.id) && y.type == 1)
                             {
                                 classIds.Add(z.id);
                             }
@@ -243,7 +243,7 @@ namespace TEAMModelOS.FunctionV4
                     {
                         z.members.ForEach(y =>
                         {
-                            if (y.id.Equals(x) && y.code.Equals(work.school) && y.type == 2)
+                            if (y.id.Equals(x.id) && y.code.Equals(work.school) && y.type == 2)
                             {
                                 classIds.Add(z.id);
                             }
@@ -301,7 +301,7 @@ namespace TEAMModelOS.FunctionV4
                     {
                         z.members.ForEach(y =>
                         {
-                            if (y.id.Equals(x) && y.type == 1)
+                            if (y.id.Equals(x.id) && y.type == 1)
                             {
                                 classIds.Add(z.id);
                             }

+ 2 - 2
TEAMModelOS.FunctionV4/CosmosDB/TriggerVote.cs

@@ -172,7 +172,7 @@ namespace TEAMModelOS.FunctionV4
                                     HashSet<string> classIds = new HashSet<string>();
                                     classLists.ForEach(z => {
                                         z.members.ForEach(y => {
-                                            if (y.id.Equals(x) && y.code.Equals(vote.school) && y.type == 2)
+                                            if (y.id.Equals(x.id) && y.code.Equals(vote.school) && y.type == 2)
                                             {
                                                 classIds.Add(z.id);
                                             }
@@ -217,7 +217,7 @@ namespace TEAMModelOS.FunctionV4
                                     HashSet<string> classIds = new HashSet<string>();
                                     classInfos.ForEach(z => {
                                         z.members.ForEach(y => {
-                                            if (y.id.Equals(x) && y.type == 1)
+                                            if (y.id.Equals(x.id) && y.type == 1)
                                             {
                                                 classIds.Add(z.id);
                                             }

+ 39 - 1
TEAMModelOS.FunctionV4/TimeTrigger/IESTimerTrigger.cs

@@ -106,9 +106,47 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
                         catch (Exception ex) { 
                           
                         }
-                        await _dingDing.SendBotMarkdown("防火墙日志记录", $"#### 防火墙日志记录\n> 记录时间:{datetime.AddHours(8).ToString("yyyy-MM-dd HH")}\n> ![screenshot]({image})\n> ###### 发布时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}" +
+                        await _dingDing.SendBotMarkdown("防火墙日志记录", $"#### 防火墙日志记录(小时)\n> 记录时间:{datetime.AddHours(8).ToString("yyyy-MM-dd HH")}\n> ![screenshot]({image})\n> ###### 发布时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}" +
                             $" [发布地址]({publishUrl}) \n", GroupNames.醍摩豆服務運維群組);
                     }
+
+                    //处理昨天的防火墙日志
+                    if (h.Equals("00"))
+                    {
+                        var pastTime = datetime.AddHours(-1);
+                        var ptY = pastTime.Year;
+                        var ptM = pastTime.Month >= 10 ? $"{pastTime.Month}" : $"0{pastTime.Month}";
+                        var ptD = pastTime.Day >= 10 ? $"{pastTime.Day}" : $"0{pastTime.Day}";
+
+                        string dayPath = $"resourceId=/SUBSCRIPTIONS/73B7F9EF-D8B7-4444-9E8D-D80B43BF3CD4/RESOURCEGROUPS/TEAMMODELCHENGDU/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/OSFIREWARE/y={ptY}/m={ptM}/d={ptD}";
+                        var retnDay = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _ipSearcher, _dingDing, dayPath, "LogStorage");
+
+                        if (retn.recCnts.IsNotEmpty()) 
+                        {
+                            //一天的统计
+                            string dayPublishUrl = $"https://teammodelos.blob.core.chinacloudapi.cn/0-public/api-count.html?url={HttpUtility.UrlEncode(retnDay.saveUrls.First(), Encoding.UTF8)}&time={HttpUtility.UrlEncode(pastTime.ToString("yyyy年MM月dd日"), Encoding.UTF8)}";
+                            string dayUrls = $"https://teammodelos.blob.core.chinacloudapi.cn/0-public/api-count.html?url={retnDay.saveUrls.First()}&time={pastTime.ToString("yyyy年MM月dd日")}";
+                            string dayUrl = $"http://cdhabook.teammodel.cn:8805/screen/screenshot-png?width=1920&height=1450&url={HttpUtility.UrlEncode(dayUrls, Encoding.UTF8)}&delay=6000";
+                            string dayImage = "";
+
+                            try
+                            {
+                                string dayStr = await _httpClient.GetStringAsync(dayUrl);
+                                if (!string.IsNullOrWhiteSpace(dayStr)) 
+                                {
+                                    JsonElement dayJson = dayStr.ToObject<JsonElement>();
+                                    dayJson.TryGetProperty("utl", out JsonElement dayBase64);
+                                    using (MemoryStream dayMs = new(Convert.FromBase64String($"{dayBase64}"))) 
+                                    {
+                                        dayImage = await _azureStorage.GetBlobContainerClient("0-public").UploadFileByContainer(dayMs, $"visitCnt/{ptY}{ptM}{ptD}", "days.png", false);
+                                    }
+                                }
+                            }
+                            catch (Exception ex) { }
+
+                            await _dingDing.SendBotMarkdown("防火墙日志记录", $"#### 防火墙日志记录(天)\n> 记录时间:{pastTime.ToString("yyyy-MM-dd")}\n> ![screenshot]({dayImage})\n> ###### 发布时间:{pastTime.ToString("yyyy-MM-dd HH:mm:ss")}" + $" [发布地址]({dayPublishUrl}) \n", GroupNames.成都开发測試群組);
+                        }
+                    }
                 }
                 else if (location.Contains("Global"))
                 {

文件差异内容过多而无法显示
+ 24 - 0
TEAMModelOS.SDK/Models/Cosmos/Student/ErrorItems.cs


+ 16 - 6
TEAMModelOS.SDK/Models/Service/BI/BILogAnalyseService.cs

@@ -102,6 +102,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             List<RecCnt> recCnts = new();
             List<string> urls = new();
 
+            DateTimeOffset dtime = DateTimeOffset.UtcNow;
+            string cDay = dtime.ToString("yyyyMMdd");
+
             try {
                 var blobClient = _azureStorage.GetBlobContainerClient($"insights-logs-applicationgatewayfirewalllog", name: connectName);
                 await foreach (BlobItem blobItem in blobClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, path))
@@ -149,13 +152,13 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                     //        aGInfos.Add(item);
                     //}
 
-                    DateTimeOffset dtime = DateTimeOffset.UtcNow;
                     string cHour = dtime.ToString("yyyyMMddHH");
-                    string cDay = dtime.ToString("yyyyMMdd");
+                    string cHH = dtime.ToString("HH");
                     if (aGInfos.Count > 0)
                     {
                         cHour = aGInfos.Select(s => DateTimeOffset.Parse(s.time).ToString("yyyyMMddHH")).First();
                         cDay = aGInfos.Select(s => DateTimeOffset.Parse(s.time).ToString("yyyyMMdd")).First();
+                        cHH = aGInfos.Select(s => DateTimeOffset.Parse(s.time).ToString("HH")).First();
                     }
 
                     RecCnt saveCnts = new();
@@ -180,15 +183,16 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                             if (dis.Length >= 2)
                             {
                                 x.code = dis[dis.Length - 1];
-                                x.name = dis[dis.Length - 2];
-                                
+                                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 = disrs[disrs.Length - 2];   //不保留省份
+                                    //x.name = region.Substring(0, region.LastIndexOf("·")); //保留省份
                                 }
                                 else {
                                     x.code = region;
@@ -208,10 +212,16 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                     saveCnts.regionCnts = regionCnts;
                     recCnts.Add(saveCnts);
                     //保存存至Blob文件
-                    var url = await _azureStorage.GetBlobContainerClient("0-public").UploadFileByContainer(saveCnts.ToJsonString(), $"visitCnt/{cDay}", $"{cHour}.json");
+                    var url = await _azureStorage.GetBlobContainerClient("0-public").UploadFileByContainer(saveCnts.ToJsonString(), $"visitCnt/{cDay}", $"{cHH}.json");
                     urls.Add(url);
                 }
 
+                if (recCnts.Count > 1) 
+                {
+                    //保存一天的数据至Blob文件
+                    var daysUrl = await _azureStorage.GetBlobContainerClient("0-public").UploadFileByContainer(recCnts.ToJsonString(), $"visitCnt/{cDay}", $"days.json");
+                }
+                
                 var azureClient = _azureStorage.GetBlobContainerClient("0-public");//获取容器连接地址
                 int expireTime = int.Parse(DateTimeOffset.UtcNow.AddDays(-180).ToString("yyyyMMdd"));
                 await foreach (var blobItem in azureClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, prefix: "visitCnt"))

+ 3 - 1
TEAMModelOS/ClientApp/src/view/syllabus/Syllabus.vue

@@ -2354,7 +2354,9 @@ export default {
       return this.$store.state.userInfo.name
     },
     getDefaultVolumeName() {
-      return this.hasSchool && this.isSchool ? this.subjectList[this.activeSubjectIndex].name + this.gradeList[this.addVolumeForm.grade] + this.semesterList[this.addVolumeForm.semester].name : ''
+      let isEnUs = localStorage.getItem('local') === 'en-us'
+      // 如果是英文语系状态下 自动拼接的课纲名称中间需要添加空格
+      return this.hasSchool && this.isSchool ? this.subjectList[this.activeSubjectIndex].name + (isEnUs ? ' ' : '') + this.gradeList[this.addVolumeForm.grade] + (isEnUs ? ' ' : '') + this.semesterList[this.addVolumeForm.semester].name : ''
     },
     getGradeName() {
       return index => {