Explorar o código

完成防火墙钉钉推送消息展现图片

CrazyIter_Bin %!s(int64=2) %!d(string=hai) anos
pai
achega
a70ba9c735
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      TEAMModelOS.FunctionV4/TimeTrigger/IESTimerTrigger.cs

+ 7 - 2
TEAMModelOS.FunctionV4/TimeTrigger/IESTimerTrigger.cs

@@ -63,7 +63,7 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
         //https://docs.azure.cn/zh-cn/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp
         //0 1 * * * * 一天中每小时的第 1 分钟
         //0 */10 * * * *  每五分钟一次
-        public async Task FireWallFileLog([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log)
+        public async Task FireWallFileLog([TimerTrigger("0 1 * * * *")] TimerInfo myTimer, ILogger log)
         {
             try
             {
@@ -90,18 +90,23 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
                         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=980&url={HttpUtility.UrlEncode(ulrs,Encoding.UTF8)}&delay=5000";
+                        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]()\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.成都开发測試群組);
                     }
                 }