|
@@ -22,13 +22,13 @@ namespace IES.ExamServer.Controllers
|
|
private readonly IConfiguration _configuration;
|
|
private readonly IConfiguration _configuration;
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
private readonly IMemoryCache _memoryCache;
|
|
private readonly IMemoryCache _memoryCache;
|
|
- private readonly ILogger<ManageController> _logger;
|
|
|
|
|
|
+ private readonly ILogger _logger;
|
|
private readonly LiteDBFactory _liteDBFactory;
|
|
private readonly LiteDBFactory _liteDBFactory;
|
|
private readonly DataCenterConnectionService _connectionService;
|
|
private readonly DataCenterConnectionService _connectionService;
|
|
private readonly int DelayMicro = 10;//微观数据延迟
|
|
private readonly int DelayMicro = 10;//微观数据延迟
|
|
private readonly int DelayMacro = 100;//宏观数据延迟
|
|
private readonly int DelayMacro = 100;//宏观数据延迟
|
|
private readonly SignalRExamServerHub _signalRExamServerHub;
|
|
private readonly SignalRExamServerHub _signalRExamServerHub;
|
|
- public ManageController(LiteDBFactory liteDBFactory,ILogger<ManageController> logger, IConfiguration configuration,
|
|
|
|
|
|
+ public ManageController(LiteDBFactory liteDBFactory,ILogger logger, IConfiguration configuration,
|
|
IHttpClientFactory httpClientFactory, IMemoryCache memoryCache, DataCenterConnectionService connectionService,SignalRExamServerHub signalRExamServerHub)
|
|
IHttpClientFactory httpClientFactory, IMemoryCache memoryCache, DataCenterConnectionService connectionService,SignalRExamServerHub signalRExamServerHub)
|
|
{
|
|
{
|
|
_logger = logger;
|
|
_logger = logger;
|
|
@@ -100,17 +100,17 @@ namespace IES.ExamServer.Controllers
|
|
if (message.IsSuccessStatusCode)
|
|
if (message.IsSuccessStatusCode)
|
|
{
|
|
{
|
|
string content = await message.Content.ReadAsStringAsync();
|
|
string content = await message.Content.ReadAsStringAsync();
|
|
- JsonNode? jsonNode =JsonSerializer.Deserialize<JsonNode>(content);
|
|
|
|
|
|
+ JsonNode? jsonNode =content.ToObject<JsonNode>();
|
|
if (jsonNode!=null)
|
|
if (jsonNode!=null)
|
|
{
|
|
{
|
|
- evaluationCloud= JsonSerializer.Deserialize<EvaluationClient>(jsonNode["evaluation"]);
|
|
|
|
|
|
+ evaluationCloud=jsonNode["evaluation"]?.ToObject<EvaluationClient>();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//数据,文件,页面 0 没有更新,1 有更新
|
|
//数据,文件,页面 0 没有更新,1 有更新
|
|
- int data = 0,blob=0,webview=0,status=0;
|
|
|
|
- long dataSize = 0, blobSize=0 , webviewSize=0;
|
|
|
|
|
|
+ int data = 0,blob=0,webview=0, groupList=0, status=0;
|
|
|
|
+ long dataSize = 0, blobSize=0 , webviewSize=0, studentCount=0;
|
|
if (evaluationLocal== null && evaluationCloud==null)
|
|
if (evaluationLocal== null && evaluationCloud==null)
|
|
{
|
|
{
|
|
//线上线下没有数据
|
|
//线上线下没有数据
|
|
@@ -130,7 +130,9 @@ namespace IES.ExamServer.Controllers
|
|
blobSize=evaluationCloud.blobSize;
|
|
blobSize=evaluationCloud.blobSize;
|
|
}
|
|
}
|
|
if ((evaluationLocal.dataTime<evaluationCloud.dataTime)
|
|
if ((evaluationLocal.dataTime<evaluationCloud.dataTime)
|
|
- ||(evaluationLocal.dataSize!=evaluationCloud.dataSize))
|
|
|
|
|
|
+ ||(evaluationLocal.dataSize!=evaluationCloud.dataSize)
|
|
|
|
+ ||(evaluationLocal.paperCount!= evaluationCloud.paperCount)
|
|
|
|
+ )
|
|
{
|
|
{
|
|
data=1;
|
|
data=1;
|
|
dataSize=evaluationCloud.dataSize;
|
|
dataSize=evaluationCloud.dataSize;
|
|
@@ -143,6 +145,11 @@ namespace IES.ExamServer.Controllers
|
|
webview=1;
|
|
webview=1;
|
|
webviewSize=evaluationCloud.webviewSize;
|
|
webviewSize=evaluationCloud.webviewSize;
|
|
}
|
|
}
|
|
|
|
+ if ((evaluationLocal.studentCount!= evaluationCloud.studentCount)||(!$"{evaluationLocal.grouplistHash}".Equals(evaluationCloud.grouplistHash)))
|
|
|
|
+ {
|
|
|
|
+ groupList=1;
|
|
|
|
+ studentCount=evaluationCloud.studentCount;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else if (evaluationLocal!=null && evaluationCloud==null)
|
|
else if (evaluationLocal!=null && evaluationCloud==null)
|
|
{
|
|
{
|
|
@@ -156,9 +163,11 @@ namespace IES.ExamServer.Controllers
|
|
blob=1;
|
|
blob=1;
|
|
data=1;
|
|
data=1;
|
|
webview=1;
|
|
webview=1;
|
|
|
|
+ groupList=1;
|
|
blobSize=evaluationCloud.blobSize;
|
|
blobSize=evaluationCloud.blobSize;
|
|
dataSize=evaluationCloud.dataSize;
|
|
dataSize=evaluationCloud.dataSize;
|
|
webviewSize=evaluationCloud.webviewSize;
|
|
webviewSize=evaluationCloud.webviewSize;
|
|
|
|
+ studentCount=evaluationCloud.studentCount;
|
|
status = 4;
|
|
status = 4;
|
|
_liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Insert(evaluationLocal);
|
|
_liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Insert(evaluationLocal);
|
|
}
|
|
}
|
|
@@ -168,7 +177,7 @@ namespace IES.ExamServer.Controllers
|
|
|
|
|
|
|
|
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
- new MessageContent {messageType=Constant._Message_type_message, status=0, content="开始检查评测信息文件.." });
|
|
|
|
|
|
+ new MessageContent {dataId=evaluationLocal.id,dataName=evaluationLocal.name,messageType=Constant._Message_type_message, status=0, content="开始检查评测信息文件.." });
|
|
//校验本地文件数据
|
|
//校验本地文件数据
|
|
string packagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "package");
|
|
string packagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "package");
|
|
if (!Directory.Exists(packagePath))
|
|
if (!Directory.Exists(packagePath))
|
|
@@ -185,12 +194,31 @@ namespace IES.ExamServer.Controllers
|
|
else
|
|
else
|
|
{
|
|
{
|
|
msg_status=Constant._Message_status_success;
|
|
msg_status=Constant._Message_status_success;
|
|
|
|
+ //string jsonData = await System.IO.File.ReadAllTextAsync(path_evaluation);
|
|
|
|
+ //EvaluationClient? evaluationFile =jsonData.ToObject<EvaluationClient>();
|
|
|
|
+ //if (evaluationFile!=null)
|
|
|
|
+ //{
|
|
|
|
+ // if (evaluationFile.dataSize==evaluationLocal.dataSize )
|
|
|
|
+ // {
|
|
|
|
+ // file_error.Add("evaluation");
|
|
|
|
+ // msg_status=Constant._Message_status_error;
|
|
|
|
+ // }
|
|
|
|
+ // else
|
|
|
|
+ // {
|
|
|
|
+ // msg_status=Constant._Message_status_success;
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ //else
|
|
|
|
+ //{
|
|
|
|
+ // file_error.Add("evaluation");
|
|
|
|
+ // msg_status=Constant._Message_status_error;
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
//数据格式: [消息][信息/错误/警告][15:43]=>[开始检查评测信息文件...]
|
|
//数据格式: [消息][信息/错误/警告][15:43]=>[开始检查评测信息文件...]
|
|
//数据格式: [检查][成功/失败][15:43]=>[评测数据文件:/wwwroot/package/623a9fe6-5445-0938-ff77-aeb80066ef27/evaluation.json]
|
|
//数据格式: [检查][成功/失败][15:43]=>[评测数据文件:/wwwroot/package/623a9fe6-5445-0938-ff77-aeb80066ef27/evaluation.json]
|
|
//数据格式: [下载][成功/失败][15:43]=>[评测数据文件:/wwwroot/package/623a9fe6-5445-0938-ff77-aeb80066ef27/evaluation.json][1024kb][15ms]
|
|
//数据格式: [下载][成功/失败][15:43]=>[评测数据文件:/wwwroot/package/623a9fe6-5445-0938-ff77-aeb80066ef27/evaluation.json][1024kb][15ms]
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
- new MessageContent { messageType= Constant._Message_type_check, status=msg_status,content=$"评测数据文件:{path_evaluation}" });
|
|
|
|
|
|
+ new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType= Constant._Message_type_check, status=msg_status,content=$"评测数据文件:{path_evaluation}" });
|
|
//await Task.Delay(DelayMacro);
|
|
//await Task.Delay(DelayMacro);
|
|
string path_groupList = Path.Combine(evaluationPath, "groupList.json");
|
|
string path_groupList = Path.Combine(evaluationPath, "groupList.json");
|
|
msg_status =Constant._Message_status_info;
|
|
msg_status =Constant._Message_status_info;
|
|
@@ -204,7 +232,7 @@ namespace IES.ExamServer.Controllers
|
|
msg_status=Constant._Message_status_success;
|
|
msg_status=Constant._Message_status_success;
|
|
}
|
|
}
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
- new MessageContent { messageType= Constant._Message_type_check, status=msg_status, content=$"评测名单文件:{path_groupList}" });
|
|
|
|
|
|
+ new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType= Constant._Message_type_check, status=msg_status, content=$"评测名单文件:{path_groupList}" });
|
|
//await Task.Delay(DelayMacro);
|
|
//await Task.Delay(DelayMacro);
|
|
string path_source = Path.Combine(evaluationPath, "source.json");
|
|
string path_source = Path.Combine(evaluationPath, "source.json");
|
|
msg_status = Constant._Message_status_info;
|
|
msg_status = Constant._Message_status_info;
|
|
@@ -218,17 +246,17 @@ namespace IES.ExamServer.Controllers
|
|
msg_status=Constant._Message_status_success;
|
|
msg_status=Constant._Message_status_success;
|
|
}
|
|
}
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
- new MessageContent { messageType= Constant._Message_type_check, status=msg_status, content=$"评测原始数据:{path_source}" });
|
|
|
|
|
|
+ new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType= Constant._Message_type_check, status=msg_status, content=$"评测原始数据:{path_source}" });
|
|
// await Task.Delay(DelayMacro);
|
|
// await Task.Delay(DelayMacro);
|
|
msg_status =Constant._Message_status_info;
|
|
msg_status =Constant._Message_status_info;
|
|
try {
|
|
try {
|
|
|
|
|
|
string evaluation_str = await System.IO.File.ReadAllTextAsync(path_evaluation);
|
|
string evaluation_str = await System.IO.File.ReadAllTextAsync(path_evaluation);
|
|
- JsonNode? evaluation_data = JsonSerializer.Deserialize<JsonNode>(evaluation_str);
|
|
|
|
|
|
+ JsonNode? evaluation_data = evaluation_str.ToObject<JsonNode>();
|
|
|
|
|
|
if (evaluation_data!=null)
|
|
if (evaluation_data!=null)
|
|
{
|
|
{
|
|
- EvaluationClient? evaluationClient = JsonSerializer.Deserialize<EvaluationClient>(evaluation_data["evaluationClient"]);
|
|
|
|
|
|
+ EvaluationClient? evaluationClient = evaluation_data["evaluationClient"]?.ToObject<EvaluationClient>();
|
|
if (evaluationClient!=null)
|
|
if (evaluationClient!=null)
|
|
{
|
|
{
|
|
if ((!string.IsNullOrWhiteSpace(evaluationLocal.blobHash) && evaluationLocal.blobHash.Equals(evaluationClient.blobHash))
|
|
if ((!string.IsNullOrWhiteSpace(evaluationLocal.blobHash) && evaluationLocal.blobHash.Equals(evaluationClient.blobHash))
|
|
@@ -247,10 +275,10 @@ namespace IES.ExamServer.Controllers
|
|
msg_status=Constant._Message_status_error;
|
|
msg_status=Constant._Message_status_error;
|
|
}
|
|
}
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
- new MessageContent { messageType=Constant._Message_type_message, status=msg_status, content="校验本地数据文件..." });
|
|
|
|
|
|
+ new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType=Constant._Message_type_message, status=msg_status, content="校验本地数据文件..." });
|
|
}
|
|
}
|
|
|
|
|
|
- List<EvaluationExam>? evaluationExams = JsonSerializer.Deserialize<List<EvaluationExam>>(evaluation_data["evaluationExams"]);
|
|
|
|
|
|
+ List<EvaluationExam>? evaluationExams = evaluation_data["evaluationExams"]?.ToObject<List<EvaluationExam>>();
|
|
if (evaluationExams.IsNotEmpty())
|
|
if (evaluationExams.IsNotEmpty())
|
|
{
|
|
{
|
|
string path_papers = Path.Combine(evaluationPath, "papers");
|
|
string path_papers = Path.Combine(evaluationPath, "papers");
|
|
@@ -286,7 +314,10 @@ namespace IES.ExamServer.Controllers
|
|
msg_status=Constant._Message_status_warning; ;
|
|
msg_status=Constant._Message_status_warning; ;
|
|
paper_error_count++;
|
|
paper_error_count++;
|
|
}
|
|
}
|
|
- contents.Add(new MessageContent { messageType=Constant._Message_type_check, status=msg_status, content=$"试卷文件信息:{paper.paperName}" });
|
|
|
|
|
|
+ contents.Add(new MessageContent {
|
|
|
|
+ dataId=evaluationLocal.id,
|
|
|
|
+ dataName=evaluationLocal.name,
|
|
|
|
+ messageType=Constant._Message_type_check, status=msg_status, content=$"试卷文件信息:{paper.paperName}" });
|
|
}
|
|
}
|
|
int paper_msg_status = Constant. _Message_status_info;
|
|
int paper_msg_status = Constant. _Message_status_info;
|
|
if (paper_error_count>0)
|
|
if (paper_error_count>0)
|
|
@@ -298,6 +329,8 @@ namespace IES.ExamServer.Controllers
|
|
}
|
|
}
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
new MessageContent {
|
|
new MessageContent {
|
|
|
|
+ dataId=evaluationLocal.id,
|
|
|
|
+ dataName=evaluationLocal.name,
|
|
messageType=Constant._Message_type_message,
|
|
messageType=Constant._Message_type_message,
|
|
status=paper_msg_status,
|
|
status=paper_msg_status,
|
|
content=$"试卷名称:[{paperIndex}]{evaluationExam.examName}-{evaluationExam.subjectName}-{paper.paperName}\r\n文件数量:{paper.blobs.Count()},检测成功数量:{contents.Count(x => x.status==Constant._Message_status_success)},检测异常数量{contents.Count(x => x.status==Constant._Message_status_error)}",
|
|
content=$"试卷名称:[{paperIndex}]{evaluationExam.examName}-{evaluationExam.subjectName}-{paper.paperName}\r\n文件数量:{paper.blobs.Count()},检测成功数量:{contents.Count(x => x.status==Constant._Message_status_success)},检测异常数量{contents.Count(x => x.status==Constant._Message_status_error)}",
|
|
@@ -311,13 +344,14 @@ namespace IES.ExamServer.Controllers
|
|
catch (Exception e) {
|
|
catch (Exception e) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ //检测参考名单
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
await _signalRExamServerHub.SendMessage(deviceId, Constant._Message_grant_type_check_file,
|
|
- new MessageContent { messageType=Constant._Message_type_message, status=0, content="提取评测数据文件..." });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ new MessageContent {
|
|
|
|
+ dataId=evaluationLocal.id,
|
|
|
|
+ dataName=evaluationLocal.name,
|
|
|
|
+ messageType=Constant._Message_type_message, status=0, content="提取评测数据文件..." });
|
|
}
|
|
}
|
|
-
|
|
|
|
- return Ok(new {code=200, evaluation= evaluationLocal,data,blob,webview,dataSize,blobSize,webviewSize,status });
|
|
|
|
|
|
+ return Ok(new {code=200, evaluation= evaluationLocal,data,blob,webview,dataSize,blobSize,webviewSize,status ,groupList,studentCount});
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|