CrazyIter_Bin 4 months ago
parent
commit
38ab0ccea8

+ 3 - 3
TEAMModelBI/TEAMModelBI.csproj

@@ -65,9 +65,9 @@
 		<SpaRoot>ClientApp\</SpaRoot>
 		<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
 		<UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-		<Version>5.2501.8</Version>
-		<AssemblyVersion>5.2501.8.1</AssemblyVersion>
-		<FileVersion>5.2501.8.1</FileVersion>
+		<Version>5.2501.15</Version>
+		<AssemblyVersion>5.2501.15.1</AssemblyVersion>
+		<FileVersion>5.2501.15.1</FileVersion>
 		<Description>TEAMModelBI(BI)</Description>
 		<PackageReleaseNotes>BI版本说明版本切换标记2022000908</PackageReleaseNotes>
 		<PackageId>TEAMModelBI</PackageId>

+ 13 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/.config/dotnet-tools.json

@@ -0,0 +1,13 @@
+{
+  "version": 1,
+  "isRoot": true,
+  "tools": {
+    "dotnet-ef": {
+      "version": "9.0.1",
+      "commands": [
+        "dotnet-ef"
+      ],
+      "rollForward": false
+    }
+  }
+}

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

@@ -35,7 +35,11 @@
 	<ItemGroup>
 		<PackageReference Include="AutoMapper" Version="13.0.1" />
 		<PackageReference Include="LiteDB" Version="5.0.21" />
+		<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
+		<PackageReference Include="NLog" Version="5.3.4" />
+		<PackageReference Include="NLog.Extensions.Logging" Version="5.3.15" />
 		<PackageReference Include="SkiaSharp.QrCode" Version="0.7.0" />
+		<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="6.0.2" />
 		<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
 		<PackageReference Include="System.Management" Version="6.0.2" />
 		<PackageReference Include="VueCliMiddleware" Version="6.0.0" />
@@ -46,10 +50,10 @@
 	</ItemGroup>
 
 	<ItemGroup>
-	  <Content Update="wwwroot">
+	  <Content Update="nlog.config">
 	    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 	  </Content>
-	  <Content Update="wwwroot\package\schools.json">
+	  <Content Update="wwwroot">
 	    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 	  </Content>
 	</ItemGroup>

+ 24 - 13
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Program.cs

@@ -19,6 +19,8 @@ using Microsoft.Extensions.FileProviders;
 using System.Text.Encodings.Web;
 using System.Text.Unicode;
 using Microsoft.Extensions.Logging;
+using System.Runtime.InteropServices;
+using NLog.Extensions.Logging;
 
 namespace IES.ExamServer
 {
@@ -26,7 +28,14 @@ namespace IES.ExamServer
     {
         public async static Task Main(string[] args)
         {
-            
+            Console.OutputEncoding = Encoding.UTF8;
+            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)||RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+            { }
+            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+            {
+            }
+
+            //
             //var mutex = new Mutex(true, "IES.ExamServer", out var createdNew);
             //if (!createdNew)
             //{
@@ -97,7 +106,8 @@ namespace IES.ExamServer
             //bool enableConsoleOutput = true;
             //builder.Logging.AddProvider(new CustomFileLoggerProvider(Path.Combine(Directory.GetCurrentDirectory(), "Logs"), enableConsoleOutput));
             // Ìí¼ÓÈÕÖ¾·þÎñ
-           
+            builder.Logging.ClearProviders();
+            builder.Logging.AddNLog();
             var app = builder.Build();
 
             // Configure the HTTP request pipeline.
@@ -128,13 +138,14 @@ namespace IES.ExamServer
             {
                 Directory.CreateDirectory(packagePath);
             }
-            app.UseStaticFiles(new StaticFileOptions
-            {
-                FileProvider = new PhysicalFileProvider(
-                Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "package")),
-                RequestPath = "/package",
-                ContentTypeProvider = contentTypeProvider,
-            });
+            //new StaticFileOptions
+            //{
+            //    FileProvider = new PhysicalFileProvider(
+            //    Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "package")),
+            //    RequestPath = "/package",
+            //    ContentTypeProvider = contentTypeProvider,
+            //}
+            app.UseStaticFiles();
 
             app.UseRouting();
 
@@ -157,7 +168,7 @@ namespace IES.ExamServer
                  npm install -g @vue
                  vue create app
                  */
-//#if DEBUG
+#if DEBUG
                 endpoints.MapToVueCliProxy(
                     "{*path}",
                     new SpaOptions { SourcePath = "ClientApp" },
@@ -165,9 +176,9 @@ namespace IES.ExamServer
                     // regex: "Compiled successfully",
                     forceKill: true
                     );
-//#else
-//                endpoints.MapFallbackToFile("index.html");
-//#endif
+#else
+                endpoints.MapFallbackToFile("index.html");
+#endif
             });
 
 

+ 65 - 34
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Services/IndexService.cs

@@ -9,7 +9,8 @@ using System.Text.Json.Nodes;
 using System.Text.RegularExpressions;
 using System.Management;
 using IES.ExamServer.Models;
-
+using System.CodeDom.Compiler;
+ 
 namespace IES.ExamServer.Services
 {
     public static class IndexService
@@ -20,38 +21,65 @@ namespace IES.ExamServer.Services
             string os = RuntimeInformation.OSDescription;
             //获取当前客户端的服务端口
             string currentUserName = Environment.UserName;
-           
+            string MachineName =Environment.MachineName;
+            //var s = Environment;
             ServerDevice device = new ServerDevice { name =hostName, userName=currentUserName, os= os,region=region,remote=remote };
             int CpuCoreCount = 0;
             long MenemorySize = 0;
             if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
             {
+                CpuCoreCount = Environment.ProcessorCount;
+                MenemorySize = MemoryInfo.GetTotalPhysicalMemory();
+                //using (PerformanceCounter pc = new PerformanceCounter("Memory", "Available Bytes"))
+                //{
+                //    // 获取可用内存
+                //    AvailableMemory = (long)pc.NextValue();
+
+                //}
+                //using (PerformanceCounter pc = new PerformanceCounter("Memory", "Committed Bytes"))
+                //{
+                //    // 获取可用内存
+                //    CommittedMemory= (long)pc.NextValue();
+
+                //}
+                //MenemorySize=AvailableMemory+CommittedMemory;
+                //
+
                 // 获取CPU核心数
                 //int processorCount = Environment.ProcessorCount;
                 //Console.WriteLine("CPU 核心数: " + processorCount);
-                using (ManagementClass managementClass = new ManagementClass("Win32_Processor"))
-                {
-                    using (ManagementObjectCollection managementObjectCollection = managementClass.GetInstances())
-                    {
-                        foreach (ManagementObject managementObject in managementObjectCollection)
-                        {
-                            CpuCoreCount += Convert.ToInt32(managementObject.Properties["NumberOfLogicalProcessors"].Value);
-                        }
-                    }
-                }
-                using (ManagementClass mc = new ManagementClass("Win32_ComputerSystem"))
-                {
-                    using (ManagementObjectCollection moc = mc.GetInstances())
-                    {
-                        foreach (ManagementObject mo in moc)
-                        {
-                            if (mo["TotalPhysicalMemory"]!= null)
-                            {
-                                MenemorySize = Convert.ToInt64(mo["TotalPhysicalMemory"]);
-                            }
-                        }
-                    }
-                }
+                //using (ManagementClass managementClass = new ManagementClass("Win32_Processor"))
+                //{
+                //    using (ManagementObjectCollection managementObjectCollection = managementClass.GetInstances())
+                //    {
+                //        foreach (ManagementObject managementObject in managementObjectCollection)
+                //        {
+                //            CpuCoreCount += Convert.ToInt32(managementObject.Properties["NumberOfLogicalProcessors"].Value);
+                //        }
+                //    }
+                //}
+                //using (ManagementObjectSearcher searcher1 = new ManagementObjectSearcher("SELECT TotalPhysicalMemory FROM Win32_ComputerSystem"))
+                //{
+                //    foreach (ManagementObject obj in searcher1.Get())
+                //    {
+                //       long  MenemorySizes1 = Convert.ToInt64(obj["TotalPhysicalMemory"]);
+                //        break; // 只需要第一个结果
+                //    }
+                //}
+
+                //using (ManagementClass mc = new ManagementClass("Win32_ComputerSystem"))
+                //{
+                //    using (ManagementObjectCollection moc = mc.GetInstances())
+                //    {
+                //        foreach (ManagementObject mo in moc)
+                //        {
+                //            if (mo["TotalPhysicalMemory"]!= null)
+                //            {
+                //                MenemorySize = Convert.ToInt64(mo["TotalPhysicalMemory"]);
+                //            }
+                //        }
+                //    }
+                //}
                 if (Environment.Is64BitOperatingSystem)
                 {
                     device.bit="64";
@@ -60,15 +88,18 @@ namespace IES.ExamServer.Services
                 {
                     device.bit="32";
                 }
-                ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Name, MaxClockSpeed FROM Win32_Processor");
-                foreach (ManagementObject mo in searcher.Get())
-                {
-                    string? cpuName = mo["Name"].ToString();
-                    string? clockSpeed = mo["MaxClockSpeed"].ToString();
-                    //Console.WriteLine($"CPU 名称: {cpuName}");
-                    //Console.WriteLine($"CPU 主频: {clockSpeed} MHz");
-                    device.cpuInfos.Add(new CPUInfo { name = cpuName, hz = clockSpeed });
-                }
+                //ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Name, MaxClockSpeed FROM Win32_Processor");
+                //foreach (ManagementObject mo in searcher.Get())
+                //{
+                //    string? cpuName = mo["Name"].ToString();
+                //    string? clockSpeed = mo["MaxClockSpeed"].ToString();
+                //    //Console.WriteLine($"CPU 名称: {cpuName}");
+                //    //Console.WriteLine($"CPU 主频: {clockSpeed} MHz");
+                //    device.cpuInfos.Add(new CPUInfo { name = cpuName, hz = clockSpeed });
+                //}
+                string cpuName =  MemoryInfo.GetCpuName();
+                var clockSpeed = MemoryInfo.GetCpuSpeed();
+                device.cpuInfos.Add(new CPUInfo { name = cpuName, hz = $"{clockSpeed}" });
             }
             else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
             {

+ 89 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Services/MemoryInfo.cs

@@ -0,0 +1,89 @@
+using Microsoft.Win32;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace IES.ExamServer.Services
+{
+    public static class MemoryInfo
+    {
+        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+        private class MEMORYSTATUSEX
+        {
+            public uint dwLength;
+            public uint dwMemoryLoad;
+            public ulong ullTotalPhys;
+            public ulong ullAvailPhys;
+            public ulong ullTotalPageFile;
+            public ulong ullAvailPageFile;
+            public ulong ullTotalVirtual;
+            public ulong ullAvailVirtual;
+            public ulong ullAvailExtendedVirtual;
+
+            public MEMORYSTATUSEX()
+            {
+                dwLength = (uint)Marshal.SizeOf(typeof(MEMORYSTATUSEX));
+            }
+        }
+        // 从注册表获取 CPU 名称
+        public static string GetCpuNameFromRegistry()
+        {
+            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0"))
+            {
+                if (key != null)
+                {
+                    object cpuName = key.GetValue("ProcessorNameString");
+                    if (cpuName != null)
+                    {
+                        return cpuName.ToString();
+                    }
+                }
+            }
+            throw new Exception("Failed to retrieve CPU name from registry.");
+        }
+
+        // 从注册表获取 CPU 主频
+        public static uint GetCpuSpeedFromRegistry()
+        {
+            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0"))
+            {
+                if (key != null)
+                {
+                    object cpuSpeed = key.GetValue("~MHz");
+                    if (cpuSpeed != null)
+                    {
+                        return Convert.ToUInt32(cpuSpeed);
+                    }
+                }
+            }
+            throw new Exception("Failed to retrieve CPU speed from registry.");
+        }
+        // 从注册表获取 CPU 主频
+       
+
+        [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+        private static extern bool GlobalMemoryStatusEx([In, Out] MEMORYSTATUSEX lpBuffer);
+        public static string GetCpuName()
+        {
+            return GetCpuNameFromRegistry();
+        }
+
+        // 获取 CPU 主频
+        public static uint GetCpuSpeed()
+        {
+            return GetCpuSpeedFromRegistry();
+        }
+        /// <summary>
+        /// 获取系统的总物理内存(以字节为单位)
+        /// </summary>
+        public static long GetTotalPhysicalMemory()
+        {
+            MEMORYSTATUSEX memStatus = new MEMORYSTATUSEX();
+            if (GlobalMemoryStatusEx(memStatus))
+            {
+                return (long)memStatus.ullTotalPhys;
+            }
+            throw new System.ComponentModel.Win32Exception();
+        }
+    }
+
+}

+ 1 - 1
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/appsettings.json

@@ -27,7 +27,7 @@
   "ExamServer": {
     "Timeout": 30000,
     "Delay": 500,
-    "CenterUrl": "https://localhost:5001" //https://www.teammodel.cn
+    "CenterUrl": "https://www.teammodel.cn" //https://www.teammodel.cn,https://localhost:5001
   },
   "ExamClient": {
     "Domain": "edge-exam.habook.cn"

+ 24 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/nlog.config

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      autoReload="true"
+      throwConfigExceptions="true">
+	<targets>
+		<target name="file"
+				xsi:type="File"
+				fileName="Logs/${shortdate}.log"
+		layout="${longdate} ${level:uppercase=true} ${message} ${exception:format=ToString}"
+		archiveFileName="Logs/{#}.log"
+		archiveEvery="Day"
+		archiveNumbering="Date"
+		maxArchiveFiles="30"
+		keepFileOpen="false"
+		concurrentWrites="true" />
+		<target name="console"
+				xsi:type="Console"
+				layout="${longdate} ${level:uppercase=true} ${message} ${exception:format=ToString}" />
+	</targets>
+	<rules>
+		<logger name="*" minlevel="Debug" writeTo="file,console" />
+	</rules>
+</nlog>

File diff suppressed because it is too large
+ 0 - 11924
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/wwwroot/package/schools.json


+ 3 - 3
TEAMModelOS.Function/TEAMModelOS.Function.csproj

@@ -5,9 +5,9 @@
     <OutputType>Exe</OutputType>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-	<Version>5.2501.8</Version>
-	<AssemblyVersion>5.2501.8.1</AssemblyVersion>
-	<FileVersion>5.2501.8.1</FileVersion>
+	<Version>5.2501.15</Version>
+	<AssemblyVersion>5.2501.15.1</AssemblyVersion>
+	<FileVersion>5.2501.15.1</FileVersion>
 	<PackageId>TEAMModelOS.FunctionV4</PackageId>
 	<Authors>teammodel</Authors>
 	<Company>醍摩豆(成都)信息技术有限公司</Company>

+ 3 - 3
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -1,9 +1,9 @@
 <Project Sdk="Microsoft.NET.Sdk">
 	<PropertyGroup>
 		<TargetFramework>net8.0</TargetFramework>
-		<Version>5.2501.8</Version>
-		<AssemblyVersion>5.2501.8.1</AssemblyVersion>
-		<FileVersion>5.2501.8.1</FileVersion>
+		<Version>5.2501.15</Version>
+		<AssemblyVersion>5.2501.15.1</AssemblyVersion>
+		<FileVersion>5.2501.15.1</FileVersion>
 		<PackageReleaseNotes>发版</PackageReleaseNotes>
 	</PropertyGroup>
 

+ 5 - 5
TEAMModelOS/TEAMModelOS.csproj

@@ -80,11 +80,11 @@
 		<SpaRoot>ClientApp\</SpaRoot>
 		<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
 		<UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-		<Version>5.2501.8</Version>
-		<AssemblyVersion>5.2501.8.1</AssemblyVersion>
-		<FileVersion>5.2501.8.1</FileVersion>
+		<Version>5.2501.15</Version>
+		<AssemblyVersion>5.2501.15.1</AssemblyVersion>
+		<FileVersion>5.2501.15.1</FileVersion>
 		<Description>TEAMModelOS(IES5)</Description>
-		<PackageReleaseNotes>IES版本说明版本切换标记5.2501.8.1</PackageReleaseNotes>
+		<PackageReleaseNotes>IES版本说明版本切换标记5.2501.15.1</PackageReleaseNotes>
 		<PackageId>TEAMModelOS</PackageId>
 		<Authors>teammodel</Authors>
 		<Company>醍摩豆(成都)信息技术有限公司</Company>
@@ -116,7 +116,7 @@
 		<!-- Build Target: Restore NPM packages using npm -->
 		<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
 
-		<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
+		<Exec WorkingDirectory="$(SpaRoot)" Command="cnpm install" />
 	</Target>
 
 	<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">

+ 1 - 1
TEAMModelOS/appsettings.Development.json

@@ -18,7 +18,7 @@
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
     "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/",
     //"HttpTrigger": "http://localhost:7071/api/"
-    "Version": "5.2501.8.1"
+    "Version": "5.2501.15.1"
   },
   "Azure": {
     // 测试站数据库

+ 1 - 1
TEAMModelOS/appsettings.json

@@ -18,7 +18,7 @@
     "Exp": 86400,
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
     "HttpTrigger": "https://teammodelosfunction.chinacloudsites.cn/api/",
-    "Version": "5.2501.8.1"
+    "Version": "5.2501.15.1"
   },
   "Azure": {
     "Storage": {