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
{
#if DEBUG
public const string ServicePathAuthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Authenticated/{0}";
public const string ServicePathUnauthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Unauthenticated/{0}";
#else
//#if DEBUG
// public const string ServicePathAuthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Authenticated/{0}";
// public const string ServicePathUnauthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Unauthenticated/{0}";
//#else
public const string ServicePathAuthenticatedTemplate = "http://DISCO:9292/Services/Client/Authenticated/{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)
{
+35 -12
View File
@@ -51,7 +51,7 @@ namespace Disco.Client.Interop
{
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())
{
@@ -65,6 +65,12 @@ namespace Disco.Client.Interop
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;
}
else
@@ -85,7 +91,7 @@ namespace Disco.Client.Interop
{
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())
{
@@ -155,17 +161,10 @@ namespace Disco.Client.Interop
}
private static void ApplyBaseBoardInformation(this DeviceHardware DeviceHardware)
{
// 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
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 FROM Win32_BaseBoard"))
using (var mSearcher = new ManagementObjectSearcher("SELECT SerialNumber, Manufacturer, Model, Product FROM Win32_BaseBoard"))
{
using (var mResults = mSearcher.Get())
{
@@ -173,8 +172,33 @@ namespace Disco.Client.Interop
{
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))
{
DeviceHardware.Manufacturer = manufacturer.Trim();
}
var model = (string)mItem.GetPropertyValue("Model");
if (DeviceHardware.Model == null && !string.IsNullOrWhiteSpace(model))
{
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))
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;
@@ -193,7 +217,6 @@ namespace Disco.Client.Interop
throw new Exception("Disco Client was unable to retrieve BaseBoard information from WMI", ex);
}
}
}
private static void ApplySystemProductInformation(this DeviceHardware DeviceHardware)
{
+5 -5
View File
@@ -20,13 +20,13 @@ namespace Disco.ClientBootstrapper
private StringBuilder errorMessage;
private Process clientProcess;
#if DEBUG
public const string DiscoServerName = "WS-GSHARP";
public const int DiscoServerPort = 57252;
#else
//#if DEBUG
// public const string DiscoServerName = "WS-GSHARP";
// public const int DiscoServerPort = 57252;
//#else
public const string DiscoServerName = "DISCO";
public const int DiscoServerPort = 9292;
#endif
//#endif
public BootstrapperLoop(IStatus StatusUI, LoopCompleteCallback Callback)
{