|
@@ -16,6 +16,8 @@ using TEAMModelOS.SDK.Helper.Common.StringHelper;
|
|
|
using TEAMModelOS.Models;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
using System.Text;
|
|
|
+using Azure.Messaging.ServiceBus;
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -24,18 +26,22 @@ namespace TEAMModelOS.Controllers
|
|
|
//[Authorize(Roles = "IES5")]
|
|
|
[Route("teacher/comment")]
|
|
|
[ApiController]
|
|
|
- public class CommentController :ControllerBase
|
|
|
+ public class CommentController : ControllerBase
|
|
|
{
|
|
|
private readonly AzureCosmosFactory _azureCosmos;
|
|
|
private readonly DingDing _dingDing;
|
|
|
private readonly Option _option;
|
|
|
private readonly AzureStorageFactory _azureStorage;
|
|
|
- public CommentController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage)
|
|
|
+ public IConfiguration _configuration { get; set; }
|
|
|
+ private readonly AzureServiceBusFactory _serviceBus;
|
|
|
+ public CommentController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage, AzureServiceBusFactory serviceBus, IConfiguration configuration)
|
|
|
{
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_dingDing = dingDing;
|
|
|
_option = option?.Value;
|
|
|
_azureStorage = azureStorage;
|
|
|
+ _serviceBus = serviceBus;
|
|
|
+ _configuration = configuration;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -100,7 +106,7 @@ namespace TEAMModelOS.Controllers
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
- return Ok();
|
|
|
+ return Ok();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新保存教师评语罐头,如果评语列表为空则删除
|
|
@@ -126,7 +132,7 @@ namespace TEAMModelOS.Controllers
|
|
|
// {
|
|
|
// IdPk idPk = await _azureCosmos.DeleteAsync<Comment>(request.id, request.code);
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
//}
|
|
|
////return builder.Data(comment).build();
|
|
|
return Ok();
|
|
@@ -163,7 +169,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- ExamClassResult classResult = new ExamClassResult();
|
|
|
+ ExamClassResult classResult = new ExamClassResult();
|
|
|
List<List<string>> ans = answer.ToObject<List<List<string>>>();
|
|
|
List<List<string>> standard = new List<List<string>>();
|
|
|
List<double> points = new List<double>();
|
|
@@ -183,9 +189,11 @@ namespace TEAMModelOS.Controllers
|
|
|
/*string FileName = result.examId + "/" + result.subjectId + "/" + studentId + "mark";
|
|
|
string blob = await _azureStorage.UploadFileByContainer(school.ToString(), ans.ToJsonString(), "exam", FileName + "/" + "ans.json");*/
|
|
|
//result.studentAnswers[index].Add(blob);
|
|
|
- if (result.mark == null || result.mark.Count == 0) {
|
|
|
+ if (result.mark == null || result.mark.Count == 0)
|
|
|
+ {
|
|
|
List<string> annotation = new List<string>();
|
|
|
- foreach (string ids in result.studentIds) {
|
|
|
+ foreach (string ids in result.studentIds)
|
|
|
+ {
|
|
|
annotation.Add("");
|
|
|
}
|
|
|
result.mark = annotation;
|
|
@@ -193,7 +201,15 @@ namespace TEAMModelOS.Controllers
|
|
|
result.mark[index] = builder.ToString();
|
|
|
classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
|
|
|
}
|
|
|
+ await Task.WhenAll(tasks);
|
|
|
+ /* //变更blob 大小
|
|
|
+ ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new Azure.Cosmos.PartitionKey($"Exam-{school}"));
|
|
|
+ info.size = await _azureStorage.GetBlobContainerClient(school.ToString()).GetBlobsSize($"exam/{id}");
|
|
|
+ var messageBlob = new ServiceBusMessage(new { id = Guid.NewGuid().ToString(), progress = "annotation", root = $"exam/{id}", name = school }.ToJsonString());
|
|
|
|
|
|
+ messageBlob.ApplicationProperties.Add("name", "BlobRoot");
|
|
|
+ var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);*/
|
|
|
return Ok(new { classResult });
|
|
|
}
|
|
|
catch (Exception e)
|