diff --git a/EgwCoreLib.BlazorTest/Pages/TestHwInfo.razor b/EgwCoreLib.BlazorTest/Pages/TestHwInfo.razor
index 401fd60..ce3fe40 100644
--- a/EgwCoreLib.BlazorTest/Pages/TestHwInfo.razor
+++ b/EgwCoreLib.BlazorTest/Pages/TestHwInfo.razor
@@ -3,7 +3,7 @@
@using EgwCoreLib.Utils
-
+
+
-
Sublicense
@@ -38,19 +38,19 @@
AppKey
@appKey
- -
-
+
-
+
-
+
-
Machine Info
- @if (ListMachineInfo != null && ListMachineInfo.Count > 0)
+ @if (ListAllMacInfo != null && ListAllMacInfo.Count > 0)
{
- @foreach (var item in ListMachineInfo)
+ @foreach (var item in ListAllMacInfo)
{
-
@item.Key
@@ -60,12 +60,90 @@
}
+
+ @if (ListUserInfo != null && ListUserInfo.Count > 0)
+ {
+
+ -
+ UserInfo
+
+ @foreach (var item in ListUserInfo)
+ {
+ -
+
@item.Key
+ @item.Value
+
+ }
+
+ }
+ @if (ListNetInfo != null && ListNetInfo.Count > 0)
+ {
+
+
+ -
+ NetInfo
+
+ @foreach (var item in ListNetInfo)
+ {
+ -
+
@item.Key
+ @item.Value
+
+ }
+
+ }
+
+
+
+ -
+ CpuInfo
+
+ @foreach (var item in ListOsInfo)
+ {
+ -
+
@item.Key
+ @item.Value
+
+ }
+
+
+
+ -
+ OsInfo
+
+ @foreach (var item in ListOsInfo)
+ {
+ -
+
@item.Key
+ @item.Value
+
+ }
+
+
+
+ -
+ VolInfo
+
+ @foreach (var item in ListVolInfo)
+ {
+ -
+
@item.Key
+ @item.Value
+
+ }
+
+
@code {
+ protected Dictionary
ListAllMacInfo { get; set; } = new Dictionary();
+ protected Dictionary ListCpuInfo { get; set; } = new Dictionary();
protected Dictionary ListDevId { get; set; } = new Dictionary();
- protected Dictionary ListMachineInfo { get; set; } = new Dictionary();
+ protected Dictionary ListNetInfo { get; set; } = new Dictionary();
+ protected Dictionary ListOsInfo { get; set; } = new Dictionary();
+ protected Dictionary ListUserInfo { get; set; } = new Dictionary();
+ protected Dictionary ListVolInfo { get; set; } = new Dictionary();
protected MachineDataValidator MDValidator { get; set; } = new MachineDataValidator();
@@ -99,15 +177,27 @@
.AddProcessorId()
.AddMotherboardSerialNumber()
.AddSystemDriveSerialNumber())
+ // .OnLinux(linux => linux
+ // .AddMotherboardSerialNumber()
+ // .AddSystemDriveSerialNumber())
+ // .OnMac(mac => mac
+ // .AddSystemDriveSerialNumber()
+ // .AddPlatformSerialNumber())
.ToString();
ListDevId.Add("DevId_03", deviceId);
- ListMachineInfo = MachineDataValidator.userInfo;
+ ListNetInfo = new Dictionary(MachineDataValidator.netInfo);
+ ListOsInfo = new Dictionary(MachineDataValidator.osInfo);
+ ListUserInfo = new Dictionary(MachineDataValidator.userInfo);
+ ListCpuInfo = new Dictionary(MachineDataValidator.cpuInfo);
+ ListVolInfo = new Dictionary(MachineDataValidator.volInfo);
+
+ ListAllMacInfo = new Dictionary(MachineDataValidator.userInfo);
foreach (var item in MachineDataValidator.netInfo)
{
- if (!ListMachineInfo.ContainsKey(item.Key))
+ if (!ListAllMacInfo.ContainsKey(item.Key))
{
- ListMachineInfo.Add(item.Key, item.Value);
+ ListAllMacInfo.Add(item.Key, item.Value);
}
}
diff --git a/EgwCoreLib.Utils/MachineInfo.cs b/EgwCoreLib.Utils/MachineInfo.cs
index e0f9bfb..4084414 100644
--- a/EgwCoreLib.Utils/MachineInfo.cs
+++ b/EgwCoreLib.Utils/MachineInfo.cs
@@ -185,6 +185,25 @@ namespace EgwCoreLib.Utils
searchWmiParam(DictParam, obj, "ProductName", "ProductName");
searchWmiParam(DictParam, obj, "ServiceName", "ServiceName");
}
+
+ // ora cerco IP...
+ try
+ {
+ moc = new ManagementObjectSearcher("select * from Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'true'").Get();
+ }
+ catch
+ {
+ Log.Error("Error: WMI API Not loaded.");
+ return DictParam;
+ }
+ int idx = 0;
+ foreach (ManagementObject obj in moc)
+ {
+ searchWmiParam(DictParam, obj, $"Int.{idx}.Name", "Caption");
+ searchWmiParamMulti(DictParam, obj, $"Int.{idx}.Ipv4", "IPAddress", ".");
+ searchWmiParamMulti(DictParam, obj, $"Int.{idx}.Ipv6", "IPAddress", ":");
+ idx++;
+ }
return DictParam;
}
@@ -270,7 +289,7 @@ namespace EgwCoreLib.Utils
DictParam.Add("UserDomainName", Environment.UserDomainName);
DictParam.Add("UserName", Environment.UserName);
}
- catch(Exception exc)
+ catch (Exception exc)
{
Log.Error($"Error in GetUserInfo{Environment.NewLine}{exc}");
}
@@ -314,20 +333,54 @@ namespace EgwCoreLib.Utils
///
/// Effettua estrazione parametri WMI da elenco recuperato
///
- ///
+ ///
///
///
///
- private static void searchWmiParam(Dictionary Processor, ManagementObject obj, string pName, string pKey)
+ private static void searchWmiParam(Dictionary OutDict, ManagementObject obj, string pName, string pKey)
{
try
{
var objVal = $"{obj[pKey]}";
string strVal = objVal != null ? objVal : "";
- Processor.Add(pName, strVal);
+ OutDict.Add(pName, strVal);
}
catch
{ }
+
+ }
+
+ ///
+ /// Effettua estrazione parametri WMI da elenco recuperato come array
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private static void searchWmiParamMulti(Dictionary OutDict, ManagementObject obj, string pName, string pKey, string filtCond)
+ {
+ try
+ {
+ int id = 0;
+ var objVal = (string[])obj[pKey];
+ var filtObj = objVal.Where(x => x.Contains(filtCond)).ToList();
+ bool hasMulti = filtObj.Count > 1;
+ foreach (var str in filtObj)
+ {
+ if (hasMulti)
+ {
+ OutDict.Add($"{pName}.{id++}", str);
+ }
+ else
+ {
+ OutDict.Add($"{pName}", str);
+ }
+ }
+ }
+ catch
+ { }
+
}
#endregion Private Methods