From 312e8ccad554d6d0e7d21444e069731e770db978 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 27 Oct 2019 12:09:07 +0200 Subject: 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. --- .../MachineSetup/MachineSetupManager.cs | 3 + .../OS/DefaultOperationSystemManager.cs | 64 ++++++++++ .../Tango.PPC.Common/OS/IOperationSystemManager.cs | 12 ++ .../Tango.PPC.Common/Web/MachineSetupRequest.cs | 2 + .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 136 ++++++++++++--------- .../PPC/Tango.PPC.UI/Views/MainView.xaml | 15 --- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- 7 files changed, 163 insertions(+), 71 deletions(-) (limited to 'Software/Visual_Studio/PPC') 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"); } + + /// + /// Gets the machine unique identifier. + /// + /// + public Task GetDeviceId() + { + return Task.Factory.StartNew(() => + { + 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; + } + }); + } + + /// + /// Gets the machine host name. + /// + /// + public Task GetDeviceName() + { + return Task.Factory.StartNew(() => + { + 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 @@ -44,6 +44,18 @@ namespace Tango.PPC.Common.OS /// Task ChangeTimeZone(TimeZoneInfo timeZone); + /// + /// Gets the machine unique identifier. + /// + /// + Task GetDeviceId(); + + /// + /// Gets the machine host name. + /// + /// + Task GetDeviceName(); + /// /// Restarts the system. /// 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; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index dce92c2dd..7284830a0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -13,6 +13,7 @@ xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:commonControls="clr-namespace:Tango.PPC.Common.Controls;assembly=Tango.PPC.Common" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:components="clr-namespace:Tango.Touch.Components;assembly=Tango.Touch" xmlns:keyboard="clr-namespace:Tango.Touch.Keyboard;assembly=Tango.Touch" mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:LayoutViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LayoutViewVM}"> @@ -20,6 +21,7 @@ + @@ -228,55 +230,79 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + - - + + + - - + - - - - - - - - - + + + - + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index 0ee8058c0..6d6d57526 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -23,25 +23,10 @@ - - - - - - - - - - - diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + -- cgit v1.3.1