1.0.0-alpha.219

1.使用初始化config数据库的mac地址作为节点编号
2.更换网卡时需要根据新网卡生成序列号


Former-commit-id: f9f3d908b7332831c2d7dc1e7d2b66f84d0c6bf2
TangShanKaiPing
wanggang 6 years ago
parent 79e5d3dd92
commit e4fb4c91ea

@ -0,0 +1,16 @@
*.bak
*.suo
*.db
*.user
.vs
obj
Obj
bin
Bin
debug
Debug
release
Release
Logs
logs
node_modules

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Management" Version="4.7.0" />
</ItemGroup>
</Project>

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdTest", "IdTest.csproj", "{600B4FE6-FE66-4D0B-B8EB-61642AC0A595}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{600B4FE6-FE66-4D0B-B8EB-61642AC0A595}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{600B4FE6-FE66-4D0B-B8EB-61642AC0A595}.Debug|Any CPU.Build.0 = Debug|Any CPU
{600B4FE6-FE66-4D0B-B8EB-61642AC0A595}.Release|Any CPU.ActiveCfg = Release|Any CPU
{600B4FE6-FE66-4D0B-B8EB-61642AC0A595}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {79316E84-1766-4980-B4FE-09AA33D9C00C}
EndGlobalSection
EndGlobal

@ -0,0 +1,40 @@
using System;
using System.IO;
using System.Management;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
namespace IdTest
{
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine(GetCPUNumber());
}
public static string GetCPUNumber()
{
var result = string.Empty;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
result = Regex.Match(File.ReadAllText("/proc/cpuinfo"), @"Serial\s*:\s*([^\s]+)").Groups[1].Value;
}
else
{
var mc = new ManagementClass("win32_processor");
var moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (result == "")
{
result = mo.Properties["processorID"].Value.ToString();
break;
}
}
}
return result.ToLower();
}
}
}

@ -66,18 +66,18 @@ namespace IoTNode
});
}
public override void Seed(DbContext dbContext, IServiceProvider serviceProvider, IConfiguration configuration)
public override void Seed(DbContext dbContext, IServiceProvider serviceProvider, IConfiguration cfg)
{
var id = Helper.Instance.GetMacAddress();
var sn = cfg["sn"];
dbContext.Set<Node>().Add(new Node
{
Id = $"nodeid-{id}".ToGuid(),
Id = $"nodeid-{sn}".ToGuid(),
Name = "½Úµã",
Number = id,
Number = sn,
Image = "/images/classroom.png"
});
dbContext.SaveChanges();
base.Seed(dbContext, serviceProvider, configuration);
base.Seed(dbContext, serviceProvider, cfg);
}
}
}
Loading…
Cancel
Save