aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
blob: 5b49aedf1881708a35159f5314485d7514145177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.PPC.Common;
using Tango.PPC.Common.Notifications.NotificationItems;
using Tango.PPC.Jobs.Views;

namespace Tango.PPC.Jobs.ViewModels
{
    public class MainViewVM : PPCViewModel
    {
        public override void OnApplicationStarted()
        {
            MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted;
            MachineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed;
        }

        private void MachineOperator_PrintingFailed(object sender, Integration.Operation.PrintingFailedEventArgs e)
        {
            NotificationProvider.PushNotification(new MessageNotificationItem(String.Format("Job failed. ({0})", e.Exception.Message), MessageNotificationItem.MessageNotificationItemTypes.Error, () =>
            {
                NavigationManager.NavigateWithObject<JobsModule, JobView, Job>(e.Job);
                NavigationManager.ClearHistoryExcept<JobsView>();
            }));
        }

        private void MachineOperator_PrintingCompleted(object sender, Integration.Operation.PrintingEventArgs e)
        {
            NotificationProvider.PushNotification(new MessageNotificationItem("Job completed successfully.", MessageNotificationItem.MessageNotificationItemTypes.Success, () =>
            {
                NavigationManager.NavigateWithObject<JobsModule, JobView, Job>(e.Job);
                NavigationManager.ClearHistoryExcept<JobsView>();
            }));
        }
    }
}