diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index 9c4c2281d..68c4b4ae2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -28,6 +28,7 @@ using Tango.MachineStudio.RML.Models; using Tango.BL.ActionLogs; using Tango.MachineStudio.Common.Authentication; using Tango.BL.DTO; +using Tango.Core.Cryptography; namespace Tango.MachineStudio.MachineDesigner.ViewModels { @@ -504,6 +505,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.IsDeviceRegistered = false; ActiveMachine.DeviceId = null; ActiveMachine.DeviceName = null; + ActiveMachine.ActivationKey = null; ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); } } @@ -642,6 +644,17 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.Configuration.HardwareVersionChanged += Configuration_HardwareVersionChanged; + while (ActiveMachine.ActivationKey == null) //Generate a random password and make sure no machine matches it. + { + ActiveMachine.ActivationKey = PasswordGenerator.Generate(8, PasswordGenerator.PasswordType.Alpha, PasswordGenerator.PasswordCasing.Upper); + if (await ActiveMachineAdapter.Context.Machines.Where(x => x.ActivationKey == ActiveMachine.ActivationKey).CountAsync() == 0) + { + break; + } + + ActiveMachine.ActivationKey = null; + } + View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); } catch (Exception ex) |
