Client/Bootstrapper Fix: Try gathering model from BaseBoard

This commit is contained in:
Gary Sharp
2017-03-24 15:50:18 +11:00
parent d8e93cb31b
commit 526f8547f7
3 changed files with 59 additions and 36 deletions
@@ -8,13 +8,13 @@ namespace Disco.Client.Extensions
{ {
public static class ClientServicesExtensions public static class ClientServicesExtensions
{ {
#if DEBUG //#if DEBUG
public const string ServicePathAuthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Authenticated/{0}"; // public const string ServicePathAuthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Authenticated/{0}";
public const string ServicePathUnauthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Unauthenticated/{0}"; // public const string ServicePathUnauthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Unauthenticated/{0}";
#else //#else
public const string ServicePathAuthenticatedTemplate = "http://DISCO:9292/Services/Client/Authenticated/{0}"; public const string ServicePathAuthenticatedTemplate = "http://DISCO:9292/Services/Client/Authenticated/{0}";
public const string ServicePathUnauthenticatedTemplate = "http://DISCO:9292/Services/Client/Unauthenticated/{0}"; public const string ServicePathUnauthenticatedTemplate = "http://DISCO:9292/Services/Client/Unauthenticated/{0}";
#endif //#endif
public static ResponseType Post<ResponseType>(this ServiceBase<ResponseType> Service, bool Authenticated) public static ResponseType Post<ResponseType>(this ServiceBase<ResponseType> Service, bool Authenticated)
{ {
+49 -26
View File
@@ -51,7 +51,7 @@ namespace Disco.Client.Interop
{ {
try try
{ {
using (var mSearcher = new ManagementObjectSearcher("SELECT SerialNumber, SMBIOSBIOSVersion FROM Win32_BIOS WHERE PrimaryBios=true")) using (var mSearcher = new ManagementObjectSearcher("SELECT SerialNumber, Manufacturer, SMBIOSBIOSVersion FROM Win32_BIOS WHERE PrimaryBios=true"))
{ {
using (var mResults = mSearcher.Get()) using (var mResults = mSearcher.Get())
{ {
@@ -65,6 +65,12 @@ namespace Disco.Client.Interop
DeviceHardware.SerialNumber = serialNumber.Trim(); DeviceHardware.SerialNumber = serialNumber.Trim();
} }
var manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
if (DeviceHardware.Manufacturer == null && !string.IsNullOrWhiteSpace(manufacturer))
{
DeviceHardware.Manufacturer = manufacturer.Trim();
}
ErrorReporting.DeviceIdentifier = DeviceHardware.SerialNumber; ErrorReporting.DeviceIdentifier = DeviceHardware.SerialNumber;
} }
else else
@@ -85,7 +91,7 @@ namespace Disco.Client.Interop
{ {
try try
{ {
using (var mSearcher = new ManagementObjectSearcher("SELECT Manufacturer, Model, PartOfDomain, PCSystemType, Domain FROM Win32_ComputerSystem")) using (var mSearcher = new ManagementObjectSearcher("SELECT Manufacturer, Model, PCSystemType FROM Win32_ComputerSystem"))
{ {
using (var mResults = mSearcher.Get()) using (var mResults = mSearcher.Get())
{ {
@@ -134,7 +140,7 @@ namespace Disco.Client.Interop
if (mItem != null) if (mItem != null)
{ {
Enrol.IsPartOfDomain = (bool)mItem.GetPropertyValue("PartOfDomain"); Enrol.IsPartOfDomain = (bool)mItem.GetPropertyValue("PartOfDomain");
if (Enrol.IsPartOfDomain) if (Enrol.IsPartOfDomain)
{ {
Enrol.DNSDomainName = (string)mItem.GetPropertyValue("Domain"); Enrol.DNSDomainName = (string)mItem.GetPropertyValue("Domain");
@@ -156,42 +162,59 @@ namespace Disco.Client.Interop
private static void ApplyBaseBoardInformation(this DeviceHardware DeviceHardware) private static void ApplyBaseBoardInformation(this DeviceHardware DeviceHardware)
{ {
// Added 2012-11-22 G# - Lenovo IdeaPad Serial SHIM try
// http://www.discoict.com.au/forum/feature-requests/2012/11/serial-number-detection-on-ideapads.aspx
if (string.IsNullOrWhiteSpace(DeviceHardware.SerialNumber) ||
(DeviceHardware.Manufacturer.Equals("LENOVO", StringComparison.OrdinalIgnoreCase) &&
(DeviceHardware.Model.Equals("S10-3", StringComparison.OrdinalIgnoreCase) // S10-3
|| DeviceHardware.Model.Equals("2957", StringComparison.OrdinalIgnoreCase)))) // S10-2
{ {
try using (var mSearcher = new ManagementObjectSearcher("SELECT SerialNumber, Manufacturer, Model, Product FROM Win32_BaseBoard"))
{ {
using (var mSearcher = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_BaseBoard")) using (var mResults = mSearcher.Get())
{ {
using (var mResults = mSearcher.Get()) using (var mItem = mResults.Cast<ManagementObject>().FirstOrDefault())
{ {
using (var mItem = mResults.Cast<ManagementObject>().FirstOrDefault()) if (mItem != null)
{ {
if (mItem != null) // Apply Manufacturer/Model information only if not previously found in Win32_ComputerSystem
var manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
if (DeviceHardware.Manufacturer == null && !string.IsNullOrWhiteSpace(manufacturer))
{ {
var serialNumber = (string)mItem.GetPropertyValue("SerialNumber"); DeviceHardware.Manufacturer = manufacturer.Trim();
if (!string.IsNullOrWhiteSpace(serialNumber))
{
DeviceHardware.SerialNumber = serialNumber.Trim();
ErrorReporting.DeviceIdentifier = DeviceHardware.SerialNumber;
}
} }
else
var model = (string)mItem.GetPropertyValue("Model");
if (DeviceHardware.Model == null && !string.IsNullOrWhiteSpace(model))
{ {
throw new Exception("No Win32_BaseBoard was found"); DeviceHardware.Model = model.ToString();
} }
var product = (string)mItem.GetPropertyValue("Product");
if (DeviceHardware.Model == null && !string.IsNullOrWhiteSpace(product))
{
DeviceHardware.Model = product.ToString();
}
// Added 2012-11-22 G# - Lenovo IdeaPad Serial SHIM
// http://www.discoict.com.au/forum/feature-requests/2012/11/serial-number-detection-on-ideapads.aspx
var serialNumber = (string)mItem.GetPropertyValue("SerialNumber");
if (!string.IsNullOrWhiteSpace(serialNumber) &&
(DeviceHardware.SerialNumber == null ||
((DeviceHardware.Manufacturer?.Equals("LENOVO", StringComparison.OrdinalIgnoreCase) ?? false) &&
((DeviceHardware.Model?.Equals("S10-3", StringComparison.OrdinalIgnoreCase) ?? false) // S10-3
|| (DeviceHardware.Model?.Equals("2957", StringComparison.OrdinalIgnoreCase) ?? false)))))
{
DeviceHardware.SerialNumber = serialNumber.Trim();
ErrorReporting.DeviceIdentifier = DeviceHardware.SerialNumber;
}
}
else
{
throw new Exception("No Win32_BaseBoard was found");
} }
} }
} }
} }
catch (Exception ex) }
{ catch (Exception ex)
throw new Exception("Disco Client was unable to retrieve BaseBoard information from WMI", ex); {
} throw new Exception("Disco Client was unable to retrieve BaseBoard information from WMI", ex);
} }
} }
+5 -5
View File
@@ -20,13 +20,13 @@ namespace Disco.ClientBootstrapper
private StringBuilder errorMessage; private StringBuilder errorMessage;
private Process clientProcess; private Process clientProcess;
#if DEBUG //#if DEBUG
public const string DiscoServerName = "WS-GSHARP"; // public const string DiscoServerName = "WS-GSHARP";
public const int DiscoServerPort = 57252; // public const int DiscoServerPort = 57252;
#else //#else
public const string DiscoServerName = "DISCO"; public const string DiscoServerName = "DISCO";
public const int DiscoServerPort = 9292; public const int DiscoServerPort = 9292;
#endif //#endif
public BootstrapperLoop(IStatus StatusUI, LoopCompleteCallback Callback) public BootstrapperLoop(IStatus StatusUI, LoopCompleteCallback Callback)
{ {