diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-18 06:42:24 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-18 06:42:24 +0200 |
| commit | 3fdc25ceb866f146076aa376b2ff36e45394ff8c (patch) | |
| tree | 6ee243411cbc9b403b647e40fadd2b617bd32e39 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 3d0ea1389f4ac2024e4b3cbad7a2d579cd291fdb (diff) | |
| download | Tango-3fdc25ceb866f146076aa376b2ff36e45394ff8c.tar.gz Tango-3fdc25ceb866f146076aa376b2ff36e45394ff8c.zip | |
Added unique constraint on ACTIVATION_KEY.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs | 10 |
1 files changed, 8 insertions, 2 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 7f558c0c9..a0c01324e 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 @@ -643,9 +643,15 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.Configuration.HardwareVersionChanged += Configuration_HardwareVersionChanged; - if (ActiveMachine.ActivationKey == null) + 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); + 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); |
