ManageController.cs 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
  1. using ICSharpCode.SharpZipLib.GZip;
  2. using IES.ExamLibrary.Models;
  3. using IES.ExamServer.DI;
  4. using IES.ExamServer.DI.SignalRHost;
  5. using IES.ExamServer.Filters;
  6. using IES.ExamServer.Helper;
  7. using IES.ExamServer.Helpers;
  8. using IES.ExamServer.Models;
  9. using IES.ExamServer.Services;
  10. using Microsoft.AspNetCore.Http;
  11. using Microsoft.AspNetCore.Mvc;
  12. using Microsoft.AspNetCore.SignalR;
  13. using Microsoft.Extensions.Caching.Memory;
  14. using Microsoft.Extensions.Configuration;
  15. using System;
  16. using System.Diagnostics.Eventing.Reader;
  17. using System.Diagnostics.Metrics;
  18. using System.Linq.Expressions;
  19. using System.Net.Http;
  20. using System.Net.Http.Json;
  21. using System.Security.Cryptography.X509Certificates;
  22. using System.Text.Json;
  23. using System.Text.Json.Nodes;
  24. using System.Text.RegularExpressions;
  25. using static IES.ExamServer.Services.ManageService;
  26. using static System.Reflection.Metadata.BlobBuilder;
  27. namespace IES.ExamServer.Controllers
  28. {
  29. [ApiController]
  30. [Route("manage")]
  31. public class ManageController : BaseController
  32. {
  33. private readonly IConfiguration _configuration;
  34. private readonly IHttpClientFactory _httpClientFactory;
  35. private readonly IMemoryCache _memoryCache;
  36. private readonly ILogger<ManageController> _logger;
  37. private readonly LiteDBFactory _liteDBFactory;
  38. private readonly CenterServiceConnectionService _connectionService;
  39. private readonly int DelayMicro = 10;//微观数据延迟
  40. private readonly int DelayMacro = 100;//宏观数据延迟
  41. private readonly IHubContext<SignalRExamServerHub> _signalRExamServerHub;
  42. private readonly DataQueue _dataQueue;
  43. public ManageController(LiteDBFactory liteDBFactory, ILogger<ManageController> logger, IConfiguration configuration,
  44. IHttpClientFactory httpClientFactory, IMemoryCache memoryCache, CenterServiceConnectionService connectionService,
  45. IHubContext<SignalRExamServerHub> signalRExamServerHub, DataQueue dataQueue)
  46. {
  47. _logger = logger;
  48. _configuration=configuration;
  49. _httpClientFactory=httpClientFactory;
  50. _memoryCache=memoryCache;
  51. _liteDBFactory=liteDBFactory;
  52. _connectionService=connectionService;
  53. _signalRExamServerHub=signalRExamServerHub;
  54. _dataQueue=dataQueue;
  55. }
  56. /// <summary>
  57. /// 导出数据
  58. ///通过线上回传数据需要鉴权验证等操作。
  59. ///通过离线包回传数据需要加密操作
  60. /// </summary>
  61. /// <param name="json"></param>
  62. /// <returns></returns>
  63. [HttpPost("export-evaluation-result")]
  64. [AuthToken("admin", "teacher", "visitor")]
  65. public IActionResult ExportEvaluationResult(JsonNode json)
  66. {
  67. string evaluationId = $"{json["evaluationId"]}";
  68. string shortCode = $"{json["shortCode"]}";
  69. string openCode = $"{json["openCode"]}";
  70. string? loginToken = HttpContext.GetXAuth("AuthToken");
  71. EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>()
  72. .FindOne(x => x.id!.Equals(evaluationId) && x.openCode!.Equals(openCode));
  73. //已作答
  74. int answerCount = 0;
  75. //未作答
  76. int absentCount = 0;
  77. List<SubjectPushData> subjectPushDatas = new List<SubjectPushData>();
  78. List<SubjectPushData> subjectPushNew = new List<SubjectPushData>();
  79. if (evaluationClient!=null)
  80. {
  81. var datas = _liteDBFactory.GetLiteDatabase().GetCollection<SubjectPushData>()
  82. .Find(x => !string.IsNullOrWhiteSpace(x.evaluationId) && x.evaluationId!.Equals(evaluationId)).ToList();
  83. if (datas.IsNotEmpty())
  84. {
  85. subjectPushDatas.AddRange(datas);
  86. }
  87. var data = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>()
  88. .Find(x => !string.IsNullOrWhiteSpace(x.evaluationId) && x.evaluationId.Equals(evaluationId));
  89. if (data.IsNotEmpty())
  90. {
  91. foreach (var item in data)
  92. {
  93. foreach (var subjectResult in item.subjectResults)
  94. {
  95. if (subjectResult.finished==1)
  96. {
  97. SubjectPushData subjectPushData = new SubjectPushData(subjectResult, item);
  98. subjectPushData.loginToken=loginToken;
  99. if (!datas.Exists(x => x.id!.Equals(subjectPushData.id)))
  100. {
  101. //数据丢失导致的推送SubjectPushData 没有被保存的问题
  102. subjectPushDatas.Add(subjectPushData);
  103. subjectPushNew.Add(subjectPushData);
  104. }
  105. }
  106. else { absentCount++; }
  107. }
  108. }
  109. }
  110. if (subjectPushNew.IsNotEmpty())
  111. {
  112. _liteDBFactory.GetLiteDatabase().GetCollection<SubjectPushData>().Upsert(subjectPushNew);
  113. }
  114. }
  115. answerCount=subjectPushDatas.Count(x => x.finished==1 && x.answers.IsNotEmpty());
  116. absentCount+=subjectPushDatas.Count()-answerCount;
  117. //TODO 以及增加 作答文件的相关数据。
  118. return Ok(new { answerCount, absentCount, subjectPushDatas });
  119. }
  120. /// <summary>
  121. /// 手动推送
  122. ///通过线上回传数据需要鉴权验证等操作。
  123. ///通过离线包回传数据需要加密操作
  124. /// </summary>
  125. /// <param name="json"></param>
  126. /// <returns></returns>
  127. [HttpPost("manual-push")]
  128. [AuthToken("admin", "teacher", "visitor")]
  129. public async Task<IActionResult> ManualPush(JsonNode json)
  130. {
  131. string evaluationId = $"{json["evaluationId"]}";
  132. //string shortCode = $"{json["shortCode"]}";
  133. string openCode = $"{json["openCode"]}";
  134. string deviceId = $"{json["deviceId"]}";
  135. EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>()
  136. .FindOne(x => x.id!.Equals(evaluationId) && x.openCode!.Equals(openCode));
  137. int count = 0;
  138. string? loginToken = HttpContext.GetXAuth("AuthToken");
  139. if (evaluationClient!=null)
  140. {
  141. var datas = _liteDBFactory.GetLiteDatabase().GetCollection<SubjectPushData>()
  142. .Find(x => !string.IsNullOrWhiteSpace(x.evaluationId) && x.evaluationId!.Equals(evaluationId)).ToList();
  143. if (datas.IsNotEmpty())
  144. {
  145. foreach (var item in datas)
  146. {
  147. if (item.pushed<=1 && item.finished==1)
  148. {
  149. item.order=count;
  150. item.loginToken=loginToken;
  151. count++;
  152. //_logger.LogInformation($"推送数据加入队列=>>序号:{subjectPushData.order}--学号:{item.studentId}--姓名:{item.studentName}--科目:{subjectResult.subjectName}");
  153. await _dataQueue.TryAddAsync(item);
  154. }
  155. }
  156. }
  157. var data = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>()
  158. .Find(x =>!string.IsNullOrWhiteSpace(x.evaluationId) && x.evaluationId.Equals(evaluationId) );
  159. List<SubjectPushData> subjectPushDatas = new List<SubjectPushData>();
  160. if (data.IsNotEmpty())
  161. {
  162. foreach (var item in data)
  163. {
  164. foreach (var subjectResult in item.subjectResults)
  165. {
  166. if ( subjectResult.finished==1)
  167. {
  168. SubjectPushData subjectPushData= new SubjectPushData(subjectResult, item);
  169. subjectPushData.order=count;
  170. subjectPushData.loginToken=loginToken;
  171. if (!datas.Exists(x => x.id!.Equals(subjectPushData.id)))
  172. {
  173. //数据丢失导致的推送SubjectPushData 没有被保存的问题
  174. subjectPushDatas.Add(subjectPushData);
  175. //未被推送的数据
  176. if (subjectPushData.pushed<=1 && subjectPushData.finished==1)
  177. {
  178. count++;
  179. subjectPushData.pushed=1;
  180. await _dataQueue.TryAddAsync(subjectPushData);
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. if (subjectPushDatas.IsNotEmpty())
  188. {
  189. _liteDBFactory.GetLiteDatabase().GetCollection<SubjectPushData>().Upsert(subjectPushDatas);
  190. }
  191. }
  192. return Ok(new { code=200, message="推送成功!", count });
  193. }
  194. /// <summary>
  195. /// 清理缓存,列出缓存占用空间,type =list列出,type=clear清理,不能清理近期及正在激活的数据,并且提示清理中暂未上传或者导出的数据。
  196. /// </summary>
  197. /// <param name="json"></param>
  198. /// <returns></returns>
  199. [HttpPost("clean-cache")]
  200. [AuthToken("admin", "teacher", "visitor")]
  201. public async Task<IActionResult> CleanCache(JsonNode json)
  202. {
  203. return Ok();
  204. }
  205. //C#.NET 6 后端与前端流式通信
  206. //https://www.doubao.com/chat/collection/687687510791426?type=Thread
  207. //下载日志记录:1.步骤,检查,2.获取描述信息,3.分类型,4下载文件,5.前端处理,6.返回结果 , 正在下载...==> [INFO]https://www.doubao.com/chat/collection/687687510791426?type=Thread [Size=180kb] Ok...
  208. //进度条 展示下载文件总大小和已下载,末尾展示 文件总个数和已下载个数
  209. //https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/8.0.7/signalr.min.js
  210. /* int data = 0,blob=0, groupList=0
  211. {
  212. "evaluationId":"idssss",
  213. "shortCode":"1234567890",
  214. "ownerId":"hbcn/tmdid",
  215. "data":1,
  216. "blob":1,
  217. "groupList":1
  218. }
  219. */
  220. //如果要访问中心,则需要教师登录联网。
  221. [HttpPost("download-package-music")]
  222. [AuthToken("admin", "teacher", "visitor")]
  223. public async Task<IActionResult> DownloadPackageMusic(JsonNode json)
  224. {
  225. return Ok();
  226. }
  227. [HttpPost("download-package")]
  228. [AuthToken("admin", "teacher", "visitor")]
  229. public async Task<IActionResult> DownloadPackage(JsonNode json)
  230. {
  231. var token = GetAuthTokenInfo();
  232. //检查试卷文件完整性
  233. List<string> successMsgs = new List<string>();
  234. List<string> errorMsgs = new List<string>();
  235. EvaluationCheckFileResult result = new EvaluationCheckFileResult() { successMsgs=successMsgs, errorMsgs=errorMsgs };
  236. if (token.scope.Equals(ExamConstant.ScopeTeacher) || token.scope.Equals(ExamConstant.ScopeVisitor))
  237. {
  238. if (_connectionService.centerIsConnected)
  239. {
  240. Teacher? teacher = _liteDBFactory.GetLiteDatabase().GetCollection<Teacher>().FindOne(x => x.id!.Equals(token.id));
  241. string id = $"{json["evaluationId"]}";
  242. string shortCode = $"{json["shortCode"]}";
  243. string deviceId = $"{json["deviceId"]}";
  244. EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().FindOne(x => x.id!.Equals(id) && x.shortCode!.Equals(shortCode));
  245. if (teacher != null && evaluationClient!= null)
  246. {
  247. int msg_status = Constant._Message_status_info;
  248. string msg_content = msg_status.Equals(Constant._Message_status_success) ? "成功" : "失败";
  249. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  250. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = 0, content = "检测云端数据是否匹配..." });
  251. var dataInfo= await GetEvaluationFromCenter(GetXAuthToken(), _configuration, _httpClientFactory, shortCode, evaluationClient.id!);
  252. if (dataInfo.centerCode.Equals("200")&& dataInfo.evaluationCloud!=null)
  253. {
  254. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  255. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_success, content = $"云端数据检测结果:{dataInfo.centerMsg},状态:{dataInfo.centerCode}" },true);
  256. string? CenterUrl = _configuration.GetValue<string>("ExamServer:CenterUrl");
  257. var client = _httpClientFactory.CreateClient();
  258. if (client.DefaultRequestHeaders.Contains(Constant._X_Auth_AuthToken))
  259. {
  260. client.DefaultRequestHeaders.Remove(Constant._X_Auth_AuthToken);
  261. }
  262. client.DefaultRequestHeaders.Add(Constant._X_Auth_AuthToken, teacher.x_auth_token);
  263. HttpResponseMessage message = await client.PostAsJsonAsync($"{CenterUrl}/blob/sas-read", new { containerName = $"{dataInfo.evaluationCloud.ownerId}" });
  264. string sas = string.Empty;
  265. string url = string.Empty;
  266. string cnt = string.Empty;
  267. if (message.IsSuccessStatusCode)
  268. {
  269. //url sas timeout name
  270. string content = await message.Content.ReadAsStringAsync();
  271. JsonNode? jsonNode = content.ToObject<JsonNode>();
  272. if (jsonNode != null)
  273. {
  274. sas = $"{jsonNode["sas"]}";
  275. cnt = $"{jsonNode["name"]}";
  276. url = $"{jsonNode["url"]}";
  277. msg_status = Constant._Message_status_success;
  278. }
  279. else
  280. {
  281. msg_status = Constant._Message_status_error;
  282. }
  283. }
  284. else
  285. {
  286. msg_status = Constant._Message_status_error;
  287. }
  288. msg_content = msg_status.Equals(Constant._Message_status_success) ? "成功" : "失败";
  289. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  290. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = msg_status, content = $"获取云端下载授权=>{msg_content}" }, true);
  291. var httpClient = _httpClientFactory.CreateClient();
  292. string packagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "package");
  293. string evaluationPath = Path.Combine(packagePath, dataInfo.evaluationCloud.id!);
  294. //删除文件夹
  295. FileHelper.DeleteFolder(evaluationPath);
  296. string evaluationDataPath = Path.Combine(evaluationPath, "data");
  297. if (!Directory.Exists(evaluationDataPath))
  298. {
  299. Directory.CreateDirectory(evaluationDataPath);
  300. }
  301. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  302. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_info, content = $"下载前清理资源" });
  303. string evaluationData = string.Empty;
  304. {
  305. //evaluation
  306. string evaluationUrl = $"{url}/{cnt}/package/{json["evaluationId"]}/data/evaluation.json?{sas}";
  307. HttpResponseMessage dataMessage = await httpClient.GetAsync(evaluationUrl);
  308. if (dataMessage.IsSuccessStatusCode)
  309. {
  310. var content = await dataMessage.Content.ReadAsStringAsync();
  311. evaluationData=content;
  312. string path_evaluation = Path.Combine(evaluationDataPath, "evaluation.json");
  313. await System.IO.File.WriteAllTextAsync(path_evaluation, content);
  314. successMsgs.Add("评测信息文件evaluation.json文件下载成功!");
  315. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  316. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_success, content = $"评测信息文件evaluation.json文件下载成功!" });
  317. }
  318. else
  319. {
  320. errorMsgs.Add("评测信息文件evaluation.json文件下载失败!");
  321. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  322. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_error, content = $"评测信息文件evaluation.json文件下载失败!" }, true);
  323. }
  324. }
  325. //{
  326. // //source.json
  327. // string sourceUrl = $"{url}/{cnt}/package/{json["evaluationId"]}/data/source.json?{sas}";
  328. // HttpResponseMessage dataMessage = await httpClient.GetAsync(sourceUrl);
  329. // if (dataMessage.IsSuccessStatusCode)
  330. // {
  331. // var content = await dataMessage.Content.ReadAsStringAsync();
  332. // string path_source = Path.Combine(evaluationDataPath, "source.json");
  333. // await System.IO.File.WriteAllTextAsync(path_source, content);
  334. // successMsgs.Add("评测数据原始文件source.json文件下载成功!");
  335. // await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  336. // new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_success, content = $"评测数据原始文件source.json文件下载成功!" });
  337. // }
  338. // else
  339. // {
  340. // errorMsgs.Add("评测数据原始文件source.json文件下载失败!");
  341. // await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  342. // new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_error, content = $"评测数据原始文件source.json文件下载失败!" }, true);
  343. // }
  344. //}
  345. {
  346. //grouplist.json
  347. string grouplistUrl = $"{url}/{cnt}/package/{json["evaluationId"]}/data/grouplist.json?{sas}";
  348. HttpResponseMessage groupListMessage = await httpClient.GetAsync(grouplistUrl);
  349. if (groupListMessage.IsSuccessStatusCode)
  350. {
  351. var content = await groupListMessage.Content.ReadAsStringAsync();
  352. string path_groupList = Path.Combine(evaluationDataPath, "grouplist.json");
  353. await System.IO.File.WriteAllTextAsync(path_groupList, content);
  354. successMsgs.Add("评测名单grouplist.json文件下载成功!");
  355. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  356. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_success, content = $"评测名单grouplist.json文件下载成功!" });
  357. }
  358. else
  359. {
  360. errorMsgs.Add("评测名单grouplist.json文件下载失败!");
  361. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  362. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_error, content = $"评测名单grouplist.json文件下载失败!" }, true);
  363. }
  364. }
  365. {
  366. //下载试卷文件
  367. List<EvaluationExam>? evaluationExams = evaluationData.ToObject<JsonNode>()?["evaluationExams"]?.ToObject<List<EvaluationExam>>();
  368. int blobCount = evaluationExams!.SelectMany(x => x.papers).SelectMany(x=>x.blobs).Count();
  369. int currCount = 0;
  370. foreach (var evaluationExam in evaluationExams!)
  371. {
  372. foreach (var evaluationPaper in evaluationExam.papers)
  373. {
  374. string path_paper = Path.Combine(evaluationPath, $"papers/{evaluationPaper.paperId}");
  375. if (!Directory.Exists(path_paper))
  376. {
  377. Directory.CreateDirectory(path_paper);
  378. }
  379. //最多开启10个线程并行下载
  380. var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 5 };
  381. // 使用 Parallel.ForEachAsync 并行处理每个 blob
  382. await Parallel.ForEachAsync(evaluationPaper.blobs, parallelOptions, async (blob, cancellationToken) =>
  383. {
  384. currCount++;
  385. try
  386. {
  387. // 下载 Blob 文件到本地
  388. //httpClient.Timeout = TimeSpan.FromSeconds(300);
  389. HttpResponseMessage blobMessage = await httpClient.GetAsync($"{url}/{cnt}/{blob.path}?{sas}", cancellationToken);
  390. if (blobMessage.IsSuccessStatusCode)
  391. {
  392. byte[] bytes = await blobMessage.Content.ReadAsByteArrayAsync(cancellationToken);
  393. string? extension = Path.GetExtension(blob.path);
  394. if (extension!=null)
  395. {
  396. if (extension.Equals(extension.ToUpper()))
  397. {
  398. string? fileNameWithoutExtension = Path.GetFileNameWithoutExtension(blob.path);
  399. await System.IO.File.WriteAllBytesAsync(Path.Combine(path_paper, $"{fileNameWithoutExtension!}_1{extension}"), bytes, cancellationToken);
  400. }
  401. else
  402. {
  403. string? fileName = Path.GetFileName(blob.path);
  404. await System.IO.File.WriteAllBytesAsync(Path.Combine(path_paper, fileName!), bytes, cancellationToken);
  405. }
  406. }
  407. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  408. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_error, content = $"[进度:{currCount}/[{blobCount}]][大小:{blob.size * 1.0 / 1024 / 1024}kb]{evaluationExam.subjectName},{evaluationPaper.paperName},{blob.path}文件下载成功。" });
  409. }
  410. else
  411. {
  412. string? error = await blobMessage.Content.ReadAsStringAsync(cancellationToken);
  413. errorMsgs.Add($"{evaluationExam.subjectName},{evaluationPaper.paperName},{blob.path}文件下载失败,{blobMessage.StatusCode},{error}");
  414. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  415. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_error, content = $"[进度:{currCount}/[{blobCount}]][大小:{blob.size * 1.0 / 1024 / 1024}kb]{evaluationExam.subjectName},{evaluationPaper.paperName},{blob.path}文件下载失败,{blobMessage.StatusCode},{error}" }, true);
  416. // Console.WriteLine($"Error downloading {blob.path},{blobMessage.StatusCode},{error}");
  417. }
  418. }
  419. catch (Exception ex)
  420. {
  421. errorMsgs.Add($"{evaluationExam.subjectName},{evaluationPaper.paperName},{blob.path}文件下载错误,{ex.Message}");
  422. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  423. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_error, content = $"[进度:{currCount}/[{blobCount}]][大小:{blob.size * 1.0 / 1024 / 1024}kb]{evaluationExam.subjectName},{evaluationPaper.paperName},{blob.path}文件下载错误,{ex.Message}" }, true);
  424. // 处理异常
  425. //Console.WriteLine($"Error downloading {blob.path}: {ex.Message}");
  426. }
  427. });
  428. }
  429. }
  430. }
  431. _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Upsert(dataInfo.evaluationCloud!);
  432. (successMsgs, errorMsgs) = await ManageService.CheckFile(dataInfo.evaluationCloud!, successMsgs, errorMsgs, _signalRExamServerHub, _memoryCache, _logger, deviceId, evaluationPath, Constant._Message_grant_type_download_file);
  433. //下载完成后,对数据进行检查,然后在加密压缩。
  434. string zipPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "zip");
  435. if (!Directory.Exists(zipPath))
  436. {
  437. Directory.CreateDirectory(zipPath);
  438. }
  439. string zipFilePath = Path.Combine(zipPath, $"{dataInfo.evaluationCloud.id}-{dataInfo.evaluationCloud.blobHash}.zip");
  440. var zipInfo = ZipHelper.CreatePasswordProtectedZip(evaluationPath, zipFilePath, dataInfo.evaluationCloud.openCode!);
  441. if (zipInfo.res)
  442. {
  443. successMsgs.Add("评测数据压缩包创建成功!");
  444. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  445. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_success, content = $"评测数据压缩包创建成功!" });
  446. }
  447. else
  448. {
  449. errorMsgs.Add("评测数据压缩包创建失败!");
  450. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  451. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_error, content = $"评测数据压缩包创建失败!" }, true);
  452. }
  453. }
  454. else {
  455. string content = $"云端数据检测结果:{dataInfo.centerMsg},状态:{dataInfo.centerCode}";
  456. errorMsgs.Add(content);
  457. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_download_file,
  458. new MessageContent { dataId = evaluationClient.id, dataName = evaluationClient.name, messageType = Constant._Message_type_message, status = Constant._Message_status_error, content = content }, true);
  459. }
  460. }
  461. else
  462. {
  463. string teacherMsg = teacher==null ? "未找到教师信息" : "";
  464. string evaluationMsg = evaluationClient==null ? "未找到评测信息" : "";
  465. errorMsgs.Add($"用户信息或未找到评测信息!{teacherMsg}{evaluationMsg}");
  466. }
  467. }
  468. else {
  469. errorMsgs.Add($"云端数据中心未连接");
  470. }
  471. }
  472. else
  473. {
  474. errorMsgs.Add($"请使用教师或访客账号登录!");
  475. }
  476. result.checkError=result.errorMsgs.Count();
  477. result.checkSuccess=result.successMsgs.Count();
  478. result.checkTotal=result.checkSuccess+result.checkError;
  479. if (result.errorMsgs.Count()==0)
  480. {
  481. return Ok(new { code = 200, msg = "下载成功!", result });
  482. }
  483. else {
  484. return Ok(new { code = 1, msg = "下载失败!", result });
  485. }
  486. }
  487. /// <summary>
  488. /// 输入开卷码,查询评测信息,并返回数据。
  489. /// </summary>
  490. /// <param name="json"></param>
  491. /// <returns></returns>
  492. [HttpPost("open-evaluation")]
  493. [AuthToken("admin", "teacher", "visitor")]
  494. public async Task<IActionResult> OpenEvaluation(JsonNode json)
  495. {
  496. string deviceId = $"{json["deviceId"]}";
  497. string evaluationId = $"{json["evaluationId"]}";
  498. string openCode = $"{json["openCode"]}";
  499. string shortCode = $"{json["shortCode"]}";
  500. var token = GetAuthTokenInfo();
  501. List<string> successMsgs = new List<string>();
  502. List<string> errorMsgs = new List<string>();
  503. EvaluationCheckFileResult result = new EvaluationCheckFileResult() { successMsgs=successMsgs, errorMsgs =errorMsgs };
  504. if (!string.IsNullOrEmpty(openCode) && !string.IsNullOrEmpty(evaluationId))
  505. {
  506. EvaluationClient? evaluationLocal = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().FindOne(x => x.id!.Equals(evaluationId) && x.openCode!.Equals(openCode) && x.shortCode!.Equals(shortCode));
  507. if (evaluationLocal!=null)
  508. {
  509. //ManageService.CheckData(evaluationLocal, null, successMsgs, errorMsgs, _liteDBFactory);
  510. await _signalRExamServerHub.SendMessage(_memoryCache, _logger, deviceId, Constant._Message_grant_type_check_file,
  511. new MessageContent { dataId=evaluationLocal.id, dataName=evaluationLocal.name, messageType=Constant._Message_type_message, status=0, content="开始检查评测信息文件.." });
  512. //判断文件包的压缩包是否存在。
  513. string zipPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "zip");
  514. //校验本地文件数据
  515. string packagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "package");
  516. string evaluationPath = Path.Combine(packagePath, evaluationLocal.id!);
  517. if (System.IO.File.Exists(Path.Combine(zipPath, $"{evaluationLocal.id}-{evaluationLocal.blobHash}.zip")))
  518. {
  519. string key = $"{Constant._KeyEvaluationZipExtract}:{evaluationId}:{openCode}";
  520. successMsgs.Add("加载评测试卷文件包!");
  521. //string keyData = _memoryCache.Get<string>(key);
  522. //if (!string.IsNullOrWhiteSpace(keyData))
  523. //{
  524. //}
  525. //else {
  526. //}
  527. //删除文件夹
  528. FileHelper.DeleteFolder(evaluationPath);
  529. if (!Directory.Exists(evaluationPath))
  530. {
  531. Directory.CreateDirectory(evaluationPath);
  532. }
  533. //解压文件包
  534. var extractRes = await ZipHelper.ExtractPasswordProtectedZip(Path.Combine(zipPath, $"{evaluationLocal.id}-{evaluationLocal.blobHash}.zip"), evaluationPath, evaluationLocal.openCode!, _signalRExamServerHub,_memoryCache,_logger,deviceId,evaluationLocal);
  535. if (extractRes.res)
  536. {
  537. _memoryCache.Set(key,key,TimeSpan.FromSeconds(30));
  538. successMsgs.Add("评测试卷文件包解压成功!");
  539. (successMsgs, errorMsgs) = await ManageService.CheckFile(evaluationLocal, successMsgs, errorMsgs, _signalRExamServerHub, _memoryCache, _logger, deviceId, evaluationPath, Constant._Message_grant_type_check_file);
  540. }
  541. else {
  542. errorMsgs.Add("评测试卷文件包解压失败!");
  543. //return Ok(new { code = 3, msg = "评测试卷文件包解压失败!" });
  544. }
  545. }
  546. else {
  547. errorMsgs.Add("评测试卷文件包不存在!");
  548. //return Ok(new { code = 3, msg = "评测试卷文件包不存在!" });
  549. }
  550. }
  551. else {
  552. errorMsgs.Add("未找到评测信息!");
  553. // return Ok(new { code = 2, msg = "未找到评测信息!" });
  554. }
  555. }
  556. else
  557. {
  558. errorMsgs.Add("评测ID或提取码均未填写!");
  559. // return Ok(new { code = 1, msg = "评测ID或提取码均未填写!" });
  560. }
  561. result.checkTotal = result.errorMsgs.Count() + result.successMsgs.Count();
  562. result.checkError= result.errorMsgs.Count();
  563. result.checkSuccess = result.successMsgs.Count();
  564. if (result.errorMsgs.Count()==0)
  565. {
  566. return Ok(new { code = 200, msg = "校验成功!", result });
  567. }
  568. else
  569. {
  570. return Ok(new { code = 1, msg = "校验失败!", result });
  571. }
  572. }
  573. /// <summary>
  574. /// 检查数据包是否有更新,zip是否存在,数据文件是否完整,名单文件是否完整。
  575. /// 如果有智音模块,则需要检查智音音乐缓存是否完整。
  576. /// </summary>
  577. /// <param name="json"></param>
  578. /// <returns></returns>
  579. [HttpPost("check-evaluation")]
  580. [AuthToken("admin", "teacher", "visitor")]
  581. public async Task<IActionResult> CheckEvaluation(JsonNode json)
  582. {
  583. string shortCode = $"{json["shortCode"]}";
  584. string evaluationId = $"{json["evaluationId"]}";
  585. string checkCenter = $"{json["checkCenter"]}";
  586. string deviceId = $"{json["deviceId"]}";
  587. string centerCode = string.Empty, centerMsg = string.Empty;
  588. Expression<Func<EvaluationClient, bool>> predicate = x => true;
  589. var token = GetAuthTokenInfo();
  590. if (!string.IsNullOrEmpty(shortCode) || !string.IsNullOrEmpty(evaluationId))
  591. {
  592. if (!string.IsNullOrEmpty(shortCode))
  593. {
  594. predicate= predicate.And(x => !string.IsNullOrWhiteSpace(x.shortCode) && x.shortCode.Equals(shortCode));
  595. }
  596. if (!string.IsNullOrWhiteSpace(evaluationId))
  597. {
  598. predicate= predicate.And(x => x.id!.Equals(evaluationId));
  599. }
  600. }
  601. else
  602. {
  603. return Ok(new { code = 400, msg = "评测ID或提取码均未填写!" });
  604. }
  605. IEnumerable<EvaluationClient>? evaluationClients = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Find(predicate);
  606. EvaluationClient? evaluationLocal = null;
  607. EvaluationClient? evaluationCloud = null;
  608. if (evaluationClients!=null && evaluationClients.Count()>0)
  609. {
  610. evaluationLocal= evaluationClients.First();
  611. }
  612. List<string> successMsgs = new List<string>();
  613. List<string> errorMsgs = new List<string>();
  614. //从数据中心搜索
  615. if ("1".Equals($"{checkCenter}"))
  616. {
  617. if (_connectionService.centerIsConnected)
  618. {
  619. if (token.scope.Equals(ExamConstant.ScopeTeacher) || token.scope.Equals(ExamConstant.ScopeVisitor))//由于已经绑定学校,访客教师也可以访问中心。
  620. {
  621. Teacher? teacher = _liteDBFactory.GetLiteDatabase().GetCollection<Teacher>().FindOne(x => x.id!.Equals(token.id));
  622. if (teacher != null)
  623. {
  624. (evaluationCloud, centerCode, centerMsg)= await ManageService.GetEvaluationFromCenter(GetXAuthToken(), _configuration,_httpClientFactory,shortCode,evaluationId);
  625. }
  626. else
  627. {
  628. centerCode = $"401";
  629. centerMsg = "当前登录账号未找到";
  630. }
  631. }
  632. }
  633. else
  634. {
  635. centerCode = $"404";
  636. centerMsg = "云端数据中心未连接";
  637. }
  638. if (centerCode.Equals("200"))
  639. {
  640. successMsgs.Add($"云端数据检测结果:{centerMsg},状态:{centerCode}");
  641. }
  642. else
  643. {
  644. errorMsgs.Add($"云端数据检测结果:{centerMsg},状态:{centerCode}");
  645. }
  646. }
  647. EvaluationCheckDataResult checkDataResult;
  648. (checkDataResult, evaluationLocal) = ManageService.CheckData( evaluationLocal, evaluationCloud, successMsgs, errorMsgs, _liteDBFactory);
  649. Dictionary<string, object?>? evaluation = null;
  650. if (evaluationLocal!=null)
  651. {
  652. string zipPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "zip");
  653. //判断文件包的压缩包是否存在。
  654. if (!System.IO.File.Exists(Path.Combine(zipPath, $"{evaluationLocal.id}-{evaluationLocal.blobHash}.zip")))
  655. {
  656. checkDataResult.zip =1;
  657. checkDataResult.blob=1;
  658. checkDataResult.data=1;
  659. checkDataResult.groupList=1;
  660. checkDataResult.blobSize=evaluationLocal.blobSize;
  661. checkDataResult.dataSize=evaluationLocal.dataSize;
  662. checkDataResult.studentCount=evaluationLocal.studentCount;
  663. errorMsgs.Add($"评测文件包压缩包不存在,需要重新下载评测!");
  664. }
  665. var properties = evaluationLocal.GetType().GetProperties();
  666. evaluation = new Dictionary<string, object?>();
  667. foreach (var property in properties)
  668. {
  669. if (!property.Name.Equals("openCode"))
  670. {
  671. evaluation[property.Name] = property.GetValue(evaluationLocal);
  672. }
  673. }
  674. }
  675. return Ok(new
  676. {
  677. code = 200,
  678. evaluation = evaluation,
  679. result = checkDataResult
  680. });
  681. }
  682. /// <summary>
  683. /// 获取当前评测的开考设置信息
  684. /// </summary>
  685. /// <param name="json"></param>
  686. /// <returns></returns>
  687. [HttpPost("list-evaluation-round")]
  688. [AuthToken("admin", "teacher", "visitor")]
  689. public IActionResult ListEvaluationRound(JsonNode json)
  690. {
  691. string evaluationId = $"{json["evaluationId"]}";
  692. string openCode = $"{json["openCode"]}";
  693. string shortCode = $"{json["shortCode"]}";
  694. EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>()
  695. .FindOne(x => x.id!.Equals(evaluationId) && x.shortCode!.Equals(shortCode) && x.openCode!.Equals(openCode));
  696. if (evaluationClient!=null)
  697. {
  698. IEnumerable<EvaluationRoundSetting>? settings = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationRoundSetting>().Find(x => x.evaluationId!.Equals(evaluationClient.id)).OrderByDescending(x => x.activate).ThenByDescending(x => x.startline).ThenByDescending(x => x.createTime);
  699. if (settings.IsNotEmpty())
  700. {
  701. return Ok(new { code = 200, msg = "OK", settings = settings });
  702. }
  703. else
  704. {
  705. return Ok(new { code = 2, msg = "未设置开考信息!" });
  706. }
  707. }
  708. else
  709. {
  710. return Ok(new { code = 1, msg = "未找到评测信息!" });
  711. }
  712. }
  713. /// <summary>
  714. /// 获取当前评测的开考设置信息
  715. /// </summary>
  716. /// <param name="json"></param>
  717. /// <returns></returns>
  718. [HttpPost("load-evaluation-round")]
  719. [AuthToken("admin", "teacher", "visitor")]
  720. public IActionResult LoadEvaluationRound(JsonNode json)
  721. {
  722. string evaluationId = $"{json["evaluationId"]}";
  723. string openCode = $"{json["openCode"]}";
  724. string shortCode = $"{json["shortCode"]}";
  725. string settingId = $"{json["settingId"]}";
  726. EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>()
  727. .FindOne(x => x.id!.Equals(evaluationId) && x.shortCode!.Equals(shortCode) && x.openCode!.Equals(openCode));
  728. EvaluationRoundSetting? setting = null;
  729. if (evaluationClient!=null)
  730. {
  731. setting = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationRoundSetting>().FindOne(x =>x.id!.Equals(settingId) && x.evaluationId!.Equals(evaluationClient.id));
  732. if (setting!=null)
  733. {
  734. IEnumerable<EvaluationStudentResult>? results = null;
  735. var members = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationMember>().Find(x => x.evaluationId!.Equals(evaluationClient.id) && x.roundId!.Equals(setting.id));
  736. //并获取学生的作答信息
  737. //顺便返回本轮的学生名单
  738. if (members!=null && members.Count()>0)
  739. {
  740. results = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>()
  741. .Find(x => members.Select(x => x.id).Contains(x.studentId)&&!string.IsNullOrWhiteSpace(x.evaluationId) && x.evaluationId.Equals(evaluationClient.id));
  742. if (results.Count()==members.Count())
  743. {
  744. return Ok(new { code = 200, setting, results });
  745. }
  746. else {
  747. return Ok(new { code = 200,msg="学生作答信息数量不匹配", setting, results });
  748. }
  749. }
  750. else
  751. {
  752. return Ok(new { code = 200,msg="未分配学生名单,或名单没有学生!", setting , results });
  753. }
  754. }
  755. else
  756. {
  757. return Ok(new { code = 2, msg = "未设置开考信息!" });
  758. }
  759. }
  760. else {
  761. return Ok(new { code = 1, msg = "未找到评测信息!" });
  762. }
  763. }
  764. /// <summary>
  765. /// 设置评测开考信息(本轮名单,计时规则,分配试卷等)
  766. /// </summary>
  767. /// <param name="json"></param>
  768. /// <returns></returns>
  769. [HttpPost("setting-evaluation-round")]
  770. [AuthToken("admin", "teacher", "visitor")]
  771. public IActionResult SettingEvaluationRound(JsonNode json)
  772. {
  773. EvaluationRoundSetting? setting = json.ToObject<EvaluationRoundSetting>();
  774. if (setting!=null)
  775. {
  776. var db = _liteDBFactory.GetLiteDatabase();
  777. var collection = db.GetCollection<EvaluationClient>() ;
  778. //&& x.openCode!.Equals($"{json["openCode"]}")&& x.shortCode!.Equals($"{json["shortCode"]}")
  779. string shortCode = $"{json["shortCode"]}";
  780. string openCode = $"{json["openCode"]}";
  781. EvaluationClient ? evaluationClient = collection.FindOne(x => x.id!.Equals(setting.evaluationId)
  782. && !string.IsNullOrWhiteSpace(x.shortCode) && x.shortCode.Equals(x.shortCode)
  783. && !string.IsNullOrWhiteSpace(x.openCode) && x.openCode.Equals(openCode) );
  784. if (evaluationClient!=null)
  785. {
  786. IEnumerable<EvaluationRoundSetting> settings = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationRoundSetting>().Find(x => x.evaluationId!.Equals(evaluationClient.id));
  787. if (settings != null && settings.Count() > 0)
  788. {
  789. var datas = settings.ToList();
  790. foreach (EvaluationRoundSetting item in datas)
  791. {
  792. item.activate = 0;
  793. }
  794. _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationRoundSetting>().Upsert(datas);
  795. }
  796. /// 判断是否包含所有分组
  797. bool isAllContained = setting.groupList.All(x => evaluationClient.grouplist.Any(y => y.id == x.id));
  798. if (isAllContained && evaluationClient.grouplist.IsNotEmpty())
  799. {
  800. var ids= setting.groupList.Select(x => x.id).OrderBy(x=>x);
  801. //增加排序,保证id的唯一性
  802. setting.id=ShaHashHelper.GetSHA1($"{evaluationClient.id}_{string.Join("", ids) }");
  803. setting.createTime= DateTimeOffset.Now.ToUnixTimeMilliseconds();
  804. _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationRoundSetting>().Upsert(setting);
  805. _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Upsert(evaluationClient);
  806. /// 分配试卷
  807. var(roundStudentPapers, members, results, code, msg)= ManageService.AssignStudentPaper(evaluationClient, setting,_connectionService, _liteDBFactory, _logger);
  808. //var (roundStudentPapers, members, results,code,msg) = AssignStudentPaper(evaluationClient, setting);
  809. return Ok(new { code = code, msg =msg , setting, results, roundStudentPapers });
  810. }
  811. else
  812. {
  813. return Ok(new { code = 3, msg = "开考名单不在当前评测中!" });
  814. }
  815. }
  816. else { return Ok(new { code = 2, msg = "未找到评测,请确认评测ID、提取码、开卷码是否正确!" }); }
  817. }
  818. else
  819. {
  820. return Ok(new { code = 1, msg = "未完善设置信息!" });
  821. }
  822. }
  823. /// <summary>
  824. /// 加载本地的活动列表
  825. /// </summary>
  826. /// <param name="json"></param>
  827. /// <returns></returns>
  828. [HttpPost("list-local-evaluation")]
  829. [AuthToken("admin", "teacher", "visitor")]
  830. public IActionResult ListLocalEvaluation(JsonNode json)
  831. {
  832. if (!string.IsNullOrWhiteSpace($"{_connectionService.serverDevice?.school?.id}"))
  833. {
  834. string code = $"{_connectionService!.serverDevice!.school!.id}";
  835. IEnumerable<EvaluationClient>? evaluationClients = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Find(x => x.ownerId!.Equals(code)).OrderByDescending(x => x.stime);
  836. if (evaluationClients != null)
  837. {
  838. var result = evaluationClients.Select(client =>
  839. {
  840. var properties = client.GetType().GetProperties();
  841. var anonymousObject = new Dictionary<string, object?>();
  842. foreach (var property in properties)
  843. {
  844. if (!property.Name.Equals("openCode"))
  845. {
  846. anonymousObject[property.Name] = property.GetValue(client);
  847. }
  848. }
  849. return anonymousObject;
  850. });
  851. return Ok(new { code = 200, evaluation = result });
  852. }
  853. else
  854. {
  855. return Ok(new { code = 200, evaluation = new List<EvaluationClient>() });
  856. }
  857. }
  858. else
  859. {
  860. return Ok(new { code = 200, evaluation = new List<EvaluationClient>() });
  861. }
  862. }
  863. }
  864. }