aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs15
1 files changed, 14 insertions, 1 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..0f439c83d 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
{
@@ -475,7 +476,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
ActiveMachineAdapter.ApplicationOsVersions = (await ActiveMachineAdapter.Context.ApplicationOsVersions.ToListAsync()).ToObservableCollection();
ActiveMachineAdapter.EmbeddedFirmwareVersions = (await ActiveMachineAdapter.Context.EmbeddedFirmwareVersions.ToListAsync()).ToObservableCollection();
ActiveMachineAdapter.DispenserTypes = (await ActiveMachineAdapter.Context.DispenserTypes.ToListAsync()).ToObservableCollection();
- ActiveMachineAdapter.LiquidTypes = (await ActiveMachineAdapter.Context.LiquidTypes.ToListAsync()).ToObservableCollection();
+ ActiveMachineAdapter.LiquidTypes = (await ActiveMachineAdapter.Context.LiquidTypes.ToListAsync()).OrderBy(x => x.PreferredIndex).ToObservableCollection();
ActiveMachineAdapter.MidTankTypes = (await ActiveMachineAdapter.Context.MidTankTypes.ToListAsync()).ToObservableCollection();
ActiveMachineAdapter.CartridgeTypes = (await ActiveMachineAdapter.Context.CartridgeTypes.ToListAsync()).ToObservableCollection();
ActiveMachineAdapter.IdsPackFormulas = (await ActiveMachineAdapter.Context.IdsPackFormulas.ToListAsync()).ToObservableCollection();
@@ -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)