diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer')
2 files changed, 27 insertions, 13 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 96d8582a7..35e27c834 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 @@ -2234,23 +2234,37 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (_notification.ShowQuestion("Are you sure you want to delete the selected jobs?")) { - var jobsToReport = SelectedJobs.Select(x => JobDTO.FromObservable(x)).ToList(); - - LogManager.Log(String.Format("Removing {0} jobs...", SelectedJobs.Count)); - SelectedJobs.ToList().ForEach(x => + try { - x.Delete(_machineDbContext); - }); + IsFree = false; + + var jobsToReport = SelectedJobs.Select(x => JobDTO.FromObservable(x)).ToList(); - using (_notification.PushTaskItem("Removing selected jobs...")) + LogManager.Log(String.Format("Removing {0} jobs...", SelectedJobs.Count)); + SelectedJobs.ToList().ForEach(x => + { + x.Delete(_machineDbContext); + }); + + using (_notification.PushTaskItem("Removing selected jobs...")) + { + LogManager.Log("Saving selected machine to database..."); + await SelectedMachine.SaveAsync(_machineDbContext); + } + + foreach (var job in jobsToReport) + { + _actionLogManager.InsertLog(ActionLogType.JobDeleted, AuthenticationProvider.CurrentUser, job.Name, job, "Job deleted using Machine Studio.", true); + } + } + catch (Exception ex) { - LogManager.Log("Saving selected machine to database..."); - await SelectedMachine.SaveAsync(_machineDbContext); + LogManager.Log(ex, "Error removing the selected job."); + _notification.ShowError($"Error removing the selected job.\n{ex.FlattenMessage()}"); } - - foreach (var job in jobsToReport) + finally { - _actionLogManager.InsertLog(ActionLogType.JobDeleted, AuthenticationProvider.CurrentUser, job.Name, job, "Job deleted using Machine Studio.", true); + IsFree = true; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml index a3d2dbd68..ce632539e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml @@ -28,7 +28,7 @@ <converters:BooleanInverseConverter x:Key="BooleanInverseConverter" /> </UserControl.Resources> - <Grid> + <Grid IsEnabled="{Binding IsFree}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="600"/> |
