|
@@ -1,5 +1,6 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Text;
|
|
|
using System.Text.Json;
|
|
|
using System.Threading.Tasks;
|
|
|
using Azure.Cosmos;
|
|
@@ -143,31 +144,37 @@ namespace TEAMModelFunction
|
|
|
await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Blob()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /*
|
|
|
- public async Task Blob([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "blob", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
|
|
|
+ /// <summary>
|
|
|
+ /// 根据容器的根目录刷新redis并获取redis的最新使用情况
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="msg"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task BlobRoot([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "blobroot", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
|
|
|
try
|
|
|
{
|
|
|
// await _dingDing.SendBotMsg($"ServiceBus,Blob(){msg}", GroupNames.醍摩豆服務運維群組);
|
|
|
var jsonMsg = JsonDocument.Parse(msg);
|
|
|
- if(jsonMsg.RootElement.TryGetProperty("name", out JsonElement name)&& name.ValueKind==JsonValueKind.String)
|
|
|
+ if (jsonMsg.RootElement.TryGetProperty("name", out JsonElement name) && name.ValueKind == JsonValueKind.String
|
|
|
+ && jsonMsg.RootElement.TryGetProperty("root", out JsonElement root) && root.ValueKind == JsonValueKind.String)
|
|
|
{
|
|
|
- jsonMsg.RootElement.TryGetProperty("root", out JsonElement root);
|
|
|
- List<string> roots= root.ToObject<List<string>>();
|
|
|
List<Dictionary<string, double?>> list = new List<Dictionary<string, double?>>();
|
|
|
- foreach (var rt in roots) {
|
|
|
- var client = _azureStorage.GetBlobContainerClient($"{name}");
|
|
|
- var size = await client.GetBlobsCatalogSize(rt);
|
|
|
- list.Add(size.Item2);
|
|
|
- await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", new RedisValue($"{name}"), new RedisValue($"{long.Parse($"{size.Item1}")}"));
|
|
|
- foreach (var key in size.Item2.Keys)
|
|
|
+ string u = System.Web.HttpUtility.UrlDecode($"{root}", Encoding.UTF8).Split("/")[0];
|
|
|
+ var client = _azureStorage.GetBlobContainerClient($"{name}");
|
|
|
+ var size = await client.GetBlobsSize(u);
|
|
|
+ await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{name}", u);
|
|
|
+ await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{name}", u, size.HasValue ? size.Value : 0);
|
|
|
+ var scores= await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{name}");
|
|
|
+ double blobsize = 0;
|
|
|
+ if (scores != default &&scores!=null) {
|
|
|
+ foreach (var score in scores)
|
|
|
{
|
|
|
- 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);
|
|
|
+ blobsize = blobsize + score.Score;
|
|
|
}
|
|
|
}
|
|
|
+ await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", new RedisValue($"{name}"), new RedisValue($"{blobsize}"));
|
|
|
+
|
|
|
await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Blob() 容器:{name}使用:{root},文件分类:{list.ToJsonString()}",
|
|
|
- GroupNames.成都开发測試群組);
|
|
|
+ GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -176,7 +183,6 @@ namespace TEAMModelFunction
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- */
|
|
|
|
|
|
/// <summary>
|
|
|
/// 完善课程变更,StuListChange, originCode是学校编码 则表示名单是学校自定义名单,如果是tmdid则表示醍摩豆的私有名单,scope=school,private。
|