diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
| commit | 00a491d93733d4625ad329b2ba8237f445364b3f (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs deleted file mode 100644 index 59d119f21..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Dialogs/HeadCleaningViewVM.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Timers; -using Tango.BL.Entities; -using Tango.Core.Commands; -using Tango.Core.DI; -using Tango.Integration.Operation; -using Tango.PMR.Printing; -using Tango.PPC.Common; -using Tango.PPC.Common.Connection; -using Tango.PPC.Common.Notifications; -using Tango.Settings; -using Tango.SharedUI; - -namespace Tango.PPC.Maintenance.Dialogs -{ - public class HeadCleaningViewVM : DialogViewVM - { - private HeadCleaningHandler _handler; - - [TangoInject] - private IMachineProvider MachineProvider { get; set; } - - [TangoInject] - private INotificationProvider NotificationProvider { get; set; } - - private bool _isStarted; - public bool IsStarted - { - get { return _isStarted; } - set { _isStarted = value; RaisePropertyChangedAuto(); } - } - - private bool _isCompleted; - public bool IsCompleted - { - get { return _isCompleted; } - set { _isCompleted = value; RaisePropertyChangedAuto(); } - } - - private bool _isAborting; - public bool IsAborting - { - get { return _isAborting; } - set { _isAborting = value; RaisePropertyChangedAuto(); } - } - - private bool _isFailed; - public bool IsFailed - { - get { return _isFailed; } - set { _isFailed = value; RaisePropertyChangedAuto(); } - } - - private StartHeadCleaningResponse _status; - public StartHeadCleaningResponse Status - { - get { return _status; } - set { _status = value; RaisePropertyChangedAuto(); } - } - - public RelayCommand StartCommand { get; set; } - public RelayCommand AbortCommand { get; set; } - - public HeadCleaningViewVM() - { - CanClose = true; - TangoIOC.Default.Inject(this); - StartCommand = new RelayCommand(Start); - AbortCommand = new RelayCommand(Abort); - } - - private async void Start() - { - try - { - CanClose = false; - IsStarted = true; - _handler = await MachineProvider.MachineOperator.PerformHeadCleaning(); - _handler.Completed += _handler_Completed; - _handler.Failed += _handler_Failed; - _handler.StatusChanged += _handler_StatusChanged; - } - catch (Exception ex) - { - _handler_Failed(this, ex); - } - } - - private void _handler_StatusChanged(object sender, HeadCleaningStatusChangedEventArgs e) - { - Status = e.Status; - } - - private void _handler_Failed(object sender, Exception e) - { - IsStarted = false; - IsFailed = true; - InvokeUI(() => - { - CanClose = true; - Cancel(); - NotificationProvider.ShowError($"Error occurred while trying to perform the head cleaning.\n{e.FlattenMessage()}"); - }); - } - - private void _handler_Completed(object sender, EventArgs e) - { - IsStarted = false; - IsCompleted = true; - InvokeUI(() => - { - Accept(); - NotificationProvider.ShowSuccess("Head cleaning completed successfully."); - }); - } - - protected override void Cancel() - { - if (CanClose) - { - base.Cancel(); - } - } - - private async void Abort() - { - IsAborting = true; - try - { - await _handler.Abort(); - CanClose = true; - Cancel(); - await NotificationProvider.ShowInfo("Head cleaning aborted."); - } - catch (Exception ex) - { - if (!IsCompleted) - { - CanClose = true; - IsAborting = false; - await NotificationProvider.ShowError($"Error occurred while trying to abort the head cleaning.\n{ex.FlattenMessage()}"); - } - } - } - } -} |
