😎1、调整获取计算机信息兼容.net6 2.获取数据库表(实体)集合采用精确匹配 3、升级依赖
This commit is contained in:
parent
2170428932
commit
7159f607b0
@ -13,7 +13,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="3.0.0" />
|
||||
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="3.1.0" />
|
||||
<PackageReference Include="AngleSharp" Version="1.1.2" />
|
||||
<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" />
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||
|
||||
@ -190,7 +190,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
if (bracketIndex != -1)
|
||||
dbTableName = dbTableName.Substring(0, bracketIndex);
|
||||
|
||||
var table = dbTableInfos.FirstOrDefault(u => u.Name.ToLower().StartsWith((config != null && config.DbSettings.EnableUnderLine ? UtilMethods.ToUnderLine(dbTableName) : dbTableName).ToLower()));
|
||||
var table = dbTableInfos.FirstOrDefault(u => u.Name.ToLower().Equals((config != null && config.DbSettings.EnableUnderLine ? UtilMethods.ToUnderLine(dbTableName) : dbTableName).ToLower()));
|
||||
if (table == null) continue;
|
||||
tableOutputList.Add(new TableOutput
|
||||
{
|
||||
|
||||
@ -189,8 +189,11 @@ public static class ComputerUtil
|
||||
}
|
||||
else
|
||||
{
|
||||
#if NET8_0 || NET9_0
|
||||
string output = ShellUtil.Cmd("wmic", "cpu get LoadPercentage");
|
||||
// string output = ShellUtil.PowerShell("Get-CimInstance -ClassName Win32_Processor | Measure-Command {Start-Sleep -Seconds 1}");
|
||||
#else
|
||||
string output = ShellUtil.PowerShell("Get-CimInstance -ClassName Win32_Processor | Measure-Command {Start-Sleep -Seconds 1}");
|
||||
#endif
|
||||
cpuRates.AddRange(output.Replace("LoadPercentage", string.Empty).Trim().Split("\r\r\n"));
|
||||
}
|
||||
return cpuRates;
|
||||
@ -205,10 +208,10 @@ public static class ComputerUtil
|
||||
string runTime = string.Empty;
|
||||
if (IsMacOS())
|
||||
{
|
||||
//macOS 获取系统启动时间:
|
||||
//sysctl -n kern.boottime | awk '{print $4}' | tr -d ','
|
||||
//返回:1705379131
|
||||
//使用date格式化即可
|
||||
// macOS 获取系统启动时间:
|
||||
// sysctl -n kern.boottime | awk '{print $4}' | tr -d ','
|
||||
// 返回:1705379131
|
||||
// 使用date格式化即可
|
||||
string output = ShellUtil.Bash("date -r $(sysctl -n kern.boottime | awk '{print $4}' | tr -d ',') +\"%Y-%m-%d %H:%M:%S\"").Trim();
|
||||
runTime = DateTimeUtil.FormatTime((DateTime.Now - output.ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
|
||||
}
|
||||
@ -219,8 +222,11 @@ public static class ComputerUtil
|
||||
}
|
||||
else
|
||||
{
|
||||
#if NET8_0 || NET9_0
|
||||
string output = ShellUtil.Cmd("wmic", "OS get LastBootUpTime/Value");
|
||||
// string output = ShellUtil.PowerShell("(Get-Date) - (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime");
|
||||
#else
|
||||
string output = ShellUtil.PowerShell("(Get-Date) - (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime");
|
||||
#endif
|
||||
string[] outputArr = output.Split('=', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||
if (outputArr.Length == 2)
|
||||
runTime = DateTimeUtil.FormatTime((DateTime.Now - outputArr[1].Split('.')[0].ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
|
||||
@ -331,8 +337,11 @@ public class MemoryMetricsClient
|
||||
/// <returns></returns>
|
||||
public static MemoryMetrics GetWindowsMetrics()
|
||||
{
|
||||
#if NET8_0 || NET9_0
|
||||
string output = ShellUtil.Cmd("wmic", "OS get FreePhysicalMemory,TotalVisibleMemorySize /Value");
|
||||
// string output = ShellUtil.PowerShell("Get-CimInstance -ClassName Win32_OperatingSystem | Select FreePhysicalMemory, TotalVisibleMemorySize");
|
||||
#else
|
||||
string output = ShellUtil.PowerShell("Get-CimInstance -ClassName Win32_OperatingSystem | Select FreePhysicalMemory, TotalVisibleMemorySize");
|
||||
#endif
|
||||
var metrics = new MemoryMetrics();
|
||||
var lines = output.Trim().Split('\n', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||
if (lines.Length <= 0) return metrics;
|
||||
@ -447,6 +456,7 @@ public class ShellUtil
|
||||
/// <returns></returns>
|
||||
public static string PowerShell(string script)
|
||||
{
|
||||
#if NET8_0 || NET9_0
|
||||
using var PowerShellInstance = System.Management.Automation.PowerShell.Create();
|
||||
PowerShellInstance.AddScript(script);
|
||||
var PSOutput = PowerShellInstance.Invoke();
|
||||
@ -457,6 +467,9 @@ public class ShellUtil
|
||||
output.AppendLine(outputItem.BaseObject.ToString());
|
||||
}
|
||||
return output.ToString();
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,6 +531,7 @@ public class ShellHelper
|
||||
/// <returns></returns>
|
||||
public static string PowerShell(string script)
|
||||
{
|
||||
#if NET8_0 || NET9_0
|
||||
using var PowerShellInstance = System.Management.Automation.PowerShell.Create();
|
||||
PowerShellInstance.AddScript(script);
|
||||
var PSOutput = PowerShellInstance.Invoke();
|
||||
@ -528,5 +542,8 @@ public class ShellHelper
|
||||
output.AppendLine(outputItem.BaseObject.ToString());
|
||||
}
|
||||
return output.ToString();
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user