Merge branch 'release/AddNetInfo_01'
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
@using EgwCoreLib.Utils
|
||||
|
||||
|
||||
<div class="row small">
|
||||
<div class="row small" style="font-size: 0.8rem;">
|
||||
<div class="col-6">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active">
|
||||
@@ -20,8 +20,8 @@
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
<hr />
|
||||
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active">
|
||||
Sublicense
|
||||
@@ -38,19 +38,19 @@
|
||||
<div class="px-1">AppKey</div>
|
||||
<div class="px-1">@appKey</div>
|
||||
</li>
|
||||
<li>
|
||||
<button class="btn btn-primary" @onclick="Regenerate">ReGen</button>
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<button class="btn btn-info btn-sm w-100" @onclick="Regenerate">ReGen</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="col-4">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active">
|
||||
Machine Info
|
||||
</li>
|
||||
@if (ListMachineInfo != null && ListMachineInfo.Count > 0)
|
||||
@if (ListAllMacInfo != null && ListAllMacInfo.Count > 0)
|
||||
{
|
||||
@foreach (var item in ListMachineInfo)
|
||||
@foreach (var item in ListAllMacInfo)
|
||||
{
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div class="px-1">@item.Key</div>
|
||||
@@ -60,12 +60,90 @@
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
@if (ListUserInfo != null && ListUserInfo.Count > 0)
|
||||
{
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active">
|
||||
UserInfo
|
||||
</li>
|
||||
@foreach (var item in ListUserInfo)
|
||||
{
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div class="px-1">@item.Key</div>
|
||||
<div class="px-1">@item.Value</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@if (ListNetInfo != null && ListNetInfo.Count > 0)
|
||||
{
|
||||
<br />
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active">
|
||||
NetInfo
|
||||
</li>
|
||||
@foreach (var item in ListNetInfo)
|
||||
{
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div class="px-1">@item.Key</div>
|
||||
<div class="px-1">@item.Value</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active">
|
||||
CpuInfo
|
||||
</li>
|
||||
@foreach (var item in ListOsInfo)
|
||||
{
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div class="px-1">@item.Key</div>
|
||||
<div class="px-1">@item.Value</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<br />
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active">
|
||||
OsInfo
|
||||
</li>
|
||||
@foreach (var item in ListOsInfo)
|
||||
{
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div class="px-1">@item.Key</div>
|
||||
<div class="px-1">@item.Value</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<br />
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active">
|
||||
VolInfo
|
||||
</li>
|
||||
@foreach (var item in ListVolInfo)
|
||||
{
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div class="px-1">@item.Key</div>
|
||||
<div class="px-1">@item.Value</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
protected Dictionary<string, string> ListAllMacInfo { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> ListCpuInfo { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> ListDevId { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> ListMachineInfo { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> ListNetInfo { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> ListOsInfo { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> ListUserInfo { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> ListVolInfo { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
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<string, string>(MachineDataValidator.netInfo);
|
||||
ListOsInfo = new Dictionary<string, string>(MachineDataValidator.osInfo);
|
||||
ListUserInfo = new Dictionary<string, string>(MachineDataValidator.userInfo);
|
||||
ListCpuInfo = new Dictionary<string, string>(MachineDataValidator.cpuInfo);
|
||||
ListVolInfo = new Dictionary<string, string>(MachineDataValidator.volInfo);
|
||||
|
||||
ListAllMacInfo = new Dictionary<string, string>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// Effettua estrazione parametri WMI da elenco recuperato
|
||||
/// </summary>
|
||||
/// <param name="Processor"></param>
|
||||
/// <param name="OutDict"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="pName"></param>
|
||||
/// <param name="pKey"></param>
|
||||
private static void searchWmiParam(Dictionary<string, string> Processor, ManagementObject obj, string pName, string pKey)
|
||||
private static void searchWmiParam(Dictionary<string, string> 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
|
||||
{ }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua estrazione parametri WMI da elenco recuperato come array
|
||||
/// </summary>
|
||||
/// <param name="OutDict"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="pName"></param>
|
||||
/// <param name="pKey"></param>
|
||||
/// <param name="filtCond"></param>
|
||||
private static void searchWmiParamMulti(Dictionary<string, string> 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
|
||||
|
||||
Reference in New Issue
Block a user