CrazyIter_Bin 3 months ago
parent
commit
39a0c32bea

+ 5 - 1
TEAMModelOS.Extension/IES.Exam/IES.ExamLibrary/Models/EvaluationCommon.cs

@@ -346,10 +346,14 @@ namespace IES.ExamServer.Models
     public class BlobHashInfo 
     {
         /// <summary>
-        /// 文件路径
+        /// 云端blob文件路径
         /// </summary>
         public string? path { get; set; }
         /// <summary>
+        /// 本地存储文件路径
+        /// </summary>
+        public string? local { get; set; }
+        /// <summary>
         /// 文件大小
         /// </summary>
         public long size {  get; set; }

+ 6 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Controllers/ManageController.cs

@@ -667,6 +667,7 @@ namespace IES.ExamServer.Controllers
             {
                 var result = evaluationClients.Select(client =>
                 {
+                    
                     var properties = client.GetType().GetProperties();
                     var anonymousObject = new Dictionary<string, object?>();
                     foreach (var property in properties)
@@ -887,6 +888,10 @@ namespace IES.ExamServer.Controllers
                             }
                             if (results.Count>0)
                             {
+                                foreach (var item in results)
+                                {
+                                    item.subjectResults= item.subjectResults.DistinctBy(x => x.id).ToList();
+                                }
                                 _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>().Upsert(results);
                             }
                         }
@@ -918,6 +923,7 @@ namespace IES.ExamServer.Controllers
                 code = 5;
                 msg = "名单成员与作答记录数量不匹配!";
             }
+           
             if (roundStudentPapers.Count()!= results.SelectMany(x => x.subjectResults).Count())
             {
                 code = 6;

+ 18 - 10
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Controllers/StudentController.cs

@@ -119,22 +119,30 @@ namespace IES.ExamServer.Controllers
                             evaluationClient.deadline = setting.deadline;
                             evaluationClient.startline = setting.startline;
                             evaluationClient.activate = setting.activate;
-                            var anonymousObject = new Dictionary<string, object?>();
-                            var properties = evaluationClient.GetType().GetProperties();
-                            foreach (var property in properties)
-                            {
-                                if (!property.Name.Equals("shortCode") && !property.Name.Equals("openCode"))
-                                {
-                                    anonymousObject[property.Name] = property.GetValue(evaluationClient);
-                                }
-                            }
-                            return Ok(new { evaluationClient = anonymousObject, code = 200, msg = msg });
+                            evaluationClient.grouplist = setting.groupList;
                         }
                         else 
                         {
                             msg="本轮开考信息未设置!";
                             code=6;
                         }
+                        //foreach (var subject in evaluationClient.subjects)
+                        //{
+                        //    foreach (var paper in subject.papers)
+                        //    {
+                        //        paper.blob=$"package/{evaluationClient.id}/papers/{paper.paperId}";
+                        //    }
+                        //}
+                        var anonymousObject = new Dictionary<string, object?>();
+                        var properties = evaluationClient.GetType().GetProperties();
+                        foreach (var property in properties)
+                        {
+                            if (!property.Name.Equals("shortCode") && !property.Name.Equals("openCode"))
+                            {
+                                anonymousObject[property.Name] = property.GetValue(evaluationClient);
+                            }
+                        }
+                        return Ok(new { evaluationClient = anonymousObject, code = code, msg = msg, setting });
                     }
                 }
                 else

+ 9 - 1
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Services/ManageService.cs

@@ -356,7 +356,15 @@ namespace IES.ExamServer.Services
                 dataSize=evaluationCloud.dataSize;
                 studentCount=evaluationCloud.studentCount;
                 status = 4;
-                _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Insert(evaluationLocal);
+                //foreach (var subject in evaluationLocal.subjects)
+                //{
+                //    foreach (var paper in subject.papers)
+                //    {
+                //        paper.blob=$"package/{evaluationLocal.id}/papers/{paper.paperId}";
+                //    }
+                //}
+                _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().Upsert(evaluationLocal);
+
                 errorMsgs.Add($"获取到最新的评测数据,需要下载数据包,文件包,名单信息!");
             }
             EvaluationCheckDataResult checkDataResult= new EvaluationCheckDataResult { data = data, blob = blob, groupList = groupList, status = status, dataSize = dataSize, blobSize = blobSize, studentCount = studentCount,zip=zip ,successMsgs=successMsgs,errorMsgs=errorMsgs};

+ 27 - 6
TEAMModelOS.SDK/Models/Service/EvaluationSyncInfoService.cs

@@ -4,19 +4,16 @@ using IES.ExamServer.Models;
 using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Net.Http;
-using System.Reflection.Metadata.Ecma335;
 using System.Text;
 using System.Text.Json;
-using System.Text.Json.Nodes;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.Normal;
-using TEAMModelOS.SDK.Models.Cosmos.Student;
-using TEAMModelOS.SDK.Models.Dtos;
 
 
 namespace TEAMModelOS.SDK.Models.Service
@@ -381,13 +378,21 @@ namespace TEAMModelOS.SDK.Models.Service
                                 }
                                 var hash = blobItem.Properties.ContentHash;
                                 var path = blobItem.Name;
+                                var ext = Path.GetExtension(path);
+                                string fileName = Path.GetFileName(path);
+                                if (ext.ToUpper().Equals(ext)) 
+                                {
+                                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
+                                    fileName= $"{fileNameWithoutExtension!}_1{ext}";
+                                }
                                 var size = blobItem.Properties.ContentLength;
                                 blobs.Add(new BlobHashInfo
                                 {
                                     hash = Md5Hash.GetbyteToString(hash),
-                                    last = lastModified.HasValue ? lastModified.Value.ToUnixTimeMilliseconds() : 0,
+                                    last = lastModified.HasValue ? lastModified.Value.ToUnixTimeMilliseconds() : 0 ,
                                     path = path,
-                                    size = size.HasValue ? size.Value : 0
+                                    size = size.HasValue ? size.Value : 0,
+                                    local=$"package/{evaluationSyncInfo.id}/papers{paper.paperId}/{fileName}"
                                 });
                             };
                             evaluationPaper =  evaluationExam.papers.Find(x => x.paperId.Equals(paper.paperId));
@@ -519,6 +524,22 @@ namespace TEAMModelOS.SDK.Models.Service
                 string evaluationSyncInfoSJson = evaluationSyncInfo.ToJsonString();
                 dataSize+= Encoding.UTF8.GetByteCount(evaluationSyncInfoSJson);
                 evaluationClient.dataSize = dataSize;
+               //重组blob路径,使之适配局域网端读取。
+                evaluationClient.subjects.ForEach(x => {
+                    x.papers.ForEach(y => {
+                        y.blob=$"package/{evaluationClient.id}/papers{y.paperId}";
+                    });
+                });
+                evaluationExams.ForEach(x => {
+                    x.papers.ForEach(y => {
+                        y.blob=$"package/{evaluationClient.id}/papers{y.paperId}";
+                    });
+                });
+                evaluationSyncInfo.subjects.ForEach(x => {
+                    x.papers.ForEach(y => {
+                        y.blob=$"package/{evaluationClient.id}/papers{y.paperId}";
+                    });
+                });
                 await azureStorage.GetBlobContainerClient(ownerId).UploadFileByContainer(sourceJson, $"package/{id}/data", "source.json");
                 await azureStorage.GetBlobContainerClient(ownerId).UploadFileByContainer(groupListJson, $"package/{id}/data", "grouplist.json");
                 await azureStorage.GetBlobContainerClient(ownerId).UploadFileByContainer(new { evaluationClient, evaluationExams }.ToJsonString(), $"package/{id}/data", "evaluation.json");