【新增】 获取学生端本地的IPV4地址
This commit is contained in:
@@ -122,8 +122,6 @@ class Program
|
|||||||
throw new Exception($"压缩失败: {ex.Message}");
|
throw new Exception($"压缩失败: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 下载文件方法
|
// 下载文件方法
|
||||||
if (action == "/downloadfiles")
|
if (action == "/downloadfiles")
|
||||||
{
|
{
|
||||||
@@ -170,6 +168,15 @@ class Program
|
|||||||
Console.WriteLine($"操作失败: {ex.Message}");
|
Console.WriteLine($"操作失败: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 获取学生端本地的IPV4地址
|
||||||
|
if (action == "/getipv4address") {
|
||||||
|
Console.WriteLine("获取IPV4");
|
||||||
|
responseMessage = Dns.GetHostEntry(Dns.GetHostName())
|
||||||
|
.AddressList
|
||||||
|
.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork)
|
||||||
|
?.ToString() ?? "未找到IPv4地址";
|
||||||
|
}
|
||||||
|
// 打开本地判分的JAVA环境
|
||||||
if (action == "/openjudgement")
|
if (action == "/openjudgement")
|
||||||
{
|
{
|
||||||
string relativePath = "";
|
string relativePath = "";
|
||||||
@@ -442,6 +449,7 @@ class Program
|
|||||||
responseMessage = "Error: " + ex.Message;
|
responseMessage = "Error: " + ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 停止软件
|
||||||
else if (action == "/stop")
|
else if (action == "/stop")
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(fileToOpen))
|
if (!string.IsNullOrEmpty(fileToOpen))
|
||||||
@@ -469,6 +477,7 @@ class Program
|
|||||||
responseMessage = "Missing 'file' parameter.";
|
responseMessage = "Missing 'file' parameter.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 检测学生端环境
|
||||||
else if (action == "/check")
|
else if (action == "/check")
|
||||||
{
|
{
|
||||||
string apiUrl = "http://" + ip + ":48080/admin-api/exam/app/getAppCheckList/" + taskId; // ← 替换成你的接口地址
|
string apiUrl = "http://" + ip + ":48080/admin-api/exam/app/getAppCheckList/" + taskId; // ← 替换成你的接口地址
|
||||||
@@ -1000,25 +1009,25 @@ class Program
|
|||||||
return null; // 没找到
|
return null; // 没找到
|
||||||
}
|
}
|
||||||
// 获取进程命令行,需要添加 System.Management 引用
|
// 获取进程命令行,需要添加 System.Management 引用
|
||||||
public static string GetCommandLine(Process process)
|
//public static string GetCommandLine(Process process)
|
||||||
{
|
//{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using (var searcher = new System.Management.ManagementObjectSearcher(
|
// using (var searcher = new System.Management.ManagementObjectSearcher(
|
||||||
"SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id))
|
// "SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id))
|
||||||
{
|
// {
|
||||||
foreach (var obj in searcher.Get())
|
// foreach (var obj in searcher.Get())
|
||||||
{
|
// {
|
||||||
return obj["CommandLine"]?.ToString();
|
// return obj["CommandLine"]?.ToString();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch
|
// catch
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user