diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-10-27 12:09:07 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-10-27 12:09:07 +0200 |
| commit | 312e8ccad554d6d0e7d21444e069731e770db978 (patch) | |
| tree | d20a3657dab87de400675f5f8aca77c0f124b2bd /Software/Visual_Studio/PPC/Tango.PPC.Common/OS | |
| parent | 4954a924b8a5b8fd7a213a444027e74b936359be (diff) | |
| download | Tango-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/OS')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs | 64 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs | 12 |
2 files changed, 76 insertions, 0 deletions
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> |
