|
@@ -41,6 +41,9 @@ namespace IES.ExamServer.Controllers
|
|
|
_connectionService=connectionService;
|
|
|
_signalRExamServerHub=signalRExamServerHub;
|
|
|
}
|
|
|
+ ///通过线上回传数据需要鉴权验证等操作。
|
|
|
+ ///通过离线包回传数据需要加密操作
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 清理缓存,列出缓存占用空间,type =list列出,type=clear清理,不能清理近期及正在激活的数据,并且提示清理中暂未上传或者导出的数据。
|
|
|
/// </summary>
|
|
@@ -175,30 +178,35 @@ namespace IES.ExamServer.Controllers
|
|
|
client.DefaultRequestHeaders.Remove(Constant._X_Auth_AuthToken);
|
|
|
}
|
|
|
client.DefaultRequestHeaders.Add(Constant._X_Auth_AuthToken, teacher.x_auth_token);
|
|
|
- HttpResponseMessage message = await client.PostAsJsonAsync($"{CenterUrl}/evaluation-sync/find-sync-info", new { shortCode, evaluationId });
|
|
|
- if (message.IsSuccessStatusCode)
|
|
|
- {
|
|
|
- string content = await message.Content.ReadAsStringAsync();
|
|
|
- JsonNode? jsonNode = content.ToObject<JsonNode>();
|
|
|
- if (jsonNode != null)
|
|
|
+ try {
|
|
|
+ HttpResponseMessage message = await client.PostAsJsonAsync($"{CenterUrl}/evaluation-sync/find-sync-info", new { shortCode, evaluationId });
|
|
|
+ if (message.IsSuccessStatusCode)
|
|
|
{
|
|
|
- centerCode = $"{jsonNode["code"]}";
|
|
|
- centerMsg = $"{jsonNode["msg"]}";
|
|
|
- if ($"{jsonNode["code"]}".Equals("200"))
|
|
|
+ string content = await message.Content.ReadAsStringAsync();
|
|
|
+ JsonNode? jsonNode = content.ToObject<JsonNode>();
|
|
|
+ if (jsonNode != null)
|
|
|
{
|
|
|
- evaluationCloud = jsonNode["evaluation"]?.ToObject<EvaluationClient>();
|
|
|
+ centerCode = $"{jsonNode["code"]}";
|
|
|
+ centerMsg = $"{jsonNode["msg"]}";
|
|
|
+ if ($"{jsonNode["code"]}".Equals("200"))
|
|
|
+ {
|
|
|
+ evaluationCloud = jsonNode["evaluation"]?.ToObject<EvaluationClient>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ centerCode = "500";
|
|
|
+ centerMsg = "数据转换异常";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- centerCode = "500";
|
|
|
- centerMsg = "数据转换异常";
|
|
|
+ centerCode = $"{message.StatusCode}";
|
|
|
+ centerMsg = "数据中心访问异常";
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- centerCode = $"{message.StatusCode}";
|
|
|
- centerMsg = "数据中心访问异常";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ centerCode = $"500";
|
|
|
+ centerMsg = $"数据中心访问异常:{ex.Message}";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -291,7 +299,6 @@ namespace IES.ExamServer.Controllers
|
|
|
status = 4;
|
|
|
_liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Insert(evaluationLocal);
|
|
|
}
|
|
|
- List<string> file_error = new List<string>();
|
|
|
|
|
|
if (evaluationLocal!=null)
|
|
|
{
|
|
@@ -301,35 +308,19 @@ namespace IES.ExamServer.Controllers
|
|
|
//校验本地文件数据
|
|
|
string packagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "package");
|
|
|
if (!Directory.Exists(packagePath))
|
|
|
- Directory.CreateDirectory(packagePath);
|
|
|
- string evaluationPath = Path.Combine(packagePath,"exam", evaluationLocal.id!);
|
|
|
- // await Task.Delay(DelayMacro);
|
|
|
-
|
|
|
- string path_evaluation = Path.Combine(evaluationPath, "evaluation.json");
|
|
|
- if (!System.IO.File.Exists(path_evaluation))
|
|
|
{
|
|
|
- file_error.Add("evaluation");
|
|
|
- msg_status=Constant._Message_status_error;
|
|
|
- checkTotal++;
|
|
|
- checkError++;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- msg_status=Constant._Message_status_success;
|
|
|
- checkTotal++;
|
|
|
- checkSuccess++;
|
|
|
+ Directory.CreateDirectory(packagePath);
|
|
|
}
|
|
|
- //数据格式: [消息][信息/错误/警告][15:43]=>[开始检查评测信息文件...]
|
|
|
- //数据格式: [检查][成功/失败][15:43]=>[评测数据文件:/wwwroot/package/623a9fe6-5445-0938-ff77-aeb80066ef27/evaluation.json]
|
|
|
- //数据格式: [下载][成功/失败][15:43]=>[评测数据文件:/wwwroot/package/623a9fe6-5445-0938-ff77-aeb80066ef27/evaluation.json][1024kb][15ms]
|
|
|
- await _signalRExamServerHub.SendMessage(_memoryCache,_logger,deviceId, Constant._Message_grant_type_check_file,
|
|
|
- new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType= Constant._Message_type_check, status=msg_status,content=$"评测数据文件:{path_evaluation}" });
|
|
|
+ string evaluationPath = Path.Combine(packagePath, evaluationLocal.id!);
|
|
|
+ string evaluationDataPath = Path.Combine(evaluationPath,"data");
|
|
|
+ // await Task.Delay(DelayMacro);
|
|
|
+
|
|
|
//await Task.Delay(DelayMacro);
|
|
|
- string path_groupList = Path.Combine(evaluationPath, "groupList.json");
|
|
|
+ string path_groupList = Path.Combine(evaluationDataPath, "groupList.json");
|
|
|
msg_status =Constant._Message_status_info;
|
|
|
if (!System.IO.File.Exists(path_groupList))
|
|
|
{
|
|
|
- file_error.Add("groupList");
|
|
|
+ groupList=1;
|
|
|
msg_status=Constant._Message_status_error;
|
|
|
checkTotal++;
|
|
|
checkError++;
|
|
@@ -343,11 +334,11 @@ namespace IES.ExamServer.Controllers
|
|
|
await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_check_file,
|
|
|
new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType= Constant._Message_type_check, status=msg_status, content=$"评测名单文件:{path_groupList}" });
|
|
|
//await Task.Delay(DelayMacro);
|
|
|
- string path_source = Path.Combine(evaluationPath, "source.json");
|
|
|
+ string path_source = Path.Combine(evaluationDataPath, "source.json");
|
|
|
msg_status = Constant._Message_status_info;
|
|
|
if (!System.IO.File.Exists(path_source))
|
|
|
{
|
|
|
- file_error.Add("source");
|
|
|
+ data=1;
|
|
|
msg_status=Constant._Message_status_error;
|
|
|
checkTotal++;
|
|
|
checkError++;
|
|
@@ -360,102 +351,144 @@ namespace IES.ExamServer.Controllers
|
|
|
}
|
|
|
await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_check_file,
|
|
|
new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType= Constant._Message_type_check, status=msg_status, content=$"评测原始数据:{path_source}" });
|
|
|
- // await Task.Delay(DelayMacro);
|
|
|
msg_status =Constant._Message_status_info;
|
|
|
try {
|
|
|
//TODO 重整本地文件路径。 文件可能不存在D:\VisualStudioProjects\TEAMModelOS\TEAMModelOS.Extension\IES.Exam\IES.ExamServer\wwwroot\package\exam\6af32bbd-144e-4366-8bc0-61ba4c85677c\evaluation.json
|
|
|
- string evaluation_str = await System.IO.File.ReadAllTextAsync(path_evaluation);
|
|
|
- JsonNode? evaluation_data = evaluation_str.ToObject<JsonNode>();
|
|
|
-
|
|
|
- if (evaluation_data!=null)
|
|
|
+ string path_evaluation = Path.Combine(evaluationDataPath, "evaluation.json");
|
|
|
+ if (!System.IO.File.Exists(path_evaluation))
|
|
|
+ {
|
|
|
+ blob=1;
|
|
|
+ data=1;
|
|
|
+ msg_status=Constant._Message_status_error;
|
|
|
+ checkTotal++;
|
|
|
+ checkError++;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- EvaluationClient? evaluationClient = evaluation_data["evaluationClient"]?.ToObject<EvaluationClient>();
|
|
|
- if (evaluationClient!=null)
|
|
|
+ msg_status=Constant._Message_status_success;
|
|
|
+ checkTotal++;
|
|
|
+ checkSuccess++;
|
|
|
+ }
|
|
|
+ //数据格式: [消息][信息/错误/警告][15:43]=>[开始检查评测信息文件...]
|
|
|
+ //数据格式: [检查][成功/失败][15:43]=>[评测数据文件:/wwwroot/package/623a9fe6-5445-0938-ff77-aeb80066ef27/evaluation.json]
|
|
|
+ //数据格式: [下载][成功/失败][15:43]=>[评测数据文件:/wwwroot/package/623a9fe6-5445-0938-ff77-aeb80066ef27/evaluation.json][1024kb][15ms]
|
|
|
+ await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_check_file,
|
|
|
+ new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType= Constant._Message_type_check, status=msg_status, content=$"评测数据文件:{path_evaluation}" });
|
|
|
+ if (System.IO.File.Exists(path_evaluation))
|
|
|
+ {
|
|
|
+ string evaluation_str = await System.IO.File.ReadAllTextAsync(path_evaluation);
|
|
|
+ JsonNode? evaluation_data = evaluation_str.ToObject<JsonNode>();
|
|
|
+ if (evaluation_data==null)
|
|
|
+ {
|
|
|
+ blob=1;
|
|
|
+ data=1;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- if ((!string.IsNullOrWhiteSpace(evaluationLocal.blobHash) && evaluationLocal.blobHash.Equals(evaluationClient.blobHash))
|
|
|
- &&(evaluationLocal.blobTime==evaluationClient.blobTime)
|
|
|
- &&(evaluationLocal.blobCount== evaluationClient.blobCount)
|
|
|
- &&(evaluationLocal.blobSize== evaluationClient.blobSize)&& (evaluationLocal.dataTime==evaluationClient.dataTime)
|
|
|
- &&(evaluationLocal.dataSize==evaluationClient.dataSize)&&(evaluationLocal.webviewCount==evaluationClient.webviewCount)
|
|
|
- &&(evaluationLocal.webviewSize== evaluationClient.webviewSize)
|
|
|
- &&(evaluationLocal.webviewTime== evaluationClient.webviewTime)
|
|
|
- &&(!string.IsNullOrWhiteSpace(evaluationLocal.webviewPath)&& evaluationLocal.webviewPath.Equals(evaluationClient.webviewPath)))
|
|
|
+ EvaluationClient? evaluationClient = evaluation_data["evaluationClient"]?.ToObject<EvaluationClient>();
|
|
|
+ if (evaluationClient!=null)
|
|
|
{
|
|
|
- msg_status=Constant._Message_status_info;
|
|
|
+ if ((!string.IsNullOrWhiteSpace(evaluationLocal.blobHash) && evaluationLocal.blobHash.Equals(evaluationClient.blobHash))
|
|
|
+ &&(evaluationLocal.blobTime==evaluationClient.blobTime)
|
|
|
+ &&(evaluationLocal.blobCount== evaluationClient.blobCount)
|
|
|
+ &&(evaluationLocal.blobSize== evaluationClient.blobSize)&& (evaluationLocal.dataTime==evaluationClient.dataTime)
|
|
|
+ &&(evaluationLocal.dataSize==evaluationClient.dataSize)&&(evaluationLocal.webviewCount==evaluationClient.webviewCount)
|
|
|
+ &&(evaluationLocal.webviewSize== evaluationClient.webviewSize)
|
|
|
+ &&(evaluationLocal.webviewTime== evaluationClient.webviewTime)
|
|
|
+ &&(!string.IsNullOrWhiteSpace(evaluationLocal.webviewPath)&& evaluationLocal.webviewPath.Equals(evaluationClient.webviewPath)))
|
|
|
+ {
|
|
|
+ msg_status=Constant._Message_status_info;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data=1;
|
|
|
+ msg_status=Constant._Message_status_error;
|
|
|
+ }
|
|
|
+ await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_check_file,
|
|
|
+ new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType=Constant._Message_type_message, status=msg_status, content="校验本地试卷文件..." });
|
|
|
}
|
|
|
- else
|
|
|
+ else { data=1; }
|
|
|
+
|
|
|
+ List<EvaluationExam>? evaluationExams = evaluation_data["evaluationExams"]?.ToObject<List<EvaluationExam>>();
|
|
|
+ if (evaluationExams.IsEmpty())
|
|
|
{
|
|
|
- msg_status=Constant._Message_status_error;
|
|
|
+ blob=1;
|
|
|
+ data=1;
|
|
|
}
|
|
|
- await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_check_file,
|
|
|
- new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType=Constant._Message_type_message, status=msg_status, content="校验本地试卷文件..." });
|
|
|
- }
|
|
|
-
|
|
|
- List<EvaluationExam>? evaluationExams = evaluation_data["evaluationExams"]?.ToObject<List<EvaluationExam>>();
|
|
|
- if (evaluationExams.IsNotEmpty())
|
|
|
- {
|
|
|
- string path_papers = Path.Combine(evaluationPath, "papers");
|
|
|
- var papers_files = FileHelper.ListAllFiles(path_papers);
|
|
|
- foreach (var evaluationExam in evaluationExams!)
|
|
|
+ else
|
|
|
{
|
|
|
-
|
|
|
- int paperIndex = 0;
|
|
|
- foreach (var paper in evaluationExam.papers)
|
|
|
+
|
|
|
+ foreach (var evaluationExam in evaluationExams!)
|
|
|
{
|
|
|
- paperIndex++;
|
|
|
- List<MessageContent> contents = new List<MessageContent>();
|
|
|
- int paper_error_count = 0;
|
|
|
- foreach (var blobInfo in paper.blobs)
|
|
|
+ string path_papers = Path.Combine(evaluationPath, "exams");
|
|
|
+ var papers_files = FileHelper.ListAllFiles(path_papers);
|
|
|
+ int paperIndex = 0;
|
|
|
+ foreach (var paper in evaluationExam.papers)
|
|
|
{
|
|
|
- msg_status=Constant._Message_status_info;
|
|
|
- if (!string.IsNullOrWhiteSpace(blobInfo.path))
|
|
|
+ paperIndex++;
|
|
|
+ List<MessageContent> contents = new List<MessageContent>();
|
|
|
+ int paper_error_count = 0;
|
|
|
+ foreach (var blobInfo in paper.blobs)
|
|
|
{
|
|
|
-
|
|
|
- var file = papers_files.Find(x => x.Contains(blobInfo.path));
|
|
|
- if (file!=null)
|
|
|
+ msg_status=Constant._Message_status_info;
|
|
|
+ if (!string.IsNullOrWhiteSpace(blobInfo.path))
|
|
|
{
|
|
|
- msg_status=1;
|
|
|
- msg_status=Constant._Message_status_success;
|
|
|
+
|
|
|
+ var file = papers_files.Find(x => x.Contains(blobInfo.path));
|
|
|
+ if (file!=null)
|
|
|
+ {
|
|
|
+ msg_status=1;
|
|
|
+ msg_status=Constant._Message_status_success;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ msg_status=Constant._Message_status_error;
|
|
|
+ paper_error_count++;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- else {
|
|
|
- msg_status=Constant._Message_status_error;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ msg_status=Constant._Message_status_warning; ;
|
|
|
paper_error_count++;
|
|
|
}
|
|
|
-
|
|
|
+ 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;
|
|
|
+ if (paper_error_count>0)
|
|
|
+ {
|
|
|
+ blob=1;
|
|
|
+ paper_msg_status=Constant._Message_status_error;
|
|
|
}
|
|
|
- else {
|
|
|
- msg_status=Constant._Message_status_warning; ;
|
|
|
- paper_error_count++;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ paper_msg_status=Constant._Message_status_success;
|
|
|
}
|
|
|
- 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;
|
|
|
- if (paper_error_count>0)
|
|
|
- {
|
|
|
- paper_msg_status=Constant._Message_status_error;
|
|
|
- }
|
|
|
- else {
|
|
|
- paper_msg_status=Constant._Message_status_success;
|
|
|
+ await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_check_file,
|
|
|
+ new MessageContent
|
|
|
+ {
|
|
|
+ dataId=evaluationLocal.id,
|
|
|
+ dataName=evaluationLocal.name,
|
|
|
+ messageType=Constant._Message_type_message,
|
|
|
+ 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)}",
|
|
|
+ contents=contents
|
|
|
+ });
|
|
|
}
|
|
|
- await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_check_file,
|
|
|
- new MessageContent {
|
|
|
- dataId=evaluationLocal.id,
|
|
|
- dataName=evaluationLocal.name,
|
|
|
- messageType=Constant._Message_type_message,
|
|
|
- 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)}",
|
|
|
- contents=contents
|
|
|
- });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception e) {
|
|
|
-
|
|
|
+ catch (Exception e) {
|
|
|
+ _logger.LogData<object>(new {code=500,msg=e.Message,data = new { content= e.StackTrace } }, evaluationLocal.id!);
|
|
|
}
|
|
|
|
|
|
//检查需要更新的项目:
|
|
@@ -540,7 +573,7 @@ namespace IES.ExamServer.Controllers
|
|
|
checkTotal,
|
|
|
checkSuccess,
|
|
|
checkError,
|
|
|
- checkWarning
|
|
|
+ checkWarning,
|
|
|
});
|
|
|
}
|
|
|
|