|
@@ -1,9 +1,11 @@
|
|
|
-using Azure.Cosmos;
|
|
|
+using Azure.Core;
|
|
|
+using Azure.Cosmos;
|
|
|
using Azure.Messaging.ServiceBus;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
using OpenXmlPowerTools;
|
|
|
+using StackExchange.Redis;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -357,7 +359,7 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
}
|
|
|
|
|
|
public static async void DoAutoDeleteSchoolLessonRecord(LessonRecord lessonRecord, string scope, CosmosClient client, string school, string tmdid,
|
|
|
- Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration, CoreAPIHttpService _coreAPIHttpService,DingDing _dingDing)
|
|
|
+ Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration, CoreAPIHttpService _coreAPIHttpService,DingDing _dingDing,AzureRedisFactory _azureRedis)
|
|
|
{
|
|
|
if (lessonRecord.scope.Equals("school"))
|
|
|
{
|
|
@@ -570,8 +572,36 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- save = false;
|
|
|
- school_lesson_expire = Constant.school_lesson_expire;
|
|
|
+ ///未设置openAutoClean=1时,则检查学校使用空间是否充足。
|
|
|
+ var sbm = new List<ServiceBusMessage>();
|
|
|
+ double usize = 0;
|
|
|
+ int tsize = schoolBase.tsize;
|
|
|
+ //schoolBase.tsize
|
|
|
+ //計算學校或個人的使用空間
|
|
|
+ RedisValue redisValue = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", $"{schoolBase.id}");
|
|
|
+ if (redisValue.HasValue && long.TryParse(redisValue.ToString(), out var bsize))
|
|
|
+ {
|
|
|
+ usize = Math.Round(bsize / 1073741824.0 - (tsize), 2, MidpointRounding.AwayFromZero); //1073741824 1G
|
|
|
+ }
|
|
|
+ else //如果檢測不到緩存,觸發刷新計算空間
|
|
|
+ {
|
|
|
+ var messageBlob = new ServiceBusMessage(new { id = Guid.NewGuid().ToString(), progress = "update", name = $"{schoolBase.id}" }.ToJsonString()); ;
|
|
|
+ messageBlob.ApplicationProperties.Add("name", "BlobRoot");
|
|
|
+ sbm.Add(messageBlob);
|
|
|
+ await _serviceBus.GetServiceBusClient().SendBatchMessageAsync(_configuration.GetValue<string>("Azure:ServiceBus:ActiveTask"), sbm);
|
|
|
+
|
|
|
+ }
|
|
|
+ ///空间充足的情况保存。
|
|
|
+ if (schoolBase.size - usize > 0)
|
|
|
+ {
|
|
|
+ save = true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ save = false;
|
|
|
+ school_lesson_expire = Constant.school_lesson_expire;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
if (!save && school_lesson_expire > 0)
|
|
|
{
|