|
@@ -17,6 +17,7 @@ using System.IdentityModel.Tokens.Jwt;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using TEAMModelOS.Filter;
|
|
using TEAMModelOS.Filter;
|
|
using StackExchange.Redis;
|
|
using StackExchange.Redis;
|
|
|
|
+using Azure.Messaging.ServiceBus;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers.Core
|
|
namespace TEAMModelOS.Controllers.Core
|
|
{
|
|
{
|
|
@@ -236,17 +237,23 @@ namespace TEAMModelOS.Controllers.Core
|
|
{
|
|
{
|
|
|
|
|
|
request.TryGetProperty("containerName", out JsonElement containerName);
|
|
request.TryGetProperty("containerName", out JsonElement containerName);
|
|
|
|
+ request.TryGetProperty("cache", out JsonElement cache);
|
|
var name =containerName.GetString();
|
|
var name =containerName.GetString();
|
|
- //RedisValue value = default;
|
|
|
|
- //value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", name);
|
|
|
|
- //if (value != default && !value.IsNullOrEmpty)
|
|
|
|
- //{
|
|
|
|
- // JsonElement record = value.ToString().ToObject<JsonElement>();
|
|
|
|
- // if (record.TryGetInt64(out long blobsize))
|
|
|
|
- // {
|
|
|
|
- // return Ok(new { size= blobsize });
|
|
|
|
- // }
|
|
|
|
- //}
|
|
|
|
|
|
+ try {
|
|
|
|
+ if (cache.GetBoolean())
|
|
|
|
+ {
|
|
|
|
+ RedisValue value = default;
|
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", name);
|
|
|
|
+ if (value != default && !value.IsNullOrEmpty)
|
|
|
|
+ {
|
|
|
|
+ JsonElement record = value.ToString().ToObject<JsonElement>();
|
|
|
|
+ if (record.TryGetInt64(out long blobsize))
|
|
|
|
+ {
|
|
|
|
+ return Ok(new { size = blobsize });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch { }
|
|
var client = _azureStorage.GetBlobContainerClient(name);
|
|
var client = _azureStorage.GetBlobContainerClient(name);
|
|
var size = await client.GetBlobsSize();
|
|
var size = await client.GetBlobsSize();
|
|
await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, size);
|
|
await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, size);
|
|
@@ -284,7 +291,10 @@ namespace TEAMModelOS.Controllers.Core
|
|
}
|
|
}
|
|
useSize = useSize + disSize;
|
|
useSize = useSize + disSize;
|
|
await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, useSize);
|
|
await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, useSize);
|
|
- return Ok(new { disSize, urlsSize , useSize , blobSize });
|
|
|
|
|
|
+ var messageBlob = new ServiceBusMessage(new {id=Guid.NewGuid().ToString(), progress = "update",code=name}.ToJsonString());
|
|
|
|
+ messageBlob.ApplicationProperties.Add("name", "Blob");
|
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageBlob);
|
|
|
|
+ return Ok(new { size=useSize });
|
|
}
|
|
}
|
|
|
|
|
|
private static (string, string) BlobUrlString(string sasUrl)
|
|
private static (string, string) BlobUrlString(string sasUrl)
|