😎增加获取机器序列号接口
This commit is contained in:
parent
2cc272c001
commit
4f6fc8da4e
@ -21,6 +21,7 @@
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.4.5" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.4.5" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.4.5" />
|
||||
<PackageReference Include="Hardware.Info" Version="100.1.0.1" />
|
||||
<PackageReference Include="IPTools.China" Version="1.6.0" />
|
||||
<PackageReference Include="IPTools.International" Version="1.6.0" />
|
||||
<PackageReference Include="Magicodes.IE.Excel" Version="2.7.5.1" />
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
//
|
||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
|
||||
using Hardware.Info;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
@ -123,7 +124,7 @@ public class SysCommonService : IDynamicApiController, ITransient
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载标记错误的临时 Excel(全局)
|
||||
/// 下载标记错误的临时 Excel(全局) 🔖
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisplayName("下载标记错误的临时 Excel")]
|
||||
@ -140,4 +141,31 @@ public class SysCommonService : IDynamicApiController, ITransient
|
||||
FileDownloadName = $"{(string.IsNullOrEmpty(fileName) ? "错误标记_" + DateTime.Now.ToString("yyyyMMddhhmmss") : fileName)}.xlsx"
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器序列号 🔖
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetMachineSerialKey()
|
||||
{
|
||||
try
|
||||
{
|
||||
IHardwareInfo hardwareInfo = new HardwareInfo();
|
||||
hardwareInfo.RefreshBIOSList(); // 刷新 BIOS 信息
|
||||
hardwareInfo.RefreshMotherboardList(); // 刷新主板信息
|
||||
hardwareInfo.RefreshCPUList(false); // 刷新 CPU 信息
|
||||
|
||||
var biosSerialNumber = hardwareInfo.BiosList.MinBy(u => u.SerialNumber)?.SerialNumber;
|
||||
var mbSerialNumber = hardwareInfo.MotherboardList.MinBy(u => u.SerialNumber)?.SerialNumber;
|
||||
var cpuProcessorId = hardwareInfo.CpuList.MinBy(u => u.ProcessorId)?.ProcessorId;
|
||||
// 根据 BIOS、主板和 CPU 信息生成 MD5 摘要
|
||||
var md5Data = MD5Encryption.Encrypt($"{biosSerialNumber}_{mbSerialNumber}_{cpuProcessorId}", true);
|
||||
var serialKey = $"{md5Data[..8]}-{md5Data[8..16]}-{md5Data[16..24]}-{md5Data[24..]}";
|
||||
return serialKey;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw Oops.Oh($"获取机器码失败:{ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user