|
@@ -21,6 +21,8 @@ using TEAMModelOS.SDK.Models.Service;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
using System.Text;
|
|
|
using static TEAMModelOS.SDK.Models.Teacher;
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.Common.Inner;
|
|
|
+using Azure.Storage.Blobs.Models;
|
|
|
|
|
|
namespace TEAMModelFunction
|
|
|
{
|
|
@@ -52,7 +54,7 @@ namespace TEAMModelFunction
|
|
|
[FunctionName("knowledge-change")]
|
|
|
public async Task<IActionResult> KnowledgeChange([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log) {
|
|
|
string data = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
- var json = JsonDocument.Parse(data).RootElement;
|
|
|
+ var json = JsonDocument.Parse(data).RootElement;
|
|
|
List<OldNew> old_new = null;
|
|
|
string school = null;
|
|
|
if (json.TryGetProperty("school", out JsonElement _school))
|
|
@@ -95,6 +97,22 @@ namespace TEAMModelFunction
|
|
|
});
|
|
|
foreach (var item in items)
|
|
|
{
|
|
|
+ ItemBlob itemBlob = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ BlobDownloadInfo blobDownloadResult = await _azureStorage.GetBlobContainerClient($"hbcn").GetBlobClient($"/item/{item.id}/{item.id}.json").DownloadAsync();
|
|
|
+ if (blobDownloadResult != null)
|
|
|
+ {
|
|
|
+ var blob = JsonDocument.Parse(blobDownloadResult.Content);
|
|
|
+ itemBlob = blob.RootElement.ToObject<ItemBlob>();
|
|
|
+ itemBlob.exercise.knowledge = item.knowledge;
|
|
|
+ await _azureStorage.UploadFileByContainer("hbcn", itemBlob.ToJsonString(), "item", $"{item.id}/{item.id}.json", true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ itemBlob = null;
|
|
|
+ }
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
|
|
|
}
|
|
|
}
|