diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 143 |
1 files changed, 106 insertions, 37 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 7cc76bdcc..f3e7711f9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -42,6 +42,16 @@ namespace Tango.PPC.Jobs.ViewModels #region Properties + private BL.Enumerations.JobStatuses _jobStatus; + /// <summary> + /// Gets or sets the temporary job status. + /// </summary> + public BL.Enumerations.JobStatuses JobStatus + { + get { return _jobStatus; } + set { _jobStatus = value; RaisePropertyChangedAuto(); } + } + private Job _job; /// <summary> /// Gets or sets the selected job. @@ -190,6 +200,20 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public RelayCommand DyeCommand { get; set; } + /// <summary> + /// Gets or sets the approve sample command. + /// </summary> + public RelayCommand ApproveSampleCommand { get; set; } + + /// <summary> + /// Gets or sets the repeat sample dye command. + /// </summary> + public RelayCommand RepeatSampleDyeCommand { get; set; } + + /// <summary> + /// Gets or sets another sample command. + /// </summary> + public RelayCommand AnotherSampleCommand { get; set; } #endregion #region Constructors @@ -220,7 +244,7 @@ namespace Tango.PPC.Jobs.ViewModels RemoveSegmentCommand = new RelayCommand<Segment>(RemoveSegment); RemoveBrushStopCommand = new RelayCommand<BrushStop>(RemoveBrushStop); RemoveJobCommand = new RelayCommand(RemoveJob); - SaveJobCommand = new RelayCommand(SaveJob); + SaveJobCommand = new RelayCommand(() => SaveJob()); ReplaceBrushStopCommand = new RelayCommand<BrushStop>(InvokeColorAdjustmentForBrushStop); TwineCatalogFieldTapCommand = new RelayCommand<BrushStop>(InvokeTwineCatalogForBrushStop); IncreaseDecreaseSamplesToDyeCommand = new RelayCommand<string>((x) => @@ -240,6 +264,10 @@ namespace Tango.PPC.Jobs.ViewModels StartSampleDyeCommand = new RelayCommand(StartSampleDye); DyeCommand = new RelayCommand(StartJob, CanStartJob); + + ApproveSampleCommand = new RelayCommand(ApproveSampleDye); + RepeatSampleDyeCommand = new RelayCommand(RepeatSampleDye); + AnotherSampleCommand = new RelayCommand(DyeAnotherSample); } #endregion @@ -249,13 +277,22 @@ namespace Tango.PPC.Jobs.ViewModels /// <summary> /// Saves the job. /// </summary> - private async void SaveJob() + private async void SaveJob(bool displayNotification = true) { + if (JobStatus != BL.Enumerations.JobStatuses.Draft) + { + Job.JobStatus = JobStatus; + } + if (Job.Validate(_db)) { await _db.SaveChangesAsync(); RaiseMessage(new JobSavedMessage() { Job = Job }); - await NotificationProvider.ShowInfo(String.Format("Job '{0}' saved successfully.", Job.Name)); + + if (displayNotification) + { + await NotificationProvider.ShowInfo(String.Format("Job '{0}' saved successfully.", Job.Name)); + } } } @@ -468,11 +505,48 @@ namespace Tango.PPC.Jobs.ViewModels } } - MachineProvider.MachineOperator.Print(sampleDyeJob); + SaveJob(false); + + var thisJob = Job; + + MachineProvider.MachineOperator.Print(sampleDyeJob).Completed += (x, e) => + { + thisJob.JobStatus = BL.Enumerations.JobStatuses.PendingApproval; + + if (Job != null && Job.Guid == thisJob.Guid) + { + JobStatus = BL.Enumerations.JobStatuses.PendingApproval; + } + }; NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); } + /// <summary> + /// Sets the job status back to not approved. + /// </summary> + private void RepeatSampleDye() + { + JobStatus = BL.Enumerations.JobStatuses.Draft; + } + + /// <summary> + /// Approves the sample dye. + /// </summary> + private void ApproveSampleDye() + { + JobStatus = BL.Enumerations.JobStatuses.Approved; + SaveJob(false); + } + + /// <summary> + /// Dyes another sample. + /// </summary> + private void DyeAnotherSample() + { + JobStatus = BL.Enumerations.JobStatuses.Draft; + } + #endregion #region Out Of Gamut Check Thread @@ -521,51 +595,46 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public async override void OnNavigatedTo() { - if (_job_to_load == null || (_job_to_load != null && Job != null && _job_to_load.Guid == Job.Guid)) + if (!(_job_to_load == null || (_job_to_load != null && Job != null && _job_to_load.Guid == Job.Guid))) { - if (_job_to_load_intent == JobNavigationIntent.SampleDye) + NotificationProvider.SetGlobalBusyMessage("Loading job details..."); + + _can_navigate_back = false; + base.OnNavigatedTo(); + + if (_db != null) { - View.DisplaySampleDye(); + _db.Dispose(); } - return; - } - NotificationProvider.SetGlobalBusyMessage("Loading job details..."); + _db = ObservablesContext.CreateDefault(); + var a = _db.Jobs.ToList(); + Job = await _db.Jobs.SingleOrDefaultAsync(x => x.Guid == _job_to_load.Guid); + Job.ValidateOnPropertyChanged = true; + Rmls = await _db.Rmls.ToListAsync(); + ColorSpaces = await _db.ColorSpaces.ToListAsync(); + SpoolTypes = await _db.SpoolTypes.ToListAsync(); + Customers = await _db.Customers.Where(x => x.OrganizationGuid == MachineProvider.Machine.OrganizationGuid).ToListAsync(); - _can_navigate_back = false; - base.OnNavigatedTo(); + if (!_check_gamut_thread.IsAlive) + { + _check_gamut_thread.Start(); + } - if (_db != null) - { - _db.Dispose(); - } + SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); + SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); - _db = ObservablesContext.CreateDefault(); - var a = _db.Jobs.ToList(); - Job = await _db.Jobs.SingleOrDefaultAsync(x => x.Guid == _job_to_load.Guid); - Job.ValidateOnPropertyChanged = true; - Rmls = await _db.Rmls.ToListAsync(); - ColorSpaces = await _db.ColorSpaces.ToListAsync(); - SpoolTypes = await _db.SpoolTypes.ToListAsync(); - Customers = await _db.Customers.Where(x => x.OrganizationGuid == MachineProvider.Machine.OrganizationGuid).ToListAsync(); + InvokeUIOnIdle(() => + { + NotificationProvider.ReleaseGlobalBusyMessage(); + }); - if (!_check_gamut_thread.IsAlive) - { - _check_gamut_thread.Start(); + _job_to_load = null; } - SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); - SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); - - InvokeUIOnIdle(() => - { - NotificationProvider.ReleaseGlobalBusyMessage(); - }); - - _job_to_load = null; - if (_job_to_load_intent == JobNavigationIntent.SampleDye) { + JobStatus = Job.JobStatus; View.DisplaySampleDye(); } } |
