diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-18 21:05:38 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-18 21:05:38 +0200 |
| commit | 44af6a05f13cff1defd8ef4a01c4ecdbd7833c33 (patch) | |
| tree | 4747a57757f8206bdc97826a9febf1685f0cf341 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels | |
| parent | 68916b0c7e3322ff1ca8b45ed789973a23ccac51 (diff) | |
| download | Tango-44af6a05f13cff1defd8ef4a01c4ecdbd7833c33.tar.gz Tango-44af6a05f13cff1defd8ef4a01c4ecdbd7833c33.zip | |
Changed DTO's to include byte[] when generated but mapped by reference.
More improvements to action logs.
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.cs | 142 |
1 files changed, 79 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 4b276462e..bb8f117c3 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 @@ -1746,6 +1746,8 @@ namespace Tango.MachineStudio.Developer.ViewModels tables.Add(newTable); } + var rmlBeforeDTO = RmlDTO.FromObservable(SelectedRML); + group.Active = true; group.ProcessParametersTables = tables.ToSynchronizedObservableCollection(); group.Rml = SelectedRML; @@ -1760,6 +1762,8 @@ namespace Tango.MachineStudio.Developer.ViewModels SelectedRML.ProcessParametersTablesGroups.Add(group); await SelectedRML.SaveAsync(_activeJobDbContext); + _actionLogManager.InsertLog(ActionLogType.RmlSaved, AuthenticationProvider.CurrentUser, SelectedRML.Name, rmlBeforeDTO, RmlDTO.FromObservable(SelectedRML), "Active process parameters changed from Machine Studio Research module."); + InvalidateLiquidFactorsAndProcessTables(); } @@ -1804,98 +1808,110 @@ namespace Tango.MachineStudio.Developer.ViewModels using (_notification.PushTaskItem("Loading job details...")) { - await Task.Factory.StartNew(() => + try { - _disable_gamut_check = true; + await Task.Factory.StartNew(() => + { + _disable_gamut_check = true; - LogManager.Log(String.Format("Loading job {0}...", SelectedMachineJob.Name)); - SelectedSegments = new ObservableCollection<Segment>(); - SelectedBrushStops = new ObservableCollection<BrushStop>(); - SelectedRML = null; - SelectedSegment = null; - SelectedGroupHistory = null; - SelectedBrushStop = null; - SelectedProcessParametersTable = null; - RmlProcessParametersTableGroup = null; + LogManager.Log(String.Format("Loading job {0}...", SelectedMachineJob.Name)); + SelectedSegments = new ObservableCollection<Segment>(); + SelectedBrushStops = new ObservableCollection<BrushStop>(); + SelectedRML = null; + SelectedSegment = null; + SelectedGroupHistory = null; + SelectedBrushStop = null; + SelectedProcessParametersTable = null; + RmlProcessParametersTableGroup = null; - _blockInvalidateCommands = false; + _blockInvalidateCommands = false; - LogManager.Log("Creating active job DB context..."); - _activeJobDbContext = ObservablesContext.CreateDefault(); + LogManager.Log("Creating active job DB context..."); + _activeJobDbContext = ObservablesContext.CreateDefault(); - LogManager.Log("Initializing available color spaces, RMLs & Winding methods..."); + LogManager.Log("Initializing available color spaces, RMLs & Winding methods..."); - //var processParamsGroups = _activeJobDbContext.ProcessParametersTablesGroups.ToList(); - //var processParams = _activeJobDbContext.ProcessParametersTables.ToList(); + //var processParamsGroups = _activeJobDbContext.ProcessParametersTablesGroups.ToList(); + //var processParams = _activeJobDbContext.ProcessParametersTables.ToList(); - ColorSpaces = _activeJobDbContext.ColorSpaces.ToObservableCollection(); - Rmls = _activeJobDbContext.Rmls.ToObservableCollection(); - WindingMethods = _activeJobDbContext.WindingMethods.ToObservableCollection(); - SpoolTypes = _activeJobDbContext.SpoolTypes.ToObservableCollection(); + ColorSpaces = _activeJobDbContext.ColorSpaces.ToObservableCollection(); + Rmls = _activeJobDbContext.Rmls.ToObservableCollection(); + WindingMethods = _activeJobDbContext.WindingMethods.ToObservableCollection(); + SpoolTypes = _activeJobDbContext.SpoolTypes.ToObservableCollection(); - LogManager.Log("Loading machine spools..."); - _activeJobDbContext.Spools.Where(x => x.MachineGuid == SelectedMachine.Guid).Load(); + LogManager.Log("Loading machine spools..."); + _activeJobDbContext.Spools.Where(x => x.MachineGuid == SelectedMachine.Guid).Load(); - LogManager.Log("Setting active job..."); - ActiveJob = new JobBuilder(_activeJobDbContext).Set(SelectedMachineJob.Guid).WithUser().WithSegments().WithBrushStops().WithConfiguration().WithRML().Build(); + LogManager.Log("Setting active job..."); + ActiveJob = new JobBuilder(_activeJobDbContext).Set(SelectedMachineJob.Guid).WithUser().WithSegments().WithBrushStops().WithConfiguration().WithRML().Build(); - //_activeJobDbContext.Ccts.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList(); - //_activeJobDbContext.Cats.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList(); - //_activeJobDbContext.Machines.SingleOrDefault(x => x.Guid == ActiveJob.MachineGuid); - //_activeJobDbContext.Configurations.SingleOrDefault(x => x.Guid == ActiveJob.Machine.ConfigurationGuid); + //_activeJobDbContext.Ccts.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList(); + //_activeJobDbContext.Cats.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList(); + //_activeJobDbContext.Machines.SingleOrDefault(x => x.Guid == ActiveJob.MachineGuid); + //_activeJobDbContext.Configurations.SingleOrDefault(x => x.Guid == ActiveJob.Machine.ConfigurationGuid); - //_activeJobDbContext.LiquidTypesRmls.ToList(); + //_activeJobDbContext.LiquidTypesRmls.ToList(); - //_activeJobDbContext.IdsPackFormulas.ToList(); - //_activeJobDbContext.LiquidTypes.ToList(); - //_activeJobDbContext.MidTankTypes.ToList(); - //_activeJobDbContext.DispenserTypes.ToList(); + //_activeJobDbContext.IdsPackFormulas.ToList(); + //_activeJobDbContext.LiquidTypes.ToList(); + //_activeJobDbContext.MidTankTypes.ToList(); + //_activeJobDbContext.DispenserTypes.ToList(); - //_activeJobDbContext.IdsPacks.Where(x => x.ConfigurationGuid == ActiveJob.Machine.ConfigurationGuid).ToList(); + //_activeJobDbContext.IdsPacks.Where(x => x.ConfigurationGuid == ActiveJob.Machine.ConfigurationGuid).ToList(); - _beforeSaveJobDTO = JobDTO.FromObservable(ActiveJob); + _beforeSaveJobDTO = JobDTO.FromObservable(ActiveJob); - LogManager.Log("Setting selected segment..."); - _selectedSegment = ActiveJob.OrderedSegments.FirstOrDefault(); + LogManager.Log("Setting selected segment..."); + _selectedSegment = ActiveJob.OrderedSegments.FirstOrDefault(); - ActiveJob.LengthChanged -= ActiveJob_LengthChanged; - ActiveJob.LengthChanged += ActiveJob_LengthChanged; + ActiveJob.LengthChanged -= ActiveJob_LengthChanged; + ActiveJob.LengthChanged += ActiveJob_LengthChanged; - _selectedRML = ActiveJob.Rml; - InvalidateLiquidFactorsAndProcessTables(); - RaisePropertyChanged(nameof(SelectedRML)); + _selectedRML = ActiveJob.Rml; + InvalidateLiquidFactorsAndProcessTables(); + RaisePropertyChanged(nameof(SelectedRML)); - UpdateEstimatedDuration(); + UpdateEstimatedDuration(); - _blockInvalidateCommands = false; - InvalidateRelayCommands(); + _blockInvalidateCommands = false; + InvalidateRelayCommands(); - _disable_gamut_check = false; + _disable_gamut_check = false; - _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; - _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; + _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; - _settings.Save(); - }); + _settings.Save(); + }); - SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments); - SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); + SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments); + SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); - foreach (var segment in ActiveJob.Segments) - { - SetSegmentBrushStopsLiquidVolumes(segment); - } + foreach (var segment in ActiveJob.Segments) + { + SetSegmentBrushStopsLiquidVolumes(segment); + } - SelectedSegment = _selectedSegment; + SelectedSegment = _selectedSegment; + + if (ActiveJob != null) + { + _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString(); + } - if (ActiveJob != null) + UIHelper.DoEvents(); + _navigation.NavigateTo(DeveloperNavigationView.JobView); + } + catch (Exception ex) { - _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString(); + LogManager.Log(ex, "Error loading job."); + _notification.ShowError($"An error occurred while trying to load the selected job.\n{ex.FlattenMessage()}"); + } + finally + { + CanWork = true; } - - UIHelper.DoEvents(); - _navigation.NavigateTo(DeveloperNavigationView.JobView); } CanWork = true; |
