|
@@ -1270,10 +1270,12 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("school_code", out JsonElement code)) return BadRequest();
|
|
|
if (!request.TryGetProperty("action", out JsonElement type)) return BadRequest();
|
|
|
long usedSpace = 0;//已被使用的空間量(G)
|
|
|
+ School school = null;
|
|
|
+ string school_code = code.ToString(); // 學校簡碼
|
|
|
try
|
|
|
{
|
|
|
// [變數宣告]
|
|
|
- string school_code = code.ToString(); // 學校簡碼
|
|
|
+
|
|
|
string action = type.ToString(); // 功能分類
|
|
|
string queryText = ""; // 統一sql文記憶體
|
|
|
|
|
@@ -1309,6 +1311,10 @@ namespace TEAMModelOS.Controllers
|
|
|
long? syllabusSize = await blobClient.GetBlobsSize("syllabus");
|
|
|
long? examSize = await blobClient.GetBlobsSize("exam");
|
|
|
long? recordsSize = await blobClient.GetBlobsSize("records");
|
|
|
+ long? yxptSize = await blobClient.GetBlobsSize("yxpt");
|
|
|
+ long? trainSize = await blobClient.GetBlobsSize("train");
|
|
|
+ long? homeworkSize = await blobClient.GetBlobsSize("homework");
|
|
|
+ long? avatarSize = await blobClient.GetBlobsSize("avatar");
|
|
|
docSize = docSize != null ? docSize : 0;
|
|
|
videoSize = videoSize != null ? videoSize : 0;
|
|
|
imageSize = imageSize != null ? imageSize : 0;
|
|
@@ -1323,11 +1329,11 @@ namespace TEAMModelOS.Controllers
|
|
|
thumSize = thumSize != null ? thumSize : 0;
|
|
|
syllabusSize = syllabusSize != null ? syllabusSize : 0;
|
|
|
examSize = examSize != null ? examSize : 0;
|
|
|
- usedSpace = Convert.ToInt64(Math.Ceiling((double)((recordsSize+docSize + videoSize + imageSize + paperSize + itemSize + otherSize + voteSize + audioSize + resSize + tempSize + thumSize + syllabusSize + examSize) / bytes)));
|
|
|
+ usedSpace = Convert.ToInt64(Math.Ceiling((double)((avatarSize + homeworkSize + trainSize + yxptSize + recordsSize + docSize + videoSize + imageSize + paperSize + itemSize + otherSize + voteSize + audioSize + resSize + tempSize + thumSize + syllabusSize + examSize) / bytes)));
|
|
|
}
|
|
|
long avaliable = this.baseSpaceSize; // (G) 目前學校申請空間總數
|
|
|
long teacherSpace = 0; // 教師可設定的空間量(G)
|
|
|
- School school = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school_code, new PartitionKey("Base"));
|
|
|
+ school = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school_code, new PartitionKey("Base"));
|
|
|
if (school.size <= 0)
|
|
|
{
|
|
|
school.size = baseSpaceSize;
|
|
@@ -1462,6 +1468,19 @@ namespace TEAMModelOS.Controllers
|
|
|
await _dingDing.SendBotMsg($"OS,{_option.Location},schoool/teacher-space\n{ex.Message}\n{ex.StackTrace}\n{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
|
return BadRequest();
|
|
|
}
|
|
|
+ finally {
|
|
|
+ if (school != null) {
|
|
|
+ string sql = "select sum(c.size ) from c ";
|
|
|
+ int teachSize = 0;
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<int>(queryText: sql,
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
|
|
|
+ {
|
|
|
+ teachSize += item;
|
|
|
+ }
|
|
|
+ school.tsize = teachSize;
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey("Base"));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("teacher-import-manage")]
|