aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-11-13 18:03:13 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-11-13 18:03:13 +0200
commitd846db14084016e877563a20175e1516183baaa1 (patch)
treef066e338f15cc225e85f7d66172bdcb8b1ead106 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels
parentb0fe0a84b041dca551c2112a4bac29b61031fa95 (diff)
parent1d022e2c2de474a714e26413101b8ab4586e7987 (diff)
downloadTango-d846db14084016e877563a20175e1516183baaa1.tar.gz
Tango-d846db14084016e877563a20175e1516183baaa1.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs123
1 files changed, 60 insertions, 63 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
index fec02529b..fd20a0b1c 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
@@ -1479,39 +1479,15 @@ namespace Tango.MachineStudio.Developer.ViewModels
JobHandler.Failed += (x, ex) =>
{
- if (ex is InsufficientLiquidQuantityException)
- {
- InvokeUI(() =>
- {
- _notification.ShowModalDialog<InsufficientLiquidQuantityViewVM, InsufficientLiquidQuantityView>(new InsufficientLiquidQuantityViewVM(ex as InsufficientLiquidQuantityException), (_) =>
- {
-
- MachineOperator.EnableJobLiquidQuantityValidation = false;
- StartJob();
+ LogManager.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name));
+ _eventLogger.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name));
+ SetJobFailed();
- }, () =>
- {
- SetJobFailed();
-
- InvokeUI(() =>
- {
- StopRecordingIfInProgress();
- });
- });
- });
- }
- else
+ InvokeUI(() =>
{
- LogManager.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name));
- _eventLogger.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name));
- SetJobFailed();
-
- InvokeUI(() =>
- {
- _notification.ShowError("Job failed. " + ex.FlattenMessage());
- StopRecordingIfInProgress();
- });
- }
+ _notification.ShowError("Job failed. " + ex.FlattenMessage());
+ StopRecordingIfInProgress();
+ });
};
JobHandler.Finalizing += (_, __) =>
@@ -1543,6 +1519,16 @@ namespace Tango.MachineStudio.Developer.ViewModels
//Finally Canceled..
};
}
+ catch (InsufficientLiquidQuantityException ex)
+ {
+ _notification.ShowModalDialog<InsufficientLiquidQuantityViewVM, InsufficientLiquidQuantityView>(new InsufficientLiquidQuantityViewVM(ex), (x) =>
+ {
+
+ MachineOperator.EnableJobLiquidQuantityValidation = false;
+ StartJob();
+
+ }, () => { });
+ }
catch (Exception ex)
{
LogManager.Log(ex);
@@ -1920,50 +1906,60 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
CanWork = false;
- using (_notification.PushTaskItem("Saving job details..."))
+ try
{
- await Task.Factory.StartNew(() =>
+ using (_notification.PushTaskItem("Saving job details..."))
{
- LogManager.Log(String.Format("Saving the active job {0}...", ActiveJob.Name));
- ActiveJob.LastUpdated = DateTime.UtcNow;
- ActiveJob.Rml = SelectedRML;
- ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds;
- _activeJobDbContext.SaveChanges();
-
- _machineDbContext.Entry(SelectedMachineJob).Reload();
+ await Task.Factory.StartNew(() =>
+ {
+ LogManager.Log(String.Format("Saving the active job {0}...", ActiveJob.Name));
+ ActiveJob.LastUpdated = DateTime.UtcNow;
+ ActiveJob.Rml = SelectedRML;
+ ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds;
+ _activeJobDbContext.SaveChanges();
+ _machineDbContext.Entry(SelectedMachineJob).Reload();
- _machineDbContext.Entry(SelectedMachineJob).Collection(x => x.Segments).Load();
- foreach (var segment in SelectedMachineJob.Segments.ToList())
- {
- _machineDbContext.Entry(segment).Collection(x => x.BrushStops).Load();
+ _machineDbContext.Entry(SelectedMachineJob).Collection(x => x.Segments).Load();
- foreach (var brushStop in segment.BrushStops.ToList())
+ foreach (var segment in SelectedMachineJob.Segments.ToList())
{
- _machineDbContext.Entry(brushStop).Reload();
- }
+ _machineDbContext.Entry(segment).Collection(x => x.BrushStops).Load();
- _machineDbContext.Entry(segment).Reload();
- }
+ foreach (var brushStop in segment.BrushStops.ToList())
+ {
+ _machineDbContext.Entry(brushStop).Reload();
+ }
- InvokeUI(() =>
- {
- SelectedMachineJob.Segments = SelectedMachineJob.Segments;
- });
+ _machineDbContext.Entry(segment).Reload();
+ }
- var settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>();
- settings.DefaultJobRmlGuid = ActiveJob.RmlGuid;
- settings.Save();
+ InvokeUI(() =>
+ {
+ SelectedMachineJob.Segments = SelectedMachineJob.Segments;
+ });
- if (ActiveJob != null)
- {
- _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString();
- }
- });
- }
+ var settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>();
+ settings.DefaultJobRmlGuid = ActiveJob.RmlGuid;
+ settings.Save();
- CanWork = true;
+ if (ActiveJob != null)
+ {
+ _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString();
+ }
+ });
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error saving active job.");
+ _notification.ShowError($"An error occurred while trying to save the current job.\n{ex.FlattenMessage()}");
+ }
+ finally
+ {
+ CanWork = true;
+ }
}
}
@@ -2273,6 +2269,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
return;
}
SelectedSegment.BrushStops.Remove(x);
+ _activeJobDbContext.BrushStops.Remove(x);
});
ArrangeBrushStopsIndices();