|
@@ -173,7 +173,6 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
int tsize = 0; //學校分配給老師的總空間
|
|
|
double usize = 0; //學校或個人已使用空間
|
|
|
string timezone = string.Empty;
|
|
|
-
|
|
|
if (sp)
|
|
|
{
|
|
|
//取得學校資訊
|
|
@@ -216,7 +215,6 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
messageBlob.ApplicationProperties.Add("name", "BlobRoot");
|
|
|
sbm.Add(messageBlob);
|
|
|
}
|
|
|
-
|
|
|
//取得學校或個人名單
|
|
|
(List<RMember> students, _) = await GroupListService.GetStutmdidListids(_coreAPIHttpService, db, _dingDing, new List<string>() { request.sid }, request.school);
|
|
|
//觸發IMEI更新消息
|
|
@@ -240,15 +238,42 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
};
|
|
|
await db.GetContainer(Constant.TEAMModelOS, request.sp.Equals("school") ? "School" : "Teacher").CreateItemAsync(lr, new PartitionKey(lr.code));
|
|
|
-
|
|
|
//觸發開課統計
|
|
|
var messageChange = new ServiceBusMessage(lr.ToJsonString());
|
|
|
messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
|
|
|
sbm.Add(messageChange);
|
|
|
-
|
|
|
//批量發送消息
|
|
|
await _serviceBus.GetServiceBusClient().SendBatchMessageAsync(_configuration.GetValue<string>("Azure:ServiceBus:ActiveTask"), sbm);
|
|
|
+
|
|
|
+ if (sp && usize>size)
|
|
|
+ {
|
|
|
+ ////处理学校开课,空间不足时。检查是否有 当前教师tid,强制保存save<>1,没有标记未删除status<>404,没有被收藏favorite<=0 ,时间最旧的一条记录startTime
|
|
|
+ LessonRecord lessonRecord = null;
|
|
|
+ string sql = $"SELECT top 1 value(c) FROM c where ( c.expire<=0 or IS_DEFINED(c.expire) = false ) and c.tmdid='{tid}' and c.save<>1 and c.status<>404 and c.favorite<=0 order by c.startTime ";
|
|
|
+ await foreach (var item in db.GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<LessonRecord>(
|
|
|
+ queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"LessonRecord-{request.school}") }))
|
|
|
+ {
|
|
|
+ lessonRecord = item;
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
+ if (lessonRecord != null)
|
|
|
+ {
|
|
|
+ lessonRecord.status = 404;
|
|
|
+ await db.GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(lessonRecord, lessonRecord.id, new PartitionKey(lessonRecord.code));
|
|
|
+ var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
+ var messageChangeEvent = new ServiceBusMessage(request.ToJsonString());
|
|
|
+ messageChangeEvent.ApplicationProperties.Add("name", "LessonRecordEvent");
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChangeEvent);
|
|
|
+ //保证客户端可以正常开课。
|
|
|
+ usize -= 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ { //没有找到匹配当前 教师tid,save<>1,status<>404,没有被收藏,时间最旧的一条记录。无法手动再继续 usize -= 1;,则不能继续开课。
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return Ok(new { status = 200, lr.id, students, size, usize });
|
|
|
}
|
|
|
catch (Exception ex)
|