😎1、修复短信发送 2、代码清理
This commit is contained in:
parent
7718884dc3
commit
7e02e177b1
@ -49,7 +49,7 @@
|
|||||||
<PackageReference Include="SSH.NET" Version="2024.2.0" />
|
<PackageReference Include="SSH.NET" Version="2024.2.0" />
|
||||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.5.1" />
|
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.5.1" />
|
||||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1170" />
|
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1171" />
|
||||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@ -86,7 +86,7 @@ public class SysSmsService : IDynamicApiController, ITransient
|
|||||||
PhoneNumbers = phoneNumber, // 待发送手机号, 多个以逗号分隔
|
PhoneNumbers = phoneNumber, // 待发送手机号, 多个以逗号分隔
|
||||||
SignName = template.SignName, // 短信签名
|
SignName = template.SignName, // 短信签名
|
||||||
TemplateCode = template.TemplateCode, // 短信模板
|
TemplateCode = template.TemplateCode, // 短信模板
|
||||||
TemplateParam = templateParam.ToString(), // 模板中的变量替换JSON串
|
TemplateParam = templateParam.ToJson(), // 模板中的变量替换JSON串
|
||||||
OutId = YitIdHelper.NextId().ToString()
|
OutId = YitIdHelper.NextId().ToString()
|
||||||
};
|
};
|
||||||
var sendSmsResponse = await client.SendSmsAsync(sendSmsRequest);
|
var sendSmsResponse = await client.SendSmsAsync(sendSmsRequest);
|
||||||
|
|||||||
@ -188,11 +188,7 @@ public static class ComputerUtil
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if NET8_0 || NET9_0
|
|
||||||
string output = ShellUtil.Cmd("wmic", "cpu get LoadPercentage");
|
string output = ShellUtil.Cmd("wmic", "cpu get LoadPercentage");
|
||||||
#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"));
|
cpuRates.AddRange(output.Replace("LoadPercentage", string.Empty).Trim().Split("\r\r\n"));
|
||||||
}
|
}
|
||||||
return cpuRates;
|
return cpuRates;
|
||||||
@ -221,11 +217,7 @@ public static class ComputerUtil
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if NET8_0 || NET9_0
|
|
||||||
string output = ShellUtil.Cmd("wmic", "OS get LastBootUpTime/Value");
|
string output = ShellUtil.Cmd("wmic", "OS get LastBootUpTime/Value");
|
||||||
#else
|
|
||||||
string output = ShellUtil.PowerShell("(Get-Date) - (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime");
|
|
||||||
#endif
|
|
||||||
string[] outputArr = output.Split('=', (char)StringSplitOptions.RemoveEmptyEntries);
|
string[] outputArr = output.Split('=', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (outputArr.Length == 2)
|
if (outputArr.Length == 2)
|
||||||
runTime = DateTimeUtil.FormatTime((DateTime.Now - outputArr[1].Split('.')[0].ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
|
runTime = DateTimeUtil.FormatTime((DateTime.Now - outputArr[1].Split('.')[0].ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
|
||||||
@ -336,11 +328,7 @@ public class MemoryMetricsClient
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static MemoryMetrics GetWindowsMetrics()
|
public static MemoryMetrics GetWindowsMetrics()
|
||||||
{
|
{
|
||||||
#if NET8_0 || NET9_0
|
|
||||||
string output = ShellUtil.Cmd("wmic", "OS get FreePhysicalMemory,TotalVisibleMemorySize /Value");
|
string output = ShellUtil.Cmd("wmic", "OS get FreePhysicalMemory,TotalVisibleMemorySize /Value");
|
||||||
#else
|
|
||||||
string output = ShellUtil.PowerShell("Get-CimInstance -ClassName Win32_OperatingSystem | Select FreePhysicalMemory, TotalVisibleMemorySize");
|
|
||||||
#endif
|
|
||||||
var metrics = new MemoryMetrics();
|
var metrics = new MemoryMetrics();
|
||||||
var lines = output.Trim().Split('\n', (char)StringSplitOptions.RemoveEmptyEntries);
|
var lines = output.Trim().Split('\n', (char)StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (lines.Length <= 1) return metrics;
|
if (lines.Length <= 1) return metrics;
|
||||||
@ -448,7 +436,6 @@ public class ShellUtil
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string PowerShell(string script)
|
public static string PowerShell(string script)
|
||||||
{
|
{
|
||||||
#if NET8_0 || NET9_0
|
|
||||||
using var PowerShellInstance = System.Management.Automation.PowerShell.Create();
|
using var PowerShellInstance = System.Management.Automation.PowerShell.Create();
|
||||||
PowerShellInstance.AddScript(script);
|
PowerShellInstance.AddScript(script);
|
||||||
var PSOutput = PowerShellInstance.Invoke();
|
var PSOutput = PowerShellInstance.Invoke();
|
||||||
@ -459,9 +446,6 @@ public class ShellUtil
|
|||||||
output.AppendLine(outputItem.BaseObject.ToString());
|
output.AppendLine(outputItem.BaseObject.ToString());
|
||||||
}
|
}
|
||||||
return output.ToString();
|
return output.ToString();
|
||||||
#else
|
|
||||||
return "";
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +507,6 @@ public class ShellHelper
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string PowerShell(string script)
|
public static string PowerShell(string script)
|
||||||
{
|
{
|
||||||
#if NET8_0 || NET9_0
|
|
||||||
using var PowerShellInstance = System.Management.Automation.PowerShell.Create();
|
using var PowerShellInstance = System.Management.Automation.PowerShell.Create();
|
||||||
PowerShellInstance.AddScript(script);
|
PowerShellInstance.AddScript(script);
|
||||||
var PSOutput = PowerShellInstance.Invoke();
|
var PSOutput = PowerShellInstance.Invoke();
|
||||||
@ -534,8 +517,5 @@ public class ShellHelper
|
|||||||
output.AppendLine(outputItem.BaseObject.ToString());
|
output.AppendLine(outputItem.BaseObject.ToString());
|
||||||
}
|
}
|
||||||
return output.ToString();
|
return output.ToString();
|
||||||
#else
|
|
||||||
return "";
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ public class SuperApiAop : DefaultSuperApiAop
|
|||||||
|
|
||||||
var logger = App.GetRequiredService<ILoggerFactory>().CreateLogger(CommonConst.SysLogCategoryName);
|
var logger = App.GetRequiredService<ILoggerFactory>().CreateLogger(CommonConst.SysLogCategoryName);
|
||||||
using var scope = logger.ScopeContext(new Dictionary<object, object> {
|
using var scope = logger.ScopeContext(new Dictionary<object, object> {
|
||||||
{ "loggingMonitor", apiInfo.ToString() }
|
{ "loggingMonitor", apiInfo.ToJson() }
|
||||||
});
|
});
|
||||||
logger.Log(logLevel, "ReZero超级API接口日志");
|
logger.Log(logLevel, "ReZero超级API接口日志");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "admin.net.pro",
|
"name": "admin.net.pro",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.4.33",
|
"version": "2.4.33",
|
||||||
"lastBuildTime": "2025.01.23",
|
"lastBuildTime": "2025.01.24",
|
||||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||||
"author": "zuohuaijun",
|
"author": "zuohuaijun",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user