aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-10-27 12:09:07 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-10-27 12:09:07 +0200
commit312e8ccad554d6d0e7d21444e069731e770db978 (patch)
treed20a3657dab87de400675f5f8aca77c0f124b2bd /Software/Visual_Studio/PPC/Tango.PPC.Common
parent4954a924b8a5b8fd7a213a444027e74b936359be (diff)
downloadTango-312e8ccad554d6d0e7d21444e069731e770db978.tar.gz
Tango-312e8ccad554d6d0e7d21444e069731e770db978.zip
Added DEVICE_ID, DEVICE_NAME & IS_DEVICE_REGISTERED fields to db.
Prevent multiple machine setup from different devices. Moved notification to inner layout on PPC. Improved PPC notification bar. Added more machine status support from embedded. FIxed issue with external bridge and emergency pressed.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs3
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs64
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs12
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs2
4 files changed, 81 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
index 94091b284..004c37096 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
@@ -132,6 +132,9 @@ namespace Tango.PPC.Common.MachineSetup
MachineSetupRequest request = new MachineSetupRequest();
request.SerialNumber = serialNumber;
+ request.DeviceID = await _windows_manager.GetDeviceId();
+ request.DeviceName = await _windows_manager.GetDeviceName();
+
MachineSetupResponse setup_response = null;
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs
index d0c8567a1..2164a71c3 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs
@@ -168,5 +168,69 @@ namespace Tango.PPC.Common.OS
{
Process.Start("shutdown.exe", "-s -t 0");
}
+
+ /// <summary>
+ /// Gets the machine unique identifier.
+ /// </summary>
+ /// <returns></returns>
+ public Task<string> GetDeviceId()
+ {
+ return Task.Factory.StartNew<String>(() =>
+ {
+ try
+ {
+ ManagementObjectCollection mbsList = null;
+ ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select * From Win32_processor");
+ mbsList = mbs.Get();
+ string id = "";
+ foreach (ManagementObject mo in mbsList)
+ {
+ id = mo["ProcessorID"].ToString();
+ }
+
+ string max_address = "";
+
+ using (ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"))
+ {
+ using (ManagementObjectCollection moc = mc.GetInstances())
+ {
+ if (moc != null)
+ {
+ foreach (ManagementObject mo in moc)
+ {
+ if (string.IsNullOrEmpty(max_address)) // only return MAC Address from first card
+ {
+ if (mo["MacAddress"] != null)
+ {
+ max_address = mo["MacAddress"].ToString();
+ }
+ }
+ mo.Dispose();
+ }
+ }
+ }
+ }
+
+ return id + "_" + max_address;
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Could not extract device id. Falling back to device name...");
+ return GetDeviceName().Result;
+ }
+ });
+ }
+
+ /// <summary>
+ /// Gets the machine host name.
+ /// </summary>
+ /// <returns></returns>
+ public Task<string> GetDeviceName()
+ {
+ return Task.Factory.StartNew<String>(() =>
+ {
+ return Environment.MachineName;
+ });
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs
index f3ec398fc..3e24ffe72 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs
@@ -45,6 +45,18 @@ namespace Tango.PPC.Common.OS
Task ChangeTimeZone(TimeZoneInfo timeZone);
/// <summary>
+ /// Gets the machine unique identifier.
+ /// </summary>
+ /// <returns></returns>
+ Task<String> GetDeviceId();
+
+ /// <summary>
+ /// Gets the machine host name.
+ /// </summary>
+ /// <returns></returns>
+ Task<String> GetDeviceName();
+
+ /// <summary>
/// Restarts the system.
/// </summary>
/// <returns></returns>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs
index 83bec6b07..821828a48 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs
@@ -10,5 +10,7 @@ namespace Tango.PPC.Common.Web
public class MachineSetupRequest : WebRequestMessage
{
public String SerialNumber { get; set; }
+ public String DeviceID { get; set; }
+ public String DeviceName { get; set; }
}
}