aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2020-01-27 09:19:11 +0200
committerShlomo Hecht <shlomo@twine-s.com>2020-01-27 09:19:11 +0200
commitddda6089bff56e80703c8d2dce297919edc58bf1 (patch)
tree7702c5cf169124d522eacc7f1a9e0878373baedd /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
parent1d4d327571d4c0c9f4e17411551bd4dae1e2aed0 (diff)
parentbf2f3245339b9fd9148a2ad25b5ba3320e970cc1 (diff)
downloadTango-ddda6089bff56e80703c8d2dce297919edc58bf1.tar.gz
Tango-ddda6089bff56e80703c8d2dce297919edc58bf1.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs15
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs40
2 files changed, 51 insertions, 4 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs
index b68239b4b..f583fa15e 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs
@@ -309,6 +309,19 @@ namespace Tango.MachineStudio.RML.ViewModels
}
}
+ private double GetTotalMaximumLiquidVolumeLimit()
+ {
+ try
+ {
+ var tables = RML.GetActiveProcessGroup().ProcessParametersTables.OrderBy(x => x.TableIndex).ToList();
+ return (tables[1].MaxInkUptake / tables[0].MaxInkUptake) * 100;
+ }
+ catch
+ {
+ return BrushStop.MAX_TOTAL_LIQUID_VOLUME;
+ }
+ }
+
private void OnLiquidVolumeChanged()
{
try
@@ -316,7 +329,7 @@ namespace Tango.MachineStudio.RML.ViewModels
if (LiquidsCalibrationData == null || _prevent_inverse_conversion) return;
//TODO: This is temporary because of out of range volumes.
- if (LiquidVolumes.Where(x => x.LiquidType.HasPigment).Sum(x => x.Volume) > 200)
+ if (LiquidVolumes.Where(x => x.LiquidType.HasPigment).Sum(x => x.Volume) > GetTotalMaximumLiquidVolumeLimit())
{
IsVolumesOutOfRange = true;
return;
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
index ee21b9ac3..5c55892ba 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
@@ -21,12 +21,18 @@ using Tango.MachineStudio.RML.Views;
using Tango.PMR.ColorLab;
using System.Data.Entity;
using Tango.Core.ExtensionMethods;
+using Tango.MachineStudio.Common.Authentication;
+using Tango.BL.ActionLogs;
+using Tango.BL.DTO;
namespace Tango.MachineStudio.RML.ViewModels
{
public class MainViewVM : StudioViewModel<IMainView>
{
private INotificationProvider _notification;
+ private IAuthenticationProvider _authentication;
+ private IActionLogManager _actionLogManager;
+ private RmlDTO _rmlBeforeSave;
private ObservablesContext _rmls_context;
private ObservablesContext _active_context;
@@ -185,9 +191,11 @@ namespace Tango.MachineStudio.RML.ViewModels
public RelayCommand ImportRMLFileCommand { get; set; }
- public MainViewVM(INotificationProvider notificationProvider)
+ public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager)
{
_notification = notificationProvider;
+ _authentication = authentication;
+ _actionLogManager = actionLogManager;
ManageRmlCommand = new RelayCommand(() => LoadActiveRML(SelectedRML.Guid), () => SelectedRML != null);
RemoveRmlCommand = new RelayCommand(RemoveSelectedRml, () => SelectedRML != null);
CloneRmlCommand = new RelayCommand(CloneSelectedRml, () => SelectedRML != null);
@@ -334,6 +342,8 @@ namespace Tango.MachineStudio.RML.ViewModels
LiquidTypesRmls = LiquidTypesRmls,
};
+ _rmlBeforeSave = RmlDTO.FromObservable(ActiveRML);
+
View.NavigateTo(RmlNavigationView.RmlView);
InvalidateRelayCommands();
@@ -423,6 +433,9 @@ namespace Tango.MachineStudio.RML.ViewModels
_active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]);
_active_context.Rmls.Add(rml);
await _active_context.SaveChangesAsync();
+
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlCreated, _authentication.CurrentUser, rml.Name, rml, "Rml created using Machine Studio.");
+
LoadActiveRML(rml.Guid);
IsFree = true;
@@ -432,7 +445,7 @@ namespace Tango.MachineStudio.RML.ViewModels
private async void RemoveSelectedRml()
{
- if (_notification.ShowQuestion("Removing the selected RML will result in the loss of all related process parameters and default calibration data. Are you sure you want to delete the selected RML?"))
+ if (_notification.ShowQuestion("Removing the selected thread will result in the loss of all related process parameters and default calibration data. Are you sure you want to delete the selected RML?"))
{
IsFree = false;
@@ -440,7 +453,18 @@ namespace Tango.MachineStudio.RML.ViewModels
{
try
{
+ var rml_jobs = await _rmls_context.Jobs.Where(x => x.RmlGuid == SelectedRML.Guid).Include(x => x.Machine).OrderBy(x => x.Machine.SerialNumber).ToListAsync();
+
+ if (rml_jobs.Count > 0)
+ {
+ _notification.ShowError($"The following jobs must be removed or change thread type before the selected thread can be deleted:\n{String.Join("\n",rml_jobs.Select(x => $"{x.Machine.SerialNumber} => {x.Name}"))}");
+ return;
+ }
+
await SelectedRML.DeleteCascadeAsync(_rmls_context);
+
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlDeleted, _authentication.CurrentUser, SelectedRML.Name, SelectedRML, "RML deleted from Machine Studio.");
+
LoadRmls();
}
catch (Exception ex)
@@ -471,7 +495,7 @@ namespace Tango.MachineStudio.RML.ViewModels
var rml = await new RmlBuilder(context).Set(SelectedRML.Guid).WithActiveParametersGroup().WithLiquidFactors().BuildAsync();
Rml cloned = new Rml();
- rml.MapPrimitivesWithStrings(cloned);
+ rml.MapPropertiesTo(cloned, MappingFlags.NoReferenceTypes);
cloned.Code = Rmls.Max(x => x.Code) + 1;
cloned.Guid = Guid.NewGuid().ToString();
@@ -504,6 +528,8 @@ namespace Tango.MachineStudio.RML.ViewModels
context.Rmls.Add(cloned);
await context.SaveChangesAsync();
+
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlCreated, _authentication.CurrentUser, cloned.Name, cloned, "RML cloned from Machine Studio.");
}
LoadRmls();
@@ -665,7 +691,13 @@ namespace Tango.MachineStudio.RML.ViewModels
}
}
+ var rmlAfter = RmlDTO.FromObservable(ActiveRML);
+
await _active_context.SaveChangesAsync();
+
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlSaved, _authentication.CurrentUser, _rmlBeforeSave.Name, _rmlBeforeSave, rmlAfter, "RML saved using Machine Studio.");
+
+ _rmlBeforeSave = rmlAfter;
}
}
catch (Exception ex)
@@ -804,6 +836,8 @@ namespace Tango.MachineStudio.RML.ViewModels
var rmlFile = await Rml.FromRmlFile(db, json);
db.Rmls.Add(rmlFile);
+
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlImported, _authentication.CurrentUser, rmlFile.Name, rmlFile, "RML imported from Machine Studio.");
}
await db.SaveChangesAsync();