diff --git a/labs/IdTest/.gitignore b/labs/IdTest/.gitignore
new file mode 100644
index 00000000..988994ff
--- /dev/null
+++ b/labs/IdTest/.gitignore
@@ -0,0 +1,16 @@
+*.bak
+*.suo
+*.db
+*.user
+.vs
+obj
+Obj
+bin
+Bin
+debug
+Debug
+release
+Release
+Logs
+logs
+node_modules
\ No newline at end of file
diff --git a/labs/IdTest/IdTest.csproj b/labs/IdTest/IdTest.csproj
new file mode 100644
index 00000000..1f36f2b0
--- /dev/null
+++ b/labs/IdTest/IdTest.csproj
@@ -0,0 +1,12 @@
+
+
+
+ Exe
+ netcoreapp3.1
+
+
+
+
+
+
+
diff --git a/labs/IdTest/IdTest.sln b/labs/IdTest/IdTest.sln
new file mode 100644
index 00000000..8d016228
--- /dev/null
+++ b/labs/IdTest/IdTest.sln
@@ -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
diff --git a/labs/IdTest/Program.cs b/labs/IdTest/Program.cs
new file mode 100644
index 00000000..cbb5bb39
--- /dev/null
+++ b/labs/IdTest/Program.cs
@@ -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();
+ }
+ }
+}
\ No newline at end of file
diff --git a/projects/IoTNode/Startup.cs b/projects/IoTNode/Startup.cs
index 9ecdda3d..0771da76 100644
--- a/projects/IoTNode/Startup.cs
+++ b/projects/IoTNode/Startup.cs
@@ -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().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);
}
}
}
\ No newline at end of file