aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <roy.mail.net@gmail.com>2025-09-09 12:34:54 +0300
committerRoy Ben Shabat <roy.mail.net@gmail.com>2025-09-09 12:34:54 +0300
commitf87208b19e183d309a3bcacd26ecc74c4da728d4 (patch)
treeba3eba566ff125160fd162dce0de1929df08edcd /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
parentf8876913ac534f6ec6b122ce64a49d6937b4ba3c (diff)
downloadTango-f87208b19e183d309a3bcacd26ecc74c4da728d4.tar.gz
Tango-f87208b19e183d309a3bcacd26ecc74c4da728d4.zip
Changed PPC CMYK color space label to Volume.
Re-implemented machine designer clone.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs52
1 files changed, 45 insertions, 7 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 c928af0c7..06d702ca0 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
@@ -537,13 +537,51 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
machineConfigBeforeClone = ActiveMachine.Configuration;
IsNewMachine = true;
- ActiveMachine = ActiveMachine.Clone();
- ActiveMachine.Name = machineCreationDialogVM.Name;
- ActiveMachine.SerialNumber = machineCreationDialogVM.SerialNumber;
- ActiveMachine.IsDeviceRegistered = false;
- ActiveMachine.DeviceId = null;
- ActiveMachine.DeviceName = null;
- ActiveMachine.ActivationKey = null;
+ var cloned = ActiveMachine.Clone();
+ cloned.Name = machineCreationDialogVM.Name;
+ cloned.SerialNumber = machineCreationDialogVM.SerialNumber;
+ cloned.IsDeviceRegistered = false;
+ cloned.DeviceId = null;
+ cloned.DeviceName = null;
+ cloned.ActivationKey = null;
+ cloned.Organization = null;
+ cloned.SiteGuid = null;
+ cloned.OrganizationGuid = null;
+
+ while (cloned.ActivationKey == null) //Generate a random password and make sure no machine matches it.
+ {
+ cloned.ActivationKey = PasswordGenerator.Generate(8, PasswordGenerator.PasswordType.Alpha, PasswordGenerator.PasswordCasing.Upper);
+ if (await ActiveMachineAdapter.Context.Machines.Where(x => x.ActivationKey == cloned.ActivationKey).CountAsync() == 0)
+ {
+ break;
+ }
+
+ cloned.ActivationKey = null;
+ }
+
+
+ for (int i = 0; i < ActiveMachine.Configuration.IdsPacks.Count; i++)
+ {
+ var dispenser = ActiveMachine.Configuration.IdsPacks[i].Dispenser;
+
+ if (dispenser != null)
+ {
+ var clonedDispenser = new Dispenser();
+ clonedDispenser.CalibrationData = dispenser.CalibrationData;
+ clonedDispenser.DispenserType = dispenser.DispenserType;
+ clonedDispenser.DispenserTypeGuid = dispenser.DispenserTypeGuid;
+ clonedDispenser.NlPerPulse = dispenser.NlPerPulse;
+ clonedDispenser.PartNumber = dispenser.PartNumber;
+ clonedDispenser.PcbSerial = dispenser.PcbSerial;
+ clonedDispenser.PcbVersion = dispenser.PcbVersion;
+ clonedDispenser.ProductionDate = dispenser.ProductionDate;
+ clonedDispenser.SerialNumber = cloned.SerialNumber + "_D" + (i + 1);
+
+ cloned.Configuration.IdsPacks[i].Dispenser = clonedDispenser;
+ }
+ }
+
+ ActiveMachine = cloned;
ActiveMachineAdapter.Context.Machines.Add(ActiveMachine);
}
}