CrazyIter_Bin 5 月之前
父節點
當前提交
81ce7c80aa

+ 6 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/IES.ExamServer.csproj

@@ -44,6 +44,12 @@
 	    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 	  </Content>
 	</ItemGroup>
+
+	<ItemGroup>
+	  <None Update="Configs\cert.pfx">
+	    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+	  </None>
+	</ItemGroup>
 	<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build">
 		<!-- Build Target:  Ensure Node.js is installed -->
 		<Exec Command="node --version" ContinueOnError="true">

+ 47 - 1
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Program.cs

@@ -10,6 +10,7 @@ using System.Text.Json;
 using System.Text.Json.Nodes;
 using VueCliMiddleware;
 using IES.ExamServer.Services;
+using System.Text;
 
 namespace IES.ExamServer
 {
@@ -18,6 +19,15 @@ namespace IES.ExamServer
         public async static Task Main(string[] args)
         {
             var builder = WebApplication.CreateBuilder(args);
+
+            string path = $"{builder.Environment.ContentRootPath}/Configs";
+            //builder.WebHost.UseKestrel(options =>
+            //{
+            //    options.ListenAnyIP(5001, listenOptions =>
+            //    {
+            //        listenOptions.UseHttps($"{path}/cert.pfx", "cdhabook") ;
+            //    });
+            //});
             builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
             builder.Services.AddSpaStaticFiles(opt => opt.RootPath = "ClientApp/dist");
             // Add services to the container.
@@ -40,7 +50,7 @@ namespace IES.ExamServer
             };
             builder.Services.AddLiteDB(connections_LiteDB);
             builder.Services.AddMemoryCache();
-            string path = $"{builder.Environment.ContentRootPath}/Configs";
+          
             builder.Services.AddCors(options =>
             {
                 options.AddDefaultPolicy(
@@ -142,6 +152,42 @@ namespace IES.ExamServer
                 var d = server?.Features.Get<IServerAddressesFeature>();
                 IEnumerable<string>? _url = server?.Features.Get<IServerAddressesFeature>()?.Addresses;
                 ServerDevice serverDevice = IndexService.GetServerDevice(remote, region, _url);
+                //int domainStatus =0;
+                //string domain = builder.Configuration.GetValue<string>("ExamClient:Domain");
+                //foreach (var network in serverDevice.networks) 
+                //{
+                //    try
+                //    {
+                //        string domain_entry = $"{network.ip}    {domain}";
+                //        string hostsFilePath = @"C:\Windows\System32\drivers\etc\hosts";
+                //        string content = File.ReadAllText(hostsFilePath, Encoding.UTF8);
+                //        if (!content.Contains(domain_entry))
+                //        {
+                //            content += Environment.NewLine + domain_entry;
+                //            // 使用管理员权限运行此程序,不然会抛出UnauthorizedAccessException
+                //            File.WriteAllText(hostsFilePath, content, Encoding.UTF8);
+                //            domainStatus=1;
+                //            // Console.WriteLine("Hosts file updated successfully.");
+                //        }
+                //        else
+                //        {
+                //            domainStatus=1;
+                //            //Console.WriteLine("The entry already exists in the hosts file.");
+                //        }
+                //    }
+                //    catch (UnauthorizedAccessException)
+                //    {
+                //        domainStatus=2;
+                //        // Console.WriteLine("You need to run this program with administrative privileges to modify the hosts file.");
+                //    }
+                //    catch (Exception ex)
+                //    {
+                //        domainStatus=0;
+                //        // Console.WriteLine($"An error occurred: {ex.Message}");
+                //    }
+                //}
+                //serverDevice.domainStatus=domainStatus;
+                //serverDevice.domain=domain;
                 cache.Set(Constant._KeyServerDevice, serverDevice);
             });
             app.Run();

+ 8 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Services/IndexService.cs

@@ -428,6 +428,14 @@ namespace IES.ExamServer.Services
         /// 网卡 IP信息
         /// </summary>
         public List<Network> networks { get; set; } = new List<Network>();
+        /// <summary>
+        /// 本地域名
+        /// </summary>
+       // public string? domain {  get; set; }
+        /// <summary>
+        /// 域名状态 0:未注册,1:正常,2:未授权,需要手动设置或管理员运行
+        /// </summary>
+        //public int domainStatus { get; set; }
     }
     public class CPUInfo 
     {

+ 3 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/appsettings.json

@@ -20,5 +20,8 @@
     "Timeout": 30000,
     "Delay": 500,
     "CenterUrl": "https://www.teammodel.cn"
+  },
+  "ExamClient": {
+    "Domain": "edge-exam.habook.cn"
   }
 }

+ 21 - 3
TEAMModelOS.SDK/Models/Service/EvaluationSyncInfoService.cs

@@ -105,7 +105,7 @@ namespace TEAMModelOS.SDK.Models.Service
 
                                     EvaluationExam evaluationExam = new EvaluationExam()
                                     {
-                                        examId=subject.id,
+                                        examId=exam.id,
                                         evaluationId=evaluationSyncInfo.id,
                                         examName=evaluationSyncInfo.name,
                                         subjectId=subject.id,
@@ -117,6 +117,7 @@ namespace TEAMModelOS.SDK.Models.Service
                                         etime=etime,
                                         papers= group.list.Select(x => new EvaluationPaper { paperId= x.id, paperName=x.name, blob=x.blob, point=x.point,knowledge=x.knowledge,type=x.type,field=x.field }).ToList(),
                                     };
+                                    evaluationExams.Add(evaluationExam);
                                 }
                             }
                             evaluationSource.exam=exam;
@@ -175,8 +176,23 @@ namespace TEAMModelOS.SDK.Models.Service
                                         });
                                         dataTime= dataTime<exam._ts*1000 ? exam._ts*1000 : dataTime;
                                         evaluationSource.artExams.Add(exam);
+
+                                        EvaluationExam evaluationExam = new EvaluationExam()
+                                        {
+                                            examId=exam.id,
+                                            evaluationId=evaluationSyncInfo.id,
+                                            examName=evaluationSyncInfo.name,
+                                            subjectId=subject.id,
+                                            subjectName=subject.name,
+                                            classes= evaluationSyncInfo.grouplist,
+                                            owner=owner,
+                                            scope=scope,
+                                            stime=stime,
+                                            etime=etime,
+                                            papers= papers.Select(x => new EvaluationPaper { paperId= x.id, paperName=x.name, blob=x.blob, point=x.point, knowledge=x.knowledge, type=x.type, field=x.field }).ToList(),
+                                        };
+                                        evaluationExams.Add(evaluationExam);
                                     }
-                                   
                                 }
                             }
                         }
@@ -202,7 +218,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 var client = azureStorage.GetBlobContainerClient(owner);
                 foreach (var subject in evaluationSyncInfo.subjects)
                 {
-                   
+                    var evaluationExam =  evaluationExams.FindAll(x => x.subjectId.Equals(subject.subjectId)).FirstOrDefault();
                     foreach (var paper in subject.papers)
                     {
                         List<BlobHashInfo> blobs = new List<BlobHashInfo>();
@@ -226,6 +242,8 @@ namespace TEAMModelOS.SDK.Models.Service
                                     size = size.HasValue ? size.Value : 0
                                 });
                             };
+                            var evaluationPaper=  evaluationExam.papers.Find(x => x.paperId.Equals(paper.paperId));
+                            evaluationPaper.blobs=blobs;
                         }
                         catch
                         {