Quellcode durchsuchen

Merge branch 'develop3.0-tmd' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0-tmd

zhouj1203@hotmail.com vor 4 Jahren
Ursprung
Commit
ab53e472fb

+ 14 - 7
TEAMModelFunction/MonitorServicesBus.cs

@@ -151,14 +151,21 @@ namespace TEAMModelFunction
         public async Task Blob([ServiceBusTrigger("active-task", "blob", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
             try
             {
-                await _dingDing.SendBotMsg($"ServiceBus,Blob(){msg}", GroupNames.醍摩豆服務運維群組);
+               // await _dingDing.SendBotMsg($"ServiceBus,Blob(){msg}", GroupNames.醍摩豆服務運維群組);
                 var jsonMsg = JsonDocument.Parse(msg);
-                jsonMsg.RootElement.TryGetProperty("code", out JsonElement name);
-                var client = _azureStorage.GetBlobContainerClient($"{name}");
-                var size = await client.GetBlobsCatalogSize();
-                await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record",new RedisValue($"{name}"),new RedisValue($"{long.Parse($"{size.Item1}")}"));
-                await _dingDing.SendBotMsg($"ServiceBus,Blob() 容器:{name}更新大小:{size.Item1}",
-                        GroupNames.醍摩豆服務運維群組);
+                if(jsonMsg.RootElement.TryGetProperty("name", out JsonElement name)&& name.ValueKind==JsonValueKind.String)
+                {
+                    var client = _azureStorage.GetBlobContainerClient($"{name}");
+                    var size = await client.GetBlobsCatalogSize();
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", new RedisValue($"{name}"), new RedisValue($"{long.Parse($"{size.Item1}")}"));
+                    foreach (var key in size.Item2.Keys)
+                    {
+                        await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{name}", key);
+                        await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{name}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
+                    }
+                    await _dingDing.SendBotMsg($"ServiceBus,Blob() 容器:{name}使用:{size.Item1},文件分类:{size.Item2.ToJsonString()}",
+                            GroupNames.醍摩豆服務運維群組);
+                }
             }
             catch (Exception ex)
             {

+ 20 - 3
TEAMModelOS/Controllers/Core/BlobController.cs

@@ -271,6 +271,7 @@ namespace TEAMModelOS.Controllers.Core
             var size = await client.GetBlobsCatalogSize();
             await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, size.Item1);
             foreach (var key in size.Item2.Keys) {
+                await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{name}", key);
                 await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{name}", key, size.Item2[key].HasValue?size.Item2[key].Value:0);
             }
             return Ok(new { size = size.Item1, catalog = size.Item2 });
@@ -294,6 +295,19 @@ namespace TEAMModelOS.Controllers.Core
             return Ok(new {  urlsSize });
         }
 
+        /*
+         * 
+         {
+            "containerName": "hbcn",
+            "cache": true,
+            "optUrls": [
+                {
+                    "url": "video%2F37Z888piCvm9.mp4",
+                    "size": 1000
+                }
+            ]
+         }
+        */
         /// <summary>
         /// 测试单个文本内容的上传
         /// {"containerName":"hbcn","uploadSize":5000,"optUrls":[{"url":"video/37Z888piCvm9.mp4","size":0},{}]}
@@ -310,7 +324,6 @@ namespace TEAMModelOS.Controllers.Core
             var client = _azureStorage.GetBlobContainerClient(name);
             var disSize = urls.Select(x => x.size).Sum();
             RedisValue value = default;
-            long? useSize = 0;
             long blobSize = 0;
             value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", name);
             if (value != default && !value.IsNullOrEmpty)
@@ -320,9 +333,13 @@ namespace TEAMModelOS.Controllers.Core
                 {
                 }
             }
-            useSize = useSize + disSize;
+            long? useSize = blobSize + disSize;
             await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, useSize);
-            var messageBlob = new ServiceBusMessage(new {id=Guid.NewGuid().ToString(), progress = "update",code=name}.ToJsonString());
+             
+            foreach (var x in urls) {
+                await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{name}", System.Web.HttpUtility.UrlDecode(x.url, Encoding.UTF8).Split("/")[0], x.size);
+            }
+            var messageBlob = new ServiceBusMessage(new {id=Guid.NewGuid().ToString(), progress = "update",name=name}.ToJsonString());
             messageBlob.ApplicationProperties.Add("name", "Blob");
             await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageBlob);
             return Ok(new { size=useSize });

+ 0 - 1
TEAMModelOS/TEAMModelOS.csproj

@@ -51,7 +51,6 @@
   <ItemGroup>
     <Folder Include="JwtRsaFile\" />
     <Folder Include="Services\Evaluation\" />
-    <Folder Include="wwwroot\" />
   </ItemGroup>
   
   <ItemGroup>