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. --- .../Controllers/PPCController.cs | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs') diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 6f5eed749..d8dc4a7b8 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -74,11 +74,32 @@ namespace Tango.MachineService.Controllers throw new AuthenticationException("The specified serial number could not be found."); } - if (machine.SetupActivation && machine.OsKey == null) + if (machine.SetupActivation && String.IsNullOrWhiteSpace(machine.OsKey)) { throw new InvalidDataException("The specified machine is configured to perform an OS activation but is not associated with an OS activation key."); } + if (String.IsNullOrWhiteSpace(request.DeviceID)) + { + throw new InvalidDataException("Device id not set."); + } + + if (String.IsNullOrWhiteSpace(request.DeviceName)) + { + throw new InvalidDataException("Device name not set."); + } + + if (machine.IsDeviceRegistered && machine.DeviceId != request.DeviceID) + { + throw new InvalidDataException("The specified machine is already registered and device id is invalid."); + } + + machine.DeviceName = request.DeviceName; + machine.DeviceId = request.DeviceID; + machine.IsDeviceRegistered = true; + + db.SaveChanges(); + var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); @@ -122,7 +143,6 @@ namespace Tango.MachineService.Controllers response.SetupUWF = machine.SetupUwf; response.SetupFirmware = machine.SetupFirmware; response.IsDemo = machine.IsDemo; - } return response; @@ -216,6 +236,11 @@ namespace Tango.MachineService.Controllers } response.Version = latest_machine_version.Version; + + if (machine.ForceVersionUpdate) + { + response.IsUpdateAvailable = true; + } } } -- cgit v1.3.1