|
@@ -6,7 +6,6 @@ using Microsoft.Azure.WebJobs;
|
|
|
using Microsoft.Azure.WebJobs.Extensions.Http;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
-using Newtonsoft.Json;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
|
using Azure.Cosmos;
|
|
|
using System.Text.Json;
|
|
@@ -117,7 +116,7 @@ namespace TEAMModelFunction
|
|
|
{
|
|
|
log.LogInformation("fix-exam-activity...");
|
|
|
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
- List<string> datas = JsonConvert.DeserializeObject<List<string>>(requestBody);
|
|
|
+ List<string> datas = JsonSerializer.Deserialize<List<string>>(requestBody);
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
var query = $"select * from c ";
|
|
@@ -214,7 +213,7 @@ namespace TEAMModelFunction
|
|
|
|
|
|
log.LogInformation("fix-vote-activity...");
|
|
|
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
- List<string> datas = JsonConvert.DeserializeObject<List<string>>(requestBody);
|
|
|
+ List<string> datas = JsonSerializer.Deserialize<List<string>>(requestBody);
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
var query = $"select * from c ";
|
|
@@ -308,7 +307,7 @@ namespace TEAMModelFunction
|
|
|
{
|
|
|
log.LogInformation("fix-survey-activity...");
|
|
|
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
- List<string> datas = JsonConvert.DeserializeObject<List<string>>(requestBody);
|
|
|
+ List<string> datas = JsonSerializer.Deserialize<List<string>>(requestBody);
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
var query = $"select * from c ";
|
|
@@ -399,7 +398,7 @@ namespace TEAMModelFunction
|
|
|
ILogger log)
|
|
|
{
|
|
|
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
- dynamic json = JsonConvert.DeserializeObject<dynamic>(requestBody);
|
|
|
+ dynamic json = JsonSerializer.Deserialize<dynamic>(requestBody);
|
|
|
string id = json.id;
|
|
|
string code = json.code;
|
|
|
if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(code)) {
|
|
@@ -474,7 +473,37 @@ namespace TEAMModelFunction
|
|
|
/// <summary>
|
|
|
///获取单个目录的大小,用于获取评测,试题,试卷,问卷,投票等 文件层级超过两层的文件。
|
|
|
///例如 /exam/uuid/xxx /item/uuid/xxx /paper/uuid/xxx /vote/uuid/xxx /suervy/uuid/xxx
|
|
|
- /// {""}
|
|
|
+ /// {"name":"hbcn","/item/uuid/xxx"}
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="req"></param>
|
|
|
+ /// <param name="log"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [FunctionName("get-prefixsize")]
|
|
|
+ public async Task<IActionResult> GetPrefixsize(
|
|
|
+ [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
|
|
|
+ ILogger log)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
+ var data = System.Text.Json.JsonSerializer.Deserialize<JsonElement>(requestBody);
|
|
|
+ if (data.TryGetProperty("name", out JsonElement name) && data.TryGetProperty("root", out JsonElement root))
|
|
|
+ {
|
|
|
+ var size = await _azureStorage.GetBlobContainerClient($"{name}").GetBlobsSize($"{root}");
|
|
|
+ return new OkObjectResult(new { size = size });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new BadRequestResult();
|
|
|
+ }
|
|
|
+ } catch (Exception ex) {
|
|
|
+ await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,get-prefixsize()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return new BadRequestResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ ///获取多个blob路径的文件大小
|
|
|
+ /// {"name":"hbcn","blobs":["/paper/uuid/xxx.json","/paper/uuid/aaa.json"]}
|
|
|
/// </summary>
|
|
|
/// <param name="req"></param>
|
|
|
/// <param name="log"></param>
|
|
@@ -484,15 +513,25 @@ namespace TEAMModelFunction
|
|
|
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
|
|
|
ILogger log)
|
|
|
{
|
|
|
- string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
- var data = System.Text.Json.JsonSerializer.Deserialize<JsonElement>(requestBody);
|
|
|
- if (data.TryGetProperty("name", out JsonElement name)) {
|
|
|
- await _azureStorage.GetBlobContainerClient($"{name}").GetBlobsSize();
|
|
|
+ try {
|
|
|
+ string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
+ var data = System.Text.Json.JsonSerializer.Deserialize<JsonElement>(requestBody);
|
|
|
+ if (data.TryGetProperty("name", out JsonElement name) && data.TryGetProperty("blobs", out JsonElement blob))
|
|
|
+ {
|
|
|
+ List<string> blobs = JsonSerializer.Deserialize<List<string>>(blob.ToJsonString());
|
|
|
+ var size= await _azureStorage.GetBlobContainerClient($"{name}").GetBlobsSize(blobs);
|
|
|
+ return new OkObjectResult(new { size = size });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return new BadRequestResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,get-blobsize()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return new BadRequestResult();
|
|
|
}
|
|
|
-
|
|
|
- return new OkObjectResult(new { code = 200 });
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|